lkundrak / rpms / vim

Forked from rpms/vim 4 years ago
Clone
1eaeacc
To: vim_dev@googlegroups.com
1eaeacc
Subject: Patch 7.4.264
1eaeacc
Fcc: outbox
1eaeacc
From: Bram Moolenaar <Bram@moolenaar.net>
1eaeacc
Mime-Version: 1.0
1eaeacc
Content-Type: text/plain; charset=UTF-8
1eaeacc
Content-Transfer-Encoding: 8bit
1eaeacc
------------
1eaeacc
1eaeacc
Patch 7.4.264 (after 7.4.260)
1eaeacc
Problem:    Can't define a function starting with "g:".  Can't assign a
1eaeacc
	    funcref to a buffer-local variable.
1eaeacc
Solution:   Skip "g:" at the start of a function name.  Don't check for colons
1eaeacc
	    when assigning to a variable.
1eaeacc
Files:	    src/eval.c, src/testdir/test_eval.in, src/testdir/test_eval.ok
1eaeacc
1eaeacc
1eaeacc
*** ../vim-7.4.263/src/eval.c	2014-04-23 19:44:26.366774008 +0200
1eaeacc
--- src/eval.c	2014-04-23 20:40:16.738693276 +0200
1eaeacc
***************
1eaeacc
*** 21583,21589 ****
1eaeacc
       * Get the function name.  There are these situations:
1eaeacc
       * func	    normal function name
1eaeacc
       *		    "name" == func, "fudi.fd_dict" == NULL
1eaeacc
-      * s:func	    script-local function name
1eaeacc
       * dict.func    new dictionary entry
1eaeacc
       *		    "name" == NULL, "fudi.fd_dict" set,
1eaeacc
       *		    "fudi.fd_di" == NULL, "fudi.fd_newkey" == func
1eaeacc
--- 21583,21588 ----
1eaeacc
***************
1eaeacc
*** 21593,21598 ****
1eaeacc
--- 21592,21599 ----
1eaeacc
       * dict.func    existing dict entry that's not a Funcref
1eaeacc
       *		    "name" == NULL, "fudi.fd_dict" set,
1eaeacc
       *		    "fudi.fd_di" set, "fudi.fd_newkey" == NULL
1eaeacc
+      * s:func	    script-local function name
1eaeacc
+      * g:func	    global function name, same as "func"
1eaeacc
       */
1eaeacc
      p = eap->arg;
1eaeacc
      name = trans_function_name(&p, eap->skip, 0, &fudi);
1eaeacc
***************
1eaeacc
*** 22286,22292 ****
1eaeacc
      }
1eaeacc
      else
1eaeacc
      {
1eaeacc
! 	if (lead == 2)	/* skip over "s:" */
1eaeacc
  	    lv.ll_name += 2;
1eaeacc
  	len = (int)(end - lv.ll_name);
1eaeacc
      }
1eaeacc
--- 22287,22294 ----
1eaeacc
      }
1eaeacc
      else
1eaeacc
      {
1eaeacc
! 	/* skip over "s:" and "g:" */
1eaeacc
! 	if (lead == 2 || (lv.ll_name[0] == 'g' && lv.ll_name[1] == ':'))
1eaeacc
  	    lv.ll_name += 2;
1eaeacc
  	len = (int)(end - lv.ll_name);
1eaeacc
      }
1eaeacc
***************
1eaeacc
*** 22317,22333 ****
1eaeacc
      else if (!(flags & TFN_INT) && builtin_function(lv.ll_name, len))
1eaeacc
      {
1eaeacc
  	EMSG2(_("E128: Function name must start with a capital or \"s:\": %s"),
1eaeacc
! 								  lv.ll_name);
1eaeacc
  	goto theend;
1eaeacc
      }
1eaeacc
!     if (!skip)
1eaeacc
      {
1eaeacc
  	char_u *cp = vim_strchr(lv.ll_name, ':');
1eaeacc
  
1eaeacc
  	if (cp != NULL && cp < end)
1eaeacc
  	{
1eaeacc
! 	    EMSG2(_("E884: Function name cannot contain a colon: %s"),
1eaeacc
! 								  lv.ll_name);
1eaeacc
  	    goto theend;
1eaeacc
  	}
1eaeacc
      }
1eaeacc
--- 22319,22334 ----
1eaeacc
      else if (!(flags & TFN_INT) && builtin_function(lv.ll_name, len))
1eaeacc
      {
1eaeacc
  	EMSG2(_("E128: Function name must start with a capital or \"s:\": %s"),
1eaeacc
! 								       start);
1eaeacc
  	goto theend;
1eaeacc
      }
1eaeacc
!     if (!skip && !(flags & TFN_QUIET))
1eaeacc
      {
1eaeacc
  	char_u *cp = vim_strchr(lv.ll_name, ':');
1eaeacc
  
1eaeacc
  	if (cp != NULL && cp < end)
1eaeacc
  	{
1eaeacc
! 	    EMSG2(_("E884: Function name cannot contain a colon: %s"), start);
1eaeacc
  	    goto theend;
1eaeacc
  	}
1eaeacc
      }
1eaeacc
*** ../vim-7.4.263/src/testdir/test_eval.in	2014-04-23 17:43:37.362948683 +0200
1eaeacc
--- src/testdir/test_eval.in	2014-04-23 20:36:50.494698246 +0200
1eaeacc
***************
1eaeacc
*** 144,150 ****
1eaeacc
  :delcommand AR
1eaeacc
  :call garbagecollect(1)
1eaeacc
  :"
1eaeacc
! :" function name includes a colon
1eaeacc
  :try
1eaeacc
  :func! g:test()
1eaeacc
  :echo "test"
1eaeacc
--- 144,150 ----
1eaeacc
  :delcommand AR
1eaeacc
  :call garbagecollect(1)
1eaeacc
  :"
1eaeacc
! :" function name not starting with capital
1eaeacc
  :try
1eaeacc
  :func! g:test()
1eaeacc
  :echo "test"
1eaeacc
***************
1eaeacc
*** 153,158 ****
1eaeacc
--- 153,167 ----
1eaeacc
  :$put =v:exception
1eaeacc
  :endtry
1eaeacc
  :"
1eaeacc
+ :" function name includes a colon
1eaeacc
+ :try
1eaeacc
+ :func! b:test()
1eaeacc
+ :echo "test"
1eaeacc
+ :endfunc
1eaeacc
+ :catch
1eaeacc
+ :$put =v:exception
1eaeacc
+ :endtry
1eaeacc
+ :"
1eaeacc
  :" function name folowed by #
1eaeacc
  :try
1eaeacc
  :func! test2() "#
1eaeacc
***************
1eaeacc
*** 162,167 ****
1eaeacc
--- 171,183 ----
1eaeacc
  :$put =v:exception
1eaeacc
  :endtry
1eaeacc
  :"
1eaeacc
+ :" function name starting with/without "g:", buffer-local funcref.
1eaeacc
+ :function! g:Foo()
1eaeacc
+ :  $put ='called Foo()'
1eaeacc
+ :endfunction
1eaeacc
+ :let b:my_func = function('Foo')
1eaeacc
+ :call b:my_func()
1eaeacc
+ :"
1eaeacc
  :/^start:/+1,$wq! test.out
1eaeacc
  :" vim: et ts=4 isk-=\: fmr=???,???
1eaeacc
  :call getchar()
1eaeacc
*** ../vim-7.4.263/src/testdir/test_eval.ok	2014-04-23 17:43:37.362948683 +0200
1eaeacc
--- src/testdir/test_eval.ok	2014-04-23 20:37:45.526696920 +0200
1eaeacc
***************
1eaeacc
*** 336,339 ****
1eaeacc
--- 336,341 ----
1eaeacc
  Executing call setreg(1, ["", "", [], ""])
1eaeacc
  Vim(call):E730: using List as a String
1eaeacc
  Vim(function):E128: Function name must start with a capital or "s:": g:test()
1eaeacc
+ Vim(function):E128: Function name must start with a capital or "s:": b:test()
1eaeacc
  Vim(function):E128: Function name must start with a capital or "s:": test2() "#
1eaeacc
+ called Foo()
1eaeacc
*** ../vim-7.4.263/src/version.c	2014-04-23 19:44:26.370774008 +0200
1eaeacc
--- src/version.c	2014-04-23 20:27:17.614712050 +0200
1eaeacc
***************
1eaeacc
*** 736,737 ****
1eaeacc
--- 736,739 ----
1eaeacc
  {   /* Add new patch number below this line */
1eaeacc
+ /**/
1eaeacc
+     264,
1eaeacc
  /**/
1eaeacc
1eaeacc
-- 
1eaeacc
In order for something to become clean, something else must become dirty;
1eaeacc
but you can get everything dirty without getting anything clean.
1eaeacc
1eaeacc
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
1eaeacc
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
1eaeacc
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
1eaeacc
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///