37 |
|
|
38 |
#define LOOPREPEAT 50000 |
#define LOOPREPEAT 50000 |
39 |
|
|
40 |
|
#define BUFFER_SIZE 30000 |
41 |
|
#define DBUFFER_SIZE 1024 |
42 |
|
|
43 |
|
|
44 |
static FILE *outfile; |
static FILE *outfile; |
45 |
static int log_store = 0; |
static int log_store = 0; |
52 |
static size_t gotten_store; |
static size_t gotten_store; |
53 |
|
|
54 |
|
|
55 |
|
static const int utf8_table1[] = { |
|
static int utf8_table1[] = { |
|
56 |
0x0000007f, 0x000007ff, 0x0000ffff, 0x001fffff, 0x03ffffff, 0x7fffffff}; |
0x0000007f, 0x000007ff, 0x0000ffff, 0x001fffff, 0x03ffffff, 0x7fffffff}; |
57 |
|
|
58 |
static int utf8_table2[] = { |
static const int utf8_table2[] = { |
59 |
0, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc}; |
0, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc}; |
60 |
|
|
61 |
static int utf8_table3[] = { |
static const int utf8_table3[] = { |
62 |
0xff, 0x1f, 0x0f, 0x07, 0x03, 0x01}; |
0xff, 0x1f, 0x0f, 0x07, 0x03, 0x01}; |
63 |
|
|
64 |
|
|
320 |
} |
} |
321 |
|
|
322 |
fprintf(outfile, "\n"); |
fprintf(outfile, "\n"); |
|
|
|
323 |
first_callout = 0; |
first_callout = 0; |
324 |
|
|
325 |
if ((int)(cb->callout_data) != 0) |
if (cb->callout_data != NULL) |
326 |
{ |
{ |
327 |
fprintf(outfile, "Callout data = %d\n", (int)(cb->callout_data)); |
int callout_data = *((int *)(cb->callout_data)); |
328 |
return (int)(cb->callout_data); |
if (callout_data != 0) |
329 |
|
{ |
330 |
|
fprintf(outfile, "Callout data = %d\n", callout_data); |
331 |
|
return callout_data; |
332 |
|
} |
333 |
} |
} |
334 |
|
|
335 |
return (cb->callout_number != callout_fail_id)? 0 : |
return (cb->callout_number != callout_fail_id)? 0 : |
392 |
#endif |
#endif |
393 |
int debug = 0; |
int debug = 0; |
394 |
int done = 0; |
int done = 0; |
395 |
unsigned char buffer[30000]; |
|
396 |
unsigned char dbuffer[1024]; |
unsigned char *buffer; |
397 |
|
unsigned char *dbuffer; |
398 |
|
|
399 |
|
/* Get buffers from malloc() so that Electric Fence will check their misuse |
400 |
|
when I am debugging. */ |
401 |
|
|
402 |
|
buffer = (unsigned char *)malloc(BUFFER_SIZE); |
403 |
|
dbuffer = (unsigned char *)malloc(DBUFFER_SIZE); |
404 |
|
|
405 |
/* Static so that new_malloc can use it. */ |
/* Static so that new_malloc can use it. */ |
406 |
|
|
466 |
/* Get the store for the offsets vector, and remember what it was */ |
/* Get the store for the offsets vector, and remember what it was */ |
467 |
|
|
468 |
size_offsets_max = size_offsets; |
size_offsets_max = size_offsets; |
469 |
offsets = malloc(size_offsets_max * sizeof(int)); |
offsets = (int *)malloc(size_offsets_max * sizeof(int)); |
470 |
if (offsets == NULL) |
if (offsets == NULL) |
471 |
{ |
{ |
472 |
printf("** Failed to get %d bytes of memory for offsets vector\n", |
printf("** Failed to get %d bytes of memory for offsets vector\n", |
530 |
use_utf8 = 0; |
use_utf8 = 0; |
531 |
|
|
532 |
if (infile == stdin) printf(" re> "); |
if (infile == stdin) printf(" re> "); |
533 |
if (fgets((char *)buffer, sizeof(buffer), infile) == NULL) break; |
if (fgets((char *)buffer, BUFFER_SIZE, infile) == NULL) break; |
534 |
if (infile != stdin) fprintf(outfile, "%s", (char *)buffer); |
if (infile != stdin) fprintf(outfile, "%s", (char *)buffer); |
535 |
fflush(outfile); |
fflush(outfile); |
536 |
|
|
561 |
} |
} |
562 |
if (*pp != 0) break; |
if (*pp != 0) break; |
563 |
|
|
564 |
len = sizeof(buffer) - (pp - buffer); |
len = BUFFER_SIZE - (pp - buffer); |
565 |
if (len < 256) |
if (len < 256) |
566 |
{ |
{ |
567 |
fprintf(outfile, "** Expression too long - missing delimiter?\n"); |
fprintf(outfile, "** Expression too long - missing delimiter?\n"); |
621 |
case 'U': options |= PCRE_UNGREEDY; break; |
case 'U': options |= PCRE_UNGREEDY; break; |
622 |
case 'X': options |= PCRE_EXTRA; break; |
case 'X': options |= PCRE_EXTRA; break; |
623 |
case '8': options |= PCRE_UTF8; use_utf8 = 1; break; |
case '8': options |= PCRE_UTF8; use_utf8 = 1; break; |
624 |
|
case '?': options |= PCRE_NO_UTF8_CHECK; break; |
625 |
|
|
626 |
case 'L': |
case 'L': |
627 |
ppp = pp; |
ppp = pp; |
661 |
|
|
662 |
if (rc != 0) |
if (rc != 0) |
663 |
{ |
{ |
664 |
(void)regerror(rc, &preg, (char *)buffer, sizeof(buffer)); |
(void)regerror(rc, &preg, (char *)buffer, BUFFER_SIZE); |
665 |
fprintf(outfile, "Failed: POSIX code %d: %s\n", rc, buffer); |
fprintf(outfile, "Failed: POSIX code %d: %s\n", rc, buffer); |
666 |
goto SKIP_DATA; |
goto SKIP_DATA; |
667 |
} |
} |
702 |
{ |
{ |
703 |
for (;;) |
for (;;) |
704 |
{ |
{ |
705 |
if (fgets((char *)buffer, sizeof(buffer), infile) == NULL) |
if (fgets((char *)buffer, BUFFER_SIZE, infile) == NULL) |
706 |
{ |
{ |
707 |
done = 1; |
done = 1; |
708 |
goto CONTINUE; |
goto CONTINUE; |
790 |
} |
} |
791 |
|
|
792 |
if (get_options == 0) fprintf(outfile, "No options\n"); |
if (get_options == 0) fprintf(outfile, "No options\n"); |
793 |
else fprintf(outfile, "Options:%s%s%s%s%s%s%s%s%s\n", |
else fprintf(outfile, "Options:%s%s%s%s%s%s%s%s%s%s\n", |
794 |
((get_options & PCRE_ANCHORED) != 0)? " anchored" : "", |
((get_options & PCRE_ANCHORED) != 0)? " anchored" : "", |
795 |
((get_options & PCRE_CASELESS) != 0)? " caseless" : "", |
((get_options & PCRE_CASELESS) != 0)? " caseless" : "", |
796 |
((get_options & PCRE_EXTENDED) != 0)? " extended" : "", |
((get_options & PCRE_EXTENDED) != 0)? " extended" : "", |
799 |
((get_options & PCRE_DOLLAR_ENDONLY) != 0)? " dollar_endonly" : "", |
((get_options & PCRE_DOLLAR_ENDONLY) != 0)? " dollar_endonly" : "", |
800 |
((get_options & PCRE_EXTRA) != 0)? " extra" : "", |
((get_options & PCRE_EXTRA) != 0)? " extra" : "", |
801 |
((get_options & PCRE_UNGREEDY) != 0)? " ungreedy" : "", |
((get_options & PCRE_UNGREEDY) != 0)? " ungreedy" : "", |
802 |
((get_options & PCRE_UTF8) != 0)? " utf8" : ""); |
((get_options & PCRE_UTF8) != 0)? " utf8" : "", |
803 |
|
((get_options & PCRE_NO_UTF8_CHECK) != 0)? " no_utf8_check" : ""); |
804 |
|
|
805 |
if (((((real_pcre *)re)->options) & PCRE_ICHANGED) != 0) |
if (((((real_pcre *)re)->options) & PCRE_ICHANGED) != 0) |
806 |
fprintf(outfile, "Case state changes\n"); |
fprintf(outfile, "Case state changes\n"); |
865 |
else if (extra == NULL) |
else if (extra == NULL) |
866 |
fprintf(outfile, "Study returned NULL\n"); |
fprintf(outfile, "Study returned NULL\n"); |
867 |
|
|
868 |
|
/* Don't output study size; at present it is in any case a fixed |
869 |
|
value, but it varies, depending on the computer architecture, and |
870 |
|
so messes up the test suite. */ |
871 |
|
|
872 |
else if (do_showinfo) |
else if (do_showinfo) |
873 |
{ |
{ |
874 |
size_t size; |
size_t size; |
875 |
uschar *start_bits = NULL; |
uschar *start_bits = NULL; |
876 |
new_info(re, extra, PCRE_INFO_STUDYSIZE, &size); |
new_info(re, extra, PCRE_INFO_STUDYSIZE, &size); |
877 |
new_info(re, extra, PCRE_INFO_FIRSTTABLE, &start_bits); |
new_info(re, extra, PCRE_INFO_FIRSTTABLE, &start_bits); |
878 |
fprintf(outfile, "Study size = %d\n", size); |
/* fprintf(outfile, "Study size = %d\n", size); */ |
879 |
if (start_bits == NULL) |
if (start_bits == NULL) |
880 |
fprintf(outfile, "No starting character set\n"); |
fprintf(outfile, "No starting character set\n"); |
881 |
else |
else |
939 |
callout_fail_id = -1; |
callout_fail_id = -1; |
940 |
|
|
941 |
if (infile == stdin) printf("data> "); |
if (infile == stdin) printf("data> "); |
942 |
if (fgets((char *)buffer, sizeof(buffer), infile) == NULL) |
if (fgets((char *)buffer, BUFFER_SIZE, infile) == NULL) |
943 |
{ |
{ |
944 |
done = 1; |
done = 1; |
945 |
goto CONTINUE; |
goto CONTINUE; |
1113 |
{ |
{ |
1114 |
size_offsets_max = n; |
size_offsets_max = n; |
1115 |
free(offsets); |
free(offsets); |
1116 |
use_offsets = offsets = malloc(size_offsets_max * sizeof(int)); |
use_offsets = offsets = (int *)malloc(size_offsets_max * sizeof(int)); |
1117 |
if (offsets == NULL) |
if (offsets == NULL) |
1118 |
{ |
{ |
1119 |
printf("** Failed to get %d bytes of memory for offsets vector\n", |
printf("** Failed to get %d bytes of memory for offsets vector\n", |
1128 |
case 'Z': |
case 'Z': |
1129 |
options |= PCRE_NOTEOL; |
options |= PCRE_NOTEOL; |
1130 |
continue; |
continue; |
1131 |
|
|
1132 |
|
case '?': |
1133 |
|
options |= PCRE_NO_UTF8_CHECK; |
1134 |
|
continue; |
1135 |
} |
} |
1136 |
*q++ = c; |
*q++ = c; |
1137 |
} |
} |
1148 |
int eflags = 0; |
int eflags = 0; |
1149 |
regmatch_t *pmatch = NULL; |
regmatch_t *pmatch = NULL; |
1150 |
if (use_size_offsets > 0) |
if (use_size_offsets > 0) |
1151 |
pmatch = malloc(sizeof(regmatch_t) * use_size_offsets); |
pmatch = (regmatch_t *)malloc(sizeof(regmatch_t) * use_size_offsets); |
1152 |
if ((options & PCRE_NOTBOL) != 0) eflags |= REG_NOTBOL; |
if ((options & PCRE_NOTBOL) != 0) eflags |= REG_NOTBOL; |
1153 |
if ((options & PCRE_NOTEOL) != 0) eflags |= REG_NOTEOL; |
if ((options & PCRE_NOTEOL) != 0) eflags |= REG_NOTEOL; |
1154 |
|
|
1156 |
|
|
1157 |
if (rc != 0) |
if (rc != 0) |
1158 |
{ |
{ |
1159 |
(void)regerror(rc, &preg, (char *)buffer, sizeof(buffer)); |
(void)regerror(rc, &preg, (char *)buffer, BUFFER_SIZE); |
1160 |
fprintf(outfile, "No match: POSIX code %d: %s\n", rc, buffer); |
fprintf(outfile, "No match: POSIX code %d: %s\n", rc, buffer); |
1161 |
} |
} |
1162 |
else |
else |
1215 |
|
|
1216 |
if (extra == NULL) |
if (extra == NULL) |
1217 |
{ |
{ |
1218 |
extra = malloc(sizeof(pcre_extra)); |
extra = (pcre_extra *)malloc(sizeof(pcre_extra)); |
1219 |
extra->flags = 0; |
extra->flags = 0; |
1220 |
} |
} |
1221 |
extra->flags |= PCRE_EXTRA_MATCH_LIMIT; |
extra->flags |= PCRE_EXTRA_MATCH_LIMIT; |
1254 |
{ |
{ |
1255 |
if (extra == NULL) |
if (extra == NULL) |
1256 |
{ |
{ |
1257 |
extra = malloc(sizeof(pcre_extra)); |
extra = (pcre_extra *)malloc(sizeof(pcre_extra)); |
1258 |
extra->flags = 0; |
extra->flags = 0; |
1259 |
} |
} |
1260 |
extra->flags |= PCRE_EXTRA_CALLOUT_DATA; |
extra->flags |= PCRE_EXTRA_CALLOUT_DATA; |
1261 |
extra->callout_data = (void *)callout_data; |
extra->callout_data = &callout_data; |
1262 |
count = pcre_exec(re, extra, (char *)bptr, len, start_offset, |
count = pcre_exec(re, extra, (char *)bptr, len, start_offset, |
1263 |
options | g_notempty, use_offsets, use_size_offsets); |
options | g_notempty, use_offsets, use_size_offsets); |
1264 |
extra->flags &= ~PCRE_EXTRA_CALLOUT_DATA; |
extra->flags &= ~PCRE_EXTRA_CALLOUT_DATA; |