jkunstle / rpms / vim

Forked from rpms/vim 3 years ago
Clone

Blame SOURCES/7.4.264

073263
To: vim_dev@googlegroups.com
073263
Subject: Patch 7.4.264
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.264 (after 7.4.260)
073263
Problem:    Can't define a function starting with "g:".  Can't assign a
073263
	    funcref to a buffer-local variable.
073263
Solution:   Skip "g:" at the start of a function name.  Don't check for colons
073263
	    when assigning to a variable.
073263
Files:	    src/eval.c, src/testdir/test_eval.in, src/testdir/test_eval.ok
073263
073263
073263
*** ../vim-7.4.263/src/eval.c	2014-04-23 19:44:26.366774008 +0200
073263
--- src/eval.c	2014-04-23 20:40:16.738693276 +0200
073263
***************
073263
*** 21583,21589 ****
073263
       * Get the function name.  There are these situations:
073263
       * func	    normal function name
073263
       *		    "name" == func, "fudi.fd_dict" == NULL
073263
-      * s:func	    script-local function name
073263
       * dict.func    new dictionary entry
073263
       *		    "name" == NULL, "fudi.fd_dict" set,
073263
       *		    "fudi.fd_di" == NULL, "fudi.fd_newkey" == func
073263
--- 21583,21588 ----
073263
***************
073263
*** 21593,21598 ****
073263
--- 21592,21599 ----
073263
       * dict.func    existing dict entry that's not a Funcref
073263
       *		    "name" == NULL, "fudi.fd_dict" set,
073263
       *		    "fudi.fd_di" set, "fudi.fd_newkey" == NULL
073263
+      * s:func	    script-local function name
073263
+      * g:func	    global function name, same as "func"
073263
       */
073263
      p = eap->arg;
073263
      name = trans_function_name(&p, eap->skip, 0, &fudi);
073263
***************
073263
*** 22286,22292 ****
073263
      }
073263
      else
073263
      {
073263
! 	if (lead == 2)	/* skip over "s:" */
073263
  	    lv.ll_name += 2;
073263
  	len = (int)(end - lv.ll_name);
073263
      }
073263
--- 22287,22294 ----
073263
      }
073263
      else
073263
      {
073263
! 	/* skip over "s:" and "g:" */
073263
! 	if (lead == 2 || (lv.ll_name[0] == 'g' && lv.ll_name[1] == ':'))
073263
  	    lv.ll_name += 2;
073263
  	len = (int)(end - lv.ll_name);
073263
      }
073263
***************
073263
*** 22317,22333 ****
073263
      else if (!(flags & TFN_INT) && builtin_function(lv.ll_name, len))
073263
      {
073263
  	EMSG2(_("E128: Function name must start with a capital or \"s:\": %s"),
073263
! 								  lv.ll_name);
073263
  	goto theend;
073263
      }
073263
!     if (!skip)
073263
      {
073263
  	char_u *cp = vim_strchr(lv.ll_name, ':');
073263
  
073263
  	if (cp != NULL && cp < end)
073263
  	{
073263
! 	    EMSG2(_("E884: Function name cannot contain a colon: %s"),
073263
! 								  lv.ll_name);
073263
  	    goto theend;
073263
  	}
073263
      }
073263
--- 22319,22334 ----
073263
      else if (!(flags & TFN_INT) && builtin_function(lv.ll_name, len))
073263
      {
073263
  	EMSG2(_("E128: Function name must start with a capital or \"s:\": %s"),
073263
! 								       start);
073263
  	goto theend;
073263
      }
073263
!     if (!skip && !(flags & TFN_QUIET))
073263
      {
073263
  	char_u *cp = vim_strchr(lv.ll_name, ':');
073263
  
073263
  	if (cp != NULL && cp < end)
073263
  	{
073263
! 	    EMSG2(_("E884: Function name cannot contain a colon: %s"), start);
073263
  	    goto theend;
073263
  	}
073263
      }
073263
*** ../vim-7.4.263/src/testdir/test_eval.in	2014-04-23 17:43:37.362948683 +0200
073263
--- src/testdir/test_eval.in	2014-04-23 20:36:50.494698246 +0200
073263
***************
073263
*** 144,150 ****
073263
  :delcommand AR
073263
  :call garbagecollect(1)
073263
  :"
073263
! :" function name includes a colon
073263
  :try
073263
  :func! g:test()
073263
  :echo "test"
073263
--- 144,150 ----
073263
  :delcommand AR
073263
  :call garbagecollect(1)
073263
  :"
073263
! :" function name not starting with capital
073263
  :try
073263
  :func! g:test()
073263
  :echo "test"
073263
***************
073263
*** 153,158 ****
073263
--- 153,167 ----
073263
  :$put =v:exception
073263
  :endtry
073263
  :"
073263
+ :" function name includes a colon
073263
+ :try
073263
+ :func! b:test()
073263
+ :echo "test"
073263
+ :endfunc
073263
+ :catch
073263
+ :$put =v:exception
073263
+ :endtry
073263
+ :"
073263
  :" function name folowed by #
073263
  :try
073263
  :func! test2() "#
073263
***************
073263
*** 162,167 ****
073263
--- 171,183 ----
073263
  :$put =v:exception
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
  :call getchar()
073263
*** ../vim-7.4.263/src/testdir/test_eval.ok	2014-04-23 17:43:37.362948683 +0200
073263
--- src/testdir/test_eval.ok	2014-04-23 20:37:45.526696920 +0200
073263
***************
073263
*** 336,339 ****
073263
--- 336,341 ----
073263
  Executing call setreg(1, ["", "", [], ""])
073263
  Vim(call):E730: using List as a String
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
*** ../vim-7.4.263/src/version.c	2014-04-23 19:44:26.370774008 +0200
073263
--- src/version.c	2014-04-23 20:27:17.614712050 +0200
073263
***************
073263
*** 736,737 ****
073263
--- 736,739 ----
073263
  {   /* Add new patch number below this line */
073263
+ /**/
073263
+     264,
073263
  /**/
073263
073263
-- 
073263
In order for something to become clean, something else must become dirty;
073263
but you can get everything dirty without getting anything clean.
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    ///