summaryrefslogtreecommitdiffstats
path: root/patches/source/vim/patches/7.4.293
blob: 5cc60a1ea392bc8a6a7232826a7060a49995153c (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
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
To: vim_dev@googlegroups.com
Subject: Patch 7.4.293
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.293
Problem:    It is not possible to ignore composing characters at a specific
	    point in a pattern.
Solution:   Add the %C item.
Files:	    src/regexp.c, src/regexp_nfa.c, src/testdir/test95.in,
	    src/testdir/test95.ok, runtime/doc/pattern.txt


*** ../vim-7.4.292/src/regexp.c	2014-05-13 18:03:55.729737466 +0200
--- src/regexp.c	2014-05-13 18:27:08.725749659 +0200
***************
*** 244,249 ****
--- 244,250 ----
  
  #define RE_MARK		207	/* mark cmp  Match mark position */
  #define RE_VISUAL	208	/*	Match Visual area */
+ #define RE_COMPOSING	209	/* any composing characters */
  
  /*
   * Magic characters have a special meaning, they don't match literally.
***************
*** 2208,2213 ****
--- 2209,2218 ----
  		    ret = regnode(RE_VISUAL);
  		    break;
  
+ 		case 'C':
+ 		    ret = regnode(RE_COMPOSING);
+ 		    break;
+ 
  		/* \%[abc]: Emit as a list of branches, all ending at the last
  		 * branch which matches nothing. */
  		case '[':
***************
*** 4710,4720 ****
  			    status = RA_NOMATCH;
  		    }
  #ifdef FEAT_MBYTE
! 		    /* Check for following composing character. */
  		    if (status != RA_NOMATCH
  			    && enc_utf8
  			    && UTF_COMPOSINGLIKE(reginput, reginput + len)
! 			    && !ireg_icombine)
  		    {
  			/* raaron: This code makes a composing character get
  			 * ignored, which is the correct behavior (sometimes)
--- 4715,4727 ----
  			    status = RA_NOMATCH;
  		    }
  #ifdef FEAT_MBYTE
! 		    /* Check for following composing character, unless %C
! 		     * follows (skips over all composing chars). */
  		    if (status != RA_NOMATCH
  			    && enc_utf8
  			    && UTF_COMPOSINGLIKE(reginput, reginput + len)
! 			    && !ireg_icombine
! 			    && OP(next) != RE_COMPOSING)
  		    {
  			/* raaron: This code makes a composing character get
  			 * ignored, which is the correct behavior (sometimes)
***************
*** 4791,4796 ****
--- 4798,4813 ----
  		status = RA_NOMATCH;
  	    break;
  #endif
+ 	  case RE_COMPOSING:
+ #ifdef FEAT_MBYTE
+ 	    if (enc_utf8)
+ 	    {
+ 		/* Skip composing characters. */
+ 		while (utf_iscomposing(utf_ptr2char(reginput)))
+ 		    mb_cptr_adv(reginput);
+ 	    }
+ #endif
+ 	    break;
  
  	  case NOTHING:
  	    break;
*** ../vim-7.4.292/src/regexp_nfa.c	2014-05-13 16:44:25.633695709 +0200
--- src/regexp_nfa.c	2014-05-13 19:25:58.285780556 +0200
***************
*** 81,86 ****
--- 81,87 ----
      NFA_COMPOSING,		    /* Next nodes in NFA are part of the
  				       composing multibyte char */
      NFA_END_COMPOSING,		    /* End of a composing char in the NFA */
+     NFA_ANY_COMPOSING,		    /* \%C: Any composing characters. */
      NFA_OPT_CHARS,		    /* \%[abc] */
  
      /* The following are used only in the postfix form, not in the NFA */
***************
*** 1418,1423 ****
--- 1419,1428 ----
  		    EMIT(NFA_VISUAL);
  		    break;
  
+ 		case 'C':
+ 		    EMIT(NFA_ANY_COMPOSING);
+ 		    break;
+ 
  		case '[':
  		    {
  			int	    n;
***************
*** 2429,2434 ****
--- 2434,2440 ----
  	case NFA_MARK_LT:	STRCPY(code, "NFA_MARK_LT "); break;
  	case NFA_CURSOR:	STRCPY(code, "NFA_CURSOR "); break;
  	case NFA_VISUAL:	STRCPY(code, "NFA_VISUAL "); break;
+ 	case NFA_ANY_COMPOSING:	STRCPY(code, "NFA_ANY_COMPOSING "); break;
  
  	case NFA_STAR:		STRCPY(code, "NFA_STAR "); break;
  	case NFA_STAR_NONGREEDY: STRCPY(code, "NFA_STAR_NONGREEDY "); break;
***************
*** 2967,2972 ****
--- 2973,2979 ----
  	    case NFA_NLOWER_IC:
  	    case NFA_UPPER_IC:
  	    case NFA_NUPPER_IC:
+ 	    case NFA_ANY_COMPOSING:
  		/* possibly non-ascii */
  #ifdef FEAT_MBYTE
  		if (has_mbyte)
***************
*** 4152,4157 ****
--- 4159,4165 ----
  		continue;
  
  	    case NFA_ANY:
+ 	    case NFA_ANY_COMPOSING:
  	    case NFA_IDENT:
  	    case NFA_SIDENT:
  	    case NFA_KWORD:
***************
*** 4395,4401 ****
      switch (state->c)
      {
  	case NFA_MATCH:
! 	    nfa_match = TRUE;
  	    break;
  
  	case NFA_SPLIT:
--- 4403,4409 ----
      switch (state->c)
      {
  	case NFA_MATCH:
! //	    nfa_match = TRUE;
  	    break;
  
  	case NFA_SPLIT:
***************
*** 5151,5156 ****
--- 5159,5165 ----
  
  	case NFA_MATCH:
  	case NFA_MCLOSE:
+ 	case NFA_ANY_COMPOSING:
  	    /* empty match works always */
  	    return 0;
  
***************
*** 5573,5578 ****
--- 5582,5593 ----
  	    {
  	    case NFA_MATCH:
  	      {
+ #ifdef FEAT_MBYTE
+ 		/* If the match ends before a composing characters and
+ 		 * ireg_icombine is not set, that is not really a match. */
+ 		if (enc_utf8 && !ireg_icombine && utf_iscomposing(curc))
+ 		    break;
+ #endif
  		nfa_match = TRUE;
  		copy_sub(&submatch->norm, &t->subs.norm);
  #ifdef FEAT_SYN_HL
***************
*** 6120,6125 ****
--- 6135,6157 ----
  		}
  		break;
  
+ 	    case NFA_ANY_COMPOSING:
+ 		/* On a composing character skip over it.  Otherwise do
+ 		 * nothing.  Always matches. */
+ #ifdef FEAT_MBYTE
+ 		if (enc_utf8 && utf_iscomposing(curc))
+ 		{
+ 		    add_off = clen;
+ 		}
+ 		else
+ #endif
+ 		{
+ 		    add_here = TRUE;
+ 		    add_off = 0;
+ 		}
+ 		add_state = t->state->out;
+ 		break;
+ 
  	    /*
  	     * Character classes like \a for alpha, \d for digit etc.
  	     */
***************
*** 6484,6495 ****
  		if (!result && ireg_ic)
  		    result = MB_TOLOWER(c) == MB_TOLOWER(curc);
  #ifdef FEAT_MBYTE
! 		/* If there is a composing character which is not being
! 		 * ignored there can be no match. Match with composing
! 		 * character uses NFA_COMPOSING above. */
! 		if (result && enc_utf8 && !ireg_icombine
! 						&& clen != utf_char2len(curc))
! 		    result = FALSE;
  #endif
  		ADD_STATE_IF_MATCH(t->state);
  		break;
--- 6516,6525 ----
  		if (!result && ireg_ic)
  		    result = MB_TOLOWER(c) == MB_TOLOWER(curc);
  #ifdef FEAT_MBYTE
! 		/* If ireg_icombine is not set only skip over the character
! 		 * itself.  When it is set skip over composing characters. */
! 		if (result && enc_utf8 && !ireg_icombine)
! 		    clen = utf_char2len(curc);
  #endif
  		ADD_STATE_IF_MATCH(t->state);
  		break;
diff: ../vim-7.4.292/src/testdir/test95.insrc/testdir/test95.ok,: No such file or directory
diff: src/testdir/test95.insrc/testdir/test95.ok,: No such file or directory
*** ../vim-7.4.292/runtime/doc/pattern.txt	2013-08-10 13:24:59.000000000 +0200
--- runtime/doc/pattern.txt	2014-05-13 18:59:57.621766895 +0200
***************
*** 545,550 ****
--- 545,551 ----
  |/\%u|	\%u	\%u	match specified multibyte character (eg \%u20ac)
  |/\%U|	\%U	\%U	match specified large multibyte character (eg
  			\%U12345678)
+ |/\%C|	\%C	\%C	match any composing characters
  
  Example			matches ~
  \<\I\i*		or
***************
*** 1207,1218 ****
  8. Composing characters					*patterns-composing*
  
  							*/\Z*
! When "\Z" appears anywhere in the pattern, composing characters are ignored.
! Thus only the base characters need to match, the composing characters may be
! different and the number of composing characters may differ.  Only relevant
! when 'encoding' is "utf-8".
  Exception: If the pattern starts with one or more composing characters, these
  must match.
  
  When a composing character appears at the start of the pattern of after an
  item that doesn't include the composing character, a match is found at any
--- 1208,1225 ----
  8. Composing characters					*patterns-composing*
  
  							*/\Z*
! When "\Z" appears anywhere in the pattern, all composing characters are
! ignored.  Thus only the base characters need to match, the composing
! characters may be different and the number of composing characters may differ.
! Only relevant when 'encoding' is "utf-8".
  Exception: If the pattern starts with one or more composing characters, these
  must match.
+ 							*/\%C*
+ Use "\%C" to skip any composing characters.  For example, the pattern "a" does
+ not match in "càt" (where the a has the composing character 0x0300), but
+ "a\%C" does.  Note that this does not match "cát" (where the á is character
+ 0xe1, it does not have a compositing character).  It does match "cat" (where
+ the a is just an a).
  
  When a composing character appears at the start of the pattern of after an
  item that doesn't include the composing character, a match is found at any
*** ../vim-7.4.292/src/version.c	2014-05-13 18:03:55.729737466 +0200
--- src/version.c	2014-05-13 18:28:45.885750510 +0200
***************
*** 736,737 ****
--- 736,739 ----
  {   /* Add new patch number below this line */
+ /**/
+     293,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
155. You forget to eat because you're too busy surfing the net.

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