| 4208 |
ptr++; |
ptr++; |
| 4209 |
} |
} |
| 4210 |
else repeat_type = greedy_default; |
else repeat_type = greedy_default; |
| 4211 |
|
|
| 4212 |
|
/* If previous was a recursion call, wrap it in atomic brackets so that |
| 4213 |
|
previous becomes the atomic group. All recursions were so wrapped in the |
| 4214 |
|
past, but it no longer happens for non-repeated recursions. In fact, the |
| 4215 |
|
repeated ones could be re-implemented independently so as not to need this, |
| 4216 |
|
but for the moment we rely on the code for repeating groups. */ |
| 4217 |
|
|
| 4218 |
|
if (*previous == OP_RECURSE) |
| 4219 |
|
{ |
| 4220 |
|
memmove(previous + 1 + LINK_SIZE, previous, 1 + LINK_SIZE); |
| 4221 |
|
*previous = OP_ONCE; |
| 4222 |
|
PUT(previous, 1, 2 + 2*LINK_SIZE); |
| 4223 |
|
previous[2 + 2*LINK_SIZE] = OP_KET; |
| 4224 |
|
PUT(previous, 3 + 2*LINK_SIZE, 2 + 2*LINK_SIZE); |
| 4225 |
|
code += 2 + 2 * LINK_SIZE; |
| 4226 |
|
length_prevgroup = 3 + 3*LINK_SIZE; |
| 4227 |
|
|
| 4228 |
|
/* When actually compiling, we need to check whether this was a forward |
| 4229 |
|
reference, and if so, adjust the offset. */ |
| 4230 |
|
|
| 4231 |
|
if (lengthptr == NULL && cd->hwm >= cd->start_workspace + LINK_SIZE) |
| 4232 |
|
{ |
| 4233 |
|
int offset = GET(cd->hwm, -LINK_SIZE); |
| 4234 |
|
if (offset == previous + 1 - cd->start_code) |
| 4235 |
|
PUT(cd->hwm, -LINK_SIZE, offset + 1 + LINK_SIZE); |
| 4236 |
|
} |
| 4237 |
|
} |
| 4238 |
|
|
| 4239 |
|
/* Now handle repetition for the different types of item. */ |
| 4240 |
|
|
| 4241 |
/* If previous was a character match, abolish the item and generate a |
/* If previous was a character match, abolish the item and generate a |
| 4242 |
repeat item instead. If a char item has a minumum of more than one, ensure |
repeat item instead. If a char item has a minumum of more than one, ensure |
| 4756 |
} |
} |
| 4757 |
|
|
| 4758 |
/* If the maximum is unlimited, set a repeater in the final copy. For |
/* If the maximum is unlimited, set a repeater in the final copy. For |
| 4759 |
ONCE brackets, that's all we need to do. |
ONCE brackets, that's all we need to do. However, possessively repeated |
| 4760 |
|
ONCE brackets can be converted into non-capturing brackets, as the |
| 4761 |
(To be done next, after recursion adjusted) |
behaviour of (?:xx)++ is the same as (?>xx)++ and this saves having to |
|
However, possessively repeated |
|
|
ONCE brackets can be converted into non-capturing brackets, as the |
|
|
behaviour of (?:xx)++ is the same as (?>xx)++ and this saves having to |
|
| 4762 |
deal with possessive ONCEs specially. |
deal with possessive ONCEs specially. |
|
(....) |
|
| 4763 |
|
|
| 4764 |
Otherwise, if the quantifier was possessive, we convert the BRA code to |
Otherwise, if the quantifier was possessive, we convert the BRA code to |
| 4765 |
the POS form, and the KET code to KETRPOS. (It turns out to be convenient |
the POS form, and the KET code to KETRPOS. (It turns out to be convenient |
| 4780 |
{ |
{ |
| 4781 |
uschar *ketcode = code - 1 - LINK_SIZE; |
uschar *ketcode = code - 1 - LINK_SIZE; |
| 4782 |
uschar *bracode = ketcode - GET(ketcode, 1); |
uschar *bracode = ketcode - GET(ketcode, 1); |
| 4783 |
|
|
| 4784 |
/**** |
if (*bracode == OP_ONCE && possessive_quantifier) *bracode = OP_BRA; |
|
if (*bracode == OP_ONCE && possessive_quantifier) |
|
|
*bracode = OP_BRA; |
|
|
****/ |
|
|
|
|
| 4785 |
if (*bracode == OP_ONCE) |
if (*bracode == OP_ONCE) |
| 4786 |
*ketcode = OP_KETRMAX + repeat_type; |
*ketcode = OP_KETRMAX + repeat_type; |
| 4787 |
else |
else |
| 5698 |
|
|
| 5699 |
/* Fudge the value of "called" so that when it is inserted as an |
/* Fudge the value of "called" so that when it is inserted as an |
| 5700 |
offset below, what it actually inserted is the reference number |
offset below, what it actually inserted is the reference number |
| 5701 |
of the group. */ |
of the group. Then remember the forward reference. */ |
| 5702 |
|
|
| 5703 |
called = cd->start_code + recno; |
called = cd->start_code + recno; |
| 5704 |
PUTINC(cd->hwm, 0, (int)(code + 2 + LINK_SIZE - cd->start_code)); |
PUTINC(cd->hwm, 0, (int)(code + 1 - cd->start_code)); |
| 5705 |
} |
} |
| 5706 |
|
|
| 5707 |
/* If not a forward reference, and the subpattern is still open, |
/* If not a forward reference, and the subpattern is still open, |
| 5716 |
} |
} |
| 5717 |
} |
} |
| 5718 |
|
|
| 5719 |
/* Insert the recursion/subroutine item, automatically wrapped inside |
/* Insert the recursion/subroutine item. */ |
|
"once" brackets. Set up a "previous group" length so that a |
|
|
subsequent quantifier will work. */ |
|
| 5720 |
|
|
|
*code = OP_ONCE; |
|
|
PUT(code, 1, 2 + 2*LINK_SIZE); |
|
|
code += 1 + LINK_SIZE; |
|
|
|
|
| 5721 |
*code = OP_RECURSE; |
*code = OP_RECURSE; |
| 5722 |
PUT(code, 1, (int)(called - cd->start_code)); |
PUT(code, 1, (int)(called - cd->start_code)); |
| 5723 |
code += 1 + LINK_SIZE; |
code += 1 + LINK_SIZE; |
|
|
|
|
*code = OP_KET; |
|
|
PUT(code, 1, 2 + 2*LINK_SIZE); |
|
|
code += 1 + LINK_SIZE; |
|
|
|
|
|
length_prevgroup = 3 + 3*LINK_SIZE; |
|
| 5724 |
} |
} |
| 5725 |
|
|
| 5726 |
/* Can't determine a first byte now */ |
/* Can't determine a first byte now */ |