Karsten Hopp 9891cc
To: vim_dev@googlegroups.com
Karsten Hopp 9891cc
Subject: Patch 7.3.1197
Karsten Hopp 9891cc
Fcc: outbox
Karsten Hopp 9891cc
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 9891cc
Mime-Version: 1.0
Karsten Hopp 9891cc
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 9891cc
Content-Transfer-Encoding: 8bit
Karsten Hopp 9891cc
------------
Karsten Hopp 9891cc
Karsten Hopp 9891cc
Patch 7.3.1197
Karsten Hopp 9891cc
Problem:    ":wviminfo!" does not write history previously read from a viminfo
Karsten Hopp 9891cc
	    file.  (Roland Eggner)
Karsten Hopp 9891cc
Solution:   When not merging history write all entries.
Karsten Hopp 9891cc
Files:	    src/ex_cmds.c, src/ex_getln.c, src/proto/ex_getln.pro
Karsten Hopp 9891cc
Karsten Hopp 9891cc
Karsten Hopp 9891cc
*** ../vim-7.3.1196/src/ex_cmds.c	2013-06-08 18:19:39.000000000 +0200
Karsten Hopp 9891cc
--- src/ex_cmds.c	2013-06-15 16:16:33.000000000 +0200
Karsten Hopp 9891cc
***************
Karsten Hopp 9891cc
*** 1722,1732 ****
Karsten Hopp 9891cc
  }
Karsten Hopp 9891cc
  
Karsten Hopp 9891cc
  /*
Karsten Hopp 9891cc
!  * write_viminfo() -- Write the viminfo file.  The old one is read in first so
Karsten Hopp 9891cc
!  * that effectively a merge of current info and old info is done.  This allows
Karsten Hopp 9891cc
!  * multiple vims to run simultaneously, without losing any marks etc.  If
Karsten Hopp 9891cc
!  * forceit is TRUE, then the old file is not read in, and only internal info is
Karsten Hopp 9891cc
!  * written to the file. -- webb
Karsten Hopp 9891cc
   */
Karsten Hopp 9891cc
      void
Karsten Hopp 9891cc
  write_viminfo(file, forceit)
Karsten Hopp 9891cc
--- 1722,1732 ----
Karsten Hopp 9891cc
  }
Karsten Hopp 9891cc
  
Karsten Hopp 9891cc
  /*
Karsten Hopp 9891cc
!  * Write the viminfo file.  The old one is read in first so that effectively a
Karsten Hopp 9891cc
!  * merge of current info and old info is done.  This allows multiple vims to
Karsten Hopp 9891cc
!  * run simultaneously, without losing any marks etc.
Karsten Hopp 9891cc
!  * If "forceit" is TRUE, then the old file is not read in, and only internal
Karsten Hopp 9891cc
!  * info is written to the file.
Karsten Hopp 9891cc
   */
Karsten Hopp 9891cc
      void
Karsten Hopp 9891cc
  write_viminfo(file, forceit)
Karsten Hopp 9891cc
***************
Karsten Hopp 9891cc
*** 2047,2052 ****
Karsten Hopp 9891cc
--- 2047,2053 ----
Karsten Hopp 9891cc
      int		count = 0;
Karsten Hopp 9891cc
      int		eof = FALSE;
Karsten Hopp 9891cc
      vir_T	vir;
Karsten Hopp 9891cc
+     int		merge = FALSE;
Karsten Hopp 9891cc
  
Karsten Hopp 9891cc
      if ((vir.vir_line = alloc(LSIZE)) == NULL)
Karsten Hopp 9891cc
  	return;
Karsten Hopp 9891cc
***************
Karsten Hopp 9891cc
*** 2058,2066 ****
Karsten Hopp 9891cc
      if (fp_in != NULL)
Karsten Hopp 9891cc
      {
Karsten Hopp 9891cc
  	if (flags & VIF_WANT_INFO)
Karsten Hopp 9891cc
  	    eof = read_viminfo_up_to_marks(&vir,
Karsten Hopp 9891cc
  					 flags & VIF_FORCEIT, fp_out != NULL);
Karsten Hopp 9891cc
! 	else
Karsten Hopp 9891cc
  	    /* Skip info, find start of marks */
Karsten Hopp 9891cc
  	    while (!(eof = viminfo_readline(&vir))
Karsten Hopp 9891cc
  		    && vir.vir_line[0] != '>')
Karsten Hopp 9891cc
--- 2059,2070 ----
Karsten Hopp 9891cc
      if (fp_in != NULL)
Karsten Hopp 9891cc
      {
Karsten Hopp 9891cc
  	if (flags & VIF_WANT_INFO)
Karsten Hopp 9891cc
+ 	{
Karsten Hopp 9891cc
  	    eof = read_viminfo_up_to_marks(&vir,
Karsten Hopp 9891cc
  					 flags & VIF_FORCEIT, fp_out != NULL);
Karsten Hopp 9891cc
! 	    merge = TRUE;
Karsten Hopp 9891cc
! 	}
Karsten Hopp 9891cc
! 	else if (flags != 0)
Karsten Hopp 9891cc
  	    /* Skip info, find start of marks */
Karsten Hopp 9891cc
  	    while (!(eof = viminfo_readline(&vir))
Karsten Hopp 9891cc
  		    && vir.vir_line[0] != '>')
Karsten Hopp 9891cc
***************
Karsten Hopp 9891cc
*** 2079,2085 ****
Karsten Hopp 9891cc
  	write_viminfo_search_pattern(fp_out);
Karsten Hopp 9891cc
  	write_viminfo_sub_string(fp_out);
Karsten Hopp 9891cc
  #ifdef FEAT_CMDHIST
Karsten Hopp 9891cc
! 	write_viminfo_history(fp_out);
Karsten Hopp 9891cc
  #endif
Karsten Hopp 9891cc
  	write_viminfo_registers(fp_out);
Karsten Hopp 9891cc
  #ifdef FEAT_EVAL
Karsten Hopp 9891cc
--- 2083,2089 ----
Karsten Hopp 9891cc
  	write_viminfo_search_pattern(fp_out);
Karsten Hopp 9891cc
  	write_viminfo_sub_string(fp_out);
Karsten Hopp 9891cc
  #ifdef FEAT_CMDHIST
Karsten Hopp 9891cc
! 	write_viminfo_history(fp_out, merge);
Karsten Hopp 9891cc
  #endif
Karsten Hopp 9891cc
  	write_viminfo_registers(fp_out);
Karsten Hopp 9891cc
  #ifdef FEAT_EVAL
Karsten Hopp 9891cc
*** ../vim-7.3.1196/src/ex_getln.c	2013-06-08 18:19:39.000000000 +0200
Karsten Hopp 9891cc
--- src/ex_getln.c	2013-06-15 16:23:57.000000000 +0200
Karsten Hopp 9891cc
***************
Karsten Hopp 9891cc
*** 6003,6008 ****
Karsten Hopp 9891cc
--- 6003,6011 ----
Karsten Hopp 9891cc
  #endif
Karsten Hopp 9891cc
  
Karsten Hopp 9891cc
  #if (defined(FEAT_VIMINFO) && defined(FEAT_CMDHIST)) || defined(PROTO)
Karsten Hopp 9891cc
+ /*
Karsten Hopp 9891cc
+  * Buffers for history read from a viminfo file.  Only valid while reading.
Karsten Hopp 9891cc
+  */
Karsten Hopp 9891cc
  static char_u **viminfo_history[HIST_COUNT] = {NULL, NULL, NULL, NULL};
Karsten Hopp 9891cc
  static int	viminfo_hisidx[HIST_COUNT] = {0, 0, 0, 0};
Karsten Hopp 9891cc
  static int	viminfo_hislen[HIST_COUNT] = {0, 0, 0, 0};
Karsten Hopp 9891cc
***************
Karsten Hopp 9891cc
*** 6184,6192 ****
Karsten Hopp 9891cc
      }
Karsten Hopp 9891cc
  }
Karsten Hopp 9891cc
  
Karsten Hopp 9891cc
      void
Karsten Hopp 9891cc
! write_viminfo_history(fp)
Karsten Hopp 9891cc
      FILE    *fp;
Karsten Hopp 9891cc
  {
Karsten Hopp 9891cc
      int	    i;
Karsten Hopp 9891cc
      int	    type;
Karsten Hopp 9891cc
--- 6187,6202 ----
Karsten Hopp 9891cc
      }
Karsten Hopp 9891cc
  }
Karsten Hopp 9891cc
  
Karsten Hopp 9891cc
+ /*
Karsten Hopp 9891cc
+  * Write history to viminfo file in "fp".
Karsten Hopp 9891cc
+  * When "merge" is TRUE merge history lines with a previously read viminfo
Karsten Hopp 9891cc
+  * file, data is in viminfo_history[].
Karsten Hopp 9891cc
+  * When "merge" is FALSE just write all history lines.  Used for ":wviminfo!".
Karsten Hopp 9891cc
+  */
Karsten Hopp 9891cc
      void
Karsten Hopp 9891cc
! write_viminfo_history(fp, merge)
Karsten Hopp 9891cc
      FILE    *fp;
Karsten Hopp 9891cc
+     int	    merge;
Karsten Hopp 9891cc
  {
Karsten Hopp 9891cc
      int	    i;
Karsten Hopp 9891cc
      int	    type;
Karsten Hopp 9891cc
***************
Karsten Hopp 9891cc
*** 6236,6242 ****
Karsten Hopp 9891cc
  		    p = round == 1 ? history[type][i].hisstr
Karsten Hopp 9891cc
  				   : viminfo_history[type] == NULL ? NULL
Karsten Hopp 9891cc
  						   : viminfo_history[type][i];
Karsten Hopp 9891cc
! 		    if (p != NULL && (round == 2 || !history[type][i].viminfo))
Karsten Hopp 9891cc
  		    {
Karsten Hopp 9891cc
  			--num_saved;
Karsten Hopp 9891cc
  			fputc(hist_type2char(type, TRUE), fp);
Karsten Hopp 9891cc
--- 6246,6254 ----
Karsten Hopp 9891cc
  		    p = round == 1 ? history[type][i].hisstr
Karsten Hopp 9891cc
  				   : viminfo_history[type] == NULL ? NULL
Karsten Hopp 9891cc
  						   : viminfo_history[type][i];
Karsten Hopp 9891cc
! 		    if (p != NULL && (round == 2
Karsten Hopp 9891cc
! 				       || !merge
Karsten Hopp 9891cc
! 				       || !history[type][i].viminfo))
Karsten Hopp 9891cc
  		    {
Karsten Hopp 9891cc
  			--num_saved;
Karsten Hopp 9891cc
  			fputc(hist_type2char(type, TRUE), fp);
Karsten Hopp 9891cc
*** ../vim-7.3.1196/src/proto/ex_getln.pro	2013-04-14 23:19:32.000000000 +0200
Karsten Hopp 9891cc
--- src/proto/ex_getln.pro	2013-06-15 16:20:46.000000000 +0200
Karsten Hopp 9891cc
***************
Karsten Hopp 9891cc
*** 51,57 ****
Karsten Hopp 9891cc
  void prepare_viminfo_history __ARGS((int asklen, int writing));
Karsten Hopp 9891cc
  int read_viminfo_history __ARGS((vir_T *virp, int writing));
Karsten Hopp 9891cc
  void finish_viminfo_history __ARGS((void));
Karsten Hopp 9891cc
! void write_viminfo_history __ARGS((FILE *fp));
Karsten Hopp 9891cc
  void cmd_pchar __ARGS((int c, int offset));
Karsten Hopp 9891cc
  int cmd_gchar __ARGS((int offset));
Karsten Hopp 9891cc
  char_u *script_get __ARGS((exarg_T *eap, char_u *cmd));
Karsten Hopp 9891cc
--- 51,57 ----
Karsten Hopp 9891cc
  void prepare_viminfo_history __ARGS((int asklen, int writing));
Karsten Hopp 9891cc
  int read_viminfo_history __ARGS((vir_T *virp, int writing));
Karsten Hopp 9891cc
  void finish_viminfo_history __ARGS((void));
Karsten Hopp 9891cc
! void write_viminfo_history __ARGS((FILE *fp, int merge));
Karsten Hopp 9891cc
  void cmd_pchar __ARGS((int c, int offset));
Karsten Hopp 9891cc
  int cmd_gchar __ARGS((int offset));
Karsten Hopp 9891cc
  char_u *script_get __ARGS((exarg_T *eap, char_u *cmd));
Karsten Hopp 9891cc
*** ../vim-7.3.1196/src/version.c	2013-06-15 15:09:44.000000000 +0200
Karsten Hopp 9891cc
--- src/version.c	2013-06-15 16:13:55.000000000 +0200
Karsten Hopp 9891cc
***************
Karsten Hopp 9891cc
*** 730,731 ****
Karsten Hopp 9891cc
--- 730,733 ----
Karsten Hopp 9891cc
  {   /* Add new patch number below this line */
Karsten Hopp 9891cc
+ /**/
Karsten Hopp 9891cc
+     1197,
Karsten Hopp 9891cc
  /**/
Karsten Hopp 9891cc
Karsten Hopp 9891cc
-- 
Karsten Hopp 9891cc
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 9891cc
216. Your pet rock leaves home.
Karsten Hopp 9891cc
Karsten Hopp 9891cc
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 9891cc
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 9891cc
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 9891cc
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///