| 976 |
|
|
| 977 |
Arguments: |
Arguments: |
| 978 |
ptr current position in the pattern |
ptr current position in the pattern |
| 979 |
count current count of capturing parens so far encountered |
cd compile background data |
| 980 |
name name to seek, or NULL if seeking a numbered subpattern |
name name to seek, or NULL if seeking a numbered subpattern |
| 981 |
lorn name length, or subpattern number if name is NULL |
lorn name length, or subpattern number if name is NULL |
| 982 |
xmode TRUE if we are in /x mode |
xmode TRUE if we are in /x mode |
| 985 |
*/ |
*/ |
| 986 |
|
|
| 987 |
static int |
static int |
| 988 |
find_parens(const uschar *ptr, int count, const uschar *name, int lorn, |
find_parens(const uschar *ptr, compile_data *cd, const uschar *name, int lorn, |
| 989 |
BOOL xmode) |
BOOL xmode) |
| 990 |
{ |
{ |
| 991 |
const uschar *thisname; |
const uschar *thisname; |
| 992 |
|
int count = cd->bracount; |
| 993 |
|
|
| 994 |
for (; *ptr != 0; ptr++) |
for (; *ptr != 0; ptr++) |
| 995 |
{ |
{ |
| 1032 |
} |
} |
| 1033 |
|
|
| 1034 |
/* If the next character is ']', it is a data character that must be |
/* If the next character is ']', it is a data character that must be |
| 1035 |
skipped. */ |
skipped, except in JavaScript compatibility mode. */ |
| 1036 |
|
|
| 1037 |
if (ptr[1] == ']') ptr++; |
if (ptr[1] == ']' && (cd->external_options & PCRE_JAVASCRIPT_COMPAT) == 0) |
| 1038 |
|
ptr++; |
| 1039 |
|
|
| 1040 |
while (*(++ptr) != ']') |
while (*(++ptr) != ']') |
| 1041 |
{ |
{ |
| 2723 |
negate_class = TRUE; |
negate_class = TRUE; |
| 2724 |
else break; |
else break; |
| 2725 |
} |
} |
| 2726 |
|
|
| 2727 |
|
/* Empty classes are allowed in JavaScript compatibility mode. Otherwise, |
| 2728 |
|
an initial ']' is taken as a data character -- the code below handles |
| 2729 |
|
that. In JS mode, [] must always fail, so generate OP_FAIL, whereas |
| 2730 |
|
[^] must match any character, so generate OP_ALLANY. */ |
| 2731 |
|
|
| 2732 |
|
if (c ==']' && (cd->external_options & PCRE_JAVASCRIPT_COMPAT) != 0) |
| 2733 |
|
{ |
| 2734 |
|
*code++ = negate_class? OP_ALLANY : OP_FAIL; |
| 2735 |
|
if (firstbyte == REQ_UNSET) firstbyte = REQ_NONE; |
| 2736 |
|
zerofirstbyte = firstbyte; |
| 2737 |
|
break; |
| 2738 |
|
} |
| 2739 |
|
|
| 2740 |
/* If a class contains a negative special such as \S, we need to flip the |
/* If a class contains a negative special such as \S, we need to flip the |
| 2741 |
negation flag at the end, so that support for characters > 255 works |
negation flag at the end, so that support for characters > 255 works |
| 4117 |
} |
} |
| 4118 |
} |
} |
| 4119 |
} |
} |
| 4120 |
|
|
| 4121 |
|
/* If previous is OP_FAIL, it was generated by an empty class [] in |
| 4122 |
|
JavaScript mode. The other ways in which OP_FAIL can be generated, that is |
| 4123 |
|
by (*FAIL) or (?!) set previous to NULL, which gives a "nothing to repeat" |
| 4124 |
|
error above. We can just ignore the repeat in JS case. */ |
| 4125 |
|
|
| 4126 |
|
else if (*previous == OP_FAIL) goto END_REPEAT; |
| 4127 |
|
|
| 4128 |
/* Else there's some kind of shambles */ |
/* Else there's some kind of shambles */ |
| 4129 |
|
|
| 4411 |
|
|
| 4412 |
/* Search the pattern for a forward reference */ |
/* Search the pattern for a forward reference */ |
| 4413 |
|
|
| 4414 |
else if ((i = find_parens(ptr, cd->bracount, name, namelen, |
else if ((i = find_parens(ptr, cd, name, namelen, |
| 4415 |
(options & PCRE_EXTENDED) != 0)) > 0) |
(options & PCRE_EXTENDED) != 0)) > 0) |
| 4416 |
{ |
{ |
| 4417 |
PUT2(code, 2+LINK_SIZE, i); |
PUT2(code, 2+LINK_SIZE, i); |
| 4708 |
recno = GET2(slot, 0); |
recno = GET2(slot, 0); |
| 4709 |
} |
} |
| 4710 |
else if ((recno = /* Forward back reference */ |
else if ((recno = /* Forward back reference */ |
| 4711 |
find_parens(ptr, cd->bracount, name, namelen, |
find_parens(ptr, cd, name, namelen, |
| 4712 |
(options & PCRE_EXTENDED) != 0)) <= 0) |
(options & PCRE_EXTENDED) != 0)) <= 0) |
| 4713 |
{ |
{ |
| 4714 |
*errorcodeptr = ERR15; |
*errorcodeptr = ERR15; |
| 4818 |
|
|
| 4819 |
if (called == NULL) |
if (called == NULL) |
| 4820 |
{ |
{ |
| 4821 |
if (find_parens(ptr, cd->bracount, NULL, recno, |
if (find_parens(ptr, cd, NULL, recno, |
| 4822 |
(options & PCRE_EXTENDED) != 0) < 0) |
(options & PCRE_EXTENDED) != 0) < 0) |
| 4823 |
{ |
{ |
| 4824 |
*errorcodeptr = ERR15; |
*errorcodeptr = ERR15; |
| 4825 |
goto FAILED; |
goto FAILED; |