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0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
154 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
155 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
156 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1 },
157 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1 },
158 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 }
172static const uint8_t posspropstab[3][4] = {
181#ifdef SUPPORT_UNICODE
199check_char_prop(uint32_t c,
unsigned int ptype,
unsigned int pdata,
214 return (pdata ==
PRIV(ucp_gentype)[prop->
chartype]) == negated;
217 return (pdata == prop->
chartype) == negated;
220 return (pdata == prop->
script) == negated;
223 ok = (pdata == prop->
script
225 return ok == negated;
259 if (c < *
p)
return !negated;
260 if (c == *
p++)
return negated;
333#ifdef SUPPORT_UNICODE
335const uint32_t *clist_src;
347 base = get_repeat_base(c);
417#ifdef SUPPORT_UNICODE
418 if (
chr < 128 || (
chr < 256 && !utf && !ucp))
422#elif defined SUPPORT_WIDE_CHARS
436#ifdef SUPPORT_UNICODE
448 clist_src =
PRIV(ucd_caseless_sets) + code[1];
449 clist_dest = list + 2;
453 if (clist_dest >= list + 8)
461 *clist_dest++ = *clist_src;
474#ifdef SUPPORT_WIDE_CHARS
477 end = code +
GET(code, 0) - 1;
507 list[2] = (uint32_t)(
end - code);
537 const uint32_t *base_list,
PCRE2_SPTR base_end,
int *rec_limit)
541const uint32_t *chr_ptr;
542const uint32_t *ochr_ptr;
543const uint32_t *list_ptr;
545#ifdef SUPPORT_WIDE_CHARS
548const uint8_t *class_bitset;
549const uint8_t *set1, *set2, *set_end;
551BOOL accepted, invert_bits;
554if (--(*rec_limit) <= 0)
return FALSE;
588 do code +=
GET(code, 1);
while (*code ==
OP_ALT);
601 return base_list[1] != 0;
615 if (base_list[1] == 0)
return FALSE;
622 bracode = code -
GET(code, 1);
629 if (
cb->had_recurse)
return FALSE;
649 return !entered_a_group;
673 next_code = code +
GET(code, 1);
679 while (*next_code ==
OP_ALT)
681 if (!compare_opcodes(code, utf, ucp,
cb, base_list, base_end, rec_limit))
684 next_code +=
GET(next_code, 1);
687 entered_a_group =
TRUE;
693 next_code = code + 1;
697 do next_code +=
GET(next_code, 1);
while (*next_code ==
OP_ALT);
702 if (!compare_opcodes(next_code, utf, ucp,
cb, base_list, base_end,
719 code = get_chr_property_list(code, utf, ucp,
cb->fcc, list);
727 chr_ptr = base_list + 2;
733 list_ptr = base_list;
739#
if PCRE2_CODE_UNIT_WIDTH == 8
745#if PCRE2_CODE_UNIT_WIDTH == 8
751 set1 = (uint8_t *)(base_end - base_list[2]);
756 set1 = (uint8_t *)(code - list[2]);
757 list_ptr = base_list;
766 ((list_ptr == list ? code : base_end) - list_ptr[2]);
769#ifdef SUPPORT_WIDE_CHARS
771 xclass_flags = (list_ptr == list ? code : base_end) - list_ptr[2] +
LINK_SIZE;
773 if ((*xclass_flags &
XCL_MAP) == 0)
776 if (list[1] == 0)
return (*xclass_flags &
XCL_NOT) == 0;
780 set2 = (uint8_t *)(xclass_flags + 1);
817 if ((*set1++ & ~(*set2++)) != 0)
return FALSE;
819 while (set1 < set_end);
825 if ((*set1++ & *set2++) != 0)
return FALSE;
827 while (set1 < set_end);
830 if (list[1] == 0)
return TRUE;
840 uint32_t leftop, rightop;
842 leftop = base_list[0];
845#ifdef SUPPORT_UNICODE
855 BOOL same = leftop == rightop;
858 BOOL bothprop = lisprop && risprop;
869 n = propposstab[base_list[2]][list[2]];
873 case 1: accepted = bothprop;
break;
874 case 2: accepted = (base_list[3] == list[3]) != same;
break;
875 case 3: accepted = !same;
break;
878 accepted = risprop && catposstab[base_list[3]][list[3]] == same;
882 accepted = lisprop && catposstab[list[3]][base_list[3]] == same;
907 p = posspropstab[
n-6];
908 accepted = risprop && lisprop ==
911 (list[3] !=
p[2] || !lisprop));
917 p = posspropstab[
n-9];
918 accepted = lisprop && risprop ==
919 (base_list[3] !=
p[0] &&
920 base_list[3] !=
p[1] &&
921 (base_list[3] !=
p[2] || !risprop));
927 p = posspropstab[
n-12];
928 accepted = risprop && lisprop ==
929 (catposstab[
p[0]][list[3]] &&
930 catposstab[
p[1]][list[3]] &&
931 (list[3] !=
p[3] || !lisprop));
937 p = posspropstab[
n-15];
938 accepted = lisprop && risprop ==
939 (catposstab[
p[0]][base_list[3]] &&
940 catposstab[
p[1]][base_list[3]] &&
941 (base_list[3] !=
p[3] || !risprop));
954 if (!accepted)
return FALSE;
956 if (list[1] == 0)
return TRUE;
971 ochr_ptr = list_ptr + 2;
981 ochr_ptr = list_ptr + 2;
984 if (
chr == *ochr_ptr)
1031 default:
return FALSE;
1048 default:
return FALSE;
1072#ifdef SUPPORT_UNICODE
1075 if (!check_char_prop(
chr, list_ptr[2], list_ptr[3],
1086 if (
chr > 255)
break;
1087 class_bitset = (uint8_t *)
1088 ((list_ptr == list ? code : base_end) - list_ptr[2]);
1089 if ((class_bitset[
chr >> 3] & (1u << (
chr & 7))) != 0)
return FALSE;
1092#ifdef SUPPORT_WIDE_CHARS
1094 if (
PRIV(
xclass)(
chr, (list_ptr == list ? code : base_end) -
1109 if (list[1] == 0)
return TRUE;
1144int rec_limit = 1000;
1156 c -= get_repeat_base(c) -
OP_STAR;
1158 get_chr_property_list(code, utf, ucp,
cb->fcc, list) :
NULL;
1203#ifdef SUPPORT_WIDE_CHARS
1205 repeat_opcode = code +
GET(code, 1);
1208 repeat_opcode = code + 1 + (32 /
sizeof(
PCRE2_UCHAR));
1218 end = get_chr_property_list(code, utf, ucp,
cb->fcc, list);
1219 list[1] = (c & 1) == 0;
1222 compare_opcodes(
end, utf, ucp,
cb, list,
end, &rec_limit))
1280#ifdef SUPPORT_WIDE_CHARS
1282 code +=
GET(code, 1);
1303#ifdef MAYBE_UTF_MULTI
1362 if (HAS_EXTRALEN(code[-1])) code += GET_EXTRALEN(code[-1]);
int PRIV auto_possessify(PCRE2_UCHAR *code, const compile_block *cb)
#define LAST_AUTOTAB_LEFT_OP
#define LAST_AUTOTAB_RIGHT_OP
#define UCD_OTHERCASE(ch)
#define UCD_SCRIPTX_PROP(prop)
#define GETCHARINCTEST(c, eptr)
BOOL PRIV xclass(uint32_t c, PCRE2_SPTR data, BOOL utf)
unsigned const char * end
ZEND_API void(ZEND_FASTCALL *zend_touch_vm_stack_data)(void *vm_stack_data)