| 78 |
*/ |
*/ |
| 79 |
|
|
| 80 |
static int |
static int |
| 81 |
find_minlength(const uschar *code, const uschar *startcode, int options, |
find_minlength(const pcre_uchar *code, const pcre_uchar *startcode, int options, |
| 82 |
int recurse_depth) |
int recurse_depth) |
| 83 |
{ |
{ |
| 84 |
int length = -1; |
int length = -1; |
| 85 |
BOOL utf8 = (options & PCRE_UTF8) != 0; |
BOOL utf8 = (options & PCRE_UTF8) != 0; |
| 86 |
BOOL had_recurse = FALSE; |
BOOL had_recurse = FALSE; |
| 87 |
register int branchlength = 0; |
register int branchlength = 0; |
| 88 |
register uschar *cc = (uschar *)code + 1 + LINK_SIZE; |
register pcre_uchar *cc = (pcre_uchar *)code + 1 + LINK_SIZE; |
| 89 |
|
|
| 90 |
if (*code == OP_CBRA || *code == OP_SCBRA || |
if (*code == OP_CBRA || *code == OP_SCBRA || |
| 91 |
*code == OP_CBRAPOS || *code == OP_SCBRAPOS) cc += 2; |
*code == OP_CBRAPOS || *code == OP_SCBRAPOS) cc += 2; |
| 96 |
for (;;) |
for (;;) |
| 97 |
{ |
{ |
| 98 |
int d, min; |
int d, min; |
| 99 |
uschar *cs, *ce; |
pcre_uchar *cs, *ce; |
| 100 |
register int op = *cc; |
register int op = *cc; |
| 101 |
|
|
| 102 |
switch (op) |
switch (op) |
| 372 |
case OP_REFI: |
case OP_REFI: |
| 373 |
if ((options & PCRE_JAVASCRIPT_COMPAT) == 0) |
if ((options & PCRE_JAVASCRIPT_COMPAT) == 0) |
| 374 |
{ |
{ |
| 375 |
ce = cs = (uschar *)_pcre_find_bracket(startcode, utf8, GET2(cc, 1)); |
ce = cs = (pcre_uchar *)_pcre_find_bracket(startcode, utf8, GET2(cc, 1)); |
| 376 |
if (cs == NULL) return -2; |
if (cs == NULL) return -2; |
| 377 |
do ce += GET(ce, 1); while (*ce == OP_ALT); |
do ce += GET(ce, 1); while (*ce == OP_ALT); |
| 378 |
if (cc > cs && cc < ce) |
if (cc > cs && cc < ce) |
| 424 |
caught by a recursion depth count. */ |
caught by a recursion depth count. */ |
| 425 |
|
|
| 426 |
case OP_RECURSE: |
case OP_RECURSE: |
| 427 |
cs = ce = (uschar *)startcode + GET(cc, 1); |
cs = ce = (pcre_uchar *)startcode + GET(cc, 1); |
| 428 |
do ce += GET(ce, 1); while (*ce == OP_ALT); |
do ce += GET(ce, 1); while (*ce == OP_ALT); |
| 429 |
if ((cc > cs && cc < ce) || recurse_depth > 10) |
if ((cc > cs && cc < ce) || recurse_depth > 10) |
| 430 |
had_recurse = TRUE; |
had_recurse = TRUE; |
| 540 |
Returns: pointer after the character |
Returns: pointer after the character |
| 541 |
*/ |
*/ |
| 542 |
|
|
| 543 |
static const uschar * |
static const pcre_uchar * |
| 544 |
set_table_bit(uschar *start_bits, const uschar *p, BOOL caseless, |
set_table_bit(pcre_uint8 *start_bits, const pcre_uchar *p, BOOL caseless, |
| 545 |
compile_data *cd, BOOL utf8) |
compile_data *cd, BOOL utf8) |
| 546 |
{ |
{ |
| 547 |
unsigned int c = *p; |
unsigned int c = *p; |
| 555 |
#ifdef SUPPORT_UCP |
#ifdef SUPPORT_UCP |
| 556 |
if (caseless) |
if (caseless) |
| 557 |
{ |
{ |
| 558 |
uschar buff[8]; |
pcre_uint8 buff[8]; |
| 559 |
c = UCD_OTHERCASE(c); |
c = UCD_OTHERCASE(c); |
| 560 |
(void)_pcre_ord2utf8(c, buff); |
(void)_pcre_ord2utf8(c, buff); |
| 561 |
SET_BIT(buff[0]); |
SET_BIT(buff[0]); |
| 594 |
*/ |
*/ |
| 595 |
|
|
| 596 |
static void |
static void |
| 597 |
set_type_bits(uschar *start_bits, int cbit_type, int table_limit, |
set_type_bits(pcre_uint8 *start_bits, int cbit_type, int table_limit, |
| 598 |
compile_data *cd) |
compile_data *cd) |
| 599 |
{ |
{ |
| 600 |
register int c; |
register int c; |
| 604 |
{ |
{ |
| 605 |
if ((cd->cbits[c/8] & (1 << (c&7))) != 0) |
if ((cd->cbits[c/8] & (1 << (c&7))) != 0) |
| 606 |
{ |
{ |
| 607 |
uschar buff[8]; |
pcre_uint8 buff[8]; |
| 608 |
(void)_pcre_ord2utf8(c, buff); |
(void)_pcre_ord2utf8(c, buff); |
| 609 |
SET_BIT(buff[0]); |
SET_BIT(buff[0]); |
| 610 |
} |
} |
| 634 |
*/ |
*/ |
| 635 |
|
|
| 636 |
static void |
static void |
| 637 |
set_nottype_bits(uschar *start_bits, int cbit_type, int table_limit, |
set_nottype_bits(pcre_uint8 *start_bits, int cbit_type, int table_limit, |
| 638 |
compile_data *cd) |
compile_data *cd) |
| 639 |
{ |
{ |
| 640 |
register int c; |
register int c; |
| 669 |
*/ |
*/ |
| 670 |
|
|
| 671 |
static int |
static int |
| 672 |
set_start_bits(const uschar *code, uschar *start_bits, BOOL utf8, |
set_start_bits(const pcre_uchar *code, pcre_uint8 *start_bits, BOOL utf8, |
| 673 |
compile_data *cd) |
compile_data *cd) |
| 674 |
{ |
{ |
| 675 |
register int c; |
register int c; |
| 696 |
do |
do |
| 697 |
{ |
{ |
| 698 |
BOOL try_next = TRUE; |
BOOL try_next = TRUE; |
| 699 |
const uschar *tcode = code + 1 + LINK_SIZE; |
const pcre_uchar *tcode = code + 1 + LINK_SIZE; |
| 700 |
|
|
| 701 |
if (*code == OP_CBRA || *code == OP_SCBRA || |
if (*code == OP_CBRA || *code == OP_SCBRA || |
| 702 |
*code == OP_CBRAPOS || *code == OP_SCBRAPOS) tcode += 2; |
*code == OP_CBRAPOS || *code == OP_SCBRAPOS) tcode += 2; |
| 1224 |
{ |
{ |
| 1225 |
int min; |
int min; |
| 1226 |
BOOL bits_set = FALSE; |
BOOL bits_set = FALSE; |
| 1227 |
uschar start_bits[32]; |
pcre_uint8 start_bits[32]; |
| 1228 |
pcre_extra *extra = NULL; |
pcre_extra *extra = NULL; |
| 1229 |
pcre_study_data *study; |
pcre_study_data *study; |
| 1230 |
const uschar *tables; |
const pcre_uint8 *tables; |
| 1231 |
uschar *code; |
pcre_uchar *code; |
| 1232 |
compile_data compile_block; |
compile_data compile_block; |
| 1233 |
const real_pcre *re = (const real_pcre *)external_re; |
const real_pcre *re = (const real_pcre *)external_re; |
| 1234 |
|
|
| 1246 |
return NULL; |
return NULL; |
| 1247 |
} |
} |
| 1248 |
|
|
| 1249 |
code = (uschar *)re + re->name_table_offset + |
code = (pcre_uchar *)re + re->name_table_offset + |
| 1250 |
(re->name_count * re->name_entry_size); |
(re->name_count * re->name_entry_size); |
| 1251 |
|
|
| 1252 |
/* For an anchored pattern, or an unanchored pattern that has a first char, or |
/* For an anchored pattern, or an unanchored pattern that has a first char, or |
| 1272 |
|
|
| 1273 |
/* See if we can find a fixed set of initial characters for the pattern. */ |
/* See if we can find a fixed set of initial characters for the pattern. */ |
| 1274 |
|
|
| 1275 |
memset(start_bits, 0, 32 * sizeof(uschar)); |
memset(start_bits, 0, 32 * sizeof(pcre_uint8)); |
| 1276 |
rc = set_start_bits(code, start_bits, (re->options & PCRE_UTF8) != 0, |
rc = set_start_bits(code, start_bits, (re->options & PCRE_UTF8) != 0, |
| 1277 |
&compile_block); |
&compile_block); |
| 1278 |
bits_set = rc == SSB_DONE; |
bits_set = rc == SSB_DONE; |