Karsten Hopp 4da55a
To: vim_dev@googlegroups.com
Karsten Hopp 4da55a
Subject: Patch 7.4.086
Karsten Hopp 4da55a
Fcc: outbox
Karsten Hopp 4da55a
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 4da55a
Mime-Version: 1.0
Karsten Hopp 4da55a
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 4da55a
Content-Transfer-Encoding: 8bit
Karsten Hopp 4da55a
------------
Karsten Hopp 4da55a
Karsten Hopp 4da55a
Patch 7.4.086
Karsten Hopp 4da55a
Problem:    Skipping over an expression when not evaluating it does not work
Karsten Hopp 4da55a
            properly for dict members.
Karsten Hopp 4da55a
Solution:   Skip over unrecognized expression. (ZyX)
Karsten Hopp 4da55a
Files:      src/eval.c, src/testdir/test34.in, src/testdir/test34.ok
Karsten Hopp 4da55a
Karsten Hopp 4da55a
Karsten Hopp 4da55a
*** ../vim-7.4.085/src/eval.c	2013-11-08 04:30:06.000000000 +0100
Karsten Hopp 4da55a
--- src/eval.c	2013-11-11 04:11:38.000000000 +0100
Karsten Hopp 4da55a
***************
Karsten Hopp 4da55a
*** 19845,19868 ****
Karsten Hopp 4da55a
      while (ret == OK
Karsten Hopp 4da55a
  	    && (**arg == '['
Karsten Hopp 4da55a
  		|| (**arg == '.' && rettv->v_type == VAR_DICT)
Karsten Hopp 4da55a
! 		|| (**arg == '(' && rettv->v_type == VAR_FUNC))
Karsten Hopp 4da55a
  	    && !vim_iswhite(*(*arg - 1)))
Karsten Hopp 4da55a
      {
Karsten Hopp 4da55a
  	if (**arg == '(')
Karsten Hopp 4da55a
  	{
Karsten Hopp 4da55a
  	    /* need to copy the funcref so that we can clear rettv */
Karsten Hopp 4da55a
! 	    functv = *rettv;
Karsten Hopp 4da55a
! 	    rettv->v_type = VAR_UNKNOWN;
Karsten Hopp 4da55a
  
Karsten Hopp 4da55a
! 	    /* Invoke the function.  Recursive! */
Karsten Hopp 4da55a
! 	    s = functv.vval.v_string;
Karsten Hopp 4da55a
  	    ret = get_func_tv(s, (int)STRLEN(s), rettv, arg,
Karsten Hopp 4da55a
  			curwin->w_cursor.lnum, curwin->w_cursor.lnum,
Karsten Hopp 4da55a
  			&len, evaluate, selfdict);
Karsten Hopp 4da55a
  
Karsten Hopp 4da55a
  	    /* Clear the funcref afterwards, so that deleting it while
Karsten Hopp 4da55a
  	     * evaluating the arguments is possible (see test55). */
Karsten Hopp 4da55a
! 	    clear_tv(&functv);
Karsten Hopp 4da55a
  
Karsten Hopp 4da55a
  	    /* Stop the expression evaluation when immediately aborting on
Karsten Hopp 4da55a
  	     * error, or when an interrupt occurred or an exception was thrown
Karsten Hopp 4da55a
--- 19845,19874 ----
Karsten Hopp 4da55a
      while (ret == OK
Karsten Hopp 4da55a
  	    && (**arg == '['
Karsten Hopp 4da55a
  		|| (**arg == '.' && rettv->v_type == VAR_DICT)
Karsten Hopp 4da55a
! 		|| (**arg == '(' && (!evaluate || rettv->v_type == VAR_FUNC)))
Karsten Hopp 4da55a
  	    && !vim_iswhite(*(*arg - 1)))
Karsten Hopp 4da55a
      {
Karsten Hopp 4da55a
  	if (**arg == '(')
Karsten Hopp 4da55a
  	{
Karsten Hopp 4da55a
  	    /* need to copy the funcref so that we can clear rettv */
Karsten Hopp 4da55a
! 	    if (evaluate)
Karsten Hopp 4da55a
! 	    {
Karsten Hopp 4da55a
! 		functv = *rettv;
Karsten Hopp 4da55a
! 		rettv->v_type = VAR_UNKNOWN;
Karsten Hopp 4da55a
  
Karsten Hopp 4da55a
! 		/* Invoke the function.  Recursive! */
Karsten Hopp 4da55a
! 		s = functv.vval.v_string;
Karsten Hopp 4da55a
! 	    }
Karsten Hopp 4da55a
! 	    else
Karsten Hopp 4da55a
! 		s = (char_u *)"";
Karsten Hopp 4da55a
  	    ret = get_func_tv(s, (int)STRLEN(s), rettv, arg,
Karsten Hopp 4da55a
  			curwin->w_cursor.lnum, curwin->w_cursor.lnum,
Karsten Hopp 4da55a
  			&len, evaluate, selfdict);
Karsten Hopp 4da55a
  
Karsten Hopp 4da55a
  	    /* Clear the funcref afterwards, so that deleting it while
Karsten Hopp 4da55a
  	     * evaluating the arguments is possible (see test55). */
Karsten Hopp 4da55a
! 	    if (evaluate)
Karsten Hopp 4da55a
! 		clear_tv(&functv);
Karsten Hopp 4da55a
  
Karsten Hopp 4da55a
  	    /* Stop the expression evaluation when immediately aborting on
Karsten Hopp 4da55a
  	     * error, or when an interrupt occurred or an exception was thrown
Karsten Hopp 4da55a
*** ../vim-7.4.085/src/testdir/test34.in	2012-07-16 16:51:29.000000000 +0200
Karsten Hopp 4da55a
--- src/testdir/test34.in	2013-11-11 04:10:13.000000000 +0100
Karsten Hopp 4da55a
***************
Karsten Hopp 4da55a
*** 1,6 ****
Karsten Hopp 4da55a
--- 1,7 ----
Karsten Hopp 4da55a
  Test for user functions.
Karsten Hopp 4da55a
  Also test an <expr> mapping calling a function.
Karsten Hopp 4da55a
  Also test that a builtin function cannot be replaced.
Karsten Hopp 4da55a
+ Also test for regression when calling arbitrary expression.
Karsten Hopp 4da55a
  
Karsten Hopp 4da55a
  STARTTEST
Karsten Hopp 4da55a
  :so small.vim
Karsten Hopp 4da55a
***************
Karsten Hopp 4da55a
*** 62,68 ****
Karsten Hopp 4da55a
  [(one again?:call append(line('$'), max([1, 2, 3]))
Karsten Hopp 4da55a
  :call extend(g:, {'max': function('min')})
Karsten Hopp 4da55a
  :call append(line('$'), max([1, 2, 3]))
Karsten Hopp 4da55a
! :$-7,$w! test.out
Karsten Hopp 4da55a
  :delfunc Table
Karsten Hopp 4da55a
  :delfunc Compute
Karsten Hopp 4da55a
  :delfunc Expr1
Karsten Hopp 4da55a
--- 63,79 ----
Karsten Hopp 4da55a
  [(one again?:call append(line('$'), max([1, 2, 3]))
Karsten Hopp 4da55a
  :call extend(g:, {'max': function('min')})
Karsten Hopp 4da55a
  :call append(line('$'), max([1, 2, 3]))
Karsten Hopp 4da55a
! :try
Karsten Hopp 4da55a
! :    " Regression: the first line below used to throw ?E110: Missing ')'?
Karsten Hopp 4da55a
! :    " Second is here just to prove that this line is correct when not skipping
Karsten Hopp 4da55a
! :    " rhs of &&.
Karsten Hopp 4da55a
! :    $put =(0&&(function('tr'))(1, 2, 3))
Karsten Hopp 4da55a
! :    $put =(1&&(function('tr'))(1, 2, 3))
Karsten Hopp 4da55a
! :catch
Karsten Hopp 4da55a
! :    $put ='!!! Unexpected exception:'
Karsten Hopp 4da55a
! :    $put =v:exception
Karsten Hopp 4da55a
! :endtry
Karsten Hopp 4da55a
! :$-9,$w! test.out
Karsten Hopp 4da55a
  :delfunc Table
Karsten Hopp 4da55a
  :delfunc Compute
Karsten Hopp 4da55a
  :delfunc Expr1
Karsten Hopp 4da55a
*** ../vim-7.4.085/src/testdir/test34.ok	2012-07-16 16:43:15.000000000 +0200
Karsten Hopp 4da55a
--- src/testdir/test34.ok	2013-11-11 04:10:13.000000000 +0100
Karsten Hopp 4da55a
***************
Karsten Hopp 4da55a
*** 6,8 ****
Karsten Hopp 4da55a
--- 6,10 ----
Karsten Hopp 4da55a
  1. one again
Karsten Hopp 4da55a
  3
Karsten Hopp 4da55a
  3
Karsten Hopp 4da55a
+ 0
Karsten Hopp 4da55a
+ 1
Karsten Hopp 4da55a
*** ../vim-7.4.085/src/version.c	2013-11-11 01:29:16.000000000 +0100
Karsten Hopp 4da55a
--- src/version.c	2013-11-11 04:15:59.000000000 +0100
Karsten Hopp 4da55a
***************
Karsten Hopp 4da55a
*** 740,741 ****
Karsten Hopp 4da55a
--- 740,743 ----
Karsten Hopp 4da55a
  {   /* Add new patch number below this line */
Karsten Hopp 4da55a
+ /**/
Karsten Hopp 4da55a
+     86,
Karsten Hopp 4da55a
  /**/
Karsten Hopp 4da55a
Karsten Hopp 4da55a
-- 
Karsten Hopp 4da55a
ARTHUR: The swallow may fly south with the sun, or the house martin or the
Karsten Hopp 4da55a
        plover seek warmer hot lands in winter, yet these are not strangers to
Karsten Hopp 4da55a
        our land.
Karsten Hopp 4da55a
SOLDIER: Are you suggesting coconuts migrate?
Karsten Hopp 4da55a
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
Karsten Hopp 4da55a
Karsten Hopp 4da55a
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 4da55a
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 4da55a
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 4da55a
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///