aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2017-03-29 16:51:46 -0400
committerJames McCoy <jamessan@jamessan.com>2017-03-29 21:16:58 -0400
commit1c6ae58fd1301bfe2b27ed168b5a117e92c9c4cd (patch)
treec483c94025b49b4ffe4103edc94a4f46c9db817b
parent3116f870ba274862fa6d6643d9fa0870215fed12 (diff)
downloadrneovim-1c6ae58fd1301bfe2b27ed168b5a117e92c9c4cd.tar.gz
rneovim-1c6ae58fd1301bfe2b27ed168b5a117e92c9c4cd.tar.bz2
rneovim-1c6ae58fd1301bfe2b27ed168b5a117e92c9c4cd.zip
coverity/161194: Restore check for 'keywordprg' being ":help"
998d0ffc09d5c7358db62dc88c2e2b87622f60b5 removed the explicit check for ":help", relying instead on whether the user was in a help buffer. However, this breaks escaping the identifier for use in the lookup command. 2f54d6927cc02484b528a5e8b25b64c8d6580ddd tried to fix this by removing "!kp_ex" in "if (cmdchar == 'K' && !kp_ex)", but that causes shell escaping to be used instead of escaping for tag lookup.
-rw-r--r--src/nvim/normal.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index d4919dc3b6..388ddfc8bb 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -4670,6 +4670,7 @@ static void nv_ident(cmdarg_T *cap)
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.
bool kp_ex = (*kp == ':'); // 'keywordprg' is an ex command
+ bool kp_help = (STRCMP(kp, ":he") == 0 || STRCMP(kp, ":help") == 0);
size_t buf_size = n * 2 + 30 + STRLEN(kp);
char *buf = xmalloc(buf_size);
buf[0] = NUL;
@@ -4692,7 +4693,9 @@ static void nv_ident(cmdarg_T *cap)
break;
case 'K':
- if (kp_ex) {
+ if (kp_help) {
+ STRCPY(buf, "he! ");
+ } else if (kp_ex) {
if (cap->count0 != 0) { // Send the count to the ex command.
snprintf(buf, buf_size, "%" PRId64, (int64_t)(cap->count0));
}
@@ -4755,7 +4758,7 @@ static void nv_ident(cmdarg_T *cap)
}
// Now grab the chars in the identifier
- if (cmdchar == 'K') {
+ if (cmdchar == 'K' && !kp_help) {
ptr = vim_strnsave(ptr, n);
if (kp_ex) {
// Escape the argument properly for an Ex command