summaryrefslogtreecommitdiffstats
path: root/patches/source/vim/patches/7.4.086
blob: 46f9eb90ae531863e04b31d3e24115d977923eaa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
To: vim_dev@googlegroups.com
Subject: Patch 7.4.086
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.4.086
Problem:    Skipping over an expression when not evaluating it does not work
            properly for dict members.
Solution:   Skip over unrecognized expression. (ZyX)
Files:      src/eval.c, src/testdir/test34.in, src/testdir/test34.ok


*** ../vim-7.4.085/src/eval.c	2013-11-08 04:30:06.000000000 +0100
--- src/eval.c	2013-11-11 04:11:38.000000000 +0100
***************
*** 19845,19868 ****
      while (ret == OK
  	    && (**arg == '['
  		|| (**arg == '.' && rettv->v_type == VAR_DICT)
! 		|| (**arg == '(' && rettv->v_type == VAR_FUNC))
  	    && !vim_iswhite(*(*arg - 1)))
      {
  	if (**arg == '(')
  	{
  	    /* need to copy the funcref so that we can clear rettv */
! 	    functv = *rettv;
! 	    rettv->v_type = VAR_UNKNOWN;
  
! 	    /* Invoke the function.  Recursive! */
! 	    s = functv.vval.v_string;
  	    ret = get_func_tv(s, (int)STRLEN(s), rettv, arg,
  			curwin->w_cursor.lnum, curwin->w_cursor.lnum,
  			&len, evaluate, selfdict);
  
  	    /* Clear the funcref afterwards, so that deleting it while
  	     * evaluating the arguments is possible (see test55). */
! 	    clear_tv(&functv);
  
  	    /* Stop the expression evaluation when immediately aborting on
  	     * error, or when an interrupt occurred or an exception was thrown
--- 19845,19874 ----
      while (ret == OK
  	    && (**arg == '['
  		|| (**arg == '.' && rettv->v_type == VAR_DICT)
! 		|| (**arg == '(' && (!evaluate || rettv->v_type == VAR_FUNC)))
  	    && !vim_iswhite(*(*arg - 1)))
      {
  	if (**arg == '(')
  	{
  	    /* need to copy the funcref so that we can clear rettv */
! 	    if (evaluate)
! 	    {
! 		functv = *rettv;
! 		rettv->v_type = VAR_UNKNOWN;
  
! 		/* Invoke the function.  Recursive! */
! 		s = functv.vval.v_string;
! 	    }
! 	    else
! 		s = (char_u *)"";
  	    ret = get_func_tv(s, (int)STRLEN(s), rettv, arg,
  			curwin->w_cursor.lnum, curwin->w_cursor.lnum,
  			&len, evaluate, selfdict);
  
  	    /* Clear the funcref afterwards, so that deleting it while
  	     * evaluating the arguments is possible (see test55). */
! 	    if (evaluate)
! 		clear_tv(&functv);
  
  	    /* Stop the expression evaluation when immediately aborting on
  	     * error, or when an interrupt occurred or an exception was thrown
*** ../vim-7.4.085/src/testdir/test34.in	2012-07-16 16:51:29.000000000 +0200
--- src/testdir/test34.in	2013-11-11 04:10:13.000000000 +0100
***************
*** 1,6 ****
--- 1,7 ----
  Test for user functions.
  Also test an <expr> mapping calling a function.
  Also test that a builtin function cannot be replaced.
+ Also test for regression when calling arbitrary expression.
  
  STARTTEST
  :so small.vim
***************
*** 62,68 ****
  [(one again:call append(line('$'), max([1, 2, 3]))
  :call extend(g:, {'max': function('min')})
  :call append(line('$'), max([1, 2, 3]))
! :$-7,$w! test.out
  :delfunc Table
  :delfunc Compute
  :delfunc Expr1
--- 63,79 ----
  [(one again:call append(line('$'), max([1, 2, 3]))
  :call extend(g:, {'max': function('min')})
  :call append(line('$'), max([1, 2, 3]))
! :try
! :    " Regression: the first line below used to throw ?E110: Missing ')'?
! :    " Second is here just to prove that this line is correct when not skipping
! :    " rhs of &&.
! :    $put =(0&&(function('tr'))(1, 2, 3))
! :    $put =(1&&(function('tr'))(1, 2, 3))
! :catch
! :    $put ='!!! Unexpected exception:'
! :    $put =v:exception
! :endtry
! :$-9,$w! test.out
  :delfunc Table
  :delfunc Compute
  :delfunc Expr1
*** ../vim-7.4.085/src/testdir/test34.ok	2012-07-16 16:43:15.000000000 +0200
--- src/testdir/test34.ok	2013-11-11 04:10:13.000000000 +0100
***************
*** 6,8 ****
--- 6,10 ----
  1. one again
  3
  3
+ 0
+ 1
*** ../vim-7.4.085/src/version.c	2013-11-11 01:29:16.000000000 +0100
--- src/version.c	2013-11-11 04:15:59.000000000 +0100
***************
*** 740,741 ****
--- 740,743 ----
  {   /* Add new patch number below this line */
+ /**/
+     86,
  /**/

-- 
ARTHUR: The swallow may fly south with the sun, or the house martin or the
        plover seek warmer hot lands in winter, yet these are not strangers to
        our land.
SOLDIER: Are you suggesting coconuts migrate?
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///