391 |
|
|
392 |
#if !defined NOPOSIX /* There are still compilers that require no indent */ |
#if !defined NOPOSIX /* There are still compilers that require no indent */ |
393 |
regex_t preg; |
regex_t preg; |
394 |
|
int do_posix = 0; |
395 |
#endif |
#endif |
396 |
|
|
397 |
const char *error; |
const char *error; |
403 |
int do_g = 0; |
int do_g = 0; |
404 |
int do_showinfo = showinfo; |
int do_showinfo = showinfo; |
405 |
int do_showrest = 0; |
int do_showrest = 0; |
|
int do_posix = 0; |
|
406 |
int erroroffset, len, delimiter; |
int erroroffset, len, delimiter; |
407 |
|
|
408 |
if (infile == stdin) printf(" re> "); |
if (infile == stdin) printf(" re> "); |
995 |
} |
} |
996 |
|
|
997 |
/* 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 |
998 |
PCRE_NOTEMPTY after a null match, this is not necessarily the end. |
g_notempty after a null match, this is not necessarily the end. |
999 |
We want to advance the start offset, and continue. Fudge the offset |
We want to advance the start offset, and continue. Fudge the offset |
1000 |
values to achieve this. We won't be at the end of the string - that |
values to achieve this. We won't be at the end of the string - that |
1001 |
was checked before setting PCRE_NOTEMPTY. */ |
was checked before setting g_notempty. */ |
1002 |
|
|
1003 |
else |
else |
1004 |
{ |
{ |
1025 |
/* If we have matched an empty string, first check to see if we are at |
/* If we have matched an empty string, first check to see if we are at |
1026 |
the end of the subject. If so, the /g loop is over. Otherwise, mimic |
the end of the subject. If so, the /g loop is over. Otherwise, mimic |
1027 |
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 |
1028 |
we set PCRE_NOTEMPTY and try the match again at the same point. If this |
we set PCRE_NOTEMPTY and PCRE_ANCHORED and try the match again at the |
1029 |
fails (picked up above) we advance to the next character. */ |
same point. If this fails (picked up above) we advance to the next |
1030 |
|
character. */ |
1031 |
|
|
1032 |
g_notempty = 0; |
g_notempty = 0; |
1033 |
if (offsets[0] == offsets[1]) |
if (offsets[0] == offsets[1]) |
1034 |
{ |
{ |
1035 |
if (offsets[0] == len) break; |
if (offsets[0] == len) break; |
1036 |
g_notempty = PCRE_NOTEMPTY; |
g_notempty = PCRE_NOTEMPTY | PCRE_ANCHORED; |
1037 |
} |
} |
1038 |
|
|
1039 |
/* For /g, update the start offset, leaving the rest alone */ |
/* For /g, update the start offset, leaving the rest alone */ |