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