aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval/userfunc.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index fe10d56d49..2ada0a0e59 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -2294,17 +2294,27 @@ void ex_function(exarg_T *eap)
arg = fudi.fd_newkey;
}
if (arg != NULL && (fudi.fd_di == NULL || !tv_is_func(fudi.fd_di->di_tv))) {
- int j = ((uint8_t)(*arg) == K_SPECIAL) ? 3 : 0;
- while (arg[j] != NUL && (j == 0 ? eval_isnamec1(arg[j]) : eval_isnamec(arg[j]))) {
- j++;
+ char *name_base = arg;
+ if ((uint8_t)(*arg) == K_SPECIAL) {
+ name_base = vim_strchr(arg, '_');
+ if (name_base == NULL) {
+ name_base = arg + 3;
+ } else {
+ name_base++;
+ }
}
- if (arg[j] != NUL) {
+ int i;
+ for (i = 0; name_base[i] != NUL && (i == 0
+ ? eval_isnamec1(name_base[i])
+ : eval_isnamec(name_base[i])); i++) {}
+ if (name_base[i] != NUL) {
emsg_funcname(e_invarg2, arg);
}
}
// Disallow using the g: dict.
if (fudi.fd_dict != NULL && fudi.fd_dict->dv_scope == VAR_DEF_SCOPE) {
emsg(_("E862: Cannot use g: here"));
+ goto ret_free;
}
}