3ef2ca
To: vim_dev@googlegroups.com
3ef2ca
Subject: Patch 7.4.268
3ef2ca
Fcc: outbox
3ef2ca
From: Bram Moolenaar <Bram@moolenaar.net>
3ef2ca
Mime-Version: 1.0
3ef2ca
Content-Type: text/plain; charset=UTF-8
3ef2ca
Content-Transfer-Encoding: 8bit
3ef2ca
------------
3ef2ca
3ef2ca
Patch 7.4.268
3ef2ca
Problem:    Using exists() on a funcref for a script-local function does not
3ef2ca
	    work.
3ef2ca
Solution:   Translate <SNR> to the special byte sequence.  Add a test.
3ef2ca
Files:	    src/eval.c, src/testdir/test_eval.in, src/testdir/test_eval.ok,
3ef2ca
	    src/testdir/test_eval_func.vim, Filelist
3ef2ca
3ef2ca
3ef2ca
*** ../vim-7.4.267/src/eval.c	2014-04-24 17:12:29.580911764 +0200
3ef2ca
--- src/eval.c	2014-04-29 13:49:26.759933737 +0200
3ef2ca
***************
3ef2ca
*** 22275,22280 ****
3ef2ca
--- 22275,22288 ----
3ef2ca
      {
3ef2ca
  	name = vim_strsave(name);
3ef2ca
  	*pp = end;
3ef2ca
+ 	if (STRNCMP(name, "<SNR>", 5) == 0)
3ef2ca
+ 	{
3ef2ca
+ 	    /* Change "<SNR>" to the byte sequence. */
3ef2ca
+ 	    name[0] = K_SPECIAL;
3ef2ca
+ 	    name[1] = KS_EXTRA;
3ef2ca
+ 	    name[2] = (int)KE_SNR;
3ef2ca
+ 	    mch_memmove(name + 3, name + 5, STRLEN(name + 5) + 1);
3ef2ca
+ 	}
3ef2ca
  	goto theend;
3ef2ca
      }
3ef2ca
  
3ef2ca
*** ../vim-7.4.267/src/testdir/test_eval.in	2014-04-24 17:12:29.584911764 +0200
3ef2ca
--- src/testdir/test_eval.in	2014-04-29 13:59:09.495923525 +0200
3ef2ca
***************
3ef2ca
*** 180,185 ****
3ef2ca
--- 180,188 ----
3ef2ca
  :echo g:Foo(2)
3ef2ca
  :echo Foo(3)
3ef2ca
  :"
3ef2ca
+ :" script-local function used in Funcref must exist.
3ef2ca
+ :so test_eval_func.vim
3ef2ca
+ :"
3ef2ca
  :/^start:/+1,$wq! test.out
3ef2ca
  :" vim: et ts=4 isk-=\: fmr=???,???
3ef2ca
  :call getchar()
3ef2ca
*** ../vim-7.4.267/src/testdir/test_eval.ok	2014-04-24 17:12:29.584911764 +0200
3ef2ca
--- src/testdir/test_eval.ok	2014-04-29 13:59:39.551922998 +0200
3ef2ca
***************
3ef2ca
*** 341,343 ****
3ef2ca
--- 341,347 ----
3ef2ca
  called Foo(1)
3ef2ca
  called Foo(2)
3ef2ca
  called Foo(3)
3ef2ca
+ s:Testje exists: 0
3ef2ca
+ func s:Testje exists: 1
3ef2ca
+ Bar exists: 1
3ef2ca
+ func Bar exists: 1
3ef2ca
*** ../vim-7.4.267/src/testdir/test_eval_func.vim	2014-04-29 14:02:08.415920389 +0200
3ef2ca
--- src/testdir/test_eval_func.vim	2014-04-29 13:57:34.503925189 +0200
3ef2ca
***************
3ef2ca
*** 0 ****
3ef2ca
--- 1,10 ----
3ef2ca
+ " Vim script used in test_eval.in.  Needed for script-local function.
3ef2ca
+ 
3ef2ca
+ func! s:Testje()
3ef2ca
+   return "foo"
3ef2ca
+ endfunc
3ef2ca
+ let Bar = function('s:Testje')
3ef2ca
+ $put ='s:Testje exists: ' . exists('s:Testje')
3ef2ca
+ $put ='func s:Testje exists: ' . exists('*s:Testje')
3ef2ca
+ $put ='Bar exists: ' . exists('Bar')
3ef2ca
+ $put ='func Bar exists: ' . exists('*Bar')
3ef2ca
*** ../vim-7.4.267/Filelist	2014-04-05 21:59:35.939178415 +0200
3ef2ca
--- Filelist	2014-04-29 13:58:40.207924038 +0200
3ef2ca
***************
3ef2ca
*** 88,93 ****
3ef2ca
--- 88,94 ----
3ef2ca
  		src/testdir/test60.vim \
3ef2ca
  		src/testdir/test83-tags? \
3ef2ca
  		src/testdir/test77a.com \
3ef2ca
+ 		src/testdir/test_*.vim \
3ef2ca
  		src/testdir/python2/*.py \
3ef2ca
  		src/testdir/python3/*.py \
3ef2ca
  		src/testdir/pythonx/*.py \
3ef2ca
*** ../vim-7.4.267/src/version.c	2014-04-29 12:15:22.860032651 +0200
3ef2ca
--- src/version.c	2014-04-29 13:47:32.935935732 +0200
3ef2ca
***************
3ef2ca
*** 736,737 ****
3ef2ca
--- 736,739 ----
3ef2ca
  {   /* Add new patch number below this line */
3ef2ca
+ /**/
3ef2ca
+     268,
3ef2ca
  /**/
3ef2ca
3ef2ca
-- 
3ef2ca
I AM THANKFUL...
3ef2ca
...for the piles of laundry and ironing because it means I
3ef2ca
have plenty of clothes to wear.
3ef2ca
3ef2ca
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
3ef2ca
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
3ef2ca
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
3ef2ca
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///