154 lines
4.7 KiB
Plaintext
154 lines
4.7 KiB
Plaintext
|
To: vim_dev@googlegroups.com
|
||
|
Subject: Patch 7.4.265
|
||
|
Fcc: outbox
|
||
|
From: Bram Moolenaar <Bram@moolenaar.net>
|
||
|
Mime-Version: 1.0
|
||
|
Content-Type: text/plain; charset=UTF-8
|
||
|
Content-Transfer-Encoding: 8bit
|
||
|
------------
|
||
|
|
||
|
Patch 7.4.265 (after 7.4.260)
|
||
|
Problem: Can't call a global function with "g:" in an expression.
|
||
|
Solution: Skip the "g:" when looking up the function.
|
||
|
Files: src/eval.c, src/testdir/test_eval.in, src/testdir/test_eval.ok
|
||
|
|
||
|
|
||
|
*** ../vim-7.4.264/src/eval.c 2014-04-23 20:43:07.290689167 +0200
|
||
|
--- src/eval.c 2014-04-24 17:06:38.884920215 +0200
|
||
|
***************
|
||
|
*** 8485,8517 ****
|
||
|
/* execute the function if no errors detected and executing */
|
||
|
if (evaluate && error == ERROR_NONE)
|
||
|
{
|
||
|
rettv->v_type = VAR_NUMBER; /* default rettv is number zero */
|
||
|
rettv->vval.v_number = 0;
|
||
|
error = ERROR_UNKNOWN;
|
||
|
|
||
|
! if (!builtin_function(fname, -1))
|
||
|
{
|
||
|
/*
|
||
|
* User defined function.
|
||
|
*/
|
||
|
! fp = find_func(fname);
|
||
|
|
||
|
#ifdef FEAT_AUTOCMD
|
||
|
/* Trigger FuncUndefined event, may load the function. */
|
||
|
if (fp == NULL
|
||
|
&& apply_autocmds(EVENT_FUNCUNDEFINED,
|
||
|
! fname, fname, TRUE, NULL)
|
||
|
&& !aborting())
|
||
|
{
|
||
|
/* executed an autocommand, search for the function again */
|
||
|
! fp = find_func(fname);
|
||
|
}
|
||
|
#endif
|
||
|
/* Try loading a package. */
|
||
|
! if (fp == NULL && script_autoload(fname, TRUE) && !aborting())
|
||
|
{
|
||
|
/* loaded a package, search for the function again */
|
||
|
! fp = find_func(fname);
|
||
|
}
|
||
|
|
||
|
if (fp != NULL)
|
||
|
--- 8485,8523 ----
|
||
|
/* 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(rfname, -1))
|
||
|
{
|
||
|
/*
|
||
|
* User defined function.
|
||
|
*/
|
||
|
! fp = find_func(rfname);
|
||
|
|
||
|
#ifdef FEAT_AUTOCMD
|
||
|
/* Trigger FuncUndefined event, may load the function. */
|
||
|
if (fp == NULL
|
||
|
&& apply_autocmds(EVENT_FUNCUNDEFINED,
|
||
|
! rfname, rfname, TRUE, NULL)
|
||
|
&& !aborting())
|
||
|
{
|
||
|
/* executed an autocommand, search for the function again */
|
||
|
! fp = find_func(rfname);
|
||
|
}
|
||
|
#endif
|
||
|
/* Try loading a package. */
|
||
|
! if (fp == NULL && script_autoload(rfname, TRUE) && !aborting())
|
||
|
{
|
||
|
/* loaded a package, search for the function again */
|
||
|
! fp = find_func(rfname);
|
||
|
}
|
||
|
|
||
|
if (fp != NULL)
|
||
|
*** ../vim-7.4.264/src/testdir/test_eval.in 2014-04-23 20:43:07.290689167 +0200
|
||
|
--- src/testdir/test_eval.in 2014-04-24 17:07:57.108918330 +0200
|
||
|
***************
|
||
|
*** 172,182 ****
|
||
|
:endtry
|
||
|
:"
|
||
|
:" function name starting with/without "g:", buffer-local funcref.
|
||
|
! :function! g:Foo()
|
||
|
! : $put ='called Foo()'
|
||
|
:endfunction
|
||
|
:let b:my_func = function('Foo')
|
||
|
! :call b:my_func()
|
||
|
:"
|
||
|
:/^start:/+1,$wq! test.out
|
||
|
:" vim: et ts=4 isk-=\: fmr=???,???
|
||
|
--- 172,184 ----
|
||
|
:endtry
|
||
|
:"
|
||
|
:" function name starting with/without "g:", buffer-local funcref.
|
||
|
! :function! g:Foo(n)
|
||
|
! : $put ='called Foo(' . a:n . ')'
|
||
|
:endfunction
|
||
|
:let b:my_func = function('Foo')
|
||
|
! :call b:my_func(1)
|
||
|
! :echo g:Foo(2)
|
||
|
! :echo Foo(3)
|
||
|
:"
|
||
|
:/^start:/+1,$wq! test.out
|
||
|
:" vim: et ts=4 isk-=\: fmr=???,???
|
||
|
*** ../vim-7.4.264/src/testdir/test_eval.ok 2014-04-23 20:43:07.290689167 +0200
|
||
|
--- src/testdir/test_eval.ok 2014-04-24 16:54:36.856937613 +0200
|
||
|
***************
|
||
|
*** 338,341 ****
|
||
|
Vim(function):E128: Function name must start with a capital or "s:": g:test()
|
||
|
Vim(function):E128: Function name must start with a capital or "s:": b:test()
|
||
|
Vim(function):E128: Function name must start with a capital or "s:": test2() "#
|
||
|
! called Foo()
|
||
|
--- 338,343 ----
|
||
|
Vim(function):E128: Function name must start with a capital or "s:": g:test()
|
||
|
Vim(function):E128: Function name must start with a capital or "s:": b:test()
|
||
|
Vim(function):E128: Function name must start with a capital or "s:": test2() "#
|
||
|
! called Foo(1)
|
||
|
! called Foo(2)
|
||
|
! called Foo(3)
|
||
|
*** ../vim-7.4.264/src/version.c 2014-04-23 20:43:07.290689167 +0200
|
||
|
--- src/version.c 2014-04-24 16:56:24.520935019 +0200
|
||
|
***************
|
||
|
*** 736,737 ****
|
||
|
--- 736,739 ----
|
||
|
{ /* Add new patch number below this line */
|
||
|
+ /**/
|
||
|
+ 265,
|
||
|
/**/
|
||
|
|
||
|
--
|
||
|
The sooner you fall behind, the more time you'll have to catch up.
|
||
|
|
||
|
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
||
|
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
||
|
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
||
|
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|