Karsten Hopp 406990
To: vim_dev@googlegroups.com
Karsten Hopp 406990
Subject: Patch 7.3.507
Karsten Hopp 406990
Fcc: outbox
Karsten Hopp 406990
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 406990
Mime-Version: 1.0
Karsten Hopp 406990
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 406990
Content-Transfer-Encoding: 8bit
Karsten Hopp 406990
------------
Karsten Hopp 406990
Karsten Hopp 406990
Patch 7.3.507
Karsten Hopp 406990
Problem:    When exiting with unsaved changes, selecting an existing file in
Karsten Hopp 406990
	    the file dialog, there is no dialog to ask whether the existing
Karsten Hopp 406990
	    file should be overwritten. (Felipe G. Nievinski)
Karsten Hopp 406990
Solution:   Call check_overwrite() before writing. (Christian Brabandt)
Karsten Hopp 406990
Files:	    src/ex_cmds.c, src/ex_cmds2.c, src/proto/ex_cmds.pro
Karsten Hopp 406990
Karsten Hopp 406990
Karsten Hopp 406990
*** ../vim-7.3.506/src/ex_cmds.c	2012-04-25 16:50:44.000000000 +0200
Karsten Hopp 406990
--- src/ex_cmds.c	2012-04-25 17:19:53.000000000 +0200
Karsten Hopp 406990
***************
Karsten Hopp 406990
*** 25,31 ****
Karsten Hopp 406990
  static int read_viminfo_up_to_marks __ARGS((vir_T *virp, int forceit, int writing));
Karsten Hopp 406990
  #endif
Karsten Hopp 406990
  
Karsten Hopp 406990
- static int check_overwrite __ARGS((exarg_T *eap, buf_T *buf, char_u *fname, char_u *ffname, int other));
Karsten Hopp 406990
  static int check_readonly __ARGS((int *forceit, buf_T *buf));
Karsten Hopp 406990
  #ifdef FEAT_AUTOCMD
Karsten Hopp 406990
  static void delbuf_msg __ARGS((char_u *name));
Karsten Hopp 406990
--- 25,30 ----
Karsten Hopp 406990
***************
Karsten Hopp 406990
*** 2722,2728 ****
Karsten Hopp 406990
   * May set eap->forceit if a dialog says it's OK to overwrite.
Karsten Hopp 406990
   * Return OK if it's OK, FAIL if it is not.
Karsten Hopp 406990
   */
Karsten Hopp 406990
!     static int
Karsten Hopp 406990
  check_overwrite(eap, buf, fname, ffname, other)
Karsten Hopp 406990
      exarg_T	*eap;
Karsten Hopp 406990
      buf_T	*buf;
Karsten Hopp 406990
--- 2721,2727 ----
Karsten Hopp 406990
   * May set eap->forceit if a dialog says it's OK to overwrite.
Karsten Hopp 406990
   * Return OK if it's OK, FAIL if it is not.
Karsten Hopp 406990
   */
Karsten Hopp 406990
!     int
Karsten Hopp 406990
  check_overwrite(eap, buf, fname, ffname, other)
Karsten Hopp 406990
      exarg_T	*eap;
Karsten Hopp 406990
      buf_T	*buf;
Karsten Hopp 406990
*** ../vim-7.3.506/src/ex_cmds2.c	2012-03-23 18:39:10.000000000 +0100
Karsten Hopp 406990
--- src/ex_cmds2.c	2012-04-25 17:24:37.000000000 +0200
Karsten Hopp 406990
***************
Karsten Hopp 406990
*** 1489,1494 ****
Karsten Hopp 406990
--- 1489,1495 ----
Karsten Hopp 406990
      char_u	buff[DIALOG_MSG_SIZE];
Karsten Hopp 406990
      int		ret;
Karsten Hopp 406990
      buf_T	*buf2;
Karsten Hopp 406990
+     exarg_T     ea;
Karsten Hopp 406990
  
Karsten Hopp 406990
      dialog_msg(buff, _("Save changes to \"%s\"?"),
Karsten Hopp 406990
  			(buf->b_fname != NULL) ?
Karsten Hopp 406990
***************
Karsten Hopp 406990
*** 1498,1510 ****
Karsten Hopp 406990
      else
Karsten Hopp 406990
  	ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, buff, 1);
Karsten Hopp 406990
  
Karsten Hopp 406990
      if (ret == VIM_YES)
Karsten Hopp 406990
      {
Karsten Hopp 406990
  #ifdef FEAT_BROWSE
Karsten Hopp 406990
  	/* May get file name, when there is none */
Karsten Hopp 406990
  	browse_save_fname(buf);
Karsten Hopp 406990
  #endif
Karsten Hopp 406990
! 	if (buf->b_fname != NULL)   /* didn't hit Cancel */
Karsten Hopp 406990
  	    (void)buf_write_all(buf, FALSE);
Karsten Hopp 406990
      }
Karsten Hopp 406990
      else if (ret == VIM_NO)
Karsten Hopp 406990
--- 1499,1517 ----
Karsten Hopp 406990
      else
Karsten Hopp 406990
  	ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, buff, 1);
Karsten Hopp 406990
  
Karsten Hopp 406990
+     /* Init ea pseudo-structure, this is needed for the check_overwrite()
Karsten Hopp 406990
+      * function. */
Karsten Hopp 406990
+     ea.append = ea.forceit = FALSE;
Karsten Hopp 406990
+ 
Karsten Hopp 406990
      if (ret == VIM_YES)
Karsten Hopp 406990
      {
Karsten Hopp 406990
  #ifdef FEAT_BROWSE
Karsten Hopp 406990
  	/* May get file name, when there is none */
Karsten Hopp 406990
  	browse_save_fname(buf);
Karsten Hopp 406990
  #endif
Karsten Hopp 406990
! 	if (buf->b_fname != NULL && check_overwrite(&ea, buf,
Karsten Hopp 406990
! 				    buf->b_fname, buf->b_ffname, FALSE) == OK)
Karsten Hopp 406990
! 	    /* didn't hit Cancel */
Karsten Hopp 406990
  	    (void)buf_write_all(buf, FALSE);
Karsten Hopp 406990
      }
Karsten Hopp 406990
      else if (ret == VIM_NO)
Karsten Hopp 406990
***************
Karsten Hopp 406990
*** 1532,1538 ****
Karsten Hopp 406990
  		/* May get file name, when there is none */
Karsten Hopp 406990
  		browse_save_fname(buf2);
Karsten Hopp 406990
  #endif
Karsten Hopp 406990
! 		if (buf2->b_fname != NULL)   /* didn't hit Cancel */
Karsten Hopp 406990
  		    (void)buf_write_all(buf2, FALSE);
Karsten Hopp 406990
  #ifdef FEAT_AUTOCMD
Karsten Hopp 406990
  		/* an autocommand may have deleted the buffer */
Karsten Hopp 406990
--- 1539,1547 ----
Karsten Hopp 406990
  		/* May get file name, when there is none */
Karsten Hopp 406990
  		browse_save_fname(buf2);
Karsten Hopp 406990
  #endif
Karsten Hopp 406990
! 		if (buf2->b_fname != NULL && check_overwrite(&ea, buf2,
Karsten Hopp 406990
! 				  buf2->b_fname, buf2->b_ffname, FALSE) == OK)
Karsten Hopp 406990
! 		    /* didn't hit Cancel */
Karsten Hopp 406990
  		    (void)buf_write_all(buf2, FALSE);
Karsten Hopp 406990
  #ifdef FEAT_AUTOCMD
Karsten Hopp 406990
  		/* an autocommand may have deleted the buffer */
Karsten Hopp 406990
*** ../vim-7.3.506/src/proto/ex_cmds.pro	2010-08-15 21:57:28.000000000 +0200
Karsten Hopp 406990
--- src/proto/ex_cmds.pro	2012-04-25 17:25:47.000000000 +0200
Karsten Hopp 406990
***************
Karsten Hopp 406990
*** 23,28 ****
Karsten Hopp 406990
--- 23,29 ----
Karsten Hopp 406990
  void ex_update __ARGS((exarg_T *eap));
Karsten Hopp 406990
  void ex_write __ARGS((exarg_T *eap));
Karsten Hopp 406990
  int do_write __ARGS((exarg_T *eap));
Karsten Hopp 406990
+ int check_overwrite __ARGS((exarg_T *eap, buf_T *buf, char_u *fname, char_u *ffname, int other));
Karsten Hopp 406990
  void ex_wnext __ARGS((exarg_T *eap));
Karsten Hopp 406990
  void do_wqall __ARGS((exarg_T *eap));
Karsten Hopp 406990
  int not_writing __ARGS((void));
Karsten Hopp 406990
*** ../vim-7.3.506/src/version.c	2012-04-25 17:10:12.000000000 +0200
Karsten Hopp 406990
--- src/version.c	2012-04-25 17:17:30.000000000 +0200
Karsten Hopp 406990
***************
Karsten Hopp 406990
*** 716,717 ****
Karsten Hopp 406990
--- 716,719 ----
Karsten Hopp 406990
  {   /* Add new patch number below this line */
Karsten Hopp 406990
+ /**/
Karsten Hopp 406990
+     507,
Karsten Hopp 406990
  /**/
Karsten Hopp 406990
Karsten Hopp 406990
-- 
Karsten Hopp 406990
BROTHER MAYNARD: Armaments Chapter Two Verses Nine to Twenty One.
Karsten Hopp 406990
ANOTHER MONK:    And St.  Attila raised his hand grenade up on high saying "O
Karsten Hopp 406990
                 Lord bless this thy hand grenade that with it thou mayest
Karsten Hopp 406990
                 blow thine enemies to tiny bits, in thy mercy. "and the Lord
Karsten Hopp 406990
                 did grin and people did feast upon the lambs and sloths and
Karsten Hopp 406990
                 carp and anchovies and orang-utans and breakfast cereals and
Karsten Hopp 406990
                 fruit bats and...
Karsten Hopp 406990
BROTHER MAYNARD: Skip a bit brother ...
Karsten Hopp 406990
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
Karsten Hopp 406990
Karsten Hopp 406990
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 406990
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 406990
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 406990
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///