summaryrefslogtreecommitdiffstats
path: root/patches/source/vim/patches/7.4.184
blob: d6ceb64af14548156308372a3825d6074da949b4 (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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
To: vim_dev@googlegroups.com
Subject: Patch 7.4.184
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.184
Problem:    match() does not work properly with a {count} argument.
Solution:   Compute the length once and update it.  Quit the loop when at the
            end. (Hirohito Higashi)
Files:      src/eval.c, src/testdir/test53.in, src/testdir/test53.ok


*** ../vim-7.4.183/src/eval.c	2014-02-05 22:13:02.366556787 +0100
--- src/eval.c	2014-02-22 22:13:26.644906020 +0100
***************
*** 8014,8020 ****
      {"log10",		1, 1, f_log10},
  #endif
  #ifdef FEAT_LUA
!     {"luaeval",         1, 2, f_luaeval},
  #endif
      {"map",		2, 2, f_map},
      {"maparg",		1, 4, f_maparg},
--- 8014,8020 ----
      {"log10",		1, 1, f_log10},
  #endif
  #ifdef FEAT_LUA
!     {"luaeval",		1, 2, f_luaeval},
  #endif
      {"map",		2, 2, f_map},
      {"maparg",		1, 4, f_maparg},
***************
*** 13905,13910 ****
--- 13905,13911 ----
      int		type;
  {
      char_u	*str = NULL;
+     long	len = 0;
      char_u	*expr = NULL;
      char_u	*pat;
      regmatch_T	regmatch;
***************
*** 13944,13950 ****
--- 13945,13954 ----
  	li = l->lv_first;
      }
      else
+     {
  	expr = str = get_tv_string(&argvars[0]);
+ 	len = (long)STRLEN(str);
+     }
  
      pat = get_tv_string_buf_chk(&argvars[1], patbuf);
      if (pat == NULL)
***************
*** 13968,13974 ****
  	{
  	    if (start < 0)
  		start = 0;
! 	    if (start > (long)STRLEN(str))
  		goto theend;
  	    /* When "count" argument is there ignore matches before "start",
  	     * otherwise skip part of the string.  Differs when pattern is "^"
--- 13972,13978 ----
  	{
  	    if (start < 0)
  		start = 0;
! 	    if (start > len)
  		goto theend;
  	    /* When "count" argument is there ignore matches before "start",
  	     * otherwise skip part of the string.  Differs when pattern is "^"
***************
*** 13976,13982 ****
--- 13980,13989 ----
  	    if (argvars[3].v_type != VAR_UNKNOWN)
  		startcol = start;
  	    else
+ 	    {
  		str += start;
+ 		len -= start;
+ 	    }
  	}
  
  	if (argvars[3].v_type != VAR_UNKNOWN)
***************
*** 14026,14031 ****
--- 14033,14044 ----
  #else
  		startcol = (colnr_T)(regmatch.startp[0] + 1 - str);
  #endif
+ 		if (startcol > (colnr_T)len
+ 				      || str + startcol <= regmatch.startp[0])
+ 		{
+ 		    match = FALSE;
+ 		    break;
+ 		}
  	    }
  	}
  
*** ../vim-7.4.183/src/testdir/test53.in	2013-10-02 21:54:57.000000000 +0200
--- src/testdir/test53.in	2014-02-22 22:08:24.260906501 +0100
***************
*** 4,9 ****
--- 4,11 ----
  
  Also test match() and matchstr()
  
+ Also test the gn command and repeating it.
+ 
  STARTTEST
  :so small.vim
  /^start:/
***************
*** 28,33 ****
--- 30,57 ----
  :put =matchstr(\"abcd\", \".\", 0, -1) " a
  :put =match(\"abcd\", \".\", 0, 5) " -1
  :put =match(\"abcd\", \".\", 0, -1) " 0
+ :put =match('abc', '.', 0, 1) " 0
+ :put =match('abc', '.', 0, 2) " 1
+ :put =match('abc', '.', 0, 3) " 2
+ :put =match('abc', '.', 0, 4) " -1
+ :put =match('abc', '.', 1, 1) " 1
+ :put =match('abc', '.', 2, 1) " 2
+ :put =match('abc', '.', 3, 1) " -1
+ :put =match('abc', '$', 0, 1) " 3
+ :put =match('abc', '$', 0, 2) " -1
+ :put =match('abc', '$', 1, 1) " 3
+ :put =match('abc', '$', 2, 1) " 3
+ :put =match('abc', '$', 3, 1) " 3
+ :put =match('abc', '$', 4, 1) " -1
+ :put =match('abc', '\zs', 0, 1) " 0
+ :put =match('abc', '\zs', 0, 2) " 1
+ :put =match('abc', '\zs', 0, 3) " 2
+ :put =match('abc', '\zs', 0, 4) " 3
+ :put =match('abc', '\zs', 0, 5) " -1
+ :put =match('abc', '\zs', 1, 1) " 1
+ :put =match('abc', '\zs', 2, 1) " 2
+ :put =match('abc', '\zs', 3, 1) " 3
+ :put =match('abc', '\zs', 4, 1) " -1
  /^foobar
  gncsearchmatch/one\_s*two\_s
  :1
***************
*** 49,54 ****
--- 73,84 ----
  :" Make sure there is no other match y uppercase.
  /x59
  gggnd
+ :" test repeating dgn
+ /^Johnny
+ ggdgn.
+ :" test repeating gUgn
+ /^Depp
+ gggUgn.
  :/^start:/,/^end:/wq! test.out
  ENDTEST
  
***************
*** 81,84 ****
--- 111,123 ----
  Y
  text
  Y
+ --1
+ Johnny
+ --2
+ Johnny
+ --3
+ Depp
+ --4
+ Depp
+ --5
  end:
*** ../vim-7.4.183/src/testdir/test53.ok	2013-10-02 21:54:57.000000000 +0200
--- src/testdir/test53.ok	2014-02-22 22:08:24.264906501 +0100
***************
*** 18,23 ****
--- 18,45 ----
  a
  -1
  0
+ 0
+ 1
+ 2
+ -1
+ 1
+ 2
+ -1
+ 3
+ -1
+ 3
+ 3
+ 3
+ -1
+ 0
+ 1
+ 2
+ 3
+ -1
+ 1
+ 2
+ 3
+ -1
  SEARCH:
  searchmatch
  abcdx |  | abcdx
***************
*** 30,33 ****
--- 52,64 ----
  
  text
  Y
+ --1
+ 
+ --2
+ 
+ --3
+ DEPP
+ --4
+ DEPP
+ --5
  end:
*** ../vim-7.4.183/src/version.c	2014-02-15 19:47:46.685882910 +0100
--- src/version.c	2014-02-22 22:10:49.604906270 +0100
***************
*** 740,741 ****
--- 740,743 ----
  {   /* Add new patch number below this line */
+ /**/
+     184,
  /**/

-- 
WOMAN:   I didn't know we had a king. I thought we were an autonomous
         collective.
DENNIS:  You're fooling yourself.  We're living in a dictatorship.  A
         self-perpetuating autocracy in which the working classes--
WOMAN:   Oh there you go, bringing class into it again.
DENNIS:  That's what it's all about if only people would--
                                  The Quest for the Holy Grail (Monty Python)

 /// 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    ///