aboutsummaryrefslogtreecommitdiff
path: root/src/eval.c
diff options
context:
space:
mode:
authorMarco Hinz <mh.codebro@gmail.com>2014-04-26 10:24:06 +0200
committerThiago de Arruda <tpadilha84@gmail.com>2014-04-28 08:00:28 -0300
commit9b9c1dee1352165fea2f9108456484b30b796fd6 (patch)
tree0ba21d04483152bd212f656c5d5137e0a2f99aa8 /src/eval.c
parent4d0dd14189c0f0dd4ad561d65d97aa3e1589102b (diff)
downloadrneovim-9b9c1dee1352165fea2f9108456484b30b796fd6.tar.gz
rneovim-9b9c1dee1352165fea2f9108456484b30b796fd6.tar.bz2
rneovim-9b9c1dee1352165fea2f9108456484b30b796fd6.zip
vim-patch:7.4.264
Problem: Can't define a function starting with "g:". Can't assign a funcref to a buffer-local variable. Solution: Skip "g:" at the start of a function name. Don't check for colons when assigning to a variable. https://code.google.com/p/vim/source/detail?r=00acac0af680c2d8c82db5258474b121a5908926
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/eval.c b/src/eval.c
index fe93527a36..62f9193305 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -17302,7 +17302,6 @@ void ex_function(exarg_T *eap)
// Get the function name. There are these situations:
// func function name
// "name" == func, "fudi.fd_dict" == NULL
- // s:func script-local function name
// dict.func new dictionary entry
// "name" == NULL, "fudi.fd_dict" set,
// "fudi.fd_di" == NULL, "fudi.fd_newkey" == func
@@ -17312,6 +17311,8 @@ void ex_function(exarg_T *eap)
// dict.func existing dict entry that's not a Funcref
// "name" == NULL, "fudi.fd_dict" set,
// "fudi.fd_di" set, "fudi.fd_newkey" == NULL
+ // s:func script-local function name
+ // g:func global function name, same as "func"
p = eap->arg;
name = trans_function_name(&p, eap->skip, 0, &fudi);
paren = (vim_strchr(p, '(') != NULL);
@@ -17917,8 +17918,10 @@ trans_function_name (
lead = 2;
}
} else {
- if (lead == 2) /* skip over "s:" */
+ // Skip over "s:" and "g:".
+ if (lead == 2 || (lv.ll_name[0] == 'g' && lv.ll_name[1] == ':')) {
lv.ll_name += 2;
+ }
len = (int)(end - lv.ll_name);
}
@@ -17942,17 +17945,16 @@ trans_function_name (
lead += (int)STRLEN(sid_buf);
}
} else if (!(flags & TFN_INT) && builtin_function(lv.ll_name, len)) {
- EMSG2(_(
- "E128: Function name must start with a capital or \"s:\": %s"),
- lv.ll_name);
+ EMSG2(_("E128: Function name must start with a capital or \"s:\": %s"),
+ start);
goto theend;
}
- if (!skip) {
+ if (!skip && !(flags & TFN_QUIET)) {
char_u *cp = vim_strchr(lv.ll_name, ':');
if (cp != NULL && cp < end) {
- EMSG2(_("E884: Function name cannot contain a colon: %s"), lv.ll_name);
+ EMSG2(_("E884: Function name cannot contain a colon: %s"), start);
goto theend;
}
}