82f41a5
To: vim_dev@googlegroups.com
82f41a5
Subject: Patch 7.3.103
82f41a5
Fcc: outbox
82f41a5
From: Bram Moolenaar <Bram@moolenaar.net>
82f41a5
Mime-Version: 1.0
82f41a5
Content-Type: text/plain; charset=UTF-8
82f41a5
Content-Transfer-Encoding: 8bit
82f41a5
------------
82f41a5
82f41a5
Patch 7.3.103
82f41a5
Problem:    Changing 'fileformat' and then using ":w" in an empty file sets
82f41a5
            the 'modified' option.
82f41a5
Solution:   In unchanged() don't ignore 'ff' for an empty file.
82f41a5
Files:      src/misc1.c, src/option.c, src/proto/option.pro, src/undo.c
82f41a5
82f41a5
82f41a5
*** ../vim-7.3.102/src/misc1.c	2010-12-30 12:30:26.000000000 +0100
82f41a5
--- src/misc1.c	2011-01-22 00:00:24.000000000 +0100
82f41a5
***************
82f41a5
*** 2919,2925 ****
82f41a5
      buf_T	*buf;
82f41a5
      int		ff;	/* also reset 'fileformat' */
82f41a5
  {
82f41a5
!     if (buf->b_changed || (ff && file_ff_differs(buf)))
82f41a5
      {
82f41a5
  	buf->b_changed = 0;
82f41a5
  	ml_setflags(buf);
82f41a5
--- 2919,2925 ----
82f41a5
      buf_T	*buf;
82f41a5
      int		ff;	/* also reset 'fileformat' */
82f41a5
  {
82f41a5
!     if (buf->b_changed || (ff && file_ff_differs(buf, FALSE)))
82f41a5
      {
82f41a5
  	buf->b_changed = 0;
82f41a5
  	ml_setflags(buf);
82f41a5
*** ../vim-7.3.102/src/option.c	2010-12-02 21:43:10.000000000 +0100
82f41a5
--- src/option.c	2011-01-22 00:03:40.000000000 +0100
82f41a5
***************
82f41a5
*** 11296,11311 ****
82f41a5
   * from when editing started (save_file_ff() called).
82f41a5
   * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
82f41a5
   * changed and 'binary' is not set.
82f41a5
!  * Don't consider a new, empty buffer to be changed.
82f41a5
   */
82f41a5
      int
82f41a5
! file_ff_differs(buf)
82f41a5
      buf_T	*buf;
82f41a5
  {
82f41a5
      /* In a buffer that was never loaded the options are not valid. */
82f41a5
      if (buf->b_flags & BF_NEVERLOADED)
82f41a5
  	return FALSE;
82f41a5
!     if ((buf->b_flags & BF_NEW)
82f41a5
  	    && buf->b_ml.ml_line_count == 1
82f41a5
  	    && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
82f41a5
  	return FALSE;
82f41a5
--- 11296,11314 ----
82f41a5
   * from when editing started (save_file_ff() called).
82f41a5
   * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
82f41a5
   * changed and 'binary' is not set.
82f41a5
!  * When "ignore_empty" is true don't consider a new, empty buffer to be
82f41a5
!  * changed.
82f41a5
   */
82f41a5
      int
82f41a5
! file_ff_differs(buf, ignore_empty)
82f41a5
      buf_T	*buf;
82f41a5
+     int		ignore_empty;
82f41a5
  {
82f41a5
      /* In a buffer that was never loaded the options are not valid. */
82f41a5
      if (buf->b_flags & BF_NEVERLOADED)
82f41a5
  	return FALSE;
82f41a5
!     if (ignore_empty
82f41a5
! 	    && (buf->b_flags & BF_NEW)
82f41a5
  	    && buf->b_ml.ml_line_count == 1
82f41a5
  	    && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
82f41a5
  	return FALSE;
82f41a5
*** ../vim-7.3.102/src/proto/option.pro	2010-08-15 21:57:28.000000000 +0200
82f41a5
--- src/proto/option.pro	2011-01-22 00:04:35.000000000 +0100
82f41a5
***************
82f41a5
*** 54,59 ****
82f41a5
  int option_was_set __ARGS((char_u *name));
82f41a5
  int can_bs __ARGS((int what));
82f41a5
  void save_file_ff __ARGS((buf_T *buf));
82f41a5
! int file_ff_differs __ARGS((buf_T *buf));
82f41a5
  int check_ff_value __ARGS((char_u *p));
82f41a5
  /* vim: set ft=c : */
82f41a5
--- 54,59 ----
82f41a5
  int option_was_set __ARGS((char_u *name));
82f41a5
  int can_bs __ARGS((int what));
82f41a5
  void save_file_ff __ARGS((buf_T *buf));
82f41a5
! int file_ff_differs __ARGS((buf_T *buf, int ignore_empty));
82f41a5
  int check_ff_value __ARGS((char_u *p));
82f41a5
  /* vim: set ft=c : */
82f41a5
*** ../vim-7.3.102/src/undo.c	2010-12-17 18:06:00.000000000 +0100
82f41a5
--- src/undo.c	2011-01-22 00:03:58.000000000 +0100
82f41a5
***************
82f41a5
*** 3304,3310 ****
82f41a5
  #ifdef FEAT_QUICKFIX
82f41a5
  	    !bt_dontwrite(buf) &&
82f41a5
  #endif
82f41a5
! 	    (buf->b_changed || file_ff_differs(buf));
82f41a5
  }
82f41a5
  
82f41a5
      int
82f41a5
--- 3304,3310 ----
82f41a5
  #ifdef FEAT_QUICKFIX
82f41a5
  	    !bt_dontwrite(buf) &&
82f41a5
  #endif
82f41a5
! 	    (buf->b_changed || file_ff_differs(buf, TRUE));
82f41a5
  }
82f41a5
  
82f41a5
      int
82f41a5
***************
82f41a5
*** 3314,3320 ****
82f41a5
  #ifdef FEAT_QUICKFIX
82f41a5
  	!bt_dontwrite(curbuf) &&
82f41a5
  #endif
82f41a5
! 	(curbuf->b_changed || file_ff_differs(curbuf));
82f41a5
  }
82f41a5
  
82f41a5
  #if defined(FEAT_EVAL) || defined(PROTO)
82f41a5
--- 3314,3320 ----
82f41a5
  #ifdef FEAT_QUICKFIX
82f41a5
  	!bt_dontwrite(curbuf) &&
82f41a5
  #endif
82f41a5
! 	(curbuf->b_changed || file_ff_differs(curbuf, TRUE));
82f41a5
  }
82f41a5
  
82f41a5
  #if defined(FEAT_EVAL) || defined(PROTO)
82f41a5
*** ../vim-7.3.102/src/version.c	2011-01-17 20:08:03.000000000 +0100
82f41a5
--- src/version.c	2011-01-22 00:07:56.000000000 +0100
82f41a5
***************
82f41a5
*** 716,717 ****
82f41a5
--- 716,719 ----
82f41a5
  {   /* Add new patch number below this line */
82f41a5
+ /**/
82f41a5
+     103,
82f41a5
  /**/
82f41a5
82f41a5
-- 
82f41a5
In a world without fences, who needs Gates and Windows?
82f41a5
82f41a5
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
82f41a5
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
82f41a5
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
82f41a5
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///