| 374 |
/* Definition to allow mutual recursion */ |
/* Definition to allow mutual recursion */ |
| 375 |
|
|
| 376 |
static BOOL |
static BOOL |
| 377 |
compile_regex(int, int, uschar **, const uschar **, int *, BOOL, int, int *, |
compile_regex(int, int, uschar **, const uschar **, int *, BOOL, BOOL, int, |
| 378 |
int *, branch_chain *, compile_data *, int *); |
int *, int *, branch_chain *, compile_data *, int *); |
| 379 |
|
|
| 380 |
|
|
| 381 |
|
|
| 2110 |
BOOL possessive_quantifier; |
BOOL possessive_quantifier; |
| 2111 |
BOOL is_quantifier; |
BOOL is_quantifier; |
| 2112 |
BOOL is_recurse; |
BOOL is_recurse; |
| 2113 |
|
BOOL reset_bracount; |
| 2114 |
int class_charcount; |
int class_charcount; |
| 2115 |
int class_lastchar; |
int class_lastchar; |
| 2116 |
int newoptions; |
int newoptions; |
| 3585 |
skipbytes = 0; |
skipbytes = 0; |
| 3586 |
bravalue = OP_CBRA; |
bravalue = OP_CBRA; |
| 3587 |
save_hwm = cd->hwm; |
save_hwm = cd->hwm; |
| 3588 |
|
reset_bracount = FALSE; |
| 3589 |
|
|
| 3590 |
if (*(++ptr) == '?') |
if (*(++ptr) == '?') |
| 3591 |
{ |
{ |
| 3608 |
|
|
| 3609 |
|
|
| 3610 |
/* ------------------------------------------------------------ */ |
/* ------------------------------------------------------------ */ |
| 3611 |
|
case '|': /* Reset capture count for each branch */ |
| 3612 |
|
reset_bracount = TRUE; |
| 3613 |
|
/* Fall through */ |
| 3614 |
|
|
| 3615 |
|
/* ------------------------------------------------------------ */ |
| 3616 |
case ':': /* Non-capturing bracket */ |
case ':': /* Non-capturing bracket */ |
| 3617 |
bravalue = OP_BRA; |
bravalue = OP_BRA; |
| 3618 |
ptr++; |
ptr++; |
| 4311 |
errorcodeptr, /* Where to put an error message */ |
errorcodeptr, /* Where to put an error message */ |
| 4312 |
(bravalue == OP_ASSERTBACK || |
(bravalue == OP_ASSERTBACK || |
| 4313 |
bravalue == OP_ASSERTBACK_NOT), /* TRUE if back assert */ |
bravalue == OP_ASSERTBACK_NOT), /* TRUE if back assert */ |
| 4314 |
|
reset_bracount, /* True if (?| group */ |
| 4315 |
skipbytes, /* Skip over bracket number */ |
skipbytes, /* Skip over bracket number */ |
| 4316 |
&subfirstbyte, /* For possible first char */ |
&subfirstbyte, /* For possible first char */ |
| 4317 |
&subreqbyte, /* For possible last char */ |
&subreqbyte, /* For possible last char */ |
| 4671 |
ptrptr -> the address of the current pattern pointer |
ptrptr -> the address of the current pattern pointer |
| 4672 |
errorcodeptr -> pointer to error code variable |
errorcodeptr -> pointer to error code variable |
| 4673 |
lookbehind TRUE if this is a lookbehind assertion |
lookbehind TRUE if this is a lookbehind assertion |
| 4674 |
|
reset_bracount TRUE to reset the count for each branch |
| 4675 |
skipbytes skip this many bytes at start (for brackets and OP_COND) |
skipbytes skip this many bytes at start (for brackets and OP_COND) |
| 4676 |
firstbyteptr place to put the first required character, or a negative number |
firstbyteptr place to put the first required character, or a negative number |
| 4677 |
reqbyteptr place to put the last required character, or a negative number |
reqbyteptr place to put the last required character, or a negative number |
| 4685 |
|
|
| 4686 |
static BOOL |
static BOOL |
| 4687 |
compile_regex(int options, int oldims, uschar **codeptr, const uschar **ptrptr, |
compile_regex(int options, int oldims, uschar **codeptr, const uschar **ptrptr, |
| 4688 |
int *errorcodeptr, BOOL lookbehind, int skipbytes, int *firstbyteptr, |
int *errorcodeptr, BOOL lookbehind, BOOL reset_bracount, int skipbytes, |
| 4689 |
int *reqbyteptr, branch_chain *bcptr, compile_data *cd, int *lengthptr) |
int *firstbyteptr, int *reqbyteptr, branch_chain *bcptr, compile_data *cd, |
| 4690 |
|
int *lengthptr) |
| 4691 |
{ |
{ |
| 4692 |
const uschar *ptr = *ptrptr; |
const uschar *ptr = *ptrptr; |
| 4693 |
uschar *code = *codeptr; |
uschar *code = *codeptr; |
| 4697 |
int firstbyte, reqbyte; |
int firstbyte, reqbyte; |
| 4698 |
int branchfirstbyte, branchreqbyte; |
int branchfirstbyte, branchreqbyte; |
| 4699 |
int length; |
int length; |
| 4700 |
|
int orig_bracount; |
| 4701 |
|
int max_bracount; |
| 4702 |
branch_chain bc; |
branch_chain bc; |
| 4703 |
|
|
| 4704 |
bc.outer = bcptr; |
bc.outer = bcptr; |
| 4727 |
|
|
| 4728 |
/* Loop for each alternative branch */ |
/* Loop for each alternative branch */ |
| 4729 |
|
|
| 4730 |
|
orig_bracount = max_bracount = cd->bracount; |
| 4731 |
for (;;) |
for (;;) |
| 4732 |
{ |
{ |
| 4733 |
|
/* For a (?| group, reset the capturing bracket count so that each branch |
| 4734 |
|
uses the same numbers. */ |
| 4735 |
|
|
| 4736 |
|
if (reset_bracount) cd->bracount = orig_bracount; |
| 4737 |
|
|
| 4738 |
/* Handle a change of ims options at the start of the branch */ |
/* Handle a change of ims options at the start of the branch */ |
| 4739 |
|
|
| 4740 |
if ((options & PCRE_IMS) != oldims) |
if ((options & PCRE_IMS) != oldims) |
| 4763 |
*ptrptr = ptr; |
*ptrptr = ptr; |
| 4764 |
return FALSE; |
return FALSE; |
| 4765 |
} |
} |
| 4766 |
|
|
| 4767 |
|
/* Keep the highest bracket count in case (?| was used and some branch |
| 4768 |
|
has fewer than the rest. */ |
| 4769 |
|
|
| 4770 |
|
if (cd->bracount > max_bracount) max_bracount = cd->bracount; |
| 4771 |
|
|
| 4772 |
/* In the real compile phase, there is some post-processing to be done. */ |
/* In the real compile phase, there is some post-processing to be done. */ |
| 4773 |
|
|
| 4870 |
*code++ = oldims; |
*code++ = oldims; |
| 4871 |
length += 2; |
length += 2; |
| 4872 |
} |
} |
| 4873 |
|
|
| 4874 |
|
/* Retain the highest bracket number, in case resetting was used. */ |
| 4875 |
|
|
| 4876 |
|
cd->bracount = max_bracount; |
| 4877 |
|
|
| 4878 |
/* Set values to pass back */ |
/* Set values to pass back */ |
| 4879 |
|
|
| 5349 |
code = cworkspace; |
code = cworkspace; |
| 5350 |
*code = OP_BRA; |
*code = OP_BRA; |
| 5351 |
(void)compile_regex(cd->external_options, cd->external_options & PCRE_IMS, |
(void)compile_regex(cd->external_options, cd->external_options & PCRE_IMS, |
| 5352 |
&code, &ptr, &errorcode, FALSE, 0, &firstbyte, &reqbyte, NULL, cd, &length); |
&code, &ptr, &errorcode, FALSE, FALSE, 0, &firstbyte, &reqbyte, NULL, cd, |
| 5353 |
|
&length); |
| 5354 |
if (errorcode != 0) goto PCRE_EARLY_ERROR_RETURN; |
if (errorcode != 0) goto PCRE_EARLY_ERROR_RETURN; |
| 5355 |
|
|
| 5356 |
DPRINTF(("end pre-compile: length=%d workspace=%d\n", length, |
DPRINTF(("end pre-compile: length=%d workspace=%d\n", length, |
| 5418 |
code = (uschar *)codestart; |
code = (uschar *)codestart; |
| 5419 |
*code = OP_BRA; |
*code = OP_BRA; |
| 5420 |
(void)compile_regex(re->options, re->options & PCRE_IMS, &code, &ptr, |
(void)compile_regex(re->options, re->options & PCRE_IMS, &code, &ptr, |
| 5421 |
&errorcode, FALSE, 0, &firstbyte, &reqbyte, NULL, cd, NULL); |
&errorcode, FALSE, FALSE, 0, &firstbyte, &reqbyte, NULL, cd, NULL); |
| 5422 |
re->top_bracket = cd->bracount; |
re->top_bracket = cd->bracount; |
| 5423 |
re->top_backref = cd->top_backref; |
re->top_backref = cd->top_backref; |
| 5424 |
|
|