From: Bram Moolenaar Date: Thu, 24 Apr 2014 15:12:33 +0000 (+0200) Subject: updated for version 7.4.265 X-Git-Tag: v7.4.265 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a4f317df89e662a964197f2d586ac24cf801f14f;p=vim updated for version 7.4.265 Problem: Can't call a global function with "g:" in an expression. Solution: Skip the "g:" when looking up the function. --- diff --git a/src/eval.c b/src/eval.c index d0b58ea63..f91578928 100644 --- a/src/eval.c +++ b/src/eval.c @@ -8485,33 +8485,39 @@ call_func(funcname, len, rettv, argcount, argvars, firstline, lastline, /* execute the function if no errors detected and executing */ if (evaluate && error == ERROR_NONE) { + char_u *rfname = fname; + + /* Ignore "g:" before a function name. */ + if (fname[0] == 'g' && fname[1] == ':') + rfname = fname + 2; + rettv->v_type = VAR_NUMBER; /* default rettv is number zero */ rettv->vval.v_number = 0; error = ERROR_UNKNOWN; - if (!builtin_function(fname, -1)) + if (!builtin_function(rfname, -1)) { /* * User defined function. */ - fp = find_func(fname); + fp = find_func(rfname); #ifdef FEAT_AUTOCMD /* Trigger FuncUndefined event, may load the function. */ if (fp == NULL && apply_autocmds(EVENT_FUNCUNDEFINED, - fname, fname, TRUE, NULL) + rfname, rfname, TRUE, NULL) && !aborting()) { /* executed an autocommand, search for the function again */ - fp = find_func(fname); + fp = find_func(rfname); } #endif /* Try loading a package. */ - if (fp == NULL && script_autoload(fname, TRUE) && !aborting()) + if (fp == NULL && script_autoload(rfname, TRUE) && !aborting()) { /* loaded a package, search for the function again */ - fp = find_func(fname); + fp = find_func(rfname); } if (fp != NULL) diff --git a/src/testdir/test_eval.in b/src/testdir/test_eval.in index 4919694be..214a99edb 100644 --- a/src/testdir/test_eval.in +++ b/src/testdir/test_eval.in @@ -172,11 +172,13 @@ endfun :endtry :" :" function name starting with/without "g:", buffer-local funcref. -:function! g:Foo() -: $put ='called Foo()' +:function! g:Foo(n) +: $put ='called Foo(' . a:n . ')' :endfunction :let b:my_func = function('Foo') -:call b:my_func() +:call b:my_func(1) +:echo g:Foo(2) +:echo Foo(3) :" :/^start:/+1,$wq! test.out :" vim: et ts=4 isk-=\: fmr=???,??? diff --git a/src/testdir/test_eval.ok b/src/testdir/test_eval.ok index 57383be74..cfe045b53 100644 Binary files a/src/testdir/test_eval.ok and b/src/testdir/test_eval.ok differ diff --git a/src/version.c b/src/version.c index fc95a5ad0..94d985705 100644 --- a/src/version.c +++ b/src/version.c @@ -734,6 +734,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 265, /**/ 264, /**/