| 114 |
#include "pcreposix.h" |
#include "pcreposix.h" |
| 115 |
#endif |
#endif |
| 116 |
|
|
| 117 |
/* It is also possible, for the benefit of the version imported into Exim, to |
/* It is also possible, for the benefit of the version currently imported into |
| 118 |
build pcretest without support for UTF8 (define NOUTF8), without the interface |
Exim, to build pcretest without support for UTF8 (define NOUTF8), without the |
| 119 |
to the DFA matcher (NODFA), and without the doublecheck of the old "info" |
interface to the DFA matcher (NODFA), and without the doublecheck of the old |
| 120 |
function (define NOINFOCHECK). */ |
"info" function (define NOINFOCHECK). In fact, we automatically cut out the |
| 121 |
|
UTF8 support if PCRE is built without it. */ |
| 122 |
|
|
| 123 |
|
#ifndef SUPPORT_UTF8 |
| 124 |
|
#ifndef NOUTF8 |
| 125 |
|
#define NOUTF8 |
| 126 |
|
#endif |
| 127 |
|
#endif |
| 128 |
|
|
| 129 |
|
|
| 130 |
/* Other parameters */ |
/* Other parameters */ |
| 858 |
printf(" Default recursion depth limit = %d\n", rc); |
printf(" Default recursion depth limit = %d\n", rc); |
| 859 |
(void)pcre_config(PCRE_CONFIG_STACKRECURSE, &rc); |
(void)pcre_config(PCRE_CONFIG_STACKRECURSE, &rc); |
| 860 |
printf(" Match recursion uses %s\n", rc? "stack" : "heap"); |
printf(" Match recursion uses %s\n", rc? "stack" : "heap"); |
| 861 |
exit(0); |
goto EXIT; |
| 862 |
} |
} |
| 863 |
else if (strcmp(argv[op], "-help") == 0 || |
else if (strcmp(argv[op], "-help") == 0 || |
| 864 |
strcmp(argv[op], "--help") == 0) |
strcmp(argv[op], "--help") == 0) |
| 944 |
size_t size, regex_gotten_store; |
size_t size, regex_gotten_store; |
| 945 |
int do_study = 0; |
int do_study = 0; |
| 946 |
int do_debug = debug; |
int do_debug = debug; |
| 947 |
|
int debug_lengths = 1; |
| 948 |
int do_G = 0; |
int do_G = 0; |
| 949 |
int do_g = 0; |
int do_g = 0; |
| 950 |
int do_showinfo = showinfo; |
int do_showinfo = showinfo; |
| 1135 |
case 'S': do_study = 1; break; |
case 'S': do_study = 1; break; |
| 1136 |
case 'U': options |= PCRE_UNGREEDY; break; |
case 'U': options |= PCRE_UNGREEDY; break; |
| 1137 |
case 'X': options |= PCRE_EXTRA; break; |
case 'X': options |= PCRE_EXTRA; break; |
| 1138 |
|
case 'Z': debug_lengths = 0; break; |
| 1139 |
case '8': options |= PCRE_UTF8; use_utf8 = 1; break; |
case '8': options |= PCRE_UTF8; use_utf8 = 1; break; |
| 1140 |
case '?': options |= PCRE_NO_UTF8_CHECK; break; |
case '?': options |= PCRE_NO_UTF8_CHECK; break; |
| 1141 |
|
|
| 1337 |
if (do_debug) |
if (do_debug) |
| 1338 |
{ |
{ |
| 1339 |
fprintf(outfile, "------------------------------------------------------------------\n"); |
fprintf(outfile, "------------------------------------------------------------------\n"); |
| 1340 |
pcre_printint(re, outfile); |
pcre_printint(re, outfile, debug_lengths); |
| 1341 |
} |
} |
| 1342 |
|
|
| 1343 |
if (do_showinfo) |
if (do_showinfo) |
| 1972 |
|
|
| 1973 |
for (;; gmatched++) /* Loop for /g or /G */ |
for (;; gmatched++) /* Loop for /g or /G */ |
| 1974 |
{ |
{ |
| 1975 |
|
int gany_fudge; |
| 1976 |
if (timeitm > 0) |
if (timeitm > 0) |
| 1977 |
{ |
{ |
| 1978 |
register int i; |
register int i; |
| 2256 |
what Perl's /g options does. This turns out to be rather cunning. First |
what Perl's /g options does. This turns out to be rather cunning. First |
| 2257 |
we set PCRE_NOTEMPTY and PCRE_ANCHORED and try the match again at the |
we set PCRE_NOTEMPTY and PCRE_ANCHORED and try the match again at the |
| 2258 |
same point. If this fails (picked up above) we advance to the next |
same point. If this fails (picked up above) we advance to the next |
| 2259 |
character. */ |
character. |
| 2260 |
|
|
| 2261 |
|
Yet more complication arises in the case when the newline option is |
| 2262 |
|
"any" and a pattern in multiline mode has to match at the start of a |
| 2263 |
|
line. If a previous match was at the end of a line, and advance of one |
| 2264 |
|
character just passes the \r, whereas we should prefer the longer newline |
| 2265 |
|
sequence, as does the code in pcre_exec(). So we fudge it. */ |
| 2266 |
|
|
| 2267 |
g_notempty = 0; |
g_notempty = 0; |
| 2268 |
|
gany_fudge = 0; |
| 2269 |
|
|
| 2270 |
if (use_offsets[0] == use_offsets[1]) |
if (use_offsets[0] == use_offsets[1]) |
| 2271 |
{ |
{ |
| 2272 |
if (use_offsets[0] == len) break; |
if (use_offsets[0] == len) break; |
| 2273 |
g_notempty = PCRE_NOTEMPTY | PCRE_ANCHORED; |
g_notempty = PCRE_NOTEMPTY | PCRE_ANCHORED; |
| 2274 |
|
if ((((real_pcre *)re)->options & PCRE_STARTLINE) != 0 && |
| 2275 |
|
(((real_pcre *)re)->options & PCRE_NEWLINE_BITS) == PCRE_NEWLINE_ANY && |
| 2276 |
|
use_offsets[0] < len - 1 && |
| 2277 |
|
bptr[use_offsets[0]] == '\r' && |
| 2278 |
|
bptr[use_offsets[0]+1] == '\n') |
| 2279 |
|
gany_fudge = 1; |
| 2280 |
} |
} |
| 2281 |
|
|
| 2282 |
/* For /g, update the start offset, leaving the rest alone */ |
/* For /g, update the start offset, leaving the rest alone */ |
| 2283 |
|
|
| 2284 |
if (do_g) start_offset = use_offsets[1]; |
if (do_g) start_offset = use_offsets[1] + gany_fudge; |
| 2285 |
|
|
| 2286 |
/* For /G, update the pointer and length */ |
/* For /G, update the pointer and length */ |
| 2287 |
|
|
| 2288 |
else |
else |
| 2289 |
{ |
{ |
| 2290 |
bptr += use_offsets[1]; |
bptr += use_offsets[1] + gany_fudge; |
| 2291 |
len -= use_offsets[1]; |
len -= use_offsets[1] + gany_fudge; |
| 2292 |
} |
} |
| 2293 |
} /* End of loop for /g and /G */ |
} /* End of loop for /g and /G */ |
| 2294 |
|
|