Karsten Hopp 5a04c1
To: vim-dev@vim.org
Karsten Hopp 5a04c1
Subject: patch 7.0.195
Karsten Hopp 5a04c1
Fcc: outbox
Karsten Hopp 5a04c1
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 5a04c1
Mime-Version: 1.0
Karsten Hopp 5a04c1
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 5a04c1
Content-Transfer-Encoding: 8bit
Karsten Hopp 5a04c1
------------
Karsten Hopp 5a04c1
Karsten Hopp 5a04c1
Patch 7.0.195
Karsten Hopp 5a04c1
Problem:    When a buffer is modified and 'autowriteall' is set, ":quit"
Karsten Hopp 5a04c1
            results in an endless loop when there is a conversion error while
Karsten Hopp 5a04c1
            writing. (Nikolai Weibull)
Karsten Hopp 5a04c1
Solution:   Make autowrite() return FAIL if the buffer is still changed after
Karsten Hopp 5a04c1
            writing it.
Karsten Hopp 5a04c1
Files:      src/ex_cmds2.c
Karsten Hopp 5a04c1
Karsten Hopp 5a04c1
Karsten Hopp 5a04c1
*** ../vim-7.0.194/src/ex_cmds2.c	Tue Jan 16 21:31:38 2007
Karsten Hopp 5a04c1
--- src/ex_cmds2.c	Tue Feb 13 06:11:28 2007
Karsten Hopp 5a04c1
***************
Karsten Hopp 5a04c1
*** 1242,1255 ****
Karsten Hopp 5a04c1
      buf_T	*buf;
Karsten Hopp 5a04c1
      int		forceit;
Karsten Hopp 5a04c1
  {
Karsten Hopp 5a04c1
      if (!(p_aw || p_awa) || !p_write
Karsten Hopp 5a04c1
  #ifdef FEAT_QUICKFIX
Karsten Hopp 5a04c1
! 	/* never autowrite a "nofile" or "nowrite" buffer */
Karsten Hopp 5a04c1
! 	|| bt_dontwrite(buf)
Karsten Hopp 5a04c1
  #endif
Karsten Hopp 5a04c1
! 	|| (!forceit && buf->b_p_ro) || buf->b_ffname == NULL)
Karsten Hopp 5a04c1
  	return FAIL;
Karsten Hopp 5a04c1
!     return buf_write_all(buf, forceit);
Karsten Hopp 5a04c1
  }
Karsten Hopp 5a04c1
  
Karsten Hopp 5a04c1
  /*
Karsten Hopp 5a04c1
--- 1242,1263 ----
Karsten Hopp 5a04c1
      buf_T	*buf;
Karsten Hopp 5a04c1
      int		forceit;
Karsten Hopp 5a04c1
  {
Karsten Hopp 5a04c1
+     int		r;
Karsten Hopp 5a04c1
+ 
Karsten Hopp 5a04c1
      if (!(p_aw || p_awa) || !p_write
Karsten Hopp 5a04c1
  #ifdef FEAT_QUICKFIX
Karsten Hopp 5a04c1
! 	    /* never autowrite a "nofile" or "nowrite" buffer */
Karsten Hopp 5a04c1
! 	    || bt_dontwrite(buf)
Karsten Hopp 5a04c1
  #endif
Karsten Hopp 5a04c1
! 	    || (!forceit && buf->b_p_ro) || buf->b_ffname == NULL)
Karsten Hopp 5a04c1
  	return FAIL;
Karsten Hopp 5a04c1
!     r = buf_write_all(buf, forceit);
Karsten Hopp 5a04c1
! 
Karsten Hopp 5a04c1
!     /* Writing may succeed but the buffer still changed, e.g., when there is a
Karsten Hopp 5a04c1
!      * conversion error.  We do want to return FAIL then. */
Karsten Hopp 5a04c1
!     if (buf_valid(buf) && bufIsChanged(buf))
Karsten Hopp 5a04c1
! 	r = FAIL;
Karsten Hopp 5a04c1
!     return r;
Karsten Hopp 5a04c1
  }
Karsten Hopp 5a04c1
  
Karsten Hopp 5a04c1
  /*
Karsten Hopp 5a04c1
***************
Karsten Hopp 5a04c1
*** 1472,1477 ****
Karsten Hopp 5a04c1
--- 1480,1487 ----
Karsten Hopp 5a04c1
  	if (buf == NULL)    /* No buffers changed */
Karsten Hopp 5a04c1
  	    return FALSE;
Karsten Hopp 5a04c1
  
Karsten Hopp 5a04c1
+ 	/* Try auto-writing the buffer.  If this fails but the buffer no
Karsten Hopp 5a04c1
+ 	 * longer exists it's not changed, that's OK. */
Karsten Hopp 5a04c1
  	if (check_changed(buf, p_awa, TRUE, FALSE, TRUE) && buf_valid(buf))
Karsten Hopp 5a04c1
  	    break;	    /* didn't save - still changes */
Karsten Hopp 5a04c1
      }
Karsten Hopp 5a04c1
*** ../vim-7.0.194/src/version.c	Tue Feb 13 04:03:05 2007
Karsten Hopp 5a04c1
--- src/version.c	Tue Feb 13 06:18:28 2007
Karsten Hopp 5a04c1
***************
Karsten Hopp 5a04c1
*** 668,669 ****
Karsten Hopp 5a04c1
--- 668,671 ----
Karsten Hopp 5a04c1
  {   /* Add new patch number below this line */
Karsten Hopp 5a04c1
+ /**/
Karsten Hopp 5a04c1
+     195,
Karsten Hopp 5a04c1
  /**/
Karsten Hopp 5a04c1
Karsten Hopp 5a04c1
-- 
Karsten Hopp 5a04c1
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 5a04c1
115. You are late picking up your kid from school and try to explain
Karsten Hopp 5a04c1
     to the teacher you were stuck in Web traffic.
Karsten Hopp 5a04c1
Karsten Hopp 5a04c1
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 5a04c1
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 5a04c1
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 5a04c1
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///