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