summaryrefslogtreecommitdiff
path: root/source/ap/vim/patches/7.4.001
blob: 5788972a569d9c3882230f79b0b05fb72cee8270 (plain)
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
To: vim_dev@googlegroups.com
Subject: Patch 7.4.001
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.001
Problem:    Character classes such as [a-z] to not react to 'ignorecase'.
	    Breaks man page highlighting. (Mario Grgic)
Solution:   Add separate items for classes that react to 'ignorecase'.  Clean
	    up logic handling character classes.  Add more tests.
Files:	    src/regexp_nfa.c, src/testdir/test64.in, src/testdir/test64.ok


*** ../vim-7.4.000/src/regexp_nfa.c	2013-08-01 18:27:51.000000000 +0200
--- src/regexp_nfa.c	2013-08-14 11:49:50.000000000 +0200
***************
*** 29,34 ****
--- 29,37 ----
  # define NFA_REGEXP_DEBUG_LOG	"nfa_regexp_debug.log"
  #endif
  
+ /* Added to NFA_ANY - NFA_NUPPER_IC to include a NL. */
+ #define NFA_ADD_NL		31
+ 
  enum
  {
      NFA_SPLIT = -1024,
***************
*** 183,188 ****
--- 186,198 ----
      NFA_NLOWER,		/*	Match non-lowercase char */
      NFA_UPPER,		/*	Match uppercase char */
      NFA_NUPPER,		/*	Match non-uppercase char */
+     NFA_LOWER_IC,	/*	Match [a-z] */
+     NFA_NLOWER_IC,	/*	Match [^a-z] */
+     NFA_UPPER_IC,	/*	Match [A-Z] */
+     NFA_NUPPER_IC,	/*	Match [^A-Z] */
+ 
+     NFA_FIRST_NL = NFA_ANY + NFA_ADD_NL,
+     NFA_LAST_NL = NFA_NUPPER_IC + NFA_ADD_NL,
  
      NFA_CURSOR,		/*	Match cursor pos */
      NFA_LNUM,		/*	Match line number */
***************
*** 199,207 ****
      NFA_MARK_LT,	/*	Match < mark */
      NFA_VISUAL,		/*	Match Visual area */
  
-     NFA_FIRST_NL = NFA_ANY + ADD_NL,
-     NFA_LAST_NL = NFA_NUPPER + ADD_NL,
- 
      /* Character classes [:alnum:] etc */
      NFA_CLASS_ALNUM,
      NFA_CLASS_ALPHA,
--- 209,214 ----
***************
*** 578,583 ****
--- 585,592 ----
   * On failure, return 0 (=FAIL)
   * Start points to the first char of the range, while end should point
   * to the closing brace.
+  * Keep in mind that 'ignorecase' applies at execution time, thus [a-z] may
+  * need to be interpreted as [a-zA-Z].
   */
      static int
  nfa_recognize_char_class(start, end, extra_newl)
***************
*** 681,687 ****
  	return FAIL;
  
      if (newl == TRUE)
! 	extra_newl = ADD_NL;
  
      switch (config)
      {
--- 690,696 ----
  	return FAIL;
  
      if (newl == TRUE)
! 	extra_newl = NFA_ADD_NL;
  
      switch (config)
      {
***************
*** 710,722 ****
  	case CLASS_not | CLASS_az | CLASS_AZ:
  	    return extra_newl + NFA_NALPHA;
  	case CLASS_az:
! 	   return extra_newl + NFA_LOWER;
  	case CLASS_not | CLASS_az:
! 	    return extra_newl + NFA_NLOWER;
  	case CLASS_AZ:
! 	    return extra_newl + NFA_UPPER;
  	case CLASS_not | CLASS_AZ:
! 	    return extra_newl + NFA_NUPPER;
      }
      return FAIL;
  }
--- 719,731 ----
  	case CLASS_not | CLASS_az | CLASS_AZ:
  	    return extra_newl + NFA_NALPHA;
  	case CLASS_az:
! 	   return extra_newl + NFA_LOWER_IC;
  	case CLASS_not | CLASS_az:
! 	    return extra_newl + NFA_NLOWER_IC;
  	case CLASS_AZ:
! 	    return extra_newl + NFA_UPPER_IC;
  	case CLASS_not | CLASS_AZ:
! 	    return extra_newl + NFA_NUPPER_IC;
      }
      return FAIL;
  }
***************
*** 914,920 ****
  		break;
  	    }
  
! 	    extra = ADD_NL;
  
  	    /* "\_[" is collection plus newline */
  	    if (c == '[')
--- 923,929 ----
  		break;
  	    }
  
! 	    extra = NFA_ADD_NL;
  
  	    /* "\_[" is collection plus newline */
  	    if (c == '[')
***************
*** 970,976 ****
  	    }
  #endif
  	    EMIT(nfa_classcodes[p - classchars]);
! 	    if (extra == ADD_NL)
  	    {
  		EMIT(NFA_NEWL);
  		EMIT(NFA_OR);
--- 979,985 ----
  	    }
  #endif
  	    EMIT(nfa_classcodes[p - classchars]);
! 	    if (extra == NFA_ADD_NL)
  	    {
  		EMIT(NFA_NEWL);
  		EMIT(NFA_OR);
***************
*** 1240,1260 ****
  	    {
  		/*
  		 * Try to reverse engineer character classes. For example,
! 		 * recognize that [0-9] stands for  \d and [A-Za-z_] with \h,
  		 * and perform the necessary substitutions in the NFA.
  		 */
  		result = nfa_recognize_char_class(regparse, endp,
! 							    extra == ADD_NL);
  		if (result != FAIL)
  		{
! 		    if (result >= NFA_DIGIT && result <= NFA_NUPPER)
! 			EMIT(result);
! 		    else	/* must be char class + newline */
  		    {
! 			EMIT(result - ADD_NL);
  			EMIT(NFA_NEWL);
  			EMIT(NFA_OR);
  		    }
  		    regparse = endp;
  		    mb_ptr_adv(regparse);
  		    return OK;
--- 1249,1269 ----
  	    {
  		/*
  		 * Try to reverse engineer character classes. For example,
! 		 * recognize that [0-9] stands for \d and [A-Za-z_] for \h,
  		 * and perform the necessary substitutions in the NFA.
  		 */
  		result = nfa_recognize_char_class(regparse, endp,
! 							 extra == NFA_ADD_NL);
  		if (result != FAIL)
  		{
! 		    if (result >= NFA_FIRST_NL && result <= NFA_LAST_NL)
  		    {
! 			EMIT(result - NFA_ADD_NL);
  			EMIT(NFA_NEWL);
  			EMIT(NFA_OR);
  		    }
+ 		    else
+ 			EMIT(result);
  		    regparse = endp;
  		    mb_ptr_adv(regparse);
  		    return OK;
***************
*** 1504,1510 ****
  			     * collection, add an OR below. But not for negated
  			     * range. */
  			    if (!negated)
! 				extra = ADD_NL;
  			}
  			else
  			{
--- 1513,1519 ----
  			     * collection, add an OR below. But not for negated
  			     * range. */
  			    if (!negated)
! 				extra = NFA_ADD_NL;
  			}
  			else
  			{
***************
*** 1537,1543 ****
  		    EMIT(NFA_END_COLL);
  
  		/* \_[] also matches \n but it's not negated */
! 		if (extra == ADD_NL)
  		{
  		    EMIT(reg_string ? NL : NFA_NEWL);
  		    EMIT(NFA_OR);
--- 1546,1552 ----
  		    EMIT(NFA_END_COLL);
  
  		/* \_[] also matches \n but it's not negated */
! 		if (extra == NFA_ADD_NL)
  		{
  		    EMIT(reg_string ? NL : NFA_NEWL);
  		    EMIT(NFA_OR);
***************
*** 2011,2017 ****
      if (c >= NFA_FIRST_NL && c <= NFA_LAST_NL)
      {
  	addnl = TRUE;
! 	c -= ADD_NL;
      }
  
      STRCPY(code, "");
--- 2020,2026 ----
      if (c >= NFA_FIRST_NL && c <= NFA_LAST_NL)
      {
  	addnl = TRUE;
! 	c -= NFA_ADD_NL;
      }
  
      STRCPY(code, "");
***************
*** 2217,2222 ****
--- 2226,2235 ----
  	case NFA_NLOWER:STRCPY(code, "NFA_NLOWER"); break;
  	case NFA_UPPER:	STRCPY(code, "NFA_UPPER"); break;
  	case NFA_NUPPER:STRCPY(code, "NFA_NUPPER"); break;
+ 	case NFA_LOWER_IC:  STRCPY(code, "NFA_LOWER_IC"); break;
+ 	case NFA_NLOWER_IC: STRCPY(code, "NFA_NLOWER_IC"); break;
+ 	case NFA_UPPER_IC:  STRCPY(code, "NFA_UPPER_IC"); break;
+ 	case NFA_NUPPER_IC: STRCPY(code, "NFA_NUPPER_IC"); break;
  
  	default:
  	    STRCPY(code, "CHAR(x)");
***************
*** 2687,2692 ****
--- 2700,2709 ----
  	    case NFA_NLOWER:
  	    case NFA_UPPER:
  	    case NFA_NUPPER:
+ 	    case NFA_LOWER_IC:
+ 	    case NFA_NLOWER_IC:
+ 	    case NFA_UPPER_IC:
+ 	    case NFA_NUPPER_IC:
  		/* possibly non-ascii */
  #ifdef FEAT_MBYTE
  		if (has_mbyte)
***************
*** 3841,3846 ****
--- 3858,3867 ----
  	    case NFA_NLOWER:
  	    case NFA_UPPER:
  	    case NFA_NUPPER:
+ 	    case NFA_LOWER_IC:
+ 	    case NFA_NLOWER_IC:
+ 	    case NFA_UPPER_IC:
+ 	    case NFA_NUPPER_IC:
  	    case NFA_START_COLL:
  	    case NFA_START_NEG_COLL:
  	    case NFA_NEWL:
***************
*** 5872,5877 ****
--- 5893,5920 ----
  		ADD_STATE_IF_MATCH(t->state);
  		break;
  
+ 	    case NFA_LOWER_IC:	/* [a-z] */
+ 		result = ri_lower(curc) || (ireg_ic && ri_upper(curc));
+ 		ADD_STATE_IF_MATCH(t->state);
+ 		break;
+ 
+ 	    case NFA_NLOWER_IC:	/* [^a-z] */
+ 		result = curc != NUL
+ 			  && !(ri_lower(curc) || (ireg_ic && ri_upper(curc)));
+ 		ADD_STATE_IF_MATCH(t->state);
+ 		break;
+ 
+ 	    case NFA_UPPER_IC:	/* [A-Z] */
+ 		result = ri_upper(curc) || (ireg_ic && ri_lower(curc));
+ 		ADD_STATE_IF_MATCH(t->state);
+ 		break;
+ 
+ 	    case NFA_NUPPER_IC:	/* ^[A-Z] */
+ 		result = curc != NUL
+ 			  && !(ri_upper(curc) || (ireg_ic && ri_lower(curc)));
+ 		ADD_STATE_IF_MATCH(t->state);
+ 		break;
+ 
  	    case NFA_BACKREF1:
  	    case NFA_BACKREF2:
  	    case NFA_BACKREF3:
*** ../vim-7.4.000/src/testdir/test64.in	2013-08-01 17:45:33.000000000 +0200
--- src/testdir/test64.in	2013-08-14 11:50:11.000000000 +0200
***************
*** 289,303 ****
  :call add(tl, [2, '.a\%$', " a\n "])
  :call add(tl, [2, '.a\%$', " a\n_a", "_a"])
  :"
! :"""" Test recognition of some character classes
! :call add(tl, [2, '[0-9]', '8', '8'])
! :call add(tl, [2, '[^0-9]', '8'])
! :call add(tl, [2, '[0-9a-fA-F]*', '0a7', '0a7'])
! :call add(tl, [2, '[^0-9A-Fa-f]\+', '0a7'])
! :call add(tl, [2, '[a-z_A-Z0-9]\+', 'aso_sfoij', 'aso_sfoij'])
! :call add(tl, [2, '[a-z]', 'a', 'a'])
! :call add(tl, [2, '[a-zA-Z]', 'a', 'a'])
! :call add(tl, [2, '[A-Z]', 'a'])
  :call add(tl, [2, '\C[^A-Z]\+', 'ABCOIJDEOIFNSD jsfoij sa', ' jsfoij sa'])
  :"
  :"""" Tests for \z features
--- 289,317 ----
  :call add(tl, [2, '.a\%$', " a\n "])
  :call add(tl, [2, '.a\%$', " a\n_a", "_a"])
  :"
! :"""" Test recognition of character classes
! :call add(tl, [2, '[0-7]\+', 'x0123456789x', '01234567'])
! :call add(tl, [2, '[^0-7]\+', '0a;X+% 897', 'a;X+% 89'])
! :call add(tl, [2, '[0-9]\+', 'x0123456789x', '0123456789'])
! :call add(tl, [2, '[^0-9]\+', '0a;X+% 9', 'a;X+% '])
! :call add(tl, [2, '[0-9a-fA-F]\+', 'x0189abcdefg', '0189abcdef'])
! :call add(tl, [2, '[^0-9A-Fa-f]\+', '0189g;X+% ab', 'g;X+% '])
! :call add(tl, [2, '[a-z_A-Z0-9]\+', ';+aso_SfOij ', 'aso_SfOij'])
! :call add(tl, [2, '[^a-z_A-Z0-9]\+', 'aSo_;+% sfOij', ';+% '])
! :call add(tl, [2, '[a-z_A-Z]\+', '0abyz_ABYZ;', 'abyz_ABYZ'])
! :call add(tl, [2, '[^a-z_A-Z]\+', 'abAB_09;+% yzYZ', '09;+% '])
! :call add(tl, [2, '[a-z]\+', '0abcxyz1', 'abcxyz'])
! :call add(tl, [2, '[a-z]\+', 'AabxyzZ', 'abxyz'])
! :call add(tl, [2, '[^a-z]\+', 'a;X09+% x', ';X09+% '])
! :call add(tl, [2, '[^a-z]\+', 'abX0;%yz', 'X0;%'])
! :call add(tl, [2, '[a-zA-Z]\+', '0abABxzXZ9', 'abABxzXZ'])
! :call add(tl, [2, '[^a-zA-Z]\+', 'ab09_;+ XZ', '09_;+ '])
! :call add(tl, [2, '[A-Z]\+', 'aABXYZz', 'ABXYZ'])
! :call add(tl, [2, '[^A-Z]\+', 'ABx0;%YZ', 'x0;%'])
! :call add(tl, [2, '[a-z]\+\c', '0abxyzABXYZ;', 'abxyzABXYZ'])
! :call add(tl, [2, '[A-Z]\+\c', '0abABxzXZ9', 'abABxzXZ'])
! :call add(tl, [2, '\c[^a-z]\+', 'ab09_;+ XZ', '09_;+ '])
! :call add(tl, [2, '\c[^A-Z]\+', 'ab09_;+ XZ', '09_;+ '])
  :call add(tl, [2, '\C[^A-Z]\+', 'ABCOIJDEOIFNSD jsfoij sa', ' jsfoij sa'])
  :"
  :"""" Tests for \z features
*** ../vim-7.4.000/src/testdir/test64.ok	2013-08-01 18:28:56.000000000 +0200
--- src/testdir/test64.ok	2013-08-14 11:50:37.000000000 +0200
***************
*** 650,679 ****
  OK 0 - .a\%$
  OK 1 - .a\%$
  OK 2 - .a\%$
! OK 0 - [0-9]
! OK 1 - [0-9]
! OK 2 - [0-9]
! OK 0 - [^0-9]
! OK 1 - [^0-9]
! OK 2 - [^0-9]
! OK 0 - [0-9a-fA-F]*
! OK 1 - [0-9a-fA-F]*
! OK 2 - [0-9a-fA-F]*
  OK 0 - [^0-9A-Fa-f]\+
  OK 1 - [^0-9A-Fa-f]\+
  OK 2 - [^0-9A-Fa-f]\+
  OK 0 - [a-z_A-Z0-9]\+
  OK 1 - [a-z_A-Z0-9]\+
  OK 2 - [a-z_A-Z0-9]\+
! OK 0 - [a-z]
! OK 1 - [a-z]
! OK 2 - [a-z]
! OK 0 - [a-zA-Z]
! OK 1 - [a-zA-Z]
! OK 2 - [a-zA-Z]
! OK 0 - [A-Z]
! OK 1 - [A-Z]
! OK 2 - [A-Z]
  OK 0 - \C[^A-Z]\+
  OK 1 - \C[^A-Z]\+
  OK 2 - \C[^A-Z]\+
--- 650,721 ----
  OK 0 - .a\%$
  OK 1 - .a\%$
  OK 2 - .a\%$
! OK 0 - [0-7]\+
! OK 1 - [0-7]\+
! OK 2 - [0-7]\+
! OK 0 - [^0-7]\+
! OK 1 - [^0-7]\+
! OK 2 - [^0-7]\+
! OK 0 - [0-9]\+
! OK 1 - [0-9]\+
! OK 2 - [0-9]\+
! OK 0 - [^0-9]\+
! OK 1 - [^0-9]\+
! OK 2 - [^0-9]\+
! OK 0 - [0-9a-fA-F]\+
! OK 1 - [0-9a-fA-F]\+
! OK 2 - [0-9a-fA-F]\+
  OK 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013-08-10 13:29:20.000000000 +0200
--- src/version.c	2013-08-14 11:54:57.000000000 +0200
***************
*** 729,730 ****
--- 729,732 ----
  {   /* Add new patch number below this line */
+ /**/
+     1,
  /**/

-- 
How many light bulbs does it take to change a person?

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