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