52 #define SET_BIT(c) start_bits[c/8] |= (1 << (c&7))
80 find_minlength(
const uschar *code,
const uschar *startcode,
int options)
85 register int branchlength = 0;
97 register int op = *cc;
108 cs = cc + GET(cc, 1);
123 d = find_minlength(cc, startcode, options);
126 do cc += GET(cc, 1);
while (*cc ==
OP_ALT);
139 if (length < 0 || (!had_recurse && branchlength < length))
140 length = branchlength;
141 if (*cc !=
OP_ALT)
return length;
153 do cc += GET(cc, 1);
while (*cc ==
OP_ALT);
183 do cc += GET(cc, 1);
while (*cc ==
OP_ALT);
217 branchlength +=
GET2(cc,1);
225 branchlength +=
GET2(cc,1);
294 cc += GET(cc, 1) - 33;
318 branchlength +=
GET2(cc,1);
344 if (cs == NULL)
return -2;
345 do ce += GET(ce, 1);
while (*ce ==
OP_ALT);
346 if (cc > cs && cc < ce)
351 else d = find_minlength(cs, startcode, options);
379 branchlength += min * d;
383 cs = ce = (
uschar *)startcode + GET(cc, 1);
384 if (cs == NULL)
return -2;
385 do ce += GET(ce, 1);
while (*ce ==
OP_ALT);
386 if (cc > cs && cc < ce)
389 branchlength += find_minlength(cs, startcode, options);
517 set_type_bits(
uschar *start_bits,
int cbit_type,
int table_limit,
521 for (c = 0; c < table_limit; c++) start_bits[c] |= cd->
cbits[c+cbit_type];
522 if (table_limit == 32)
return;
523 for (c = 128; c < 256; c++)
525 if ((cd->
cbits[c/8] & (1 << (c&7))) != 0)
557 set_nottype_bits(
uschar *start_bits,
int cbit_type,
int table_limit,
561 for (c = 0; c < table_limit; c++) start_bits[c] |= ~cd->
cbits[c+cbit_type];
562 if (table_limit != 32)
for (c = 24; c < 32; c++) start_bits[c] = 0xff;
597 int table_limit = utf8? 16:32;
642 rc = set_start_bits(tcode, start_bits, caseless, utf8, cd);
646 do tcode += GET(tcode, 1);
while (*tcode ==
OP_ALT);
679 do tcode += GET(tcode, 1);
while (*tcode ==
OP_ALT);
694 if (set_start_bits(++tcode, start_bits, caseless, utf8, cd) ==
SSB_FAIL)
701 do tcode += GET(tcode,1);
while (*tcode ==
OP_ALT);
709 do tcode += GET(tcode,1);
while (*tcode ==
OP_ALT);
721 tcode = set_table_bit(start_bits, tcode + 1, caseless, cd, utf8);
729 tcode = set_table_bit(start_bits, tcode + 3, caseless, cd, utf8);
742 (void)set_table_bit(start_bits, tcode + 1, caseless, cd, utf8);
787 set_nottype_bits(start_bits,
cbit_digit, table_limit, cd);
792 set_type_bits(start_bits,
cbit_digit, table_limit, cd);
800 set_nottype_bits(start_bits,
cbit_space, table_limit, cd);
801 start_bits[1] |= 0x08;
810 set_type_bits(start_bits,
cbit_space, table_limit, cd);
811 start_bits[1] = (start_bits[1] & ~0x08) | c;
816 set_nottype_bits(start_bits,
cbit_word, table_limit, cd);
821 set_type_bits(start_bits,
cbit_word, table_limit, cd);
887 set_nottype_bits(start_bits,
cbit_digit, table_limit, cd);
891 set_type_bits(start_bits,
cbit_digit, table_limit, cd);
898 set_nottype_bits(start_bits,
cbit_space, table_limit, cd);
899 start_bits[1] |= 0x08;
907 set_type_bits(start_bits,
cbit_space, table_limit, cd);
908 start_bits[1] = (start_bits[1] & ~0x08) | c;
912 set_nottype_bits(start_bits,
cbit_word, table_limit, cd);
916 set_type_bits(start_bits,
cbit_word, table_limit, cd);
933 start_bits[24] |= 0xf0;
934 memset(start_bits+25, 0xff, 7);
952 for (c = 0; c < 16; c++) start_bits[c] |= tcode[c];
953 for (c = 128; c < 256; c++)
955 if ((tcode[c/8] && (1 << (c&7))) != 0)
957 int d = (c >> 6) | 0xc0;
958 start_bits[d/8] |= (1 << (d&7));
959 c = (c & 0xc0) + 0x40 - 1;
969 for (c = 0; c < 32; c++) start_bits[c] |= tcode[c];
986 if (((tcode[1] << 8) + tcode[2]) == 0) tcode += 5;
987 else try_next =
FALSE;
1000 code += GET(code, 1);
1044 *errorptr =
"argument is not a compiled regular expression";
1050 *errorptr =
"unknown or incorrect option bit(s) set";
1078 memset(start_bits, 0, 32 *
sizeof(
uschar));
1079 bits_set = set_start_bits(code, start_bits,
1086 min = find_minlength(code, code, re->
options);
1090 if (!bits_set && min < 0)
return NULL;
1104 *errorptr =
"failed to get memory";
1118 memcpy(study->
start_bits, start_bits,
sizeof(start_bits));