| 67 |
#endif |
#endif |
| 68 |
|
|
| 69 |
|
|
| 70 |
#define PCRE_SPY /* For Win32 build, import data, not export */ |
/* We have to include pcre_internal.h because we need the internal info for |
| 71 |
|
displaying the results of pcre_study() and we also need to know about the |
| 72 |
/* We include pcre_internal.h because we need the internal info for displaying |
internal macros, structures, and other internal data values; pcretest has |
| 73 |
the results of pcre_study() and we also need to know about the internal |
"inside information" compared to a program that strictly follows the PCRE API. |
| 74 |
macros, structures, and other internal data values; pcretest has "inside |
|
| 75 |
information" compared to a program that strictly follows the PCRE API. */ |
Although pcre_internal.h does itself include pcre.h, we explicitly include it |
| 76 |
|
here before pcre_internal.h so that the PCRE_EXP_xxx macros get set |
| 77 |
|
appropriately for an application, not for building PCRE. */ |
| 78 |
|
|
| 79 |
|
#include "pcre.h" |
| 80 |
#include "pcre_internal.h" |
#include "pcre_internal.h" |
| 81 |
|
|
| 82 |
/* We need access to the data tables that PCRE uses. So as not to have to keep |
/* We need access to the data tables that PCRE uses. So as not to have to keep |
| 861 |
printf(" Default recursion depth limit = %d\n", rc); |
printf(" Default recursion depth limit = %d\n", rc); |
| 862 |
(void)pcre_config(PCRE_CONFIG_STACKRECURSE, &rc); |
(void)pcre_config(PCRE_CONFIG_STACKRECURSE, &rc); |
| 863 |
printf(" Match recursion uses %s\n", rc? "stack" : "heap"); |
printf(" Match recursion uses %s\n", rc? "stack" : "heap"); |
| 864 |
exit(0); |
goto EXIT; |
| 865 |
} |
} |
| 866 |
else if (strcmp(argv[op], "-help") == 0 || |
else if (strcmp(argv[op], "-help") == 0 || |
| 867 |
strcmp(argv[op], "--help") == 0) |
strcmp(argv[op], "--help") == 0) |
| 947 |
size_t size, regex_gotten_store; |
size_t size, regex_gotten_store; |
| 948 |
int do_study = 0; |
int do_study = 0; |
| 949 |
int do_debug = debug; |
int do_debug = debug; |
| 950 |
|
int debug_lengths = 1; |
| 951 |
int do_G = 0; |
int do_G = 0; |
| 952 |
int do_g = 0; |
int do_g = 0; |
| 953 |
int do_showinfo = showinfo; |
int do_showinfo = showinfo; |
| 1138 |
case 'S': do_study = 1; break; |
case 'S': do_study = 1; break; |
| 1139 |
case 'U': options |= PCRE_UNGREEDY; break; |
case 'U': options |= PCRE_UNGREEDY; break; |
| 1140 |
case 'X': options |= PCRE_EXTRA; break; |
case 'X': options |= PCRE_EXTRA; break; |
| 1141 |
|
case 'Z': debug_lengths = 0; break; |
| 1142 |
case '8': options |= PCRE_UTF8; use_utf8 = 1; break; |
case '8': options |= PCRE_UTF8; use_utf8 = 1; break; |
| 1143 |
case '?': options |= PCRE_NO_UTF8_CHECK; break; |
case '?': options |= PCRE_NO_UTF8_CHECK; break; |
| 1144 |
|
|
| 1340 |
if (do_debug) |
if (do_debug) |
| 1341 |
{ |
{ |
| 1342 |
fprintf(outfile, "------------------------------------------------------------------\n"); |
fprintf(outfile, "------------------------------------------------------------------\n"); |
| 1343 |
pcre_printint(re, outfile); |
pcre_printint(re, outfile, debug_lengths); |
| 1344 |
} |
} |
| 1345 |
|
|
| 1346 |
if (do_showinfo) |
if (do_showinfo) |
| 2214 |
} |
} |
| 2215 |
|
|
| 2216 |
/* Failed to match. If this is a /g or /G loop and we previously set |
/* Failed to match. If this is a /g or /G loop and we previously set |
| 2217 |
g_notempty after a null match, this is not necessarily the end. |
g_notempty after a null match, this is not necessarily the end. We want |
| 2218 |
We want to advance the start offset, and continue. In the case of UTF-8 |
to advance the start offset, and continue. We won't be at the end of the |
| 2219 |
matching, the advance must be one character, not one byte. Fudge the |
string - that was checked before setting g_notempty. |
| 2220 |
offset values to achieve this. We won't be at the end of the string - |
|
| 2221 |
that was checked before setting g_notempty. */ |
Complication arises in the case when the newline option is "any". |
| 2222 |
|
If the previous match was at the end of a line terminated by CRLF, an |
| 2223 |
|
advance of one character just passes the \r, whereas we should prefer the |
| 2224 |
|
longer newline sequence, as does the code in pcre_exec(). Fudge the |
| 2225 |
|
offset value to achieve this. |
| 2226 |
|
|
| 2227 |
|
Otherwise, in the case of UTF-8 matching, the advance must be one |
| 2228 |
|
character, not one byte. */ |
| 2229 |
|
|
| 2230 |
else |
else |
| 2231 |
{ |
{ |
| 2233 |
{ |
{ |
| 2234 |
int onechar = 1; |
int onechar = 1; |
| 2235 |
use_offsets[0] = start_offset; |
use_offsets[0] = start_offset; |
| 2236 |
if (use_utf8) |
if ((((real_pcre *)re)->options & PCRE_NEWLINE_BITS) == |
| 2237 |
|
PCRE_NEWLINE_ANY && |
| 2238 |
|
start_offset < len - 1 && |
| 2239 |
|
bptr[start_offset] == '\r' && |
| 2240 |
|
bptr[start_offset+1] == '\n') |
| 2241 |
|
onechar++; |
| 2242 |
|
else if (use_utf8) |
| 2243 |
{ |
{ |
| 2244 |
while (start_offset + onechar < len) |
while (start_offset + onechar < len) |
| 2245 |
{ |
{ |
| 2274 |
character. */ |
character. */ |
| 2275 |
|
|
| 2276 |
g_notempty = 0; |
g_notempty = 0; |
| 2277 |
|
|
| 2278 |
if (use_offsets[0] == use_offsets[1]) |
if (use_offsets[0] == use_offsets[1]) |
| 2279 |
{ |
{ |
| 2280 |
if (use_offsets[0] == len) break; |
if (use_offsets[0] == len) break; |