summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0010
blob: 9df182cc9faed6c6c8f2819376725c5d46afbb31 (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
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0010
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.0010
Problem:    efm_to_regpat() is too long.
Solution:   Split off three functions. (Yegappan Lakshmanan, closes #2924)
Files:	    src/quickfix.c


*** ../vim-8.1.0009/src/quickfix.c	2018-05-15 21:53:11.000000000 +0200
--- src/quickfix.c	2018-05-20 15:40:22.857179812 +0200
***************
*** 228,246 ****
      };
  
  /*
   * Converts a 'errorformat' string to regular expression pattern
   */
      static int
  efm_to_regpat(
  	char_u	*efm,
! 	int		len,
  	efm_T	*fmt_ptr,
  	char_u	*regpat,
  	char_u	*errmsg)
  {
      char_u	*ptr;
      char_u	*efmp;
-     char_u	*srcptr;
      int		round;
      int		idx = 0;
  
--- 228,399 ----
      };
  
  /*
+  * Convert an errorformat pattern to a regular expression pattern.
+  * See fmt_pat definition above for the list of supported patterns.
+  */
+     static char_u *
+ fmtpat_to_regpat(
+ 	char_u	*efmp,
+ 	efm_T	*fmt_ptr,
+ 	int	idx,
+ 	int	round,
+ 	char_u	*ptr,
+ 	char_u	*errmsg)
+ {
+     char_u	*srcptr;
+ 
+     if (fmt_ptr->addr[idx])
+     {
+ 	/* Each errorformat pattern can occur only once */
+ 	sprintf((char *)errmsg,
+ 		_("E372: Too many %%%c in format string"), *efmp);
+ 	EMSG(errmsg);
+ 	return NULL;
+     }
+     if ((idx && idx < 6
+ 		&& vim_strchr((char_u *)"DXOPQ", fmt_ptr->prefix) != NULL)
+ 	    || (idx == 6
+ 		&& vim_strchr((char_u *)"OPQ", fmt_ptr->prefix) == NULL))
+     {
+ 	sprintf((char *)errmsg,
+ 		_("E373: Unexpected %%%c in format string"), *efmp);
+ 	EMSG(errmsg);
+ 	return NULL;
+     }
+     fmt_ptr->addr[idx] = (char_u)++round;
+     *ptr++ = '\\';
+     *ptr++ = '(';
+ #ifdef BACKSLASH_IN_FILENAME
+     if (*efmp == 'f')
+     {
+ 	/* Also match "c:" in the file name, even when
+ 	 * checking for a colon next: "%f:".
+ 	 * "\%(\a:\)\=" */
+ 	STRCPY(ptr, "\\%(\\a:\\)\\=");
+ 	ptr += 10;
+     }
+ #endif
+     if (*efmp == 'f' && efmp[1] != NUL)
+     {
+ 	if (efmp[1] != '\\' && efmp[1] != '%')
+ 	{
+ 	    /* A file name may contain spaces, but this isn't
+ 	     * in "\f".  For "%f:%l:%m" there may be a ":" in
+ 	     * the file name.  Use ".\{-1,}x" instead (x is
+ 	     * the next character), the requirement that :999:
+ 	     * follows should work. */
+ 	    STRCPY(ptr, ".\\{-1,}");
+ 	    ptr += 7;
+ 	}
+ 	else
+ 	{
+ 	    /* File name followed by '\\' or '%': include as
+ 	     * many file name chars as possible. */
+ 	    STRCPY(ptr, "\\f\\+");
+ 	    ptr += 4;
+ 	}
+     }
+     else
+     {
+ 	srcptr = (char_u *)fmt_pat[idx].pattern;
+ 	while ((*ptr = *srcptr++) != NUL)
+ 	    ++ptr;
+     }
+     *ptr++ = '\\';
+     *ptr++ = ')';
+ 
+     return ptr;
+ }
+ 
+ /*
+  * Convert a scanf like format in 'errorformat' to a regular expression.
+  */
+     static char_u *
+ scanf_fmt_to_regpat(
+ 	char_u	*efm,
+ 	int	len,
+ 	char_u	**pefmp,
+ 	char_u	*ptr,
+ 	char_u	*errmsg)
+ {
+     char_u	*efmp = *pefmp;
+ 
+     if (*++efmp == '[' || *efmp == '\\')
+     {
+ 	if ((*ptr++ = *efmp) == '[')	/* %*[^a-z0-9] etc. */
+ 	{
+ 	    if (efmp[1] == '^')
+ 		*ptr++ = *++efmp;
+ 	    if (efmp < efm + len)
+ 	    {
+ 		*ptr++ = *++efmp;	    /* could be ']' */
+ 		while (efmp < efm + len
+ 			&& (*ptr++ = *++efmp) != ']')
+ 		    /* skip */;
+ 		if (efmp == efm + len)
+ 		{
+ 		    EMSG(_("E374: Missing ] in format string"));
+ 		    return NULL;
+ 		}
+ 	    }
+ 	}
+ 	else if (efmp < efm + len)	/* %*\D, %*\s etc. */
+ 	    *ptr++ = *++efmp;
+ 	*ptr++ = '\\';
+ 	*ptr++ = '+';
+     }
+     else
+     {
+ 	/* TODO: scanf()-like: %*ud, %*3c, %*f, ... ? */
+ 	sprintf((char *)errmsg,
+ 		_("E375: Unsupported %%%c in format string"), *efmp);
+ 	EMSG(errmsg);
+ 	return NULL;
+     }
+ 
+     *pefmp = efmp;
+ 
+     return ptr;
+ }
+ 
+ /*
+  * Analyze/parse an errorformat prefix.
+  */
+     static int
+ efm_analyze_prefix(char_u **pefmp, efm_T *fmt_ptr, char_u *errmsg)
+ {
+     char_u	*efmp = *pefmp;
+ 
+     if (vim_strchr((char_u *)"+-", *efmp) != NULL)
+ 	fmt_ptr->flags = *efmp++;
+     if (vim_strchr((char_u *)"DXAEWICZGOPQ", *efmp) != NULL)
+ 	fmt_ptr->prefix = *efmp;
+     else
+     {
+ 	sprintf((char *)errmsg,
+ 		_("E376: Invalid %%%c in format string prefix"), *efmp);
+ 	EMSG(errmsg);
+ 	return FAIL;
+     }
+ 
+     *pefmp = efmp;
+ 
+     return OK;
+ }
+ 
+ /*
   * Converts a 'errorformat' string to regular expression pattern
   */
      static int
  efm_to_regpat(
  	char_u	*efm,
! 	int	len,
  	efm_T	*fmt_ptr,
  	char_u	*regpat,
  	char_u	*errmsg)
  {
      char_u	*ptr;
      char_u	*efmp;
      int		round;
      int		idx = 0;
  
***************
*** 260,361 ****
  		    break;
  	    if (idx < FMT_PATTERNS)
  	    {
! 		if (fmt_ptr->addr[idx])
! 		{
! 		    sprintf((char *)errmsg,
! 			    _("E372: Too many %%%c in format string"), *efmp);
! 		    EMSG(errmsg);
! 		    return -1;
! 		}
! 		if ((idx
! 			    && idx < 6
! 			    && vim_strchr((char_u *)"DXOPQ",
! 				fmt_ptr->prefix) != NULL)
! 			|| (idx == 6
! 			    && vim_strchr((char_u *)"OPQ",
! 				fmt_ptr->prefix) == NULL))
! 		{
! 		    sprintf((char *)errmsg,
! 			    _("E373: Unexpected %%%c in format string"), *efmp);
! 		    EMSG(errmsg);
  		    return -1;
! 		}
! 		fmt_ptr->addr[idx] = (char_u)++round;
! 		*ptr++ = '\\';
! 		*ptr++ = '(';
! #ifdef BACKSLASH_IN_FILENAME
! 		if (*efmp == 'f')
! 		{
! 		    /* Also match "c:" in the file name, even when
! 		     * checking for a colon next: "%f:".
! 		     * "\%(\a:\)\=" */
! 		    STRCPY(ptr, "\\%(\\a:\\)\\=");
! 		    ptr += 10;
! 		}
! #endif
! 		if (*efmp == 'f' && efmp[1] != NUL)
! 		{
! 		    if (efmp[1] != '\\' && efmp[1] != '%')
! 		    {
! 			/* A file name may contain spaces, but this isn't
! 			 * in "\f".  For "%f:%l:%m" there may be a ":" in
! 			 * the file name.  Use ".\{-1,}x" instead (x is
! 			 * the next character), the requirement that :999:
! 			 * follows should work. */
! 			STRCPY(ptr, ".\\{-1,}");
! 			ptr += 7;
! 		    }
! 		    else
! 		    {
! 			/* File name followed by '\\' or '%': include as
! 			 * many file name chars as possible. */
! 			STRCPY(ptr, "\\f\\+");
! 			ptr += 4;
! 		    }
! 		}
! 		else
! 		{
! 		    srcptr = (char_u *)fmt_pat[idx].pattern;
! 		    while ((*ptr = *srcptr++) != NUL)
! 			++ptr;
! 		}
! 		*ptr++ = '\\';
! 		*ptr++ = ')';
  	    }
  	    else if (*efmp == '*')
  	    {
! 		if (*++efmp == '[' || *efmp == '\\')
! 		{
! 		    if ((*ptr++ = *efmp) == '[')	/* %*[^a-z0-9] etc. */
! 		    {
! 			if (efmp[1] == '^')
! 			    *ptr++ = *++efmp;
! 			if (efmp < efm + len)
! 			{
! 			    *ptr++ = *++efmp;	    /* could be ']' */
! 			    while (efmp < efm + len
! 				    && (*ptr++ = *++efmp) != ']')
! 				/* skip */;
! 			    if (efmp == efm + len)
! 			    {
! 				EMSG(_("E374: Missing ] in format string"));
! 				return -1;
! 			    }
! 			}
! 		    }
! 		    else if (efmp < efm + len)	/* %*\D, %*\s etc. */
! 			*ptr++ = *++efmp;
! 		    *ptr++ = '\\';
! 		    *ptr++ = '+';
! 		}
! 		else
! 		{
! 		    /* TODO: scanf()-like: %*ud, %*3c, %*f, ... ? */
! 		    sprintf((char *)errmsg,
! 			    _("E375: Unsupported %%%c in format string"), *efmp);
! 		    EMSG(errmsg);
  		    return -1;
- 		}
  	    }
  	    else if (vim_strchr((char_u *)"%\\.^$~[", *efmp) != NULL)
  		*ptr++ = *efmp;		/* regexp magic characters */
--- 413,429 ----
  		    break;
  	    if (idx < FMT_PATTERNS)
  	    {
! 		ptr = fmtpat_to_regpat(efmp, fmt_ptr, idx, round, ptr,
! 								errmsg);
! 		if (ptr == NULL)
  		    return -1;
! 		round++;
  	    }
  	    else if (*efmp == '*')
  	    {
! 		ptr = scanf_fmt_to_regpat(efm, len, &efmp, ptr, errmsg);
! 		if (ptr == NULL)
  		    return -1;
  	    }
  	    else if (vim_strchr((char_u *)"%\\.^$~[", *efmp) != NULL)
  		*ptr++ = *efmp;		/* regexp magic characters */
***************
*** 365,381 ****
  		fmt_ptr->conthere = TRUE;
  	    else if (efmp == efm + 1)		/* analyse prefix */
  	    {
! 		if (vim_strchr((char_u *)"+-", *efmp) != NULL)
! 		    fmt_ptr->flags = *efmp++;
! 		if (vim_strchr((char_u *)"DXAEWICZGOPQ", *efmp) != NULL)
! 		    fmt_ptr->prefix = *efmp;
! 		else
! 		{
! 		    sprintf((char *)errmsg,
! 			    _("E376: Invalid %%%c in format string prefix"), *efmp);
! 		    EMSG(errmsg);
  		    return -1;
- 		}
  	    }
  	    else
  	    {
--- 433,440 ----
  		fmt_ptr->conthere = TRUE;
  	    else if (efmp == efm + 1)		/* analyse prefix */
  	    {
! 		if (efm_analyze_prefix(&efmp, fmt_ptr, errmsg) == FAIL)
  		    return -1;
  	    }
  	    else
  	    {
*** ../vim-8.1.0009/src/version.c	2018-05-20 14:57:19.121429579 +0200
--- src/version.c	2018-05-20 15:37:57.138956740 +0200
***************
*** 763,764 ****
--- 763,766 ----
  {   /* Add new patch number below this line */
+ /**/
+     10,
  /**/

-- 
SECOND SOLDIER: It could be carried by an African swallow!
FIRST SOLDIER:  Oh  yes! An African swallow maybe ... but not a European
                swallow. that's my point.
                 "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    ///