073263
To: vim_dev@googlegroups.com
073263
Subject: Patch 7.4.546
073263
Fcc: outbox
073263
From: Bram Moolenaar <Bram@moolenaar.net>
073263
Mime-Version: 1.0
073263
Content-Type: text/plain; charset=UTF-8
073263
Content-Transfer-Encoding: 8bit
073263
------------
073263
073263
Patch 7.4.546
073263
Problem:    Repeated use of vim_snprintf() with a number.
073263
Solution:   Move these vim_snprintf() calls into a function.
073263
Files:	    src/window.c
073263
073263
073263
*** ../vim-7.4.545/src/window.c	2014-11-27 16:22:42.746412995 +0100
073263
--- src/window.c	2014-12-13 03:54:57.760646343 +0100
073263
***************
073263
*** 11,16 ****
073263
--- 11,17 ----
073263
  
073263
  static int path_is_url __ARGS((char_u *p));
073263
  #if defined(FEAT_WINDOWS) || defined(PROTO)
073263
+ static void cmd_with_count __ARGS((char *cmd, char_u *bufp, size_t bufsize, long Prenum));
073263
  static void win_init __ARGS((win_T *newp, win_T *oldp, int flags));
073263
  static void win_init_some __ARGS((win_T *newp, win_T *oldp));
073263
  static void frame_comp_pos __ARGS((frame_T *topfrp, int *row, int *col));
073263
***************
073263
*** 167,176 ****
073263
      case '^':
073263
  		CHECK_CMDWIN
073263
  		reset_VIsual_and_resel();	/* stop Visual mode */
073263
! 		STRCPY(cbuf, "split #");
073263
! 		if (Prenum)
073263
! 		    vim_snprintf((char *)cbuf + 7, sizeof(cbuf) - 7,
073263
! 							       "%ld", Prenum);
073263
  		do_cmdline_cmd(cbuf);
073263
  		break;
073263
  
073263
--- 168,174 ----
073263
      case '^':
073263
  		CHECK_CMDWIN
073263
  		reset_VIsual_and_resel();	/* stop Visual mode */
073263
! 		cmd_with_count("split #", cbuf, sizeof(cbuf), Prenum);
073263
  		do_cmdline_cmd(cbuf);
073263
  		break;
073263
  
073263
***************
073263
*** 199,208 ****
073263
      case Ctrl_Q:
073263
      case 'q':
073263
  		reset_VIsual_and_resel();	/* stop Visual mode */
073263
! 		STRCPY(cbuf, "quit");
073263
! 		if (Prenum)
073263
! 		    vim_snprintf((char *)cbuf + 4, sizeof(cbuf) - 5,
073263
! 							    "%ld", Prenum);
073263
  		do_cmdline_cmd(cbuf);
073263
  		break;
073263
  
073263
--- 197,203 ----
073263
      case Ctrl_Q:
073263
      case 'q':
073263
  		reset_VIsual_and_resel();	/* stop Visual mode */
073263
! 		cmd_with_count("quit", cbuf, sizeof(cbuf), Prenum);
073263
  		do_cmdline_cmd(cbuf);
073263
  		break;
073263
  
073263
***************
073263
*** 210,219 ****
073263
      case Ctrl_C:
073263
      case 'c':
073263
  		reset_VIsual_and_resel();	/* stop Visual mode */
073263
! 		STRCPY(cbuf, "close");
073263
! 		if (Prenum)
073263
! 		    vim_snprintf((char *)cbuf + 5, sizeof(cbuf) - 5,
073263
! 							       "%ld", Prenum);
073263
  		do_cmdline_cmd(cbuf);
073263
  		break;
073263
  
073263
--- 205,211 ----
073263
      case Ctrl_C:
073263
      case 'c':
073263
  		reset_VIsual_and_resel();	/* stop Visual mode */
073263
! 		cmd_with_count("close", cbuf, sizeof(cbuf), Prenum);
073263
  		do_cmdline_cmd(cbuf);
073263
  		break;
073263
  
073263
***************
073263
*** 243,252 ****
073263
      case 'o':
073263
  		CHECK_CMDWIN
073263
  		reset_VIsual_and_resel();	/* stop Visual mode */
073263
! 		STRCPY(cbuf, "only");
073263
! 		if (Prenum > 0)
073263
! 		    vim_snprintf((char *)cbuf + 4, sizeof(cbuf) - 4,
073263
! 								"%ld", Prenum);
073263
  		do_cmdline_cmd(cbuf);
073263
  		break;
073263
  
073263
--- 235,241 ----
073263
      case 'o':
073263
  		CHECK_CMDWIN
073263
  		reset_VIsual_and_resel();	/* stop Visual mode */
073263
! 		cmd_with_count("only", cbuf, sizeof(cbuf), Prenum);
073263
  		do_cmdline_cmd(cbuf);
073263
  		break;
073263
  
073263
***************
073263
*** 635,640 ****
073263
--- 624,643 ----
073263
      }
073263
  }
073263
  
073263
+     static void
073263
+ cmd_with_count(cmd, bufp, bufsize, Prenum)
073263
+     char	*cmd;
073263
+     char_u	*bufp;
073263
+     size_t	bufsize;
073263
+     long	Prenum;
073263
+ {
073263
+     size_t	len = STRLEN(cmd);
073263
+ 
073263
+     STRCPY(bufp, cmd);
073263
+     if (Prenum > 0)
073263
+ 	vim_snprintf((char *)bufp + len, bufsize - len, "%ld", Prenum);
073263
+ }
073263
+ 
073263
  /*
073263
   * split the current window, implements CTRL-W s and :split
073263
   *
073263
*** ../vim-7.4.545/src/version.c	2014-12-13 03:36:34.992435104 +0100
073263
--- src/version.c	2014-12-13 03:43:58.447663037 +0100
073263
***************
073263
*** 743,744 ****
073263
--- 743,746 ----
073263
  {   /* Add new patch number below this line */
073263
+ /**/
073263
+     546,
073263
  /**/
073263
073263
-- 
073263
The only way the average employee can speak to an executive is by taking a
073263
second job as a golf caddie.
073263
				(Scott Adams - The Dilbert principle)
073263
073263
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
073263
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
073263
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
073263
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///