vim-patch:7.4.546

Problem:    Repeated use of vim_snprintf() with a number.
Solution:   Move these vim_snprintf() calls into a function.

https://code.google.com/p/vim/source/detail?name=v7-4-546
This commit is contained in:
Felipe Morales
2015-01-20 02:01:16 -03:00
parent 7fc952ab67
commit 87953bf5ff
2 changed files with 15 additions and 14 deletions

View File

@@ -233,7 +233,7 @@ static int included_patches[] = {
549, 549,
//548 NA //548 NA
547, 547,
//546, 546,
545, 545,
//544 NA //544 NA
543, 543,

View File

@@ -124,10 +124,7 @@ do_window (
case Ctrl_HAT: case Ctrl_HAT:
case '^': case '^':
CHECK_CMDWIN reset_VIsual_and_resel(); /* stop Visual mode */ CHECK_CMDWIN 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,
"%" PRId64, (int64_t)Prenum);
do_cmdline_cmd(cbuf); do_cmdline_cmd(cbuf);
break; break;
@@ -151,9 +148,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;
@@ -161,9 +156,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 + 4, sizeof(cbuf) - 5, "%ld", Prenum);
do_cmdline_cmd(cbuf); do_cmdline_cmd(cbuf);
break; break;
@@ -189,9 +182,7 @@ newwindow:
case Ctrl_O: case Ctrl_O:
case 'o': case 'o':
CHECK_CMDWIN reset_VIsual_and_resel(); /* stop Visual mode */ CHECK_CMDWIN 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;
@@ -496,6 +487,16 @@ wingotofile:
} }
} }
static void cmd_with_count(char *cmd, char_u *bufp, size_t bufsize,
long Prenum)
{
size_t len = xstrlcpy((char *)bufp, cmd, bufsize);
if (Prenum > 0 && len < bufsize) {
vim_snprintf((char *)bufp + len, bufsize - len, "%" PRId64, Prenum);
}
}
/* /*
* split the current window, implements CTRL-W s and :split * split the current window, implements CTRL-W s and :split
* *