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