79 |
#define fileno _fileno |
#define fileno _fileno |
80 |
#endif |
#endif |
81 |
|
|
82 |
|
/* A user sent this fix for Borland Builder 5 under Windows. */ |
83 |
|
|
84 |
|
#ifdef __BORLANDC__ |
85 |
|
#define _setmode(handle, mode) setmode(handle, mode) |
86 |
|
#endif |
87 |
|
|
88 |
|
/* Not Windows */ |
89 |
|
|
90 |
#else |
#else |
91 |
#include <sys/time.h> /* These two includes are needed */ |
#include <sys/time.h> /* These two includes are needed */ |
92 |
#include <sys/resource.h> /* for setrlimit(). */ |
#include <sys/resource.h> /* for setrlimit(). */ |
189 |
static int show_malloc; |
static int show_malloc; |
190 |
static int use_utf8; |
static int use_utf8; |
191 |
static size_t gotten_store; |
static size_t gotten_store; |
192 |
|
static const unsigned char *last_callout_mark = NULL; |
193 |
|
|
194 |
/* The buffers grow automatically if very long input lines are encountered. */ |
/* The buffers grow automatically if very long input lines are encountered. */ |
195 |
|
|
198 |
static uschar *dbuffer = NULL; |
static uschar *dbuffer = NULL; |
199 |
static uschar *pbuffer = NULL; |
static uschar *pbuffer = NULL; |
200 |
|
|
201 |
|
/* Textual explanations for runtime error codes */ |
202 |
|
|
203 |
|
static const char *errtexts[] = { |
204 |
|
NULL, /* 0 is no error */ |
205 |
|
NULL, /* NOMATCH is handled specially */ |
206 |
|
"NULL argument passed", |
207 |
|
"bad option value", |
208 |
|
"magic number missing", |
209 |
|
"unknown opcode - pattern overwritten?", |
210 |
|
"no more memory", |
211 |
|
NULL, /* never returned by pcre_exec() or pcre_dfa_exec() */ |
212 |
|
"match limit exceeded", |
213 |
|
"callout error code", |
214 |
|
NULL, /* BADUTF8 is handled specially */ |
215 |
|
"bad UTF-8 offset", |
216 |
|
NULL, /* PARTIAL is handled specially */ |
217 |
|
"not used - internal error", |
218 |
|
"internal error - pattern overwritten?", |
219 |
|
"bad count value", |
220 |
|
"item unsupported for DFA matching", |
221 |
|
"backreference condition or recursion test not supported for DFA matching", |
222 |
|
"match limit not supported for DFA matching", |
223 |
|
"workspace size exceeded in DFA matching", |
224 |
|
"too much recursion for DFA matching", |
225 |
|
"recursion limit exceeded", |
226 |
|
"not used - internal error", |
227 |
|
"invalid combination of newline options", |
228 |
|
"bad offset value", |
229 |
|
NULL, /* SHORTUTF8 is handled specially */ |
230 |
|
"nested recursion at the same subject position" |
231 |
|
}; |
232 |
|
|
233 |
|
|
234 |
|
/************************************************* |
235 |
|
* Alternate character tables * |
236 |
|
*************************************************/ |
237 |
|
|
238 |
|
/* By default, the "tables" pointer when calling PCRE is set to NULL, thereby |
239 |
|
using the default tables of the library. However, the T option can be used to |
240 |
|
select alternate sets of tables, for different kinds of testing. Note also that |
241 |
|
the L (locale) option also adjusts the tables. */ |
242 |
|
|
243 |
|
/* This is the set of tables distributed as default with PCRE. It recognizes |
244 |
|
only ASCII characters. */ |
245 |
|
|
246 |
|
static const unsigned char tables0[] = { |
247 |
|
|
248 |
|
/* This table is a lower casing table. */ |
249 |
|
|
250 |
|
0, 1, 2, 3, 4, 5, 6, 7, |
251 |
|
8, 9, 10, 11, 12, 13, 14, 15, |
252 |
|
16, 17, 18, 19, 20, 21, 22, 23, |
253 |
|
24, 25, 26, 27, 28, 29, 30, 31, |
254 |
|
32, 33, 34, 35, 36, 37, 38, 39, |
255 |
|
40, 41, 42, 43, 44, 45, 46, 47, |
256 |
|
48, 49, 50, 51, 52, 53, 54, 55, |
257 |
|
56, 57, 58, 59, 60, 61, 62, 63, |
258 |
|
64, 97, 98, 99,100,101,102,103, |
259 |
|
104,105,106,107,108,109,110,111, |
260 |
|
112,113,114,115,116,117,118,119, |
261 |
|
120,121,122, 91, 92, 93, 94, 95, |
262 |
|
96, 97, 98, 99,100,101,102,103, |
263 |
|
104,105,106,107,108,109,110,111, |
264 |
|
112,113,114,115,116,117,118,119, |
265 |
|
120,121,122,123,124,125,126,127, |
266 |
|
128,129,130,131,132,133,134,135, |
267 |
|
136,137,138,139,140,141,142,143, |
268 |
|
144,145,146,147,148,149,150,151, |
269 |
|
152,153,154,155,156,157,158,159, |
270 |
|
160,161,162,163,164,165,166,167, |
271 |
|
168,169,170,171,172,173,174,175, |
272 |
|
176,177,178,179,180,181,182,183, |
273 |
|
184,185,186,187,188,189,190,191, |
274 |
|
192,193,194,195,196,197,198,199, |
275 |
|
200,201,202,203,204,205,206,207, |
276 |
|
208,209,210,211,212,213,214,215, |
277 |
|
216,217,218,219,220,221,222,223, |
278 |
|
224,225,226,227,228,229,230,231, |
279 |
|
232,233,234,235,236,237,238,239, |
280 |
|
240,241,242,243,244,245,246,247, |
281 |
|
248,249,250,251,252,253,254,255, |
282 |
|
|
283 |
|
/* This table is a case flipping table. */ |
284 |
|
|
285 |
|
0, 1, 2, 3, 4, 5, 6, 7, |
286 |
|
8, 9, 10, 11, 12, 13, 14, 15, |
287 |
|
16, 17, 18, 19, 20, 21, 22, 23, |
288 |
|
24, 25, 26, 27, 28, 29, 30, 31, |
289 |
|
32, 33, 34, 35, 36, 37, 38, 39, |
290 |
|
40, 41, 42, 43, 44, 45, 46, 47, |
291 |
|
48, 49, 50, 51, 52, 53, 54, 55, |
292 |
|
56, 57, 58, 59, 60, 61, 62, 63, |
293 |
|
64, 97, 98, 99,100,101,102,103, |
294 |
|
104,105,106,107,108,109,110,111, |
295 |
|
112,113,114,115,116,117,118,119, |
296 |
|
120,121,122, 91, 92, 93, 94, 95, |
297 |
|
96, 65, 66, 67, 68, 69, 70, 71, |
298 |
|
72, 73, 74, 75, 76, 77, 78, 79, |
299 |
|
80, 81, 82, 83, 84, 85, 86, 87, |
300 |
|
88, 89, 90,123,124,125,126,127, |
301 |
|
128,129,130,131,132,133,134,135, |
302 |
|
136,137,138,139,140,141,142,143, |
303 |
|
144,145,146,147,148,149,150,151, |
304 |
|
152,153,154,155,156,157,158,159, |
305 |
|
160,161,162,163,164,165,166,167, |
306 |
|
168,169,170,171,172,173,174,175, |
307 |
|
176,177,178,179,180,181,182,183, |
308 |
|
184,185,186,187,188,189,190,191, |
309 |
|
192,193,194,195,196,197,198,199, |
310 |
|
200,201,202,203,204,205,206,207, |
311 |
|
208,209,210,211,212,213,214,215, |
312 |
|
216,217,218,219,220,221,222,223, |
313 |
|
224,225,226,227,228,229,230,231, |
314 |
|
232,233,234,235,236,237,238,239, |
315 |
|
240,241,242,243,244,245,246,247, |
316 |
|
248,249,250,251,252,253,254,255, |
317 |
|
|
318 |
|
/* This table contains bit maps for various character classes. Each map is 32 |
319 |
|
bytes long and the bits run from the least significant end of each byte. The |
320 |
|
classes that have their own maps are: space, xdigit, digit, upper, lower, word, |
321 |
|
graph, print, punct, and cntrl. Other classes are built from combinations. */ |
322 |
|
|
323 |
|
0x00,0x3e,0x00,0x00,0x01,0x00,0x00,0x00, |
324 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
325 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
326 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
327 |
|
|
328 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03, |
329 |
|
0x7e,0x00,0x00,0x00,0x7e,0x00,0x00,0x00, |
330 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
331 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
332 |
|
|
333 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03, |
334 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
335 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
336 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
337 |
|
|
338 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
339 |
|
0xfe,0xff,0xff,0x07,0x00,0x00,0x00,0x00, |
340 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
341 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
342 |
|
|
343 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
344 |
|
0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0x07, |
345 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
346 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
347 |
|
|
348 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03, |
349 |
|
0xfe,0xff,0xff,0x87,0xfe,0xff,0xff,0x07, |
350 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
351 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
352 |
|
|
353 |
|
0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff, |
354 |
|
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f, |
355 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
356 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
357 |
|
|
358 |
|
0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff, |
359 |
|
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f, |
360 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
361 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
362 |
|
|
363 |
|
0x00,0x00,0x00,0x00,0xfe,0xff,0x00,0xfc, |
364 |
|
0x01,0x00,0x00,0xf8,0x01,0x00,0x00,0x78, |
365 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
366 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
367 |
|
|
368 |
|
0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00, |
369 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80, |
370 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
371 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
372 |
|
|
373 |
|
/* This table identifies various classes of character by individual bits: |
374 |
|
0x01 white space character |
375 |
|
0x02 letter |
376 |
|
0x04 decimal digit |
377 |
|
0x08 hexadecimal digit |
378 |
|
0x10 alphanumeric or '_' |
379 |
|
0x80 regular expression metacharacter or binary zero |
380 |
|
*/ |
381 |
|
|
382 |
|
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0- 7 */ |
383 |
|
0x00,0x01,0x01,0x00,0x01,0x01,0x00,0x00, /* 8- 15 */ |
384 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 16- 23 */ |
385 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 24- 31 */ |
386 |
|
0x01,0x00,0x00,0x00,0x80,0x00,0x00,0x00, /* - ' */ |
387 |
|
0x80,0x80,0x80,0x80,0x00,0x00,0x80,0x00, /* ( - / */ |
388 |
|
0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c, /* 0 - 7 */ |
389 |
|
0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x80, /* 8 - ? */ |
390 |
|
0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /* @ - G */ |
391 |
|
0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* H - O */ |
392 |
|
0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* P - W */ |
393 |
|
0x12,0x12,0x12,0x80,0x80,0x00,0x80,0x10, /* X - _ */ |
394 |
|
0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /* ` - g */ |
395 |
|
0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* h - o */ |
396 |
|
0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* p - w */ |
397 |
|
0x12,0x12,0x12,0x80,0x80,0x00,0x00,0x00, /* x -127 */ |
398 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 128-135 */ |
399 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 136-143 */ |
400 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 144-151 */ |
401 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 152-159 */ |
402 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 160-167 */ |
403 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 168-175 */ |
404 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 176-183 */ |
405 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 184-191 */ |
406 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 192-199 */ |
407 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 200-207 */ |
408 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 208-215 */ |
409 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 216-223 */ |
410 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 224-231 */ |
411 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 232-239 */ |
412 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 240-247 */ |
413 |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/* 248-255 */ |
414 |
|
|
415 |
|
/* This is a set of tables that came orginally from a Windows user. It seems to |
416 |
|
be at least an approximation of ISO 8859. In particular, there are characters |
417 |
|
greater than 128 that are marked as spaces, letters, etc. */ |
418 |
|
|
419 |
|
static const unsigned char tables1[] = { |
420 |
|
0,1,2,3,4,5,6,7, |
421 |
|
8,9,10,11,12,13,14,15, |
422 |
|
16,17,18,19,20,21,22,23, |
423 |
|
24,25,26,27,28,29,30,31, |
424 |
|
32,33,34,35,36,37,38,39, |
425 |
|
40,41,42,43,44,45,46,47, |
426 |
|
48,49,50,51,52,53,54,55, |
427 |
|
56,57,58,59,60,61,62,63, |
428 |
|
64,97,98,99,100,101,102,103, |
429 |
|
104,105,106,107,108,109,110,111, |
430 |
|
112,113,114,115,116,117,118,119, |
431 |
|
120,121,122,91,92,93,94,95, |
432 |
|
96,97,98,99,100,101,102,103, |
433 |
|
104,105,106,107,108,109,110,111, |
434 |
|
112,113,114,115,116,117,118,119, |
435 |
|
120,121,122,123,124,125,126,127, |
436 |
|
128,129,130,131,132,133,134,135, |
437 |
|
136,137,138,139,140,141,142,143, |
438 |
|
144,145,146,147,148,149,150,151, |
439 |
|
152,153,154,155,156,157,158,159, |
440 |
|
160,161,162,163,164,165,166,167, |
441 |
|
168,169,170,171,172,173,174,175, |
442 |
|
176,177,178,179,180,181,182,183, |
443 |
|
184,185,186,187,188,189,190,191, |
444 |
|
224,225,226,227,228,229,230,231, |
445 |
|
232,233,234,235,236,237,238,239, |
446 |
|
240,241,242,243,244,245,246,215, |
447 |
|
248,249,250,251,252,253,254,223, |
448 |
|
224,225,226,227,228,229,230,231, |
449 |
|
232,233,234,235,236,237,238,239, |
450 |
|
240,241,242,243,244,245,246,247, |
451 |
|
248,249,250,251,252,253,254,255, |
452 |
|
0,1,2,3,4,5,6,7, |
453 |
|
8,9,10,11,12,13,14,15, |
454 |
|
16,17,18,19,20,21,22,23, |
455 |
|
24,25,26,27,28,29,30,31, |
456 |
|
32,33,34,35,36,37,38,39, |
457 |
|
40,41,42,43,44,45,46,47, |
458 |
|
48,49,50,51,52,53,54,55, |
459 |
|
56,57,58,59,60,61,62,63, |
460 |
|
64,97,98,99,100,101,102,103, |
461 |
|
104,105,106,107,108,109,110,111, |
462 |
|
112,113,114,115,116,117,118,119, |
463 |
|
120,121,122,91,92,93,94,95, |
464 |
|
96,65,66,67,68,69,70,71, |
465 |
|
72,73,74,75,76,77,78,79, |
466 |
|
80,81,82,83,84,85,86,87, |
467 |
|
88,89,90,123,124,125,126,127, |
468 |
|
128,129,130,131,132,133,134,135, |
469 |
|
136,137,138,139,140,141,142,143, |
470 |
|
144,145,146,147,148,149,150,151, |
471 |
|
152,153,154,155,156,157,158,159, |
472 |
|
160,161,162,163,164,165,166,167, |
473 |
|
168,169,170,171,172,173,174,175, |
474 |
|
176,177,178,179,180,181,182,183, |
475 |
|
184,185,186,187,188,189,190,191, |
476 |
|
224,225,226,227,228,229,230,231, |
477 |
|
232,233,234,235,236,237,238,239, |
478 |
|
240,241,242,243,244,245,246,215, |
479 |
|
248,249,250,251,252,253,254,223, |
480 |
|
192,193,194,195,196,197,198,199, |
481 |
|
200,201,202,203,204,205,206,207, |
482 |
|
208,209,210,211,212,213,214,247, |
483 |
|
216,217,218,219,220,221,222,255, |
484 |
|
0,62,0,0,1,0,0,0, |
485 |
|
0,0,0,0,0,0,0,0, |
486 |
|
32,0,0,0,1,0,0,0, |
487 |
|
0,0,0,0,0,0,0,0, |
488 |
|
0,0,0,0,0,0,255,3, |
489 |
|
126,0,0,0,126,0,0,0, |
490 |
|
0,0,0,0,0,0,0,0, |
491 |
|
0,0,0,0,0,0,0,0, |
492 |
|
0,0,0,0,0,0,255,3, |
493 |
|
0,0,0,0,0,0,0,0, |
494 |
|
0,0,0,0,0,0,12,2, |
495 |
|
0,0,0,0,0,0,0,0, |
496 |
|
0,0,0,0,0,0,0,0, |
497 |
|
254,255,255,7,0,0,0,0, |
498 |
|
0,0,0,0,0,0,0,0, |
499 |
|
255,255,127,127,0,0,0,0, |
500 |
|
0,0,0,0,0,0,0,0, |
501 |
|
0,0,0,0,254,255,255,7, |
502 |
|
0,0,0,0,0,4,32,4, |
503 |
|
0,0,0,128,255,255,127,255, |
504 |
|
0,0,0,0,0,0,255,3, |
505 |
|
254,255,255,135,254,255,255,7, |
506 |
|
0,0,0,0,0,4,44,6, |
507 |
|
255,255,127,255,255,255,127,255, |
508 |
|
0,0,0,0,254,255,255,255, |
509 |
|
255,255,255,255,255,255,255,127, |
510 |
|
0,0,0,0,254,255,255,255, |
511 |
|
255,255,255,255,255,255,255,255, |
512 |
|
0,2,0,0,255,255,255,255, |
513 |
|
255,255,255,255,255,255,255,127, |
514 |
|
0,0,0,0,255,255,255,255, |
515 |
|
255,255,255,255,255,255,255,255, |
516 |
|
0,0,0,0,254,255,0,252, |
517 |
|
1,0,0,248,1,0,0,120, |
518 |
|
0,0,0,0,254,255,255,255, |
519 |
|
0,0,128,0,0,0,128,0, |
520 |
|
255,255,255,255,0,0,0,0, |
521 |
|
0,0,0,0,0,0,0,128, |
522 |
|
255,255,255,255,0,0,0,0, |
523 |
|
0,0,0,0,0,0,0,0, |
524 |
|
128,0,0,0,0,0,0,0, |
525 |
|
0,1,1,0,1,1,0,0, |
526 |
|
0,0,0,0,0,0,0,0, |
527 |
|
0,0,0,0,0,0,0,0, |
528 |
|
1,0,0,0,128,0,0,0, |
529 |
|
128,128,128,128,0,0,128,0, |
530 |
|
28,28,28,28,28,28,28,28, |
531 |
|
28,28,0,0,0,0,0,128, |
532 |
|
0,26,26,26,26,26,26,18, |
533 |
|
18,18,18,18,18,18,18,18, |
534 |
|
18,18,18,18,18,18,18,18, |
535 |
|
18,18,18,128,128,0,128,16, |
536 |
|
0,26,26,26,26,26,26,18, |
537 |
|
18,18,18,18,18,18,18,18, |
538 |
|
18,18,18,18,18,18,18,18, |
539 |
|
18,18,18,128,128,0,0,0, |
540 |
|
0,0,0,0,0,1,0,0, |
541 |
|
0,0,0,0,0,0,0,0, |
542 |
|
0,0,0,0,0,0,0,0, |
543 |
|
0,0,0,0,0,0,0,0, |
544 |
|
1,0,0,0,0,0,0,0, |
545 |
|
0,0,18,0,0,0,0,0, |
546 |
|
0,0,20,20,0,18,0,0, |
547 |
|
0,20,18,0,0,0,0,0, |
548 |
|
18,18,18,18,18,18,18,18, |
549 |
|
18,18,18,18,18,18,18,18, |
550 |
|
18,18,18,18,18,18,18,0, |
551 |
|
18,18,18,18,18,18,18,18, |
552 |
|
18,18,18,18,18,18,18,18, |
553 |
|
18,18,18,18,18,18,18,18, |
554 |
|
18,18,18,18,18,18,18,0, |
555 |
|
18,18,18,18,18,18,18,18 |
556 |
|
}; |
557 |
|
|
558 |
|
|
559 |
|
|
560 |
|
|
561 |
|
#ifndef HAVE_STRERROR |
562 |
|
/************************************************* |
563 |
|
* Provide strerror() for non-ANSI libraries * |
564 |
|
*************************************************/ |
565 |
|
|
566 |
|
/* Some old-fashioned systems still around (e.g. SunOS4) don't have strerror() |
567 |
|
in their libraries, but can provide the same facility by this simple |
568 |
|
alternative function. */ |
569 |
|
|
570 |
|
extern int sys_nerr; |
571 |
|
extern char *sys_errlist[]; |
572 |
|
|
573 |
|
char * |
574 |
|
strerror(int n) |
575 |
|
{ |
576 |
|
if (n < 0 || n >= sys_nerr) return "unknown error number"; |
577 |
|
return sys_errlist[n]; |
578 |
|
} |
579 |
|
#endif /* HAVE_STRERROR */ |
580 |
|
|
581 |
|
|
582 |
|
|
583 |
|
|
584 |
/************************************************* |
/************************************************* |
611 |
|
|
612 |
for (;;) |
for (;;) |
613 |
{ |
{ |
614 |
int rlen = buffer_size - (here - buffer); |
int rlen = (int)(buffer_size - (here - buffer)); |
615 |
|
|
616 |
if (rlen > 1000) |
if (rlen > 1000) |
617 |
{ |
{ |
961 |
fprintf(outfile, "\n"); |
fprintf(outfile, "\n"); |
962 |
first_callout = 0; |
first_callout = 0; |
963 |
|
|
964 |
|
if (cb->mark != last_callout_mark) |
965 |
|
{ |
966 |
|
fprintf(outfile, "Latest Mark: %s\n", |
967 |
|
(cb->mark == NULL)? "<unset>" : (char *)(cb->mark)); |
968 |
|
last_callout_mark = cb->mark; |
969 |
|
} |
970 |
|
|
971 |
if (cb->callout_data != NULL) |
if (cb->callout_data != NULL) |
972 |
{ |
{ |
973 |
int callout_data = *((int *)(cb->callout_data)); |
int callout_data = *((int *)(cb->callout_data)); |
1195 |
#endif |
#endif |
1196 |
printf(" -q quiet: do not output PCRE version number at start\n"); |
printf(" -q quiet: do not output PCRE version number at start\n"); |
1197 |
printf(" -S <n> set stack size to <n> megabytes\n"); |
printf(" -S <n> set stack size to <n> megabytes\n"); |
1198 |
printf(" -s output store (memory) used information\n" |
printf(" -s force each pattern to be studied\n" |
1199 |
" -t time compilation and execution\n"); |
" -t time compilation and execution\n"); |
1200 |
printf(" -t <n> time compilation and execution, repeating <n> times\n"); |
printf(" -t <n> time compilation and execution, repeating <n> times\n"); |
1201 |
printf(" -tm time execution (matching) only\n"); |
printf(" -tm time execution (matching) only\n"); |
1223 |
int timeitm = 0; |
int timeitm = 0; |
1224 |
int showinfo = 0; |
int showinfo = 0; |
1225 |
int showstore = 0; |
int showstore = 0; |
1226 |
|
int force_study = 0; |
1227 |
int quiet = 0; |
int quiet = 0; |
1228 |
int size_offsets = 45; |
int size_offsets = 45; |
1229 |
int size_offsets_max; |
int size_offsets_max; |
1272 |
{ |
{ |
1273 |
unsigned char *endptr; |
unsigned char *endptr; |
1274 |
|
|
1275 |
if (strcmp(argv[op], "-s") == 0 || strcmp(argv[op], "-m") == 0) |
if (strcmp(argv[op], "-m") == 0) showstore = 1; |
1276 |
showstore = 1; |
else if (strcmp(argv[op], "-s") == 0) force_study = 1; |
1277 |
else if (strcmp(argv[op], "-q") == 0) quiet = 1; |
else if (strcmp(argv[op], "-q") == 0) quiet = 1; |
1278 |
else if (strcmp(argv[op], "-b") == 0) debug = 1; |
else if (strcmp(argv[op], "-b") == 0) debug = 1; |
1279 |
else if (strcmp(argv[op], "-i") == 0) showinfo = 1; |
else if (strcmp(argv[op], "-i") == 0) showinfo = 1; |
1307 |
((stack_size = get_value((unsigned char *)argv[op+1], &endptr)), |
((stack_size = get_value((unsigned char *)argv[op+1], &endptr)), |
1308 |
*endptr == 0)) |
*endptr == 0)) |
1309 |
{ |
{ |
1310 |
#if defined(_WIN32) || defined(WIN32) |
#if defined(_WIN32) || defined(WIN32) || defined(__minix) |
1311 |
printf("PCRE: -S not supported on this OS\n"); |
printf("PCRE: -S not supported on this OS\n"); |
1312 |
exit(1); |
exit(1); |
1313 |
#else |
#else |
1443 |
const unsigned char *tables = NULL; |
const unsigned char *tables = NULL; |
1444 |
unsigned long int true_size, true_study_size = 0; |
unsigned long int true_size, true_study_size = 0; |
1445 |
size_t size, regex_gotten_store; |
size_t size, regex_gotten_store; |
1446 |
|
int do_allcaps = 0; |
1447 |
int do_mark = 0; |
int do_mark = 0; |
1448 |
int do_study = 0; |
int do_study = 0; |
1449 |
|
int no_force_study = 0; |
1450 |
int do_debug = debug; |
int do_debug = debug; |
1451 |
int do_G = 0; |
int do_G = 0; |
1452 |
int do_g = 0; |
int do_g = 0; |
1453 |
int do_showinfo = showinfo; |
int do_showinfo = showinfo; |
1454 |
int do_showrest = 0; |
int do_showrest = 0; |
1455 |
|
int do_showcaprest = 0; |
1456 |
int do_flip = 0; |
int do_flip = 0; |
1457 |
int erroroffset, len, delimiter, poffset; |
int erroroffset, len, delimiter, poffset; |
1458 |
|
|
1514 |
} |
} |
1515 |
} |
} |
1516 |
|
|
1517 |
fprintf(outfile, "Compiled regex%s loaded from %s\n", |
fprintf(outfile, "Compiled pattern%s loaded from %s\n", |
1518 |
do_flip? " (byte-inverted)" : "", p); |
do_flip? " (byte-inverted)" : "", p); |
1519 |
|
|
1520 |
/* Need to know if UTF-8 for printing data strings */ |
/* Need to know if UTF-8 for printing data strings */ |
1522 |
new_info(re, NULL, PCRE_INFO_OPTIONS, &get_options); |
new_info(re, NULL, PCRE_INFO_OPTIONS, &get_options); |
1523 |
use_utf8 = (get_options & PCRE_UTF8) != 0; |
use_utf8 = (get_options & PCRE_UTF8) != 0; |
1524 |
|
|
1525 |
/* Now see if there is any following study data */ |
/* Now see if there is any following study data. */ |
1526 |
|
|
1527 |
if (true_study_size != 0) |
if (true_study_size != 0) |
1528 |
{ |
{ |
1564 |
} |
} |
1565 |
|
|
1566 |
pp = p; |
pp = p; |
1567 |
poffset = p - buffer; |
poffset = (int)(p - buffer); |
1568 |
|
|
1569 |
for(;;) |
for(;;) |
1570 |
{ |
{ |
1618 |
case 's': options |= PCRE_DOTALL; break; |
case 's': options |= PCRE_DOTALL; break; |
1619 |
case 'x': options |= PCRE_EXTENDED; break; |
case 'x': options |= PCRE_EXTENDED; break; |
1620 |
|
|
1621 |
case '+': do_showrest = 1; break; |
case '+': |
1622 |
|
if (do_showrest) do_showcaprest = 1; else do_showrest = 1; |
1623 |
|
break; |
1624 |
|
|
1625 |
|
case '=': do_allcaps = 1; break; |
1626 |
case 'A': options |= PCRE_ANCHORED; break; |
case 'A': options |= PCRE_ANCHORED; break; |
1627 |
case 'B': do_debug = 1; break; |
case 'B': do_debug = 1; break; |
1628 |
case 'C': options |= PCRE_AUTO_CALLOUT; break; |
case 'C': options |= PCRE_AUTO_CALLOUT; break; |
1640 |
case 'P': do_posix = 1; break; |
case 'P': do_posix = 1; break; |
1641 |
#endif |
#endif |
1642 |
|
|
1643 |
case 'S': do_study = 1; break; |
case 'S': |
1644 |
|
if (do_study == 0) do_study = 1; else |
1645 |
|
{ |
1646 |
|
do_study = 0; |
1647 |
|
no_force_study = 1; |
1648 |
|
} |
1649 |
|
break; |
1650 |
|
|
1651 |
case 'U': options |= PCRE_UNGREEDY; break; |
case 'U': options |= PCRE_UNGREEDY; break; |
1652 |
case 'W': options |= PCRE_UCP; break; |
case 'W': options |= PCRE_UCP; break; |
1653 |
case 'X': options |= PCRE_EXTRA; break; |
case 'X': options |= PCRE_EXTRA; break; |
1654 |
|
case 'Y': options |= PCRE_NO_START_OPTIMISE; break; |
1655 |
case 'Z': debug_lengths = 0; break; |
case 'Z': debug_lengths = 0; break; |
1656 |
case '8': options |= PCRE_UTF8; use_utf8 = 1; break; |
case '8': options |= PCRE_UTF8; use_utf8 = 1; break; |
1657 |
case '?': options |= PCRE_NO_UTF8_CHECK; break; |
case '?': options |= PCRE_NO_UTF8_CHECK; break; |
1658 |
|
|
1659 |
|
case 'T': |
1660 |
|
switch (*pp++) |
1661 |
|
{ |
1662 |
|
case '0': tables = tables0; break; |
1663 |
|
case '1': tables = tables1; break; |
1664 |
|
|
1665 |
|
case '\r': |
1666 |
|
case '\n': |
1667 |
|
case ' ': |
1668 |
|
case 0: |
1669 |
|
fprintf(outfile, "** Missing table number after /T\n"); |
1670 |
|
goto SKIP_DATA; |
1671 |
|
|
1672 |
|
default: |
1673 |
|
fprintf(outfile, "** Bad table number \"%c\" after /T\n", pp[-1]); |
1674 |
|
goto SKIP_DATA; |
1675 |
|
} |
1676 |
|
break; |
1677 |
|
|
1678 |
case 'L': |
case 'L': |
1679 |
ppp = pp; |
ppp = pp; |
1680 |
/* The '\r' test here is so that it works on Windows. */ |
/* The '\r' test here is so that it works on Windows. */ |
1831 |
true_size = ((real_pcre *)re)->size; |
true_size = ((real_pcre *)re)->size; |
1832 |
regex_gotten_store = gotten_store; |
regex_gotten_store = gotten_store; |
1833 |
|
|
1834 |
/* If /S was present, study the regexp to generate additional info to |
/* If -s or /S was present, study the regex to generate additional info to |
1835 |
help with the matching. */ |
help with the matching, unless the pattern has the SS option, which |
1836 |
|
suppresses the effect of /S (used for a few test patterns where studying is |
1837 |
|
never sensible). */ |
1838 |
|
|
1839 |
if (do_study) |
if (do_study || (force_study && !no_force_study)) |
1840 |
{ |
{ |
1841 |
if (timeit > 0) |
if (timeit > 0) |
1842 |
{ |
{ |
1990 |
if (do_flip) all_options = byteflip(all_options, sizeof(all_options)); |
if (do_flip) all_options = byteflip(all_options, sizeof(all_options)); |
1991 |
|
|
1992 |
if (get_options == 0) fprintf(outfile, "No options\n"); |
if (get_options == 0) fprintf(outfile, "No options\n"); |
1993 |
else fprintf(outfile, "Options:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", |
else fprintf(outfile, "Options:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", |
1994 |
((get_options & PCRE_ANCHORED) != 0)? " anchored" : "", |
((get_options & PCRE_ANCHORED) != 0)? " anchored" : "", |
1995 |
((get_options & PCRE_CASELESS) != 0)? " caseless" : "", |
((get_options & PCRE_CASELESS) != 0)? " caseless" : "", |
1996 |
((get_options & PCRE_EXTENDED) != 0)? " extended" : "", |
((get_options & PCRE_EXTENDED) != 0)? " extended" : "", |
2006 |
((get_options & PCRE_UTF8) != 0)? " utf8" : "", |
((get_options & PCRE_UTF8) != 0)? " utf8" : "", |
2007 |
((get_options & PCRE_UCP) != 0)? " ucp" : "", |
((get_options & PCRE_UCP) != 0)? " ucp" : "", |
2008 |
((get_options & PCRE_NO_UTF8_CHECK) != 0)? " no_utf8_check" : "", |
((get_options & PCRE_NO_UTF8_CHECK) != 0)? " no_utf8_check" : "", |
2009 |
|
((get_options & PCRE_NO_START_OPTIMIZE) != 0)? " no_start_optimize" : "", |
2010 |
((get_options & PCRE_DUPNAMES) != 0)? " dupnames" : ""); |
((get_options & PCRE_DUPNAMES) != 0)? " dupnames" : ""); |
2011 |
|
|
2012 |
if (jchanged) fprintf(outfile, "Duplicate name status changes\n"); |
if (jchanged) fprintf(outfile, "Duplicate name status changes\n"); |
2074 |
/* Don't output study size; at present it is in any case a fixed |
/* Don't output study size; at present it is in any case a fixed |
2075 |
value, but it varies, depending on the computer architecture, and |
value, but it varies, depending on the computer architecture, and |
2076 |
so messes up the test suite. (And with the /F option, it might be |
so messes up the test suite. (And with the /F option, it might be |
2077 |
flipped.) */ |
flipped.) If study was forced by an external -s, don't show this |
2078 |
|
information unless -i or -d was also present. This means that, except |
2079 |
|
when auto-callouts are involved, the output from runs with and without |
2080 |
|
-s should be identical. */ |
2081 |
|
|
2082 |
if (do_study) |
if (do_study || (force_study && showinfo && !no_force_study)) |
2083 |
{ |
{ |
2084 |
if (extra == NULL) |
if (extra == NULL) |
2085 |
fprintf(outfile, "Study returned NULL\n"); |
fprintf(outfile, "Study returned NULL\n"); |
2157 |
} |
} |
2158 |
else |
else |
2159 |
{ |
{ |
2160 |
fprintf(outfile, "Compiled regex written to %s\n", to_file); |
fprintf(outfile, "Compiled pattern written to %s\n", to_file); |
2161 |
|
|
2162 |
|
/* If there is study data, write it, but verify the writing only |
2163 |
|
if the studying was requested by /S, not just by -s. */ |
2164 |
|
|
2165 |
if (extra != NULL) |
if (extra != NULL) |
2166 |
{ |
{ |
2167 |
if (fwrite(extra->study_data, 1, true_study_size, f) < |
if (fwrite(extra->study_data, 1, true_study_size, f) < |
2171 |
strerror(errno)); |
strerror(errno)); |
2172 |
} |
} |
2173 |
else fprintf(outfile, "Study data written to %s\n", to_file); |
else fprintf(outfile, "Study data written to %s\n", to_file); |
|
|
|
2174 |
} |
} |
2175 |
} |
} |
2176 |
fclose(f); |
fclose(f); |
2178 |
|
|
2179 |
new_free(re); |
new_free(re); |
2180 |
if (extra != NULL) new_free(extra); |
if (extra != NULL) new_free(extra); |
2181 |
if (tables != NULL) new_free((void *)tables); |
if (locale_set) |
2182 |
|
{ |
2183 |
|
new_free((void *)tables); |
2184 |
|
setlocale(LC_CTYPE, "C"); |
2185 |
|
locale_set = 0; |
2186 |
|
} |
2187 |
continue; /* With next regex */ |
continue; /* With next regex */ |
2188 |
} |
} |
2189 |
} /* End of non-POSIX compile */ |
} /* End of non-POSIX compile */ |
2205 |
int getlist = 0; |
int getlist = 0; |
2206 |
int gmatched = 0; |
int gmatched = 0; |
2207 |
int start_offset = 0; |
int start_offset = 0; |
2208 |
|
int start_offset_sign = 1; |
2209 |
int g_notempty = 0; |
int g_notempty = 0; |
2210 |
int use_dfa = 0; |
int use_dfa = 0; |
2211 |
|
|
2219 |
|
|
2220 |
pcre_callout = callout; |
pcre_callout = callout; |
2221 |
first_callout = 1; |
first_callout = 1; |
2222 |
|
last_callout_mark = NULL; |
2223 |
callout_extra = 0; |
callout_extra = 0; |
2224 |
callout_count = 0; |
callout_count = 0; |
2225 |
callout_fail_count = 999999; |
callout_fail_count = 999999; |
2234 |
{ |
{ |
2235 |
if (extend_inputline(infile, buffer + len, "data> ") == NULL) |
if (extend_inputline(infile, buffer + len, "data> ") == NULL) |
2236 |
{ |
{ |
2237 |
if (len > 0) break; |
if (len > 0) /* Reached EOF without hitting a newline */ |
2238 |
|
{ |
2239 |
|
fprintf(outfile, "\n"); |
2240 |
|
break; |
2241 |
|
} |
2242 |
done = 1; |
done = 1; |
2243 |
goto CONTINUE; |
goto CONTINUE; |
2244 |
} |
} |
2339 |
continue; |
continue; |
2340 |
|
|
2341 |
case '>': |
case '>': |
2342 |
|
if (*p == '-') |
2343 |
|
{ |
2344 |
|
start_offset_sign = -1; |
2345 |
|
p++; |
2346 |
|
} |
2347 |
while(isdigit(*p)) start_offset = start_offset * 10 + *p++ - '0'; |
while(isdigit(*p)) start_offset = start_offset * 10 + *p++ - '0'; |
2348 |
|
start_offset *= start_offset_sign; |
2349 |
continue; |
continue; |
2350 |
|
|
2351 |
case 'A': /* Option setting */ |
case 'A': /* Option setting */ |
2418 |
#endif |
#endif |
2419 |
use_dfa = 1; |
use_dfa = 1; |
2420 |
continue; |
continue; |
2421 |
|
#endif |
2422 |
|
|
2423 |
|
#if !defined NODFA |
2424 |
case 'F': |
case 'F': |
2425 |
options |= PCRE_DFA_SHORTEST; |
options |= PCRE_DFA_SHORTEST; |
2426 |
continue; |
continue; |
2540 |
*q++ = c; |
*q++ = c; |
2541 |
} |
} |
2542 |
*q = 0; |
*q = 0; |
2543 |
len = q - dbuffer; |
len = (int)(q - dbuffer); |
2544 |
|
|
2545 |
/* Move the data to the end of the buffer so that a read over the end of |
/* Move the data to the end of the buffer so that a read over the end of |
2546 |
the buffer will be seen by valgrind, even if it doesn't cause a crash. If |
the buffer will be seen by valgrind, even if it doesn't cause a crash. If |
2603 |
(void)pchars(dbuffer + pmatch[i].rm_so, |
(void)pchars(dbuffer + pmatch[i].rm_so, |
2604 |
pmatch[i].rm_eo - pmatch[i].rm_so, outfile); |
pmatch[i].rm_eo - pmatch[i].rm_so, outfile); |
2605 |
fprintf(outfile, "\n"); |
fprintf(outfile, "\n"); |
2606 |
if (i == 0 && do_showrest) |
if (do_showcaprest || (i == 0 && do_showrest)) |
2607 |
{ |
{ |
2608 |
fprintf(outfile, " 0+ "); |
fprintf(outfile, "%2d+ ", (int)i); |
2609 |
(void)pchars(dbuffer + pmatch[i].rm_eo, len - pmatch[i].rm_eo, |
(void)pchars(dbuffer + pmatch[i].rm_eo, len - pmatch[i].rm_eo, |
2610 |
outfile); |
outfile); |
2611 |
fprintf(outfile, "\n"); |
fprintf(outfile, "\n"); |
2747 |
} |
} |
2748 |
} |
} |
2749 |
|
|
2750 |
|
/* do_allcaps requests showing of all captures in the pattern, to check |
2751 |
|
unset ones at the end. */ |
2752 |
|
|
2753 |
|
if (do_allcaps) |
2754 |
|
{ |
2755 |
|
new_info(re, NULL, PCRE_INFO_CAPTURECOUNT, &count); |
2756 |
|
count++; /* Allow for full match */ |
2757 |
|
if (count * 2 > use_size_offsets) count = use_size_offsets/2; |
2758 |
|
} |
2759 |
|
|
2760 |
|
/* Output the captured substrings */ |
2761 |
|
|
2762 |
for (i = 0; i < count * 2; i += 2) |
for (i = 0; i < count * 2; i += 2) |
2763 |
{ |
{ |
2764 |
if (use_offsets[i] < 0) |
if (use_offsets[i] < 0) |
2765 |
|
{ |
2766 |
|
if (use_offsets[i] != -1) |
2767 |
|
fprintf(outfile, "ERROR: bad negative value %d for offset %d\n", |
2768 |
|
use_offsets[i], i); |
2769 |
|
if (use_offsets[i+1] != -1) |
2770 |
|
fprintf(outfile, "ERROR: bad negative value %d for offset %d\n", |
2771 |
|
use_offsets[i+1], i+1); |
2772 |
fprintf(outfile, "%2d: <unset>\n", i/2); |
fprintf(outfile, "%2d: <unset>\n", i/2); |
2773 |
|
} |
2774 |
else |
else |
2775 |
{ |
{ |
2776 |
fprintf(outfile, "%2d: ", i/2); |
fprintf(outfile, "%2d: ", i/2); |
2777 |
(void)pchars(bptr + use_offsets[i], |
(void)pchars(bptr + use_offsets[i], |
2778 |
use_offsets[i+1] - use_offsets[i], outfile); |
use_offsets[i+1] - use_offsets[i], outfile); |
2779 |
fprintf(outfile, "\n"); |
fprintf(outfile, "\n"); |
2780 |
if (i == 0) |
if (do_showcaprest || (i == 0 && do_showrest)) |
2781 |
{ |
{ |
2782 |
if (do_showrest) |
fprintf(outfile, "%2d+ ", i/2); |
2783 |
{ |
(void)pchars(bptr + use_offsets[i+1], len - use_offsets[i+1], |
2784 |
fprintf(outfile, " 0+ "); |
outfile); |
2785 |
(void)pchars(bptr + use_offsets[i+1], len - use_offsets[i+1], |
fprintf(outfile, "\n"); |
|
outfile); |
|
|
fprintf(outfile, "\n"); |
|
|
} |
|
2786 |
} |
} |
2787 |
} |
} |
2788 |
} |
} |
2889 |
to advance the start offset, and continue. We won't be at the end of the |
to advance the start offset, and continue. We won't be at the end of the |
2890 |
string - that was checked before setting g_notempty. |
string - that was checked before setting g_notempty. |
2891 |
|
|
2892 |
Complication arises in the case when the newline option is "any" or |
Complication arises in the case when the newline convention is "any", |
2893 |
"anycrlf". If the previous match was at the end of a line terminated by |
"crlf", or "anycrlf". If the previous match was at the end of a line |
2894 |
CRLF, an advance of one character just passes the \r, whereas we should |
terminated by CRLF, an advance of one character just passes the \r, |
2895 |
prefer the longer newline sequence, as does the code in pcre_exec(). |
whereas we should prefer the longer newline sequence, as does the code in |
2896 |
Fudge the offset value to achieve this. |
pcre_exec(). Fudge the offset value to achieve this. We check for a |
2897 |
|
newline setting in the pattern; if none was set, use pcre_config() to |
2898 |
|
find the default. |
2899 |
|
|
2900 |
Otherwise, in the case of UTF-8 matching, the advance must be one |
Otherwise, in the case of UTF-8 matching, the advance must be one |
2901 |
character, not one byte. */ |
character, not one byte. */ |
2920 |
(d == -1)? PCRE_NEWLINE_ANY : 0; |
(d == -1)? PCRE_NEWLINE_ANY : 0; |
2921 |
} |
} |
2922 |
if (((obits & PCRE_NEWLINE_BITS) == PCRE_NEWLINE_ANY || |
if (((obits & PCRE_NEWLINE_BITS) == PCRE_NEWLINE_ANY || |
2923 |
|
(obits & PCRE_NEWLINE_BITS) == PCRE_NEWLINE_CRLF || |
2924 |
(obits & PCRE_NEWLINE_BITS) == PCRE_NEWLINE_ANYCRLF) |
(obits & PCRE_NEWLINE_BITS) == PCRE_NEWLINE_ANYCRLF) |
2925 |
&& |
&& |
2926 |
start_offset < len - 1 && |
start_offset < len - 1 && |
2931 |
{ |
{ |
2932 |
while (start_offset + onechar < len) |
while (start_offset + onechar < len) |
2933 |
{ |
{ |
2934 |
int tb = bptr[start_offset+onechar]; |
if ((bptr[start_offset+onechar] & 0xc0) != 0x80) break; |
2935 |
if (tb <= 127) break; |
onechar++; |
|
tb &= 0xc0; |
|
|
if (tb != 0 && tb != 0xc0) onechar++; |
|
2936 |
} |
} |
2937 |
} |
} |
2938 |
use_offsets[1] = start_offset + onechar; |
use_offsets[1] = start_offset + onechar; |
2939 |
} |
} |
2940 |
else |
else |
2941 |
{ |
{ |
2942 |
if (count == PCRE_ERROR_NOMATCH) |
switch(count) |
2943 |
{ |
{ |
2944 |
|
case PCRE_ERROR_NOMATCH: |
2945 |
if (gmatched == 0) |
if (gmatched == 0) |
2946 |
{ |
{ |
2947 |
if (markptr == NULL) fprintf(outfile, "No match\n"); |
if (markptr == NULL) fprintf(outfile, "No match\n"); |
2948 |
else fprintf(outfile, "No match, mark = %s\n", markptr); |
else fprintf(outfile, "No match, mark = %s\n", markptr); |
2949 |
} |
} |
2950 |
|
break; |
2951 |
|
|
2952 |
|
case PCRE_ERROR_BADUTF8: |
2953 |
|
case PCRE_ERROR_SHORTUTF8: |
2954 |
|
fprintf(outfile, "Error %d (%s UTF-8 string)", count, |
2955 |
|
(count == PCRE_ERROR_BADUTF8)? "bad" : "short"); |
2956 |
|
if (use_size_offsets >= 2) |
2957 |
|
fprintf(outfile, " offset=%d reason=%d", use_offsets[0], |
2958 |
|
use_offsets[1]); |
2959 |
|
fprintf(outfile, "\n"); |
2960 |
|
break; |
2961 |
|
|
2962 |
|
default: |
2963 |
|
if (count < 0 && (-count) < sizeof(errtexts)/sizeof(const char *)) |
2964 |
|
fprintf(outfile, "Error %d (%s)\n", count, errtexts[-count]); |
2965 |
|
else |
2966 |
|
fprintf(outfile, "Error %d (Unexpected value)\n", count); |
2967 |
|
break; |
2968 |
} |
} |
2969 |
else fprintf(outfile, "Error %d\n", count); |
|
2970 |
break; /* Out of the /g loop */ |
break; /* Out of the /g loop */ |
2971 |
} |
} |
2972 |
} |
} |
3014 |
|
|
3015 |
if (re != NULL) new_free(re); |
if (re != NULL) new_free(re); |
3016 |
if (extra != NULL) new_free(extra); |
if (extra != NULL) new_free(extra); |
3017 |
if (tables != NULL) |
if (locale_set) |
3018 |
{ |
{ |
3019 |
new_free((void *)tables); |
new_free((void *)tables); |
3020 |
setlocale(LC_CTYPE, "C"); |
setlocale(LC_CTYPE, "C"); |