mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
nv_ident: sprintf => snprintf
Also fix some other clint errors.
This commit is contained in:
parent
3c32ae2ff3
commit
6eb78dcaaa
@ -4253,10 +4253,11 @@ static void nv_ident(cmdarg_T *cap)
|
|||||||
/* Allocate buffer to put the command in. Inserting backslashes can
|
/* Allocate buffer to put the command in. Inserting backslashes can
|
||||||
* double the length of the word. p_kp / curbuf->b_p_kp could be added
|
* double the length of the word. p_kp / curbuf->b_p_kp could be added
|
||||||
* and some numbers. */
|
* and some numbers. */
|
||||||
char_u *kp = (*curbuf->b_p_kp == NUL ? p_kp : curbuf->b_p_kp); //'keywordprg'
|
char_u *kp = *curbuf->b_p_kp == NUL ? p_kp : curbuf->b_p_kp; // 'keywordprg'
|
||||||
assert(*kp != NUL); //option.c::do_set() should default to ":help" if empty.
|
assert(*kp != NUL); // option.c:do_set() should default to ":help" if empty.
|
||||||
bool kp_ex = (*kp == ':'); //'keywordprg' is an ex command
|
bool kp_ex = (*kp == ':'); // 'keywordprg' is an ex command
|
||||||
char *buf = xmalloc(n * 2 + 30 + STRLEN(kp));
|
size_t buf_size = n * 2 + 30 + STRLEN(kp);
|
||||||
|
char *buf = xmalloc(buf_size);
|
||||||
buf[0] = NUL;
|
buf[0] = NUL;
|
||||||
|
|
||||||
switch (cmdchar) {
|
switch (cmdchar) {
|
||||||
@ -4279,7 +4280,7 @@ static void nv_ident(cmdarg_T *cap)
|
|||||||
case 'K':
|
case 'K':
|
||||||
if (kp_ex) {
|
if (kp_ex) {
|
||||||
if (cap->count0 != 0) { // Send the count to the ex command.
|
if (cap->count0 != 0) { // Send the count to the ex command.
|
||||||
sprintf(buf, "%" PRId64, (int64_t)(cap->count0));
|
snprintf(buf, buf_size, "%" PRId64, (int64_t)(cap->count0));
|
||||||
}
|
}
|
||||||
STRCAT(buf, kp);
|
STRCAT(buf, kp);
|
||||||
STRCAT(buf, " ");
|
STRCAT(buf, " ");
|
||||||
@ -4300,17 +4301,20 @@ static void nv_ident(cmdarg_T *cap)
|
|||||||
* really what we want? */
|
* really what we want? */
|
||||||
bool isman = (STRCMP(kp, "man") == 0);
|
bool isman = (STRCMP(kp, "man") == 0);
|
||||||
bool isman_s = (STRCMP(kp, "man -s") == 0);
|
bool isman_s = (STRCMP(kp, "man -s") == 0);
|
||||||
if (cap->count0 != 0 && !(isman || isman_s))
|
if (cap->count0 != 0 && !(isman || isman_s)) {
|
||||||
sprintf(buf, ".,.+%" PRId64, (int64_t)(cap->count0 - 1));
|
snprintf(buf, buf_size, ".,.+%" PRId64, (int64_t)(cap->count0 - 1));
|
||||||
|
}
|
||||||
|
|
||||||
STRCAT(buf, "! ");
|
STRCAT(buf, "! ");
|
||||||
if (cap->count0 == 0 && isman_s)
|
if (cap->count0 == 0 && isman_s) {
|
||||||
STRCAT(buf, "man");
|
STRCAT(buf, "man");
|
||||||
else
|
} else {
|
||||||
STRCAT(buf, kp);
|
STRCAT(buf, kp);
|
||||||
|
}
|
||||||
STRCAT(buf, " ");
|
STRCAT(buf, " ");
|
||||||
if (cap->count0 != 0 && (isman || isman_s)) {
|
if (cap->count0 != 0 && (isman || isman_s)) {
|
||||||
sprintf(buf + STRLEN(buf), "%" PRId64, (int64_t)cap->count0);
|
snprintf(buf + STRLEN(buf), buf_size - STRLEN(buf), "%" PRId64,
|
||||||
|
(int64_t)cap->count0);
|
||||||
STRCAT(buf, " ");
|
STRCAT(buf, " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4332,7 +4336,7 @@ static void nv_ident(cmdarg_T *cap)
|
|||||||
if (g_cmd)
|
if (g_cmd)
|
||||||
STRCPY(buf, "tj ");
|
STRCPY(buf, "tj ");
|
||||||
else
|
else
|
||||||
sprintf(buf, "%" PRId64 "ta ", (int64_t)cap->count0);
|
snprintf(buf, buf_size, "%" PRId64 "ta ", (int64_t)cap->count0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4391,8 +4395,9 @@ static void nv_ident(cmdarg_T *cap)
|
|||||||
init_history();
|
init_history();
|
||||||
add_to_history(HIST_SEARCH, (char_u *)buf, true, NUL);
|
add_to_history(HIST_SEARCH, (char_u *)buf, true, NUL);
|
||||||
(void)normal_search(cap, cmdchar == '*' ? '/' : '?', (char_u *)buf, 0);
|
(void)normal_search(cap, cmdchar == '*' ? '/' : '?', (char_u *)buf, 0);
|
||||||
} else
|
} else {
|
||||||
do_cmdline_cmd(buf);
|
do_cmdline_cmd(buf);
|
||||||
|
}
|
||||||
|
|
||||||
xfree(buf);
|
xfree(buf);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user