| 1567 |
|
|
| 1568 |
/* Groups with zero repeats can of course be empty; skip them. */ |
/* Groups with zero repeats can of course be empty; skip them. */ |
| 1569 |
|
|
| 1570 |
if (c == OP_BRAZERO || c == OP_BRAMINZERO) |
if (c == OP_BRAZERO || c == OP_BRAMINZERO || c == OP_SKIPZERO) |
| 1571 |
{ |
{ |
| 1572 |
code += _pcre_OP_lengths[c]; |
code += _pcre_OP_lengths[c]; |
| 1573 |
do code += GET(code, 1); while (*code == OP_ALT); |
do code += GET(code, 1); while (*code == OP_ALT); |
| 1847 |
that is referenced. This means that groups can be replicated for fixed |
that is referenced. This means that groups can be replicated for fixed |
| 1848 |
repetition simply by copying (because the recursion is allowed to refer to |
repetition simply by copying (because the recursion is allowed to refer to |
| 1849 |
earlier groups that are outside the current group). However, when a group is |
earlier groups that are outside the current group). However, when a group is |
| 1850 |
optional (i.e. the minimum quantifier is zero), OP_BRAZERO is inserted before |
optional (i.e. the minimum quantifier is zero), OP_BRAZERO or OP_SKIPZERO is |
| 1851 |
it, after it has been compiled. This means that any OP_RECURSE items within it |
inserted before it, after it has been compiled. This means that any OP_RECURSE |
| 1852 |
that refer to the group itself or any contained groups have to have their |
items within it that refer to the group itself or any contained groups have to |
| 1853 |
offsets adjusted. That one of the jobs of this function. Before it is called, |
have their offsets adjusted. That one of the jobs of this function. Before it |
| 1854 |
the partially compiled regex must be temporarily terminated with OP_END. |
is called, the partially compiled regex must be temporarily terminated with |
| 1855 |
|
OP_END. |
| 1856 |
|
|
| 1857 |
This function has been extended with the possibility of forward references for |
This function has been extended with the possibility of forward references for |
| 1858 |
recursions and subroutine calls. It must also check the list of such references |
recursions and subroutine calls. It must also check the list of such references |
| 3843 |
|
|
| 3844 |
if (repeat_min == 0) |
if (repeat_min == 0) |
| 3845 |
{ |
{ |
| 3846 |
/* If the maximum is also zero, we just omit the group from the output |
/* If the maximum is also zero, we used to just omit the group from the |
| 3847 |
altogether. */ |
output altogether, like this: |
| 3848 |
|
|
| 3849 |
if (repeat_max == 0) |
** if (repeat_max == 0) |
| 3850 |
{ |
** { |
| 3851 |
code = previous; |
** code = previous; |
| 3852 |
goto END_REPEAT; |
** goto END_REPEAT; |
| 3853 |
} |
** } |
| 3854 |
|
|
| 3855 |
/* If the maximum is 1 or unlimited, we just have to stick in the |
However, that fails when a group is referenced as a subroutine from |
| 3856 |
BRAZERO and do no more at this point. However, we do need to adjust |
elsewhere in the pattern, so now we stick in OP_SKIPZERO in front of it |
| 3857 |
any OP_RECURSE calls inside the group that refer to the group itself or |
so that it is skipped on execution. As we don't have a list of which |
| 3858 |
any internal or forward referenced group, because the offset is from |
groups are referenced, we cannot do this selectively. |
| 3859 |
the start of the whole regex. Temporarily terminate the pattern while |
|
| 3860 |
doing this. */ |
If the maximum is 1 or unlimited, we just have to stick in the BRAZERO |
| 3861 |
|
and do no more at this point. However, we do need to adjust any |
| 3862 |
|
OP_RECURSE calls inside the group that refer to the group itself or any |
| 3863 |
|
internal or forward referenced group, because the offset is from the |
| 3864 |
|
start of the whole regex. Temporarily terminate the pattern while doing |
| 3865 |
|
this. */ |
| 3866 |
|
|
| 3867 |
if (repeat_max <= 1) |
if (repeat_max <= 1) /* Covers 0, 1, and unlimited */ |
| 3868 |
{ |
{ |
| 3869 |
*code = OP_END; |
*code = OP_END; |
| 3870 |
adjust_recurse(previous, 1, utf8, cd, save_hwm); |
adjust_recurse(previous, 1, utf8, cd, save_hwm); |
| 3871 |
memmove(previous+1, previous, len); |
memmove(previous+1, previous, len); |
| 3872 |
code++; |
code++; |
| 3873 |
|
if (repeat_max == 0) |
| 3874 |
|
{ |
| 3875 |
|
*previous++ = OP_SKIPZERO; |
| 3876 |
|
goto END_REPEAT; |
| 3877 |
|
} |
| 3878 |
*previous++ = OP_BRAZERO + repeat_type; |
*previous++ = OP_BRAZERO + repeat_type; |
| 3879 |
} |
} |
| 3880 |
|
|
| 6209 |
if (groupptr == NULL) errorcode = ERR53; |
if (groupptr == NULL) errorcode = ERR53; |
| 6210 |
else PUT(((uschar *)codestart), offset, groupptr - codestart); |
else PUT(((uschar *)codestart), offset, groupptr - codestart); |
| 6211 |
} |
} |
| 6212 |
|
|
| 6213 |
/* Give an error if there's back reference to a non-existent capturing |
/* Give an error if there's back reference to a non-existent capturing |
| 6214 |
subpattern. */ |
subpattern. */ |
| 6215 |
|
|