1
0
forked from aniani/vim

updated for version 7.4.546

Problem:    Repeated use of vim_snprintf() with a number.
Solution:   Move these vim_snprintf() calls into a function.
This commit is contained in:
Bram Moolenaar
2014-12-13 03:58:09 +01:00
parent aff5c3a530
commit 2f1e51a43c
2 changed files with 21 additions and 16 deletions

View File

@@ -741,6 +741,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
546,
/**/ /**/
545, 545,
/**/ /**/

View File

@@ -11,6 +11,7 @@
static int path_is_url __ARGS((char_u *p)); static int path_is_url __ARGS((char_u *p));
#if defined(FEAT_WINDOWS) || defined(PROTO) #if defined(FEAT_WINDOWS) || defined(PROTO)
static void cmd_with_count __ARGS((char *cmd, char_u *bufp, size_t bufsize, long Prenum));
static void win_init __ARGS((win_T *newp, win_T *oldp, int flags)); static void win_init __ARGS((win_T *newp, win_T *oldp, int flags));
static void win_init_some __ARGS((win_T *newp, win_T *oldp)); static void win_init_some __ARGS((win_T *newp, win_T *oldp));
static void frame_comp_pos __ARGS((frame_T *topfrp, int *row, int *col)); static void frame_comp_pos __ARGS((frame_T *topfrp, int *row, int *col));
@@ -167,10 +168,7 @@ do_window(nchar, Prenum, xchar)
case '^': case '^':
CHECK_CMDWIN CHECK_CMDWIN
reset_VIsual_and_resel(); /* stop Visual mode */ reset_VIsual_and_resel(); /* stop Visual mode */
STRCPY(cbuf, "split #"); cmd_with_count("split #", cbuf, sizeof(cbuf), Prenum);
if (Prenum)
vim_snprintf((char *)cbuf + 7, sizeof(cbuf) - 7,
"%ld", Prenum);
do_cmdline_cmd(cbuf); do_cmdline_cmd(cbuf);
break; break;
@@ -199,10 +197,7 @@ newwindow:
case Ctrl_Q: case Ctrl_Q:
case 'q': case 'q':
reset_VIsual_and_resel(); /* stop Visual mode */ reset_VIsual_and_resel(); /* stop Visual mode */
STRCPY(cbuf, "quit"); cmd_with_count("quit", cbuf, sizeof(cbuf), Prenum);
if (Prenum)
vim_snprintf((char *)cbuf + 4, sizeof(cbuf) - 5,
"%ld", Prenum);
do_cmdline_cmd(cbuf); do_cmdline_cmd(cbuf);
break; break;
@@ -210,10 +205,7 @@ newwindow:
case Ctrl_C: case Ctrl_C:
case 'c': case 'c':
reset_VIsual_and_resel(); /* stop Visual mode */ reset_VIsual_and_resel(); /* stop Visual mode */
STRCPY(cbuf, "close"); cmd_with_count("close", cbuf, sizeof(cbuf), Prenum);
if (Prenum)
vim_snprintf((char *)cbuf + 5, sizeof(cbuf) - 5,
"%ld", Prenum);
do_cmdline_cmd(cbuf); do_cmdline_cmd(cbuf);
break; break;
@@ -243,10 +235,7 @@ newwindow:
case 'o': case 'o':
CHECK_CMDWIN CHECK_CMDWIN
reset_VIsual_and_resel(); /* stop Visual mode */ reset_VIsual_and_resel(); /* stop Visual mode */
STRCPY(cbuf, "only"); cmd_with_count("only", cbuf, sizeof(cbuf), Prenum);
if (Prenum > 0)
vim_snprintf((char *)cbuf + 4, sizeof(cbuf) - 4,
"%ld", Prenum);
do_cmdline_cmd(cbuf); do_cmdline_cmd(cbuf);
break; break;
@@ -635,6 +624,20 @@ wingotofile:
} }
} }
static void
cmd_with_count(cmd, bufp, bufsize, Prenum)
char *cmd;
char_u *bufp;
size_t bufsize;
long Prenum;
{
size_t len = STRLEN(cmd);
STRCPY(bufp, cmd);
if (Prenum > 0)
vim_snprintf((char *)bufp + len, bufsize - len, "%ld", Prenum);
}
/* /*
* split the current window, implements CTRL-W s and :split * split the current window, implements CTRL-W s and :split
* *