| 295 |
/* 55 */ |
/* 55 */ |
| 296 |
"repeating a DEFINE group is not allowed\0" |
"repeating a DEFINE group is not allowed\0" |
| 297 |
"inconsistent NEWLINE options\0" |
"inconsistent NEWLINE options\0" |
| 298 |
"\\g is not followed by a braced name or an optionally braced non-zero number\0" |
"\\g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number\0" |
| 299 |
"(?+ or (?- or (?(+ or (?(- must be followed by a non-zero number\0" |
"a numbered reference must not be zero\0" |
| 300 |
"(*VERB) with an argument is not supported\0" |
"(*VERB) with an argument is not supported\0" |
| 301 |
/* 60 */ |
/* 60 */ |
| 302 |
"(*VERB) not recognized\0" |
"(*VERB) not recognized\0" |
| 531 |
*errorcodeptr = ERR37; |
*errorcodeptr = ERR37; |
| 532 |
break; |
break; |
| 533 |
|
|
| 534 |
/* \g must be followed by a number, either plain or braced. If positive, it |
/* \g must be followed by one of a number of specific things: |
| 535 |
is an absolute backreference. If negative, it is a relative backreference. |
|
| 536 |
This is a Perl 5.10 feature. Perl 5.10 also supports \g{name} as a |
(1) A number, either plain or braced. If positive, it is an absolute |
| 537 |
reference to a named group. This is part of Perl's movement towards a |
backreference. If negative, it is a relative backreference. This is a Perl |
| 538 |
unified syntax for back references. As this is synonymous with \k{name}, we |
5.10 feature. |
| 539 |
fudge it up by pretending it really was \k. */ |
|
| 540 |
|
(2) Perl 5.10 also supports \g{name} as a reference to a named group. This |
| 541 |
|
is part of Perl's movement towards a unified syntax for back references. As |
| 542 |
|
this is synonymous with \k{name}, we fudge it up by pretending it really |
| 543 |
|
was \k. |
| 544 |
|
|
| 545 |
|
(3) For Oniguruma compatibility we also support \g followed by a name or a |
| 546 |
|
number either in angle brackets or in single quotes. However, these are |
| 547 |
|
(possibly recursive) subroutine calls, _not_ backreferences. Just return |
| 548 |
|
the -ESC_g code (cf \k). */ |
| 549 |
|
|
| 550 |
case 'g': |
case 'g': |
| 551 |
|
if (ptr[1] == '<' || ptr[1] == '\'') |
| 552 |
|
{ |
| 553 |
|
c = -ESC_g; |
| 554 |
|
break; |
| 555 |
|
} |
| 556 |
|
|
| 557 |
|
/* Handle the Perl-compatible cases */ |
| 558 |
|
|
| 559 |
if (ptr[1] == '{') |
if (ptr[1] == '{') |
| 560 |
{ |
{ |
| 561 |
const uschar *p; |
const uschar *p; |
| 582 |
while ((digitab[ptr[1]] & ctype_digit) != 0) |
while ((digitab[ptr[1]] & ctype_digit) != 0) |
| 583 |
c = c * 10 + *(++ptr) - '0'; |
c = c * 10 + *(++ptr) - '0'; |
| 584 |
|
|
| 585 |
if (c < 0) |
if (c < 0) /* Integer overflow */ |
| 586 |
{ |
{ |
| 587 |
*errorcodeptr = ERR61; |
*errorcodeptr = ERR61; |
| 588 |
break; |
break; |
| 589 |
} |
} |
| 590 |
|
|
| 591 |
if (c == 0 || (braced && *(++ptr) != '}')) |
if (braced && *(++ptr) != '}') |
| 592 |
{ |
{ |
| 593 |
*errorcodeptr = ERR57; |
*errorcodeptr = ERR57; |
| 594 |
break; |
break; |
| 595 |
} |
} |
| 596 |
|
|
| 597 |
|
if (c == 0) |
| 598 |
|
{ |
| 599 |
|
*errorcodeptr = ERR58; |
| 600 |
|
break; |
| 601 |
|
} |
| 602 |
|
|
| 603 |
if (negated) |
if (negated) |
| 604 |
{ |
{ |
| 634 |
c -= '0'; |
c -= '0'; |
| 635 |
while ((digitab[ptr[1]] & ctype_digit) != 0) |
while ((digitab[ptr[1]] & ctype_digit) != 0) |
| 636 |
c = c * 10 + *(++ptr) - '0'; |
c = c * 10 + *(++ptr) - '0'; |
| 637 |
if (c < 0) |
if (c < 0) /* Integer overflow */ |
| 638 |
{ |
{ |
| 639 |
*errorcodeptr = ERR61; |
*errorcodeptr = ERR61; |
| 640 |
break; |
break; |
| 1882 |
|
|
| 1883 |
/* See if this recursion is on the forward reference list. If so, adjust the |
/* See if this recursion is on the forward reference list. If so, adjust the |
| 1884 |
reference. */ |
reference. */ |
| 1885 |
|
|
| 1886 |
for (hc = save_hwm; hc < cd->hwm; hc += LINK_SIZE) |
for (hc = save_hwm; hc < cd->hwm; hc += LINK_SIZE) |
| 1887 |
{ |
{ |
| 1888 |
offset = GET(hc, 0); |
offset = GET(hc, 0); |
| 2458 |
/* Get next byte in the pattern */ |
/* Get next byte in the pattern */ |
| 2459 |
|
|
| 2460 |
c = *ptr; |
c = *ptr; |
| 2461 |
|
|
| 2462 |
/* If we are in the pre-compile phase, accumulate the length used for the |
/* If we are in the pre-compile phase, accumulate the length used for the |
| 2463 |
previous cycle of this loop. */ |
previous cycle of this loop. */ |
| 2464 |
|
|
| 4138 |
bravalue = OP_CBRA; |
bravalue = OP_CBRA; |
| 4139 |
save_hwm = cd->hwm; |
save_hwm = cd->hwm; |
| 4140 |
reset_bracount = FALSE; |
reset_bracount = FALSE; |
| 4141 |
|
|
| 4142 |
/* First deal with various "verbs" that can be introduced by '*'. */ |
/* First deal with various "verbs" that can be introduced by '*'. */ |
| 4143 |
|
|
| 4144 |
if (*(++ptr) == '*' && (cd->ctypes[ptr[1]] & ctype_letter) != 0) |
if (*(++ptr) == '*' && (cd->ctypes[ptr[1]] & ctype_letter) != 0) |
| 4590 |
references (?P=name) and recursion (?P>name), as well as falling |
references (?P=name) and recursion (?P>name), as well as falling |
| 4591 |
through from the Perl recursion syntax (?&name). We also come here from |
through from the Perl recursion syntax (?&name). We also come here from |
| 4592 |
the Perl \k<name> or \k'name' back reference syntax and the \k{name} |
the Perl \k<name> or \k'name' back reference syntax and the \k{name} |
| 4593 |
.NET syntax. */ |
.NET syntax, and the Oniguruma \g<...> and \g'...' subroutine syntax. */ |
| 4594 |
|
|
| 4595 |
NAMED_REF_OR_RECURSE: |
NAMED_REF_OR_RECURSE: |
| 4596 |
name = ++ptr; |
name = ++ptr; |
| 4668 |
case '5': case '6': case '7': case '8': case '9': /* subroutine */ |
case '5': case '6': case '7': case '8': case '9': /* subroutine */ |
| 4669 |
{ |
{ |
| 4670 |
const uschar *called; |
const uschar *called; |
| 4671 |
|
terminator = ')'; |
| 4672 |
|
|
| 4673 |
|
/* Come here from the \g<...> and \g'...' code (Oniguruma |
| 4674 |
|
compatibility). However, the syntax has been checked to ensure that |
| 4675 |
|
the ... are a (signed) number, so that neither ERR63 nor ERR29 will |
| 4676 |
|
be called on this path, nor with the jump to OTHER_CHAR_AFTER_QUERY |
| 4677 |
|
ever be taken. */ |
| 4678 |
|
|
| 4679 |
|
HANDLE_NUMERICAL_RECURSION: |
| 4680 |
|
|
| 4681 |
if ((refsign = *ptr) == '+') |
if ((refsign = *ptr) == '+') |
| 4682 |
{ |
{ |
| 4698 |
while((digitab[*ptr] & ctype_digit) != 0) |
while((digitab[*ptr] & ctype_digit) != 0) |
| 4699 |
recno = recno * 10 + *ptr++ - '0'; |
recno = recno * 10 + *ptr++ - '0'; |
| 4700 |
|
|
| 4701 |
if (*ptr != ')') |
if (*ptr != terminator) |
| 4702 |
{ |
{ |
| 4703 |
*errorcodeptr = ERR29; |
*errorcodeptr = ERR29; |
| 4704 |
goto FAILED; |
goto FAILED; |
| 5094 |
back references and those types that consume a character may be repeated. |
back references and those types that consume a character may be repeated. |
| 5095 |
We can test for values between ESC_b and ESC_Z for the latter; this may |
We can test for values between ESC_b and ESC_Z for the latter; this may |
| 5096 |
have to change if any new ones are ever created. */ |
have to change if any new ones are ever created. */ |
| 5097 |
|
|
| 5098 |
case '\\': |
case '\\': |
| 5099 |
tempptr = ptr; |
tempptr = ptr; |
| 5100 |
c = check_escape(&ptr, errorcodeptr, cd->bracount, options, FALSE); |
c = check_escape(&ptr, errorcodeptr, cd->bracount, options, FALSE); |
| 5121 |
|
|
| 5122 |
zerofirstbyte = firstbyte; |
zerofirstbyte = firstbyte; |
| 5123 |
zeroreqbyte = reqbyte; |
zeroreqbyte = reqbyte; |
| 5124 |
|
|
| 5125 |
|
/* \g<name> or \g'name' is a subroutine call by name and \g<n> or \g'n' |
| 5126 |
|
is a subroutine call by number (Oniguruma syntax). In fact, the value |
| 5127 |
|
-ESC_g is returned only for these cases. So we don't need to check for < |
| 5128 |
|
or ' if the value is -ESC_g. For the Perl syntax \g{n} the value is |
| 5129 |
|
-ESC_REF+n, and for the Perl syntax \g{name} the result is -ESC_k (as |
| 5130 |
|
that is a synonym for a named back reference). */ |
| 5131 |
|
|
| 5132 |
|
if (-c == ESC_g) |
| 5133 |
|
{ |
| 5134 |
|
const uschar *p; |
| 5135 |
|
save_hwm = cd->hwm; /* Normally this is set when '(' is read */ |
| 5136 |
|
terminator = (*(++ptr) == '<')? '>' : '\''; |
| 5137 |
|
|
| 5138 |
|
/* These two statements stop the compiler for warning about possibly |
| 5139 |
|
unset variables caused by the jump to HANDLE_NUMERICAL_RECURSION. In |
| 5140 |
|
fact, because we actually check for a number below, the paths that |
| 5141 |
|
would actually be in error are never taken. */ |
| 5142 |
|
|
| 5143 |
|
skipbytes = 0; |
| 5144 |
|
reset_bracount = FALSE; |
| 5145 |
|
|
| 5146 |
|
/* Test for a name */ |
| 5147 |
|
|
| 5148 |
|
if (ptr[1] != '+' && ptr[1] != '-') |
| 5149 |
|
{ |
| 5150 |
|
BOOL isnumber = TRUE; |
| 5151 |
|
for (p = ptr + 1; *p != 0 && *p != terminator; p++) |
| 5152 |
|
{ |
| 5153 |
|
if ((cd->ctypes[*p] & ctype_digit) == 0) isnumber = FALSE; |
| 5154 |
|
if ((cd->ctypes[*p] & ctype_word) == 0) break; |
| 5155 |
|
} |
| 5156 |
|
if (*p != terminator) |
| 5157 |
|
{ |
| 5158 |
|
*errorcodeptr = ERR57; |
| 5159 |
|
break; |
| 5160 |
|
} |
| 5161 |
|
if (isnumber) |
| 5162 |
|
{ |
| 5163 |
|
ptr++; |
| 5164 |
|
goto HANDLE_NUMERICAL_RECURSION; |
| 5165 |
|
} |
| 5166 |
|
is_recurse = TRUE; |
| 5167 |
|
goto NAMED_REF_OR_RECURSE; |
| 5168 |
|
} |
| 5169 |
|
|
| 5170 |
|
/* Test a signed number in angle brackets or quotes. */ |
| 5171 |
|
|
| 5172 |
|
p = ptr + 2; |
| 5173 |
|
while ((digitab[*p] & ctype_digit) != 0) p++; |
| 5174 |
|
if (*p != terminator) |
| 5175 |
|
{ |
| 5176 |
|
*errorcodeptr = ERR57; |
| 5177 |
|
break; |
| 5178 |
|
} |
| 5179 |
|
ptr++; |
| 5180 |
|
goto HANDLE_NUMERICAL_RECURSION; |
| 5181 |
|
} |
| 5182 |
|
|
| 5183 |
/* \k<name> or \k'name' is a back reference by name (Perl syntax). |
/* \k<name> or \k'name' is a back reference by name (Perl syntax). |
| 5184 |
We also support \k{name} (.NET syntax) */ |
We also support \k{name} (.NET syntax) */ |