47#define PSSTART start_pattern
48#define PSEND end_pattern
56#define PRINTABLE(c) ((c) >= 64 && (c) < 255)
58#define PRINTABLE(c) ((c) >= 32 && (c) < 127)
61#define DEBUG_CALL_PRINTINT
72#if PCRE2_CODE_UNIT_WIDTH == 8
73#define STRING_UTFn_RIGHTPAR STRING_UTF8_RIGHTPAR, 5
74#define XDIGIT(c) xdigitab[c]
77#define XDIGIT(c) (MAX_255(c)? xdigitab[c] : 0xff)
79#if PCRE2_CODE_UNIT_WIDTH == 16
80#define STRING_UTFn_RIGHTPAR STRING_UTF16_RIGHTPAR, 6
83#define STRING_UTFn_RIGHTPAR STRING_UTF32_RIGHTPAR, 6
91#if PCRE2_SIZE_MAX <= UINT32_MAX
92#define PUTOFFSET(s,p) *p++ = s
93#define GETOFFSET(s,p) s = *p++
94#define GETPLUSOFFSET(s,p) s = *(++p)
95#define READPLUSOFFSET(s,p) s = p[1]
96#define SKIPOFFSET(p) p++
99#define PUTOFFSET(s,p) \
100 { *p++ = (uint32_t)(s >> 32); *p++ = (uint32_t)(s & 0xffffffff); }
101#define GETOFFSET(s,p) \
102 { s = ((PCRE2_SIZE)p[0] << 32) | (PCRE2_SIZE)p[1]; p += 2; }
103#define GETPLUSOFFSET(s,p) \
104 { s = ((PCRE2_SIZE)p[1] << 32) | (PCRE2_SIZE)p[2]; p += 2; }
105#define READPLUSOFFSET(s,p) \
106 { s = ((PCRE2_SIZE)p[1] << 32) | (PCRE2_SIZE)p[2]; }
107#define SKIPOFFSET(p) p += 2
113#define META_CODE(x) (x & 0xffff0000u)
114#define META_DATA(x) (x & 0x0000ffffu)
115#define META_DIFF(x,y) ((x-y)>>16)
119#ifdef SUPPORT_UNICODE
121 add_list_to_class_internal(uint8_t *,
PCRE2_UCHAR **, uint32_t, uint32_t,
126 compile_regex(uint32_t, uint32_t,
PCRE2_UCHAR **, uint32_t **,
int *,
127 uint32_t, uint32_t *, uint32_t *, uint32_t *, uint32_t *,
branch_chain *,
147#define MAX_GROUP_NUMBER 65535u
148#define MAX_REPEAT_COUNT 65535u
149#define REPEAT_UNLIMITED (MAX_REPEAT_COUNT+1)
166#define COMPILE_WORK_SIZE (3000*LINK_SIZE)
168#define C16_WORK_SIZE \
169 ((COMPILE_WORK_SIZE * sizeof(PCRE2_UCHAR))/sizeof(uint16_t))
175#define GROUPINFO_DEFAULT_SIZE 256
180#define WORK_SIZE_SAFETY_MARGIN (100)
187#define NAMED_GROUP_LIST_SIZE 20
193#define PARSED_PATTERN_DEFAULT_SIZE 1024
200#define OFLOW_MAX (INT_MAX - 20)
211#define META_END 0x80000000u
213#define META_ALT 0x80010000u
214#define META_ATOMIC 0x80020000u
215#define META_BACKREF 0x80030000u
216#define META_BACKREF_BYNAME 0x80040000u
217#define META_BIGVALUE 0x80050000u
218#define META_CALLOUT_NUMBER 0x80060000u
219#define META_CALLOUT_STRING 0x80070000u
220#define META_CAPTURE 0x80080000u
221#define META_CIRCUMFLEX 0x80090000u
222#define META_CLASS 0x800a0000u
223#define META_CLASS_EMPTY 0x800b0000u
224#define META_CLASS_EMPTY_NOT 0x800c0000u
225#define META_CLASS_END 0x800d0000u
226#define META_CLASS_NOT 0x800e0000u
227#define META_COND_ASSERT 0x800f0000u
228#define META_COND_DEFINE 0x80100000u
229#define META_COND_NAME 0x80110000u
230#define META_COND_NUMBER 0x80120000u
231#define META_COND_RNAME 0x80130000u
232#define META_COND_RNUMBER 0x80140000u
233#define META_COND_VERSION 0x80150000u
234#define META_DOLLAR 0x80160000u
235#define META_DOT 0x80170000u
236#define META_ESCAPE 0x80180000u
237#define META_KET 0x80190000u
238#define META_NOCAPTURE 0x801a0000u
239#define META_OPTIONS 0x801b0000u
240#define META_POSIX 0x801c0000u
241#define META_POSIX_NEG 0x801d0000u
242#define META_RANGE_ESCAPED 0x801e0000u
243#define META_RANGE_LITERAL 0x801f0000u
244#define META_RECURSE 0x80200000u
245#define META_RECURSE_BYNAME 0x80210000u
246#define META_SCRIPT_RUN 0x80220000u
251#define META_LOOKAHEAD 0x80230000u
252#define META_LOOKAHEADNOT 0x80240000u
253#define META_LOOKBEHIND 0x80250000u
254#define META_LOOKBEHINDNOT 0x80260000u
258#define META_LOOKAHEAD_NA 0x80270000u
259#define META_LOOKBEHIND_NA 0x80280000u
265#define META_MARK 0x80290000u
266#define META_ACCEPT 0x802a0000u
267#define META_FAIL 0x802b0000u
268#define META_COMMIT 0x802c0000u
269#define META_COMMIT_ARG 0x802d0000u
270#define META_PRUNE 0x802e0000u
271#define META_PRUNE_ARG 0x802f0000u
272#define META_SKIP 0x80300000u
273#define META_SKIP_ARG 0x80310000u
274#define META_THEN 0x80320000u
275#define META_THEN_ARG 0x80330000u
279#define META_ASTERISK 0x80340000u
280#define META_ASTERISK_PLUS 0x80350000u
281#define META_ASTERISK_QUERY 0x80360000u
282#define META_PLUS 0x80370000u
283#define META_PLUS_PLUS 0x80380000u
284#define META_PLUS_QUERY 0x80390000u
285#define META_QUERY 0x803a0000u
286#define META_QUERY_PLUS 0x803b0000u
287#define META_QUERY_QUERY 0x803c0000u
288#define META_MINMAX 0x803d0000u
289#define META_MINMAX_PLUS 0x803e0000u
290#define META_MINMAX_QUERY 0x803f0000u
292#define META_FIRST_QUANTIFIER META_ASTERISK
293#define META_LAST_QUANTIFIER META_MINMAX_QUERY
300#define META_ATOMIC_SCRIPT_RUN 0x8fff0000u
306static unsigned char meta_extra_lengths[] = {
386#define SETBIT(a,b) a[(b)/8] = (uint8_t)(a[(b)/8] | (1u << ((b)&7)))
393#define REQ_UNSET 0xffffffffu
394#define REQ_NONE 0xfffffffeu
395#define REQ_CASELESS 0x00000001u
396#define REQ_VARY 0x00000002u
400#define GI_SET_FIXED_LENGTH 0x80000000u
401#define GI_NOT_FIXED_LENGTH 0x40000000u
402#define GI_FIXED_LENGTH_MASK 0x0000ffffu
408#define IS_DIGIT(x) ((x) >= CHAR_0 && (x) <= CHAR_9)
422static const uint8_t xdigitab[] =
424 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
425 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
426 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
427 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
428 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
429 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
430 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
431 0x08,0x09,0xff,0xff,0xff,0xff,0xff,0xff,
432 0xff,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0xff,
433 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
434 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
435 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
436 0xff,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0xff,
437 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
438 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
439 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
440 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
441 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
442 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
443 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
444 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
445 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
446 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
447 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
448 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
449 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
450 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
451 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
452 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
453 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
454 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
455 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
461static const uint8_t xdigitab[] =
463 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
464 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
465 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
466 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
467 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
468 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
469 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
470 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
471 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
472 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
473 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
474 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
475 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
476 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
477 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
478 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
479 0xff,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0xff,
480 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
481 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
482 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
483 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
484 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
485 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
486 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
487 0xff,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0xff,
488 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
489 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
490 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
491 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
492 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
493 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
494 0x08,0x09,0xff,0xff,0xff,0xff,0xff,0xff};
507#define ESCAPES_FIRST CHAR_0
508#define ESCAPES_LAST CHAR_z
509#define UPPER_CASE(c) (c-32)
511static const short int escapes[] = {
560#define ESCAPES_FIRST CHAR_a
561#define ESCAPES_LAST CHAR_9
562#define UPPER_CASE(c) (c+64)
564#define ESCAPES_FIRST ((unsigned char)'\x81')
565#define ESCAPES_LAST ((unsigned char)'\xf9')
566#define UPPER_CASE(c) (c-32)
569static const short int escapes[] = {
571 -
ESC_h, 0, 0,
'{', 0, 0, 0, 0,
573 0,
CHAR_CR, 0,
'}', 0, 0, 0, 0,
575 0, -
ESC_z, 0, 0, 0,
'[', 0, 0,
576 0, 0, 0, 0, 0, 0, 0, 0,
577 0, 0, 0, 0, 0,
']',
'=',
'-',
579 -
ESC_H, 0, 0, 0, 0, 0, 0, 0,
583 0, -
ESC_Z, 0, 0, 0, 0, 0, 0,
584 0, 0, 0, 0, 0, 0, 0, 0,
591static unsigned char ebcdic_escape_c[] =
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_";
608static const char verbnames[] =
631static const int verbcount =
sizeof(verbs)/
sizeof(
verbitem);
635static const uint32_t verbops[] = {
646static const char alasnames[] =
685static const int alascount =
sizeof(alasmeta)/
sizeof(
alasitem);
689static uint32_t chartypeoffset[] = {
700static const char posix_names[] =
706static const uint8_t posix_name_lengths[] = {
707 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 6, 0 };
725static const int posix_class_maps[] = {
742#ifdef SUPPORT_UNICODE
747static int posix_substitutes[] = {
763#define POSIX_SUBSIZE (sizeof(posix_substitutes) / (2*sizeof(uint32_t)))
769#define PUBLIC_LITERAL_COMPILE_OPTIONS \
770 (PCRE2_ANCHORED|PCRE2_AUTO_CALLOUT|PCRE2_CASELESS|PCRE2_ENDANCHORED| \
771 PCRE2_FIRSTLINE|PCRE2_LITERAL|PCRE2_MATCH_INVALID_UTF| \
772 PCRE2_NO_START_OPTIMIZE|PCRE2_NO_UTF_CHECK|PCRE2_USE_OFFSET_LIMIT|PCRE2_UTF)
774#define PUBLIC_COMPILE_OPTIONS \
775 (PUBLIC_LITERAL_COMPILE_OPTIONS| \
776 PCRE2_ALLOW_EMPTY_CLASS|PCRE2_ALT_BSUX|PCRE2_ALT_CIRCUMFLEX| \
777 PCRE2_ALT_VERBNAMES|PCRE2_DOLLAR_ENDONLY|PCRE2_DOTALL|PCRE2_DUPNAMES| \
778 PCRE2_EXTENDED|PCRE2_EXTENDED_MORE|PCRE2_MATCH_UNSET_BACKREF| \
779 PCRE2_MULTILINE|PCRE2_NEVER_BACKSLASH_C|PCRE2_NEVER_UCP| \
780 PCRE2_NEVER_UTF|PCRE2_NO_AUTO_CAPTURE|PCRE2_NO_AUTO_POSSESS| \
781 PCRE2_NO_DOTSTAR_ANCHOR|PCRE2_UCP|PCRE2_UNGREEDY)
783#define PUBLIC_LITERAL_COMPILE_EXTRA_OPTIONS \
784 (PCRE2_EXTRA_MATCH_LINE|PCRE2_EXTRA_MATCH_WORD|PCRE2_EXTRA_CASELESS_RESTRICT)
786#define PUBLIC_COMPILE_EXTRA_OPTIONS \
787 (PUBLIC_LITERAL_COMPILE_EXTRA_OPTIONS| \
788 PCRE2_EXTRA_ALLOW_SURROGATE_ESCAPES|PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL| \
789 PCRE2_EXTRA_ESCAPED_CR_IS_LF|PCRE2_EXTRA_ALT_BSUX| \
790 PCRE2_EXTRA_ALLOW_LOOKAROUND_BSK|PCRE2_EXTRA_ASCII_BSD| \
791 PCRE2_EXTRA_ASCII_BSS|PCRE2_EXTRA_ASCII_BSW|PCRE2_EXTRA_ASCII_POSIX| \
792 PCRE2_EXTRA_ASCII_DIGIT)
802 ERR1,
ERR2,
ERR3,
ERR4,
ERR5,
ERR6,
ERR7,
ERR8,
ERR9,
ERR10,
803 ERR11,
ERR12,
ERR13,
ERR14,
ERR15,
ERR16,
ERR17,
ERR18,
ERR19,
ERR20,
804 ERR21,
ERR22,
ERR23,
ERR24,
ERR25,
ERR26,
ERR27,
ERR28,
ERR29,
ERR30,
805 ERR31,
ERR32,
ERR33,
ERR34,
ERR35,
ERR36,
ERR37,
ERR38,
ERR39,
ERR40,
806 ERR41,
ERR42,
ERR43,
ERR44,
ERR45,
ERR46,
ERR47,
ERR48,
ERR49,
ERR50,
807 ERR51,
ERR52,
ERR53,
ERR54,
ERR55,
ERR56,
ERR57,
ERR58,
ERR59,
ERR60,
808 ERR61,
ERR62,
ERR63,
ERR64,
ERR65,
ERR66,
ERR67,
ERR68,
ERR69,
ERR70,
809 ERR71,
ERR72,
ERR73,
ERR74,
ERR75,
ERR76,
ERR77,
ERR78,
ERR79,
ERR80,
810 ERR81,
ERR82,
ERR83,
ERR84,
ERR85,
ERR86,
ERR87,
ERR88,
ERR89,
ERR90,
811 ERR91,
ERR92,
ERR93,
ERR94,
ERR95,
ERR96,
ERR97,
ERR98,
ERR99,
ERR100,
837static const pso pso_list[] = {
867static const uint8_t opcode_possessify[] = {
868 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
869 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
920#ifdef DEBUG_SHOW_PARSED
930uint32_t *pptr =
cb->parsed_pattern;
940 fprintf(stderr,
"+++ %02d %.8x ", (
int)(pptr -
cb->parsed_pattern), *pptr);
944 if (*pptr > 32 && *pptr < 128)
fprintf(stderr,
"%c", *pptr);
951 fprintf(stderr,
"**** OOPS - unknown META value - giving up ****\n");
959 fprintf(stderr,
"META_CAPTURE %d", meta_arg);
969 offset =
cb->small_ref_offset[meta_arg];
978 uint32_t ptype = *pptr >> 16;
979 uint32_t
pvalue = *pptr++ & 0xffff;
980 fprintf(stderr,
"META \\%c %d %d", (meta_arg ==
ESC_P)?
'P':
'p',
991 if (meta_arg == (uint32_t)(-escapes[cc -
ESCAPES_FIRST]))
break;
994 fprintf(stderr,
"META \\%c", cc);
1069 fprintf(stderr,
"META_OPTIONS 0x%08x 0x%08x", pptr[0], pptr[1]);
1074 fprintf(stderr,
"META (?<= %d %d", meta_arg, *pptr);
1079 fprintf(stderr,
"META (*naplb: %d %d", meta_arg, *pptr);
1084 fprintf(stderr,
"META (?<! %d %d", meta_arg, *pptr);
1089 fprintf(stderr,
"META (?C%d) next=%d/%d", pptr[2], pptr[0],
1096 uint32_t patoffset = *pptr++;
1097 uint32_t patlength = *pptr++;
1098 fprintf(stderr,
"META (?Cstring) length=%d offset=", *pptr++);
1100 fprintf(stderr,
"%zd next=%d/%d",
offset, patoffset, patlength);
1105 fprintf(stderr,
"META (?(&name) length=%d offset=", *pptr++);
1111 fprintf(stderr,
"META_BACKREF_BYNAME length=%d offset=", *pptr++);
1124 fprintf(stderr,
"META (?(DEFINE) offset=");
1130 fprintf(stderr,
"META (?(VERSION%s", (*pptr++ == 0)?
"=" :
">=");
1131 fprintf(stderr,
"%d.", *pptr++);
1132 fprintf(stderr,
"%d)", *pptr++);
1136 fprintf(stderr,
"META (?(<name>) length=%d offset=", *pptr++);
1142 fprintf(stderr,
"META (?(R&name) length=%d offset=", *pptr++);
1150 fprintf(stderr,
"META (?(Rnumber) length=%d offset=", *pptr++);
1156 fprintf(stderr,
"META (*MARK:");
1160 fprintf(stderr,
"META (*COMMIT:");
1164 fprintf(stderr,
"META (*PRUNE:");
1168 fprintf(stderr,
"META (*SKIP:");
1172 fprintf(stderr,
"META (*THEN:");
1175 for (i = 0; i < length; i++)
1177 uint32_t cc = *pptr++;
1178 if (cc > 32 && cc < 128)
fprintf(stderr,
"%c", cc);
1179 else fprintf(stderr,
"\\x{%x}", cc);
1181 fprintf(stderr,
") length=%u", length);
1206newcode = code->memctl.malloc(code->blocksize, code->memctl.memory_data);
1208memcpy(newcode, code, code->blocksize);
1209newcode->executable_jit =
NULL;
1241newcode = code->memctl.malloc(code->blocksize, code->memctl.memory_data);
1243memcpy(newcode, code, code->blocksize);
1244newcode->executable_jit =
NULL;
1247 code->memctl.memory_data);
1248if (newtables ==
NULL)
1250 code->memctl.free((
void *)newcode, code->memctl.memory_data);
1257newcode->tables = newtables;
1276 if (code->executable_jit !=
NULL)
1290 if (*ref_count == 0)
1291 code->memctl.free((
void *)code->tables, code->memctl.memory_data);
1295 code->memctl.free(code, code->memctl.memory_data);
1326 uint32_t max_value, uint32_t max_error,
int *intptr,
int *errorcodeptr)
1335if (allow_sign >= 0 &&
ptr < ptrend)
1340 max_value -= allow_sign;
1356 *errorcodeptr = max_error;
1361if (allow_sign >= 0 &&
sign != 0)
1365 *errorcodeptr =
ERR26;
1369 if (
sign > 0)
n += allow_sign;
1370 else if ((
int)
n > allow_sign)
1372 *errorcodeptr =
ERR15;
1375 else n = allow_sign + 1 -
n;
1413 uint32_t *maxp,
int *errorcodeptr)
1433 while (++pp < ptrend &&
IS_DIGIT(*pp)) {}
1437if (pp >= ptrend)
return FALSE;
1441 if (!had_minimum)
return FALSE;
1447 if (pp >= ptrend)
return FALSE;
1450 while (++pp < ptrend &&
IS_DIGIT(*pp)) {}
1452 else if (!had_minimum)
return FALSE;
1466 if (*errorcodeptr != 0)
goto EXIT;
1471 if (*errorcodeptr != 0)
goto EXIT;
1490 if (*errorcodeptr != 0)
goto EXIT;
1495 *errorcodeptr =
ERR4;
1506if (minp !=
NULL) *minp = (uint32_t)
min;
1507if (maxp !=
NULL) *maxp = (uint32_t)
max;
1552 int *errorcodeptr, uint32_t
options, uint32_t xoptions,
BOOL isclass,
1567 *errorcodeptr =
ERR1;
1623 *errorcodeptr =
ERR93;
1631 else *errorcodeptr =
ERR93;
1640 if (!read_repeat_counts(&
p, ptrend,
NULL,
NULL, errorcodeptr) &&
1642 *errorcodeptr =
ERR37;
1665 *errorcodeptr =
ERR3;
1679 *errorcodeptr =
ERR37;
1691 if (!alt_bsux) *errorcodeptr =
ERR37;
else
1695 if (
ptr >= ptrend)
break;
1702 while (hptr < ptrend && (xc =
XDIGIT(*hptr)) != 0xff)
1704 if ((cc & 0xf0000000) != 0)
1706 *errorcodeptr =
ERR77;
1710 cc = (cc << 4) | xc;
1714 if (hptr ==
ptr + 1 ||
1729 if (ptrend -
ptr < 4)
break;
1730 if ((cc =
XDIGIT(
ptr[0])) == 0xff)
break;
1731 if ((xc =
XDIGIT(
ptr[1])) == 0xff)
break;
1732 cc = (cc << 4) | xc;
1733 if ((xc =
XDIGIT(
ptr[2])) == 0xff)
break;
1734 cc = (cc << 4) | xc;
1735 if ((xc =
XDIGIT(
ptr[3])) == 0xff)
break;
1742 if (c > 0x10ffffU) *errorcodeptr =
ERR77;
1744 if (c >= 0xd800 && c <= 0xdfff &&
1746 *errorcodeptr =
ERR73;
1748 else if (c > MAX_NON_UTF_CHAR) *errorcodeptr =
ERR77;
1756 if (!alt_bsux) *errorcodeptr =
ERR37;
1785 *errorcodeptr =
ERR57;
1806 if (*errorcodeptr == 0) escape =
ESC_k;
1813 *errorcodeptr =
ERR57;
1826 if (*errorcodeptr == 0) *errorcodeptr =
ERR57;
1833 *errorcodeptr =
ERR15;
1870 if (read_number(&
ptr, ptrend, -1,
INT_MAX/10 - 1, 0, &
s, errorcodeptr) &&
1871 (
s < 10 || oldptr[-1] >=
CHAR_8 ||
s <= (
int)
cb->bracount))
1900#if PCRE2_CODE_UNIT_WIDTH == 8
1901 if (!utf && c > 0xff) *errorcodeptr =
ERR51;
1913 *errorcodeptr =
ERR55;
1920 *errorcodeptr =
ERR78;
1929 if (c == 0 && cc ==
CHAR_0)
continue;
1930#if PCRE2_CODE_UNIT_WIDTH == 32
1931 if (c >= 0x20000000l) { overflow =
TRUE;
break; }
1933 c = (c << 3) + (cc -
CHAR_0);
1934#if PCRE2_CODE_UNIT_WIDTH == 8
1935 if (c > (utf ? 0x10ffffU : 0xffU)) { overflow =
TRUE;
break; }
1936#elif PCRE2_CODE_UNIT_WIDTH == 16
1937 if (c > (utf ? 0x10ffffU : 0xffffU)) { overflow =
TRUE;
break; }
1938#elif PCRE2_CODE_UNIT_WIDTH == 32
1939 if (utf && c > 0x10ffffU) { overflow =
TRUE;
break; }
1948 *errorcodeptr =
ERR34;
1952 if (utf && c >= 0xd800 && c <= 0xdfff &&
1956 *errorcodeptr =
ERR73;
1962 *errorcodeptr =
ERR64;
1973 if (ptrend -
ptr < 2)
break;
1974 if ((cc =
XDIGIT(
ptr[0])) == 0xff)
break;
1975 if ((xc =
XDIGIT(
ptr[1])) == 0xff)
break;
1999 *errorcodeptr =
ERR78;
2008 if (c == 0 && cc == 0)
continue;
2009#if PCRE2_CODE_UNIT_WIDTH == 32
2010 if (c >= 0x10000000l) { overflow =
TRUE;
break; }
2013 if ((utf && c > 0x10ffffU) || (!utf && c > MAX_NON_UTF_CHAR))
2029 *errorcodeptr =
ERR34;
2033 if (utf && c >= 0xd800 && c <= 0xdfff &&
2037 *errorcodeptr =
ERR73;
2049 *errorcodeptr =
ERR67;
2058 if (
ptr >= ptrend || (cc =
XDIGIT(*
ptr)) == 0xff)
break;
2061 if (
ptr >= ptrend || (cc =
XDIGIT(*
ptr)) == 0xff)
break;
2082#if defined EBCDIC && 'a' != 0x81
2089 *errorcodeptr =
ERR2;
2098 if (c < 32 || c > 126)
2100 *errorcodeptr =
ERR68;
2112 c = (
'\\' == 188 &&
'`' == 74)? 0x5f : 0xff;
2115 for (i = 0; i < 32; i++)
2117 if (c == ebcdic_escape_c[i])
break;
2119 if (i < 32) c = i;
else *errorcodeptr =
ERR68;
2130 *errorcodeptr =
ERR3;
2145#ifdef SUPPORT_UNICODE
2177if (
ptr >=
cb->end_pattern)
goto ERROR_RETURN;
2186 if (
ptr >=
cb->end_pattern)
goto ERROR_RETURN;
2196 if (
ptr >=
cb->end_pattern)
goto ERROR_RETURN;
2198#if PCRE2_CODE_UNIT_WIDTH != 8
2199 while (c ==
'_' || c ==
'-' || (c <= 0xff && isspace(c)))
2201 while (c ==
'_' || c ==
'-' || isspace(c))
2204 if (
ptr >=
cb->end_pattern)
goto ERROR_RETURN;
2207 if (c ==
CHAR_NUL)
goto ERROR_RETURN;
2209 name[i] = tolower(c);
2210 if ((c ==
':' || c ==
'=') && vptr ==
NULL) vptr =
name + i;
2222 name[0] = tolower(c);
2225else goto ERROR_RETURN;
2269 *errorcodeptr =
ERR47;
2287 i = (bot +
top) >> 1;
2295 *pdataptr =
PRIV(utt)[i].value;
2298 *ptypeptr =
PRIV(utt)[i].type;
2309 *ptypeptr = ptscript;
2316 if (r > 0) bot = i + 1;
else top = i;
2319*errorcodeptr =
ERR47;
2323*errorcodeptr =
ERR46;
2382for (; ptrend -
ptr >= 2;
ptr++)
2420const char *pn = posix_names;
2422while (posix_name_lengths[yield] != 0)
2424 if (
len == posix_name_lengths[yield] &&
2426 pn += posix_name_lengths[yield] + 1;
2477 *errorcodeptr = is_group?
ERR62:
2488#ifdef SUPPORT_UNICODE
2498 *errorcodeptr =
ERR44;
2507 FORWARDCHARTEST(
ptr, ptrend);
2508 if (
ptr >= ptrend)
break;
2525 *errorcodeptr =
ERR44;
2539 *errorcodeptr =
ERR48;
2542*namelenptr = (uint32_t)(
ptr - *nameptr);
2549 if (
ptr == *nameptr)
2551 *errorcodeptr =
ERR62;
2558 *errorcodeptr =
ERR42;
2598uint32_t *previous_callout = *pcalloutptr;
2600if (previous_callout !=
NULL) previous_callout[2] = (uint32_t)(
ptr -
2603if (!auto_callout) previous_callout =
NULL;
else
2605 if (previous_callout ==
NULL ||
2606 previous_callout != parsed_pattern - 4 ||
2607 previous_callout[3] != 255)
2609 previous_callout = parsed_pattern;
2610 parsed_pattern += 4;
2612 previous_callout[2] = 0;
2613 previous_callout[3] = 255;
2615 previous_callout[1] = (uint32_t)(
ptr -
cb->start_pattern);
2618*pcalloutptr = previous_callout;
2619return parsed_pattern;
2642handle_escdsw(
int escape, uint32_t *parsed_pattern, uint32_t
options,
2645uint32_t ascii_option = 0;
2646uint32_t prop =
ESC_p;
2688 *parsed_pattern++ =
PT_SPACE << 16;
2693 *parsed_pattern++ =
PT_WORD << 16;
2698return parsed_pattern;
2734#define NSF_RESET 0x0001u
2735#define NSF_CONDASSERT 0x0002u
2736#define NSF_ATOMICSR 0x0004u
2743#define PARSE_TRACKED_OPTIONS (PCRE2_CASELESS|PCRE2_DOTALL|PCRE2_DUPNAMES| \
2744 PCRE2_EXTENDED|PCRE2_EXTENDED_MORE|PCRE2_MULTILINE|PCRE2_NO_AUTO_CAPTURE| \
2747#define PARSE_TRACKED_EXTRA_OPTIONS (PCRE2_EXTRA_CASELESS_RESTRICT| \
2748 PCRE2_EXTRA_ASCII_BSD|PCRE2_EXTRA_ASCII_BSS|PCRE2_EXTRA_ASCII_BSW| \
2749 PCRE2_EXTRA_ASCII_DIGIT|PCRE2_EXTRA_ASCII_POSIX)
2760#if PCRE2_CODE_UNIT_WIDTH == 32
2761#define PARSED_LITERAL(c, p) \
2763 if (c >= META_END) *p++ = META_BIGVALUE; \
2765 okquantifier = TRUE; \
2768#define PARSED_LITERAL(c, p) *p++ = c; okquantifier = TRUE;
2779uint32_t class_range_state;
2780uint32_t *verblengthptr =
NULL;
2781uint32_t *verbstartptr =
NULL;
2782uint32_t *previous_callout =
NULL;
2783uint32_t *parsed_pattern =
cb->parsed_pattern;
2784uint32_t *parsed_pattern_end =
cb->parsed_pattern_end;
2785uint32_t *this_parsed_item =
NULL;
2786uint32_t *prev_parsed_item =
NULL;
2787uint32_t meta_quantifier = 0;
2788uint32_t add_after_mark = 0;
2789uint32_t xoptions =
cb->cx->extra_options;
2790uint16_t nest_depth = 0;
2791int after_manual_callout = 0;
2792int expect_cond_assert = 0;
2829 while (
ptr < ptrend)
2831 if (parsed_pattern >= parsed_pattern_end)
2839 parsed_pattern = manage_callouts(thisptr, &previous_callout,
2840 auto_callout, parsed_pattern,
cb);
2849end_nests = (
nest_save *)(
cb->start_workspace +
cb->workspace_size);
2855end_nests = (
nest_save *)((
char *)end_nests -
2866 int prev_expect_cond_assert;
2867 uint32_t min_repeat = 0, max_repeat = 0;
2868 uint32_t set, unset, *optset;
2869 uint32_t xset, xunset, *xoptset;
2870 uint32_t terminator;
2871 uint32_t prev_meta_quantifier;
2872 BOOL prev_okquantifier;
2876 if (parsed_pattern >= parsed_pattern_end)
2882 if (nest_depth >
cb->cx->parens_nest_limit)
2893 if (this_parsed_item != parsed_pattern)
2895 prev_parsed_item = this_parsed_item;
2896 this_parsed_item = parsed_pattern;
2916 if (expect_cond_assert > 0)
2924#if PCRE2_CODE_UNIT_WIDTH == 32
2927 *parsed_pattern++ = c;
2931 if (after_manual_callout-- <= 0)
2932 parsed_pattern = manage_callouts(thisptr, &previous_callout,
2933 auto_callout, parsed_pattern,
cb);
2936 meta_quantifier = 0;
2958 (c > 255 && (c|1) != 0x200f && (c|1) != 0x2029) ||
2973#if PCRE2_CODE_UNIT_WIDTH == 32
2976 *parsed_pattern++ = c;
2982 verbnamelength = (
PCRE2_SIZE)(parsed_pattern - verblengthptr - 1);
2990 *verblengthptr = (uint32_t)verbnamelength;
2996 if (add_after_mark != 0)
2998 *parsed_pattern++ = add_after_mark;
3008 if (errorcode != 0)
goto FAILED;
3015#if PCRE2_CODE_UNIT_WIDTH == 32
3018 *parsed_pattern++ = c;
3022 *parsed_pattern++ =
CHAR_u;
3066 if (c < 256 && (
cb->ctypes[c] &
ctype_space) != 0)
continue;
3067#ifdef SUPPORT_UNICODE
3068 if (c ==
CHAR_NEL || (c|1) == 0x200f || (c|1) == 0x2029)
continue;
3072 while (
ptr < ptrend)
3080#ifdef SUPPORT_UNICODE
3081 if (utf) FORWARDCHARTEST(
ptr, ptrend);
3109 !read_repeat_counts(&tempptr, ptrend,
NULL,
NULL, &errorcode))))
3111 if (after_manual_callout-- <= 0)
3113 parsed_pattern = manage_callouts(thisptr, &previous_callout, auto_callout,
3114 parsed_pattern,
cb);
3115 this_parsed_item = parsed_pattern;
3128 if (expect_cond_assert > 0)
3141 ok = expect_cond_assert == 2;
3168 prev_expect_cond_assert = expect_cond_assert;
3169 expect_cond_assert = 0;
3174 prev_okquantifier = okquantifier;
3175 prev_meta_quantifier = meta_quantifier;
3176 okquantifier =
FALSE;
3177 meta_quantifier = 0;
3187 parsed_pattern[(prev_meta_quantifier ==
META_MINMAX)? -3 : -1] =
3189 0x00020000u : 0x00010000u);
3235 else if (escape < 0)
3243 cb->small_ref_offset[escape] =
offset;
3249 okquantifier =
TRUE;
3268 else switch (escape)
3271#ifdef NEVER_BACKSLASH_C
3281 okquantifier =
TRUE;
3291 *parsed_pattern++ =
CHAR_u;
3296#ifndef SUPPORT_UNICODE
3306 okquantifier =
TRUE;
3322 okquantifier =
TRUE;
3323 parsed_pattern = handle_escdsw(escape, parsed_pattern,
options,
3331#ifdef SUPPORT_UNICODE
3334 uint16_t ptype = 0, pdata = 0;
3335 if (!get_ucp(&
ptr, &negated, &ptype, &pdata, &errorcode,
cb))
3339 *parsed_pattern++ = (ptype << 16) | pdata;
3340 okquantifier =
TRUE;
3375 if (
p >= ptrend || *
p != terminator)
3383 if (errorcode != 0)
goto ESCAPE_FAILED;
3390 &errorcode,
cb))
goto ESCAPE_FAILED;
3401 okquantifier =
TRUE;
3419 okquantifier =
TRUE;
3427 goto CHECK_QUANTIFIER;
3431 goto CHECK_QUANTIFIER;
3435 goto CHECK_QUANTIFIER;
3441 if (!read_repeat_counts(&
ptr, ptrend, &min_repeat, &max_repeat,
3444 if (errorcode != 0)
goto FAILED;
3458 if (!prev_okquantifier)
3473 for (
p = parsed_pattern - 1;
p >= verbstartptr;
p--)
p[1] =
p[0];
3476 parsed_pattern += 2;
3484 *parsed_pattern++ = meta_quantifier;
3487 *parsed_pattern++ = min_repeat;
3488 *parsed_pattern++ = max_repeat;
3496 okquantifier =
TRUE;
3504 if (ptrend -
ptr >= 6 &&
3517 *has_lookbehind =
TRUE;
3530 *parsed_pattern++ =
PT_WORD << 16;
3542 check_posix_syntax(
ptr, ptrend, &tempptr))
3553 negate_class =
FALSE;
3554 while (
ptr < ptrend)
3560 else if (ptrend -
ptr >= 3 &&
3570 negate_class =
TRUE;
3611 goto CLASS_CONTINUE;
3620 goto CLASS_CONTINUE;
3629 ptrend -
ptr >= 3 &&
3632 check_posix_syntax(
ptr, ptrend, &tempptr))
3656 posix_negate =
TRUE;
3660 posix_class = check_posix_name(
ptr, (
int)(tempptr -
ptr));
3661 if (posix_class < 0)
3698#ifdef SUPPORT_UNICODE
3704 int ptype = posix_substitutes[2*posix_class];
3705 int pvalue = posix_substitutes[2*posix_class + 1];
3710 *parsed_pattern++ = (ptype << 16) |
pvalue;
3711 goto CLASS_CONTINUE;
3717 goto CLASS_CONTINUE;
3727 *parsed_pattern++ = posix_class;
3746 if (c == parsed_pattern[-2])
3748 else if (parsed_pattern[-2] > c)
3763 class_range_state = char_is_literal?
3792 char_is_literal =
FALSE;
3797 char_is_literal =
FALSE;
3802 goto CLASS_CONTINUE;
3805 goto CLASS_CONTINUE;
3853 parsed_pattern = handle_escdsw(escape, parsed_pattern,
options,
3861#ifdef SUPPORT_UNICODE
3864 uint16_t ptype = 0, pdata = 0;
3865 if (!get_ucp(&
ptr, &negated, &ptype, &pdata, &errorcode,
cb))
3869 *parsed_pattern++ = (ptype << 16) | pdata;
3921 if (
ptr >= ptrend)
goto UNCLOSED_PARENTHESIS;
3967 &errorcode,
cb))
goto FAILED;
3976 for (i = 0; i < alascount; i++)
3981 vn += alasmeta[i].len + 1;
3993 meta = alasmeta[i].meta;
3994 if (prev_expect_cond_assert > 0 &&
4015 goto POSITIVE_LOOK_AHEAD;
4018 goto POSITIVE_NONATOMIC_LOOK_AHEAD;
4021 goto NEGATIVE_LOOK_AHEAD;
4026 *parsed_pattern++ = meta;
4028 goto POST_LOOKBEHIND;
4037#ifdef SUPPORT_UNICODE
4045 else if (++top_nest >= end_nests)
4070 &errorcode,
cb))
goto FAILED;
4080 for (i = 0; i < verbcount; i++)
4085 vn += verbs[i].len + 1;
4111 verbstartptr = parsed_pattern;
4127 if (verbs[i].has_arg < 0)
4129 add_after_mark = verbs[i].meta;
4138 *parsed_pattern++ = verbs[i].meta +
4139 ((verbs[i].meta !=
META_MARK)? 0x00010000u:0);
4144 verblengthptr = parsed_pattern++;
4145 verbnamestart =
ptr;
4150 *parsed_pattern++ = verbs[i].meta;
4165 if (++
ptr >= ptrend)
goto UNCLOSED_PARENTHESIS;
4171 goto RECURSION_BYNUMBER;
4178 else if (++top_nest >= end_nests)
4184 top_nest->
flags = 0;
4206 uint32_t oldoptions =
options;
4207 uint32_t oldxoptions = xoptions;
4324 xoptions = (xoptions | xset) & (~xunset);
4333 if (
ptr >= ptrend)
goto UNCLOSED_PARENTHESIS;
4337 if (top_nest > (
nest_save *)(
cb->start_workspace) &&
4338 (top_nest-1)->
nest_depth == nest_depth) top_nest--;
4345 if (
options != oldoptions || xoptions != oldxoptions)
4349 *parsed_pattern++ = xoptions;
4358 if (++
ptr >= ptrend)
goto UNCLOSED_PARENTHESIS;
4386 okquantifier =
TRUE;
4416 if (!read_number(&
ptr, ptrend,
4419 &i, &errorcode))
goto FAILED;
4426 goto UNCLOSED_PARENTHESIS;
4433 okquantifier =
TRUE;
4446 okquantifier =
TRUE;
4452 if (++
ptr >= ptrend)
goto UNCLOSED_PARENTHESIS;
4463 expect_cond_assert = prev_expect_cond_assert - 1;
4471 previous_callout == parsed_pattern - 4 &&
4472 parsed_pattern[-1] == 255)
4473 parsed_pattern = previous_callout;
4478 previous_callout = parsed_pattern;
4479 after_manual_callout = 1;
4489 for (i = 0;
PRIV(callout_start_delims)[i] != 0; i++)
4491 if (*
ptr ==
PRIV(callout_start_delims)[i])
4493 delimiter =
PRIV(callout_end_delims)[i];
4504 parsed_pattern += 3;
4508 if (++
ptr >= ptrend)
4514 if (*
ptr == delimiter && (++
ptr >= ptrend || *
ptr != delimiter))
4524 *parsed_pattern++ = (uint32_t)calloutlength;
4536 parsed_pattern += 3;
4546 *parsed_pattern++ =
n;
4561 previous_callout[1] = (uint32_t)(
ptr -
cb->start_pattern);
4562 previous_callout[2] = 0;
4586 if (++
ptr >= ptrend)
goto UNCLOSED_PARENTHESIS;
4601 expect_cond_assert = 2;
4618 *parsed_pattern++ = i;
4620 else if (errorcode != 0)
goto FAILED;
4624 else if (ptrend -
ptr >= 10 &&
4643 goto BAD_VERSION_CONDITION;
4645 if (!read_number(&
ptr, ptrend, -1, 1000,
ERR79, &
major, &errorcode))
4648 if (
ptr >= ptrend)
goto BAD_VERSION_CONDITION;
4651 if (++
ptr >= ptrend || !
IS_DIGIT(*
ptr))
goto BAD_VERSION_CONDITION;
4653 if (
ptr >= ptrend)
goto BAD_VERSION_CONDITION;
4656 goto BAD_VERSION_CONDITION;
4660 *parsed_pattern++ = ge;
4661 *parsed_pattern++ =
major;
4662 *parsed_pattern++ =
minor;
4678 was_r_ampersand =
TRUE;
4691 &errorcode,
cb))
goto FAILED;
4695 if (was_r_ampersand)
4711 for (i = 1; i < (int)
namelen; i++)
4754 POSITIVE_LOOK_AHEAD:
4757 goto POST_ASSERTION;
4760 POSITIVE_NONATOMIC_LOOK_AHEAD:
4763 goto POST_ASSERTION;
4766 NEGATIVE_LOOK_AHEAD:
4769 goto POST_ASSERTION;
4778 if (ptrend -
ptr <= 1 ||
4791 *has_lookbehind =
TRUE;
4808 if (prev_expect_cond_assert > 0)
4811 else if (++top_nest >= end_nests)
4835 &errorcode,
cb))
goto FAILED;
4870 ng =
cb->named_groups;
4871 for (i = 0; i <
cb->names_found; i++, ng++)
4876 if (ng->
number ==
cb->bracount)
break;
4885 else if (ng->
number ==
cb->bracount)
4892 if (i < cb->names_found)
break;
4896 if (
cb->names_found >=
cb->named_group_list_size)
4898 uint32_t newsize =
cb->named_group_list_size * 2;
4901 cb->cx->memctl.memory_data);
4902 if (newspace ==
NULL)
4911 cb->cx->memctl.free((
void *)
cb->named_groups,
4912 cb->cx->memctl.memory_data);
4913 cb->named_groups = newspace;
4914 cb->named_group_list_size = newsize;
4919 cb->named_groups[
cb->names_found].name =
name;
4920 cb->named_groups[
cb->names_found].length = (uint16_t)
namelen;
4921 cb->named_groups[
cb->names_found].number =
cb->bracount;
4922 cb->named_groups[
cb->names_found].isdup = (uint16_t)isdupname;
4949 okquantifier =
TRUE;
4958 okquantifier =
FALSE;
4968 if (nest_depth == 0)
4981if (inverbname &&
ptr >= ptrend)
4990parsed_pattern = manage_callouts(
ptr, &previous_callout, auto_callout,
4991 parsed_pattern,
cb);
5010if (parsed_pattern >= parsed_pattern_end)
5017if (nest_depth == 0)
return 0;
5019UNCLOSED_PARENTHESIS:
5036BAD_VERSION_CONDITION:
5071 if (!skipassert)
return code;
5072 do code +=
GET(code, 1);
while (*code ==
OP_ALT);
5080 if (!skipassert)
return code;
5126#ifdef SUPPORT_UNICODE
5151get_othercase_range(uint32_t *cptr, uint32_t d, uint32_t *ocptr,
5152 uint32_t *odptr,
BOOL restricted)
5154uint32_t c, othercase,
next;
5162for (c = *cptr; c <= d; c++)
5164#if PCRE2_CODE_UNIT_WIDTH == 32
5168 (!restricted ||
PRIV(ucd_caseless_sets)[co] > 127))
5183if (c > d)
return -1;
5190next = othercase + 1;
5192for (++c; c <= d; c++)
5231add_to_class_internal(uint8_t *classbits,
PCRE2_UCHAR **uchardptr,
5236uint32_t classbits_end = (
end <= 0xff ?
end : 0xff);
5246#ifdef SUPPORT_UNICODE
5255 while ((rc = get_othercase_range(&c,
end, &oc, &od,
5260 if (rc > 0) n8 += add_list_to_class_internal(classbits, uchardptr,
5265 else if (oc >=
cb->class_range_start && od <= cb->class_range_end)
5273 else if (oc < start && od >=
start - 1)
start = oc;
5274 else if (od >
end && oc <=
end + 1)
5277 if (
end > classbits_end) classbits_end = (
end <= 0xff ?
end : 0xff);
5279 else n8 += add_to_class_internal(classbits, uchardptr,
options, xoptions,
5290 for (c =
start; c <= classbits_end; c++)
5302 end = MAX_NON_UTF_CHAR;
5308for (c =
start; c <= classbits_end; c++)
5315#ifdef SUPPORT_WIDE_CHARS
5322#ifdef SUPPORT_UNICODE
5343#if PCRE2_CODE_UNIT_WIDTH == 8
5349 *uchardata++ =
start;
5355 *uchardata++ =
start;
5358 *uchardptr = uchardata;
5369#ifdef SUPPORT_UNICODE
5394add_list_to_class_internal(uint8_t *classbits,
PCRE2_UCHAR **uchardptr,
5396 unsigned int except)
5404 while(
p[
n+1] ==
p[0] +
n + 1)
n++;
5405 n8 += add_to_class_internal(classbits, uchardptr,
options, xoptions,
cb,
5441cb->class_range_end =
end;
5442return add_to_class_internal(classbits, uchardptr,
options, xoptions,
cb,
5474 uint32_t xoptions,
compile_block *
cb,
const uint32_t *
p,
unsigned int except)
5482 while(
p[
n+1] ==
p[0] +
n + 1)
n++;
5483 cb->class_range_start =
p[0];
5484 cb->class_range_end =
p[
n];
5485 n8 += add_to_class_internal(classbits, uchardptr,
options, xoptions,
cb,
5515add_not_list_to_class(uint8_t *classbits,
PCRE2_UCHAR **uchardptr,
5521 n8 += add_to_class(classbits, uchardptr,
options, xoptions,
cb, 0,
p[0] - 1);
5524 while (
p[1] ==
p[0] + 1)
p++;
5525 n8 += add_to_class(classbits, uchardptr,
options, xoptions,
cb,
p[0] + 1,
5526 (
p[1] ==
NOTACHAR) ? (utf ? 0x10ffffu : 0xffffffffu) :
p[1] - 1);
5554find_dupname_details(
PCRE2_SPTR name, uint32_t length,
int *indexptr,
5557uint32_t i, groupnumber;
5563for (i = 0; i <
cb->names_found; i++)
5567 slot +=
cb->name_entry_size;
5573if (i >=
cb->names_found)
5575 *errorcodeptr =
ERR53;
5576 cb->erroroffset =
name -
cb->start_pattern;
5589 groupnumber =
GET2(slot,0);
5590 cb->backref_map |= (groupnumber < 32)? (1u << groupnumber) : 1;
5591 if (groupnumber >
cb->top_backref)
cb->top_backref = groupnumber;
5592 if (++i >=
cb->names_found)
break;
5593 slot +=
cb->name_entry_size;
5636compile_branch(uint32_t *optionsptr, uint32_t *xoptionsptr,
5637 PCRE2_UCHAR **codeptr, uint32_t **pptrptr,
int *errorcodeptr,
5638 uint32_t *firstcuptr, uint32_t *firstcuflagsptr, uint32_t *reqcuptr,
5644int group_return = 0;
5645uint32_t repeat_min = 0, repeat_max = 0;
5646uint32_t greedy_default, greedy_non_default;
5647uint32_t repeat_type, op_type;
5648uint32_t
options = *optionsptr;
5649uint32_t xoptions = *xoptionsptr;
5650uint32_t firstcu, reqcu;
5651uint32_t zeroreqcu, zerofirstcu;
5653uint32_t *pptr = *pptrptr;
5654uint32_t meta, meta_arg;
5655uint32_t firstcuflags, reqcuflags;
5656uint32_t zeroreqcuflags, zerofirstcuflags;
5657uint32_t req_caseopt, reqvary, tempreqvary;
5671const uint8_t *cbits =
cb->cbits;
5672uint8_t classbits[32];
5678#ifdef SUPPORT_UNICODE
5691#ifdef SUPPORT_WIDE_CHARS
5699greedy_non_default = greedy_default ^ 1;
5710firstcu = reqcu = zerofirstcu = zeroreqcu = 0;
5711firstcuflags = reqcuflags = zerofirstcuflags = zeroreqcuflags =
REQ_UNSET;
5725#ifdef SUPPORT_WIDE_CHARS
5726 BOOL xclass_has_prop;
5729 BOOL should_flip_negation;
5730 BOOL match_all_or_no_wide_chars;
5731 BOOL possessive_quantifier;
5732 BOOL note_group_empty;
5733 int class_has_8bitchar;
5736 uint32_t subreqcu, subfirstcu;
5737 uint32_t groupnumber;
5738 uint32_t verbarglen, verbculen;
5739 uint32_t subreqcuflags, subfirstcuflags;
5751 if (lengthptr !=
NULL)
5753 if (code >
cb->start_workspace +
cb->workspace_size -
5756 *errorcodeptr = (code >=
cb->start_workspace +
cb->workspace_size)?
5767 if (code < last_code) code = last_code;
5777 *errorcodeptr =
ERR20;
5780 *lengthptr += (
PCRE2_SIZE)(code - orig_code);
5781 if (*lengthptr > MAX_PATTERN_SIZE)
5783 *errorcodeptr =
ERR20;
5803 if (matched_char && !had_accept) okreturn = 1;
5806 previous_matched_char = matched_char;
5807 matched_char =
FALSE;
5808 note_group_empty =
FALSE;
5819 *firstcuptr = firstcu;
5820 *firstcuflagsptr = firstcuflags;
5822 *reqcuflagsptr = reqcuflags;
5836 zerofirstcuflags = firstcuflags =
REQ_NONE;
5850 matched_char =
TRUE;
5852 zerofirstcu = firstcu;
5853 zerofirstcuflags = firstcuflags;
5855 zeroreqcuflags = reqcuflags;
5868 matched_char =
TRUE;
5871 zerofirstcu = firstcu;
5872 zerofirstcuflags = firstcuflags;
5891 matched_char =
TRUE;
5905#ifdef SUPPORT_UNICODE
5908 uint32_t c = pptr[1];
5914 goto NORMAL_CHAR_SET;
5920 zeroreqcuflags = reqcuflags;
5922 zerofirstcu = firstcu;
5923 zerofirstcuflags = firstcuflags;
5930#ifdef SUPPORT_UNICODE
5934 PRIV(ucd_caseless_sets)[d] > 127))
5959 uint32_t c = pptr[1];
5961#ifdef SUPPORT_UNICODE
5964 c < 128 && pptr[2] < 128))
5969#ifdef SUPPORT_UNICODE
5973#if PCRE2_CODE_UNIT_WIDTH != 8
5974 if (c > 255) d = c;
else
5979 if (c != d && pptr[2] == d)
5985 reset_caseful =
TRUE;
5989 goto CLASS_CASELESS_CHAR;
6000 should_flip_negation = match_all_or_no_wide_chars =
FALSE;
6005#ifdef SUPPORT_WIDE_CHARS
6008 class_uchardata_base = class_uchardata;
6016 class_has_8bitchar = 0;
6017#ifdef SUPPORT_WIDE_CHARS
6018 xclass_has_prop =
FALSE;
6026 memset(classbits, 0, 32 *
sizeof(uint8_t));
6037 int posix_class = *(++pptr);
6038 int taboffset, tabopt;
6041 should_flip_negation = local_negate;
6055#ifdef SUPPORT_UNICODE
6068 *class_uchardata++ = 0;
6069 xclass_has_prop =
TRUE;
6070 goto CONTINUE_CLASS;
6089#if PCRE2_CODE_UNIT_WIDTH == 8
6092 match_all_or_no_wide_chars |= local_negate;
6108 memcpy(pbits, cbits + posix_class_maps[posix_class],
6109 32 *
sizeof(uint8_t));
6113 taboffset = posix_class_maps[posix_class + 1];
6114 tabopt = posix_class_maps[posix_class + 2];
6119 for (
int i = 0; i < 32; i++) pbits[i] |= cbits[(
int)i + taboffset];
6121 for (
int i = 0; i < 32; i++) pbits[i] &= ~cbits[(
int)i + taboffset];
6127 if (tabopt < 0) tabopt = -tabopt;
6128 if (tabopt == 1) pbits[1] &= ~0x3c;
6129 else if (tabopt == 2) pbits[11] &= 0x7f;
6135 for (
int i = 0; i < 32; i++) classbits[i] |= (uint8_t)(~pbits[i]);
6137 for (
int i = 0; i < 32; i++) classbits[i] |= pbits[i];
6141 class_has_8bitchar = 1;
6142 goto CONTINUE_CLASS;
6160#ifdef DEBUG_SHOW_PARSED
6161 fprintf(stderr,
"** Unrecognized parsed pattern item 0x%.8x "
6162 "in character class\n", meta);
6164 *errorcodeptr =
ERR89;
6171 class_has_8bitchar++;
6176 for (
int i = 0; i < 32; i++) classbits[i] |= cbits[i+
cbit_digit];
6180 should_flip_negation =
TRUE;
6181 for (
int i = 0; i < 32; i++)
6182 classbits[i] |= (uint8_t)(~cbits[i+
cbit_digit]);
6186 for (
int i = 0; i < 32; i++) classbits[i] |= cbits[i+
cbit_word];
6190 should_flip_negation =
TRUE;
6191 for (
int i = 0; i < 32; i++)
6192 classbits[i] |= (uint8_t)(~cbits[i+
cbit_word]);
6203 for (
int i = 0; i < 32; i++) classbits[i] |= cbits[i+
cbit_space];
6207 should_flip_negation =
TRUE;
6208 for (
int i = 0; i < 32; i++)
6209 classbits[i] |= (uint8_t)(~cbits[i+
cbit_space]);
6219 (
void)add_list_to_class(classbits, &class_uchardata,
6225 (
void)add_not_list_to_class(classbits, &class_uchardata,
6230 (
void)add_list_to_class(classbits, &class_uchardata,
6236 (
void)add_not_list_to_class(classbits, &class_uchardata,
6243#ifdef SUPPORT_UNICODE
6247 uint32_t ptype = *(++pptr) >> 16;
6248 uint32_t pdata = *pptr & 0xffff;
6250 *class_uchardata++ = ptype;
6251 *class_uchardata++ = pdata;
6252 xclass_has_prop =
TRUE;
6253 class_has_8bitchar--;
6259 goto CONTINUE_CLASS;
6299 if (range_is_literal &&
6304 uint32_t uc = (d <=
CHAR_z)? 0 : 64;
6305 uint32_t
C = c - uc;
6306 uint32_t
D = d - uc;
6310 class_has_8bitchar +=
6311 add_to_class(classbits, &class_uchardata,
options, xoptions,
6318 class_has_8bitchar +=
6319 add_to_class(classbits, &class_uchardata,
options, xoptions,
6326 class_has_8bitchar +=
6327 add_to_class(classbits, &class_uchardata,
options, xoptions,
6328 cb,
C + uc,
D + uc);
6335 class_has_8bitchar += add_to_class(classbits, &class_uchardata,
6337 goto CONTINUE_CLASS;
6343 class_has_8bitchar +=
6344 add_to_class(classbits, &class_uchardata,
options, xoptions,
cb,
6352#ifdef SUPPORT_WIDE_CHARS
6359 if (class_uchardata > class_uchardata_base)
6362 if (lengthptr !=
NULL)
6364 *lengthptr += class_uchardata - class_uchardata_base;
6365 class_uchardata = class_uchardata_base;
6378 zerofirstcu = firstcu;
6379 zerofirstcuflags = firstcuflags;
6381 zeroreqcuflags = reqcuflags;
6406#ifdef SUPPORT_WIDE_CHARS
6411 xclass_has_prop || !should_flip_negation))
6413 if (match_all_or_no_wide_chars || (
6414#
if PCRE2_CODE_UNIT_WIDTH == 8
6422 class_uchardata +=
PRIV(
ord2utf)(0x100, class_uchardata);
6427#if PCRE2_CODE_UNIT_WIDTH == 16
6428 *class_uchardata++ = 0x100;
6429 *class_uchardata++ = 0xffffu;
6430#elif PCRE2_CODE_UNIT_WIDTH == 32
6431 *class_uchardata++ = 0x100;
6432 *class_uchardata++ = 0xffffffffu;
6439 *code = negate_class?
XCL_NOT:0;
6445 if (class_has_8bitchar > 0)
6450 if (negate_class && !xclass_has_prop)
6453 for (
int i = 0; i < 32; i++) classbits[i] = 255 ^ classbits[i];
6455 memcpy(code, classbits, 32);
6456 code = class_uchardata + (32 /
sizeof(
PCRE2_UCHAR));
6458 else code = class_uchardata;
6462 PUT(previous, 1, (
int)(code - previous));
6474 if (lengthptr ==
NULL)
6479 for (
int i = 0; i < 32; i++) classbits[i] = 255 ^ classbits[i];
6481 memcpy(code, classbits, 32);
6497 cb->had_accept = had_accept =
TRUE;
6498 for (oc = open_caps;
6502 if (lengthptr !=
NULL)
6518 cb->had_pruneorskip =
TRUE;
6522 *code++ = verbops[(meta -
META_MARK) >> 16];
6543 cb->had_pruneorskip =
TRUE;
6548 *code++ = verbops[(meta -
META_MARK) >> 16];
6550 verbarglen = *(++pptr);
6553 for (
int i = 0; i < (int)verbarglen; i++)
6556#ifdef SUPPORT_UNICODE
6557 if (utf) mclength =
PRIV(
ord2utf)(meta, mcbuffer);
else
6563 if (lengthptr !=
NULL) *lengthptr += mclength;
else
6567 verbculen += mclength;
6571 *tempcode = verbculen;
6582 *optionsptr =
options = *(++pptr);
6583 *xoptionsptr = xoptions = *(++pptr);
6585 greedy_non_default = greedy_default ^ 1;
6606 uint32_t length = *(++pptr);
6617 for (i = 0; i <
cb->names_found; i++, ng++)
6619 if (length == ng->
length &&
6628 goto GROUP_PROCESS_NOTE_EMPTY;
6638 if (i >=
cb->names_found)
6643 for (i = 1; i < length; i++)
6645 groupnumber = groupnumber * 10 +
name[i] -
CHAR_0;
6648 *errorcodeptr =
ERR61;
6657 *errorcodeptr =
ERR15;
6666 if (groupnumber == 0) groupnumber =
RREF_ANY;
6670 goto GROUP_PROCESS_NOTE_EMPTY;
6683 if (lengthptr ==
NULL && !find_dupname_details(
name, length, &index,
6684 &
count, errorcodeptr,
cb))
return 0;
6694 goto GROUP_PROCESS_NOTE_EMPTY;
6712 groupnumber = *(++pptr);
6713 if (groupnumber >
cb->bracount)
6715 *errorcodeptr =
ERR15;
6719 if (groupnumber >
cb->top_backref)
cb->top_backref = groupnumber;
6724 goto GROUP_PROCESS_NOTE_EMPTY;
6739 goto GROUP_PROCESS_NOTE_EMPTY;
6745 goto GROUP_PROCESS_NOTE_EMPTY;
6754 cb->assert_depth += 1;
6759 cb->assert_depth += 1;
6778 cb->assert_depth += 1;
6785 cb->assert_depth += 1;
6790 cb->assert_depth += 1;
6795 cb->assert_depth += 1;
6800 goto GROUP_PROCESS_NOTE_EMPTY;
6804 goto GROUP_PROCESS_NOTE_EMPTY;
6816 GROUP_PROCESS_NOTE_EMPTY:
6817 note_group_empty =
TRUE;
6820 cb->parens_depth += 1;
6824 tempreqvary =
cb->req_varyopt;
6825 length_prevgroup = 0;
6847 cb->parens_depth -= 1;
6853 if (note_group_empty && bravalue !=
OP_COND && group_return > 0)
6854 matched_char =
TRUE;
6859 cb->assert_depth -= 1;
6890 *errorcodeptr =
ERR54;
6907 *errorcodeptr =
ERR27;
6910 if (condcount == 1) subfirstcuflags = subreqcuflags =
REQ_NONE;
6911 else if (group_return > 0) matched_char =
TRUE;
6920 if (lengthptr !=
NULL)
6924 *errorcodeptr =
ERR20;
6927 *lengthptr += length_prevgroup - 2 - 2*
LINK_SIZE;
6952 zeroreqcuflags = reqcuflags;
6953 zerofirstcu = firstcu;
6954 zerofirstcuflags = firstcuflags;
6955 groupsetfirstcu =
FALSE;
6969 firstcu = subfirstcu;
6970 firstcuflags = subfirstcuflags;
6971 groupsetfirstcu =
TRUE;
6981 else if (subfirstcuflags < REQ_NONE && subreqcuflags >=
REQ_NONE)
6983 subreqcu = subfirstcu;
6984 subreqcuflags = subfirstcuflags | tempreqvary;
6993 reqcuflags = subreqcuflags;
7012 reqcuflags = subreqcuflags;
7028 uint32_t length = *(++pptr);
7039 for (
unsigned int i = 0; i <
cb->names_found; i++, ng++)
7041 if (length == ng->
length &&
7044 is_dupname = ng->
isdup;
7045 groupnumber = ng->
number;
7053 meta_arg = groupnumber;
7054 goto HANDLE_NUMERICAL_RECURSION;
7060 cb->backref_map |= (groupnumber < 32)? (1u << groupnumber) : 1;
7061 if (groupnumber >
cb->top_backref)
7062 cb->top_backref = groupnumber;
7068 if (groupnumber == 0)
7070 *errorcodeptr =
ERR15;
7080 meta_arg = groupnumber;
7081 goto HANDLE_SINGLE_REFERENCE;
7090 if (lengthptr ==
NULL && !find_dupname_details(
name, length, &index,
7091 &
count, errorcodeptr,
cb))
return 0;
7106 PUT(code, 1, pptr[1]);
7122 if (lengthptr !=
NULL)
7124 *lengthptr += pptr[3] + (1 + 4*
LINK_SIZE);
7137 uint32_t length = pptr[3];
7141 PUT(code, 1, pptr[1]);
7147 delimiter = *callout_string++ = *pp++;
7158 while (--length > 1)
7160 if (*pp == delimiter && pp[1] == delimiter)
7162 *callout_string++ = delimiter;
7166 else *callout_string++ = *pp++;
7172 PUT(code, 1 + 2*
LINK_SIZE, (
int)(callout_string - code));
7173 code = callout_string;
7185 repeat_min = *(++pptr);
7186 repeat_max = *(++pptr);
7210 if (previous_matched_char && repeat_min > 0) matched_char =
TRUE;
7215 reqvary = (repeat_min == repeat_max)? 0 :
REQ_VARY;
7220 if (repeat_min == 0)
7222 firstcu = zerofirstcu;
7223 firstcuflags = zerofirstcuflags;
7225 reqcuflags = zeroreqcuflags;
7237 possessive_quantifier =
TRUE;
7244 repeat_type = greedy_non_default;
7245 possessive_quantifier =
FALSE;
7249 repeat_type = greedy_default;
7250 possessive_quantifier =
FALSE;
7257 tempcode = previous;
7258 op_previous = *previous;
7265 switch (op_previous)
7277 if (repeat_max == 1 && repeat_min == 1)
goto END_REPEAT;
7278 op_type = chartypeoffset[op_previous -
OP_CHAR];
7282#ifdef MAYBE_UTF_MULTI
7283 if (utf && NOT_FIRSTCU(code[-1]))
7287 mclength = (uint32_t)(code - lastchar);
7300 mcbuffer[0] = code[-1];
7302 if (op_previous <= OP_CHARI && repeat_min > 1)
7304 reqcu = mcbuffer[0];
7305 reqcuflags =
cb->req_varyopt;
7309 goto OUTPUT_SINGLE_REPEAT;
7314#ifdef SUPPORT_WIDE_CHARS
7324 if (repeat_max == 0)
7329 if (repeat_max == 1 && repeat_min == 1)
goto END_REPEAT;
7335 else if (repeat_min == 0 && repeat_max == 1)
7364 if (repeat_max == 1 && repeat_min == 1 && !possessive_quantifier)
7376 int replicate = repeat_min;
7377 if (repeat_min == repeat_max) replicate--;
7383 if (lengthptr !=
NULL)
7389 *errorcodeptr =
ERR20;
7392 *lengthptr += delta;
7395 else for (
int i = 0; i < replicate; i++)
7405 if (repeat_min == repeat_max)
break;
7413 op_previous = *previous =
OP_BRA;
7443 int len = (int)(code - previous);
7447 if (repeat_max == 1 && repeat_min == 1 && !possessive_quantifier)
7479 if (repeat_min == 0)
7503 if (repeat_max == 0)
7508 brazeroptr = previous;
7530 linkoffset = (bralink ==
NULL)? 0 : (int)(previous - bralink);
7532 PUTINC(previous, 0, linkoffset);
7550 if (lengthptr !=
NULL)
7554 (
int)length_prevgroup) ||
7557 *errorcodeptr =
ERR20;
7560 *lengthptr += delta;
7569 if (groupsetfirstcu && reqcuflags >=
REQ_NONE)
7572 reqcuflags = firstcuflags;
7574 for (uint32_t i = 1; i < repeat_min; i++)
7600 if (lengthptr !=
NULL && repeat_max > 0)
7604 (
int)length_prevgroup + 1 + 2 + 2*
LINK_SIZE) ||
7607 *errorcodeptr =
ERR20;
7611 *lengthptr += delta;
7616 else for (uint32_t i = repeat_max; i >= 1; i--)
7627 linkoffset = (bralink ==
NULL)? 0 : (int)(code - bralink);
7629 PUTINC(code, 0, linkoffset);
7639 while (bralink !=
NULL)
7642 int linkoffset = (int)(code - bralink + 1);
7644 oldlinkoffset =
GET(bra, 1);
7645 bralink = (oldlinkoffset == 0)?
NULL : bralink - oldlinkoffset;
7647 PUTINC(code, 0, linkoffset);
7648 PUT(bra, 1, linkoffset);
7685 if (*bracode ==
OP_ONCE && possessive_quantifier) *bracode =
OP_BRA;
7703 if (lengthptr ==
NULL)
7712 if (possessive_quantifier)
7720 int nlen = (int)(code - bracode);
7727 PUT(bracode, 1, nlen);
7742 if (repeat_min < 2) possessive_quantifier =
FALSE;
7763 *errorcodeptr =
ERR10;
7768 int prop_type, prop_value;
7771 if (repeat_max == 1 && repeat_min == 1)
goto END_REPEAT;
7778 prop_type = previous[1];
7779 prop_value = previous[2];
7784 OUTPUT_SINGLE_REPEAT:
7785 prop_type = prop_value = -1;
7800 if (repeat_max == 0)
goto END_REPEAT;
7804 repeat_type += op_type;
7809 if (repeat_min == 0)
7812 else if (repeat_max == 1) *code++ =
OP_QUERY + repeat_type;
7815 *code++ =
OP_UPTO + repeat_type;
7825 else if (repeat_min == 1)
7828 *code++ =
OP_PLUS + repeat_type;
7832 if (repeat_max == 1)
goto END_REPEAT;
7833 *code++ =
OP_UPTO + repeat_type;
7834 PUT2INC(code, 0, repeat_max - 1);
7851 if (repeat_max != repeat_min)
7860 *code++ = op_previous;
7863 *code++ = prop_type;
7864 *code++ = prop_value;
7871 *code++ =
OP_STAR + repeat_type;
7874 repeat_max -= repeat_min;
7875 if (repeat_max == 1)
7881 *code++ =
OP_UPTO + repeat_type;
7897 *code++ = op_previous;
7900 *code++ = prop_type;
7901 *code++ = prop_value;
7921 if (possessive_quantifier)
7950#ifdef SUPPORT_UNICODE
7951 if (utf && HAS_EXTRALEN(tempcode[-1]))
7952 tempcode += GET_EXTRALEN(tempcode[-1]);
7964#ifdef SUPPORT_WIDE_CHARS
7966 tempcode +=
GET(tempcode, 1);
7977 len = (int)(code - tempcode);
7980 unsigned int repcode = *tempcode;
7986 if (repcode <
OP_CALLOUT && opcode_possessify[repcode] > 0)
7987 *tempcode = opcode_possessify[repcode];
8000 PUT(tempcode, 1,
len);
8010 cb->req_varyopt |= reqvary;
8030 if (meta_arg < 10)
offset =
cb->small_ref_offset[meta_arg];
8033 if (meta_arg >
cb->bracount)
8036 *errorcodeptr =
ERR15;
8046 HANDLE_SINGLE_REFERENCE:
8056 cb->backref_map |= (meta_arg < 32)? (1u << meta_arg) : 1;
8057 if (meta_arg >
cb->top_backref)
cb->top_backref = meta_arg;
8072 if (meta_arg >
cb->bracount)
8075 *errorcodeptr =
ERR15;
8078 HANDLE_NUMERICAL_RECURSION:
8080 PUT(code, 1, meta_arg);
8082 groupsetfirstcu =
FALSE;
8085 zerofirstcu = firstcu;
8086 zerofirstcuflags = firstcuflags;
8097 cb->lastcapture = meta_arg;
8098 goto GROUP_PROCESS_NOTE_EMPTY;
8122 matched_char =
TRUE;
8128 zerofirstcu = firstcu;
8129 zerofirstcuflags = firstcuflags;
8131 zeroreqcuflags = reqcuflags;
8136#ifdef SUPPORT_UNICODE
8139 uint32_t ptype = *(++pptr) >> 16;
8140 uint32_t pdata = *pptr & 0xffff;
8162 if (
cb->assert_depth > 0 && meta_arg ==
ESC_K &&
8165 *errorcodeptr =
ERR99;
8186#if PCRE2_CODE_UNIT_WIDTH == 32
8201 if (
cb->max_lookbehind == 0)
cb->max_lookbehind = 1;
8216#ifdef DEBUG_SHOW_PARSED
8217 fprintf(stderr,
"** Unrecognized parsed pattern item 0x%.8x\n", *pptr);
8219 *errorcodeptr =
ERR89;
8229 matched_char =
TRUE;
8236#ifdef SUPPORT_UNICODE
8242 PRIV(ucd_caseless_sets)[caseset] > 127))
8248 firstcuflags = zerofirstcuflags =
REQ_NONE;
8259 CLASS_CASELESS_CHAR:
8264#ifdef SUPPORT_UNICODE
8265 if (utf) mclength =
PRIV(
ord2utf)(meta, mcbuffer);
else
8292 zeroreqcuflags = reqcuflags;
8298 if (mclength == 1 || req_caseopt == 0)
8300 firstcu = mcbuffer[0];
8301 firstcuflags = req_caseopt;
8305 reqcuflags =
cb->req_varyopt;
8308 else firstcuflags = reqcuflags =
REQ_NONE;
8316 zerofirstcu = firstcu;
8317 zerofirstcuflags = firstcuflags;
8319 zeroreqcuflags = reqcuflags;
8320 if (mclength == 1 || req_caseopt == 0)
8323 reqcuflags = req_caseopt |
cb->req_varyopt;
8333 reset_caseful =
FALSE;
8379 uint32_t **pptrptr,
int *errorcodeptr, uint32_t skipunits,
8380 uint32_t *firstcuptr, uint32_t *firstcuflagsptr, uint32_t *reqcuptr,
8391uint32_t *pptr = *pptrptr;
8392uint32_t firstcu, reqcu;
8393uint32_t lookbehindlength;
8394uint32_t lookbehindminlength;
8395uint32_t firstcuflags, reqcuflags;
8396uint32_t branchfirstcu, branchreqcu;
8397uint32_t branchfirstcuflags, branchreqcuflags;
8403if (
cb->cx->stack_guard !=
NULL &&
8404 cb->cx->stack_guard(
cb->parens_depth,
cb->cx->stack_guard_data))
8406 *errorcodeptr=
ERR33;
8437 lookbehindminlength = *pptr;
8440else lookbehindlength = lookbehindminlength = 0;
8450 capitem.
number = capnumber;
8451 capitem.
next = open_caps;
8453 open_caps = &capitem;
8475 if (lookbehind && lookbehindlength > 0)
8478 lookbehindminlength == lookbehindlength)
8481 PUT2INC(code, 0, lookbehindlength);
8487 PUT2INC(code, 0, lookbehindminlength);
8488 PUT2INC(code, 0, lookbehindlength);
8496 if ((branch_return =
8497 compile_branch(&
options, &xoptions, &code, &pptr, errorcodeptr,
8498 &branchfirstcu, &branchfirstcuflags, &branchreqcu, &branchreqcuflags,
8499 &bc, open_caps,
cb, (lengthptr ==
NULL)?
NULL : &length)) == 0)
8504 if (branch_return < 0) okreturn = -1;
8508 if (lengthptr ==
NULL)
8513 if (*last_branch !=
OP_ALT)
8515 firstcu = branchfirstcu;
8516 firstcuflags = branchfirstcuflags;
8517 reqcu = branchreqcu;
8518 reqcuflags = branchreqcuflags;
8532 if (firstcuflags != branchfirstcuflags || firstcu != branchfirstcu)
8539 reqcuflags = firstcuflags;
8551 branchreqcu = branchfirstcu;
8552 branchreqcuflags = branchfirstcuflags;
8558 reqcu != branchreqcu)
8562 reqcu = branchreqcu;
8563 reqcuflags |= branchreqcuflags;
8578 if (lengthptr ==
NULL)
8580 PCRE2_SIZE branch_length = code - last_branch;
8584 PUT(last_branch, 1, branch_length);
8585 branch_length = prev_length;
8586 last_branch -= branch_length;
8588 while (branch_length > 0);
8594 PUT(code, 1, (
int)(code - start_bracket));
8601 *firstcuptr = firstcu;
8602 *firstcuflagsptr = firstcuflags;
8604 *reqcuflagsptr = reqcuflags;
8605 if (lengthptr !=
NULL)
8609 *errorcodeptr =
ERR20;
8612 *lengthptr += length;
8626 if (lengthptr !=
NULL)
8628 code = *codeptr + 1 +
LINK_SIZE + skipunits;
8634 PUT(code, 1, (
int)(code - last_branch));
8694 int atomcount,
BOOL inassert)
8706 if (!is_anchored(scode, bracket_map,
cb, atomcount, inassert))
8716 uint32_t new_map = bracket_map | ((
n < 32)? (1u <<
n) : 1);
8717 if (!is_anchored(scode, new_map,
cb, atomcount, inassert))
return FALSE;
8724 if (!is_anchored(scode, bracket_map,
cb, atomcount,
TRUE))
return FALSE;
8732 if (!is_anchored(scode, bracket_map,
cb, atomcount, inassert))
8740 if (!is_anchored(scode, bracket_map,
cb, atomcount + 1, inassert))
8754 if (scode[1] !=
OP_ALLANY || (bracket_map &
cb->backref_map) != 0 ||
8755 atomcount > 0 ||
cb->had_pruneorskip || inassert ||
8764 code +=
GET(code, 1);
8799 int atomcount,
BOOL inassert)
8830 if (!is_startline(scode, bracket_map,
cb, atomcount,
TRUE))
return FALSE;
8831 do scode +=
GET(scode, 1);
while (*scode ==
OP_ALT);
8835 scode = first_significant_code(scode,
FALSE);
8844 if (!is_startline(scode, bracket_map,
cb, atomcount, inassert))
8854 unsigned int new_map = bracket_map | ((
n < 32)? (1u <<
n) : 1);
8855 if (!is_startline(scode, new_map,
cb, atomcount, inassert))
return FALSE;
8862 if (!is_startline(scode, bracket_map,
cb, atomcount,
TRUE))
8870 if (!is_startline(scode, bracket_map,
cb, atomcount + 1, inassert))
8883 if (scode[1] !=
OP_ANY || (bracket_map &
cb->backref_map) != 0 ||
8884 atomcount > 0 ||
cb->had_pruneorskip || inassert ||
8897 code +=
GET(code, 1);
8982#ifdef MAYBE_UTF_MULTI
9041 if (HAS_EXTRALEN(code[-1])) code += GET_EXTRALEN(code[-1]);
9076find_firstassertedcu(
PCRE2_SPTR code, uint32_t *
flags, uint32_t inassert)
9105 d = find_firstassertedcu(scode, &dflags, inassert +
9108 if (cflags >=
REQ_NONE) { c = d; cflags = dflags; }
9109 else if (c != d || cflags != dflags)
return 0;
9120 if (inassert == 0)
return 0;
9121 if (cflags >=
REQ_NONE) { c = scode[1]; cflags = 0; }
9122 else if (c != scode[1])
return 0;
9133 if (inassert == 0)
return 0;
9139#ifdef SUPPORT_UNICODE
9140#if PCRE2_CODE_UNIT_WIDTH == 8
9141 if (scode[1] >= 0x80)
return 0;
9142#elif PCRE2_CODE_UNIT_WIDTH == 16
9143 if (scode[1] >= 0xd800 && scode[1] <= 0xdfff)
return 0;
9148 else if (c != scode[1])
return 0;
9152 code +=
GET(code, 1);
9182 unsigned int groupno, uint32_t tablecount)
9187for (i = 0; i < tablecount; i++)
9190 if (crc == 0 && slot[
IMM2_SIZE+length] != 0)
9201 CU2BYTES((tablecount - i) *
cb->name_entry_size));
9207 slot +=
cb->name_entry_size;
9210PUT2(slot, 0, groupno);
9250parsed_skip(uint32_t *pptr, uint32_t skiptype)
9252uint32_t nestlevel = 0;
9325 if (nestlevel == 0 && skiptype ==
PSKIP_ALT)
return pptr;
9329 if (nestlevel == 0)
return pptr;
9336 meta = (meta >> 16) & 0x7fff;
9337 if (meta >=
sizeof(meta_extra_lengths))
return NULL;
9338 pptr += meta_extra_lengths[meta];
9369get_grouplength(uint32_t **pptrptr,
int *minptr,
BOOL isinline,
int *errcodeptr,
9372uint32_t *gi =
cb->groupinfo + 2 * group;
9373int branchlength, branchminlength;
9374int grouplength = -1;
9384 uint32_t groupinfo = gi[0];
9388 if (isinline) *pptrptr = parsed_skip(*pptrptr,
PSKIP_KET);
9398 branchlength = get_branchlength(pptrptr, &branchminlength, errcodeptr, lcptr,
9400 if (branchlength < 0)
goto ISNOTFIXED;
9401 if (branchlength > grouplength) grouplength = branchlength;
9402 if (branchminlength < groupminlength) groupminlength = branchminlength;
9410 gi[1] = groupminlength;
9413*minptr = groupminlength;
9443get_branchlength(uint32_t **pptrptr,
int *minptr,
int *errcodeptr,
int *lcptr,
9446int branchlength = 0;
9447int branchminlength = 0;
9448int grouplength, groupminlength;
9449uint32_t lastitemlength = 0;
9450uint32_t lastitemminlength = 0;
9451uint32_t *pptr = *pptrptr;
9459if ((*lcptr)++ > 2000)
9461 *errcodeptr =
ERR35;
9470 uint32_t *gptr, *gptrend;
9473 uint32_t itemlength = 0;
9474 uint32_t itemminlength = 0;
9479 itemlength = itemminlength = 1;
9494 if (pptr ==
NULL)
goto PARSED_SKIP_FAILED;
9502 pptr += pptr[1] + 1;
9518 itemlength = itemminlength = 1;
9524 itemlength = itemminlength = 1;
9526 if (pptr ==
NULL)
goto PARSED_SKIP_FAILED;
9531 itemlength = itemminlength = 1;
9548 if (escape ==
ESC_X)
return -1;
9549 if (escape ==
ESC_R)
9556#if PCRE2_CODE_UNIT_WIDTH != 32
9559 *errcodeptr =
ERR36;
9563 itemlength = itemminlength = 1;
9564 if (escape ==
ESC_p || escape ==
ESC_P) pptr++;
9574 *errcodeptr = check_lookbehinds(pptr + 1, &pptr, recurses,
cb, lcptr);
9575 if (*errcodeptr != 0)
return -1;
9610 if (!set_lookbehind_lengths(&pptr, errcodeptr, lcptr, recurses,
cb))
9632 uint32_t length = *(++pptr);
9636 for (i = 0; i <
cb->names_found; i++, ng++)
9641 is_dupname = ng->
isdup;
9648 *errcodeptr =
ERR15;
9659 goto RECURSE_OR_BACKREF_LENGTH;
9674 offset =
cb->small_ref_offset[group];
9675 goto RECURSE_OR_BACKREF_LENGTH;
9688 RECURSE_OR_BACKREF_LENGTH:
9689 if (group >
cb->bracount)
9692 *errcodeptr =
ERR15;
9695 if (group == 0)
goto ISNOTFIXED;
9696 for (gptr =
cb->parsed_pattern; *gptr !=
META_END; gptr++)
9705 gptrend = parsed_skip(gptr + 1,
PSKIP_KET);
9706 if (gptrend ==
NULL)
goto PARSED_SKIP_FAILED;
9707 if (pptr > gptr && pptr < gptrend)
goto ISNOTFIXED;
9709 if (r !=
NULL)
goto ISNOTFIXED;
9710 this_recurse.
prev = recurses;
9719 grouplength = get_grouplength(&gptr, &groupminlength,
FALSE, errcodeptr,
9720 lcptr, group, &this_recurse,
cb);
9721 if (grouplength < 0)
9723 if (*errcodeptr == 0)
goto ISNOTFIXED;
9726 itemlength = grouplength;
9727 itemminlength = groupminlength;
9735 pptr = parsed_skip(pptr + 1,
PSKIP_KET);
9765 grouplength = get_grouplength(&pptr, &groupminlength,
TRUE, errcodeptr,
9766 lcptr, group, recurses,
cb);
9767 if (grouplength < 0)
return -1;
9768 itemlength = grouplength;
9769 itemminlength = groupminlength;
9792 if (lastitemlength != 0 &&
9794 (
INT_MAX - branchlength)/lastitemlength <
max - 1)
9796 *errcodeptr =
ERR87;
9799 if (
min == 0) branchminlength -= lastitemminlength;
9800 else itemminlength = (
min - 1) * lastitemminlength;
9801 if (
max == 0) branchlength -= lastitemlength;
9802 else itemlength = (
max - 1) * lastitemlength;
9811 *errcodeptr =
ERR25;
9820 if (
INT_MAX - branchlength < (
int)itemlength ||
9823 *errcodeptr =
ERR87;
9827 branchminlength += itemminlength;
9831 lastitemlength = itemlength;
9832 lastitemminlength = itemminlength;
9837*minptr = branchminlength;
9873set_lookbehind_lengths(uint32_t **pptrptr,
int *errcodeptr,
int *lcptr,
9877uint32_t *bptr = *pptrptr;
9878uint32_t *gbptr = bptr;
9892 int branchlength, branchminlength;
9895 branchlength = get_branchlength(pptrptr, &branchminlength, errcodeptr, lcptr,
9898 if (branchlength < 0)
9901 if (*errcodeptr == 0) *errcodeptr =
ERR25;
9906 if (branchlength != branchminlength) variable =
TRUE;
9907 if (branchminlength < minlength) minlength = branchminlength;
9908 if (branchlength > maxlength) maxlength = branchlength;
9909 if (branchlength >
cb->max_lookbehind)
cb->max_lookbehind = branchlength;
9910 *bptr |= branchlength;
9924 gbptr[1] = minlength;
9925 if ((uint32_t)maxlength >
cb->max_varlookbehind)
9966check_lookbehinds(uint32_t *pptr, uint32_t **retptr,
9989 if (--nestlevel < 0)
9991 if (retptr !=
NULL) *retptr = pptr;
10089 pptr += 1 + pptr[1];
10095 if (!set_lookbehind_lengths(&pptr, &errorcode, lcptr, recurses,
cb))
10132BOOL zero_terminated;
10135const uint8_t *tables;
10148uint32_t firstcuflags, reqcuflags;
10149uint32_t firstcu, reqcu;
10150uint32_t setflags = 0;
10152uint32_t skipatstart;
10181if (errorptr ==
NULL || erroroffset ==
NULL)
return NULL;
10187if (pattern ==
NULL)
10189 if (patlen == 0) pattern = (
PCRE2_SPTR)
"";
else
10198if (ccontext ==
NULL)
10228if (patlen > ccontext->max_pattern_length)
10240tables = (ccontext->tables !=
NULL)? ccontext->tables :
PRIV(default_tables);
10247cb.assert_depth = 0;
10251cb.end_pattern = pattern + patlen;
10253cb.external_flags = 0;
10255cb.groupinfo = stack_groupinfo;
10258cb.max_lookbehind = 0;
10259cb.max_varlookbehind = ccontext->max_varlookbehind;
10260cb.name_entry_size = 0;
10262cb.named_groups = named_groups;
10265cb.parens_depth = 0;
10266cb.parsed_pattern = stack_parsed_pattern;
10268cb.start_code = cworkspace;
10269cb.start_pattern = pattern;
10270cb.start_workspace = cworkspace;
10290for (i = 0; i < 10; i++)
cb.small_ref_offset[i] =
PCRE2_UNSET;
10301#ifdef SUPPORT_VALGRIND
10302if (zero_terminated) VALGRIND_MAKE_MEM_NOACCESS(pattern + patlen,
CU2BYTES(1));
10310 while (patlen - skipatstart >= 2 &&
10314 for (i = 0; i <
sizeof(pso_list)/
sizeof(
pso); i++)
10317 const pso *
p = pso_list + i;
10319 if (patlen - skipatstart - 2 >=
p->length &&
10323 skipatstart +=
p->length + 2;
10327 cb.external_options |=
p->value;
10331 setflags |=
p->value;
10335 newline =
p->value;
10353 goto HAD_EARLY_ERROR;
10364 goto HAD_EARLY_ERROR;
10366 if (
p->type ==
PSO_LIMH) limit_heap = c;
10367 else if (
p->type ==
PSO_LIMM) limit_match = c;
10368 else limit_depth = c;
10369 skipatstart += pp - skipatstart;
10375 if (i >=
sizeof(pso_list)/
sizeof(
pso))
break;
10385#ifndef SUPPORT_UNICODE
10389 goto HAD_EARLY_ERROR;
10404 goto HAD_EARLY_ERROR;
10407 (errorcode =
PRIV(
valid_utf)(pattern, patlen, erroroffset)) != 0)
10410#if PCRE2_CODE_UNIT_WIDTH == 16
10414 goto HAD_EARLY_ERROR;
10425 goto HAD_EARLY_ERROR;
10430if (bsr == 0) bsr = ccontext->bsr_convention;
10434if (newline == 0) newline = ccontext->newline_convention;
10469 goto HAD_EARLY_ERROR;
10485#if PCRE2_CODE_UNIT_WIDTH == 32
10499parsed_size_needed = patlen - skipatstart + big32count;
10501if ((ccontext->extra_options &
10503 parsed_size_needed += 4;
10506 parsed_size_needed = (parsed_size_needed + 1) * 5;
10510 uint32_t *heap_parsed_pattern = ccontext->memctl.malloc(
10511 (parsed_size_needed + 1) *
sizeof(uint32_t), ccontext->memctl.memory_data);
10512 if (heap_parsed_pattern ==
NULL)
10517 cb.parsed_pattern = heap_parsed_pattern;
10519cb.parsed_pattern_end =
cb.parsed_pattern + parsed_size_needed + 1;
10523errorcode = parse_regex(
ptr,
cb.external_options, &has_lookbehind, &
cb);
10524if (errorcode != 0)
goto HAD_CB_ERROR;
10541 cb.groupinfo = ccontext->memctl.malloc(
10542 (2 * (
cb.bracount + 1))*
sizeof(uint32_t), ccontext->memctl.memory_data);
10543 if (
cb.groupinfo ==
NULL)
10546 cb.erroroffset = 0;
10550 memset(
cb.groupinfo, 0, (2 *
cb.bracount + 1) *
sizeof(uint32_t));
10551 errorcode = check_lookbehinds(
cb.parsed_pattern,
NULL,
NULL, &
cb, &loopcount);
10552 if (errorcode != 0)
goto HAD_CB_ERROR;
10557#ifdef DEBUG_SHOW_PARSED
10558fprintf(stderr,
"+++ Pre-scan complete:\n");
10564#ifdef DEBUG_SHOW_CAPTURES
10567 fprintf(stderr,
"+++Captures: %d\n",
cb.bracount);
10568 for (i = 0; i <
cb.names_found; i++, ng++)
10587cb.erroroffset = patlen;
10588pptr =
cb.parsed_pattern;
10592(
void)compile_regex(
cb.external_options, ccontext->extra_options, &code, &pptr,
10593 &errorcode, 0, &firstcu, &firstcuflags, &reqcu, &reqcuflags,
NULL,
NULL,
10596if (errorcode != 0)
goto HAD_CB_ERROR;
10600if (length > MAX_PATTERN_SIZE)
10615if (re_blocksize > ccontext->max_pattern_compiled_length)
10622 ccontext->
memctl.
malloc(re_blocksize, ccontext->memctl.memory_data);
10636re->
memctl = ccontext->memctl;
10645re->
flags = PCRE2_CODE_UNIT_WIDTH/8 |
cb.external_flags | setflags;
10671cb.parens_depth = 0;
10672cb.assert_depth = 0;
10675cb.start_code = codestart;
10683if (
cb.names_found > 0)
10686 for (i = 0; i <
cb.names_found; i++, ng++)
10694pptr =
cb.parsed_pattern;
10697regexrc = compile_regex(re->
overall_options, ccontext->extra_options, &code,
10698 &pptr, &errorcode, 0, &firstcu, &firstcuflags, &reqcu, &reqcuflags,
NULL,
10718usedlength = code - codestart;
10719if (usedlength > length) errorcode =
ERR23;
else
10722#ifdef SUPPORT_VALGRIND
10723 VALGRIND_MAKE_MEM_NOACCESS(code,
CU2BYTES(length - usedlength));
10731#define RSCAN_CACHE_SIZE 8
10733if (errorcode == 0 &&
cb.had_recurse)
10737 unsigned int ccount = 0;
10741 for (rcode = (
PCRE2_UCHAR *)find_recurse(codestart, utf);
10745 int p, groupnumber;
10747 groupnumber = (int)
GET(rcode, 1);
10748 if (groupnumber == 0) rgroup = codestart;
else
10752 for (i = 0,
p =
start; i < ccount; i++,
p = (
p + 1) & 7)
10754 if (groupnumber == rc[
p].groupnumber)
10756 rgroup = rc[
p].group;
10764 if (groupnumber > rc[
p].groupnumber) search_from = rc[
p].group;
10767 if (rgroup ==
NULL)
10770 if (rgroup ==
NULL)
10776 rc[
start].groupnumber = groupnumber;
10777 rc[
start].group = rgroup;
10782 PUT(rcode, 1, rgroup - codestart);
10789#ifdef DEBUG_CALL_PRINTINT
10791fprintf(stderr,
"Length=%lu Used=%lu\n", length, usedlength);
10809if (errorcode != 0)
goto HAD_CB_ERROR;
10818 is_anchored(codestart, 0, &
cb, 0,
FALSE))
10830 int minminlength = 0;
10837 firstcu = find_firstassertedcu(codestart, &firstcuflags, 0);
10852 if (firstcu < 128 || (!utf && !ucp && firstcu < 255))
10861#ifdef SUPPORT_UNICODE
10862#if PCRE2_CODE_UNIT_WIDTH == 8
10881 is_startline(codestart, 0, &
cb, 0,
FALSE))
10891#if PCRE2_CODE_UNIT_WIDTH == 16
10894 (firstcu & 0xf800) != 0xd800 ||
10895 (reqcu & 0xfc00) != 0xdc00)
10896#elif PCRE2_CODE_UNIT_WIDTH == 8
10899 (firstcu & 0x80) == 0 ||
10900 (reqcu & 0x80) == 0)
10919 if (reqcu < 128 || (!utf && !ucp && reqcu < 255))
10923#ifdef SUPPORT_UNICODE
10924#if PCRE2_CODE_UNIT_WIDTH == 8
10965#ifdef SUPPORT_VALGRIND
10966if (zero_terminated) VALGRIND_MAKE_MEM_DEFINED(pattern + patlen,
CU2BYTES(1));
10968if (
cb.parsed_pattern != stack_parsed_pattern)
10969 ccontext->memctl.free(
cb.parsed_pattern, ccontext->memctl.memory_data);
10971 ccontext->memctl.free((
void *)
cb.named_groups, ccontext->memctl.memory_data);
10972if (
cb.groupinfo != stack_groupinfo)
10973 ccontext->memctl.free((
void *)
cb.groupinfo, ccontext->memctl.memory_data);
10983ptr = pattern +
cb.erroroffset;
10986*erroroffset =
ptr - pattern;
10989*errorptr = errorcode;
fprintf($stream, string $format, mixed ... $values)
count(Countable|array $value, int $mode=COUNT_NORMAL)
memset(ptr, 0, type->size)
#define PCRE2_ALLOW_EMPTY_CLASS
#define pcre2_code_copy_with_tables
#define PCRE2_ZERO_TERMINATED
#define PCRE2_EXTRA_ALT_BSUX
#define PCRE2_BSR_ANYCRLF
#define PCRE2_EXTRA_ALLOW_SURROGATE_ESCAPES
#define PCRE2_ALT_VERBNAMES
#define PCRE2_EXTRA_ESCAPED_CR_IS_LF
#define PCRE2_EXTRA_ASCII_POSIX
#define PCRE2_AUTO_CALLOUT
#define PCRE2_NO_AUTO_POSSESS
#define PCRE2_MATCH_INVALID_UTF
#define PCRE2_NEWLINE_ANYCRLF
#define PCRE2_EXTENDED_MORE
#define PCRE2_EXTRA_ASCII_BSS
#define PCRE2_EXTRA_ASCII_BSD
#define PCRE2_MATCH_UNSET_BACKREF
#define PCRE2_NO_DOTSTAR_ANCHOR
#define PCRE2_EXTRA_MATCH_WORD
#define PCRE2_EXTRA_CASELESS_RESTRICT
#define PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL
#define PCRE2_EXTRA_MATCH_LINE
#define PCRE2_CALL_CONVENTION
#define PCRE2_NEWLINE_CRLF
#define PCRE2_NO_AUTO_CAPTURE
#define PCRE2_EXTRA_ASCII_DIGIT
#define PCRE2_NEVER_BACKSLASH_C
#define PCRE2_NEWLINE_NUL
#define PCRE2_EXTRA_ASCII_BSW
#define PCRE2_NO_UTF_CHECK
#define PCRE2_BSR_UNICODE
#define PCRE2_NO_START_OPTIMIZE
#define PCRE2_NEWLINE_ANY
#define PCRE2_EXTRA_ALLOW_LOOKAROUND_BSK
#define pcre2_compile_context
int PRIV auto_possessify(PCRE2_UCHAR *code, const compile_block *cb)
BOOL PRIV ckd_smul(PCRE2_SIZE *r, int a, int b)
#define GI_FIXED_LENGTH_MASK
#define PUBLIC_LITERAL_COMPILE_EXTRA_OPTIONS
#define META_LOOKBEHIND_NA
#define META_RANGE_ESCAPED
#define PARSE_TRACKED_OPTIONS
#define PUBLIC_COMPILE_EXTRA_OPTIONS
#define META_COND_VERSION
#define META_LOOKBEHINDNOT
#define META_RANGE_LITERAL
#define META_COND_RNUMBER
#define META_ATOMIC_SCRIPT_RUN
#define META_RECURSE_BYNAME
#define META_BACKREF_BYNAME
#define GI_SET_FIXED_LENGTH
#define META_CLASS_EMPTY_NOT
#define PARSED_PATTERN_DEFAULT_SIZE
#define PUBLIC_COMPILE_OPTIONS
#define META_ASTERISK_QUERY
#define META_LOOKAHEAD_NA
#define GI_NOT_FIXED_LENGTH
#define STRING_UTFn_RIGHTPAR
#define PARSED_LITERAL(c, p)
#define META_LOOKAHEADNOT
#define META_ASTERISK_PLUS
#define GETPLUSOFFSET(s, p)
int PRIV check_escape(PCRE2_SPTR *ptrptr, PCRE2_SPTR ptrend, uint32_t *chptr, int *errorcodeptr, uint32_t options, uint32_t xoptions, BOOL isclass, compile_block *cb)
#define META_CALLOUT_STRING
#define WORK_SIZE_SAFETY_MARGIN
#define META_CALLOUT_NUMBER
#define META_MINMAX_QUERY
#define READPLUSOFFSET(s, p)
#define PARSE_TRACKED_EXTRA_OPTIONS
#define PUBLIC_LITERAL_COMPILE_OPTIONS
#define COMPILE_WORK_SIZE
#define NAMED_GROUP_LIST_SIZE
#define GROUPINFO_DEFAULT_SIZE
PCRE2_SPTR PRIV find_bracket(PCRE2_SPTR code, BOOL utf, int number)
#define CHAR_LESS_THAN_SIGN
#define STRING_CRLF_RIGHTPAR
@ OP_NOT_UCP_WORD_BOUNDARY
#define STRING_NUL_RIGHTPAR
#define STRING_BSR_ANYCRLF_RIGHTPAR
#define STRING_WEIRD_STARTWORD
#define STRING_LIMIT_HEAP_EQ
#define PCRE2_FIRSTMAPSET
#define STRING_positive_lookbehind0
#define STRING_NO_AUTO_POSSESS_RIGHTPAR
#define STRING_NO_JIT_RIGHTPAR
#define STRING_NOTEMPTY_ATSTART_RIGHTPAR
#define PCRE2_NE_ATST_SET
#define STRING_non_atomic_positive_lookahead0
#define CHAR_VERTICAL_LINE
#define PCRE2_FIRSTCASELESS
#define CHAR_GRAVE_ACCENT
#define STRING_NO_START_OPT_RIGHTPAR
#define STRING_negative_lookahead0
#define CHAR_LEFT_SQUARE_BRACKET
#define STRING_NOTEMPTY_RIGHTPAR
#define CHAR_QUESTION_MARK
#define PCRE2_DEREF_TABLES
#define PCRE2_LASTCASELESS
#define CHAR_EXCLAMATION_MARK
#define MAX_UTF_CODE_POINT
#define STRING_scriptextensions
#define CHAR_COMMERCIAL_AT
#define STRING_negative_lookbehind0
#define CHAR_RIGHT_PARENTHESIS
#define STRING_ANYCRLF_RIGHTPAR
#define STRING_CR_RIGHTPAR
#define STRING_non_atomic_positive_lookbehind0
#define CHAR_RIGHT_SQUARE_BRACKET
#define STRING_script_run0
#define CHAR_RIGHT_CURLY_BRACKET
#define CHAR_LEFT_PARENTHESIS
#define CHAR_CIRCUMFLEX_ACCENT
#define CHAR_LEFT_CURLY_BRACKET
#define STRING_LIMIT_MATCH_EQ
#define COMPILE_ERROR_BASE
#define STRING_WEIRD_ENDWORD
#define STRING_UTF_RIGHTPAR
#define STRING_UCP_RIGHTPAR
#define STRING_NO_DOTSTAR_ANCHOR_RIGHTPAR
#define CHAR_GREATER_THAN_SIGN
#define STRING_atomic_script_run
#define UCD_OTHERCASE(ch)
#define PCRE2_MATCH_EMPTY
#define STRING_LIMIT_DEPTH_EQ
#define STRING_ANY_RIGHTPAR
#define STRING_LIMIT_RECURSION_EQ
#define STRING_positive_lookahead0
#define PCRE2_NOTEMPTY_SET
#define STRING_BSR_UNICODE_RIGHTPAR
#define STRING_LF_RIGHTPAR
#define TABLE_GET(c, table, default)
#define GETCHARINCTEST(c, eptr)
void PRIV jit_free(void *executable_jit, pcre2_memctl *memctl)
unsigned int PRIV ord2utf(uint32_t cvalue, PCRE2_UCHAR *buffer)
int PRIV strcmp_c8(PCRE2_SPTR str1, const char *str2)
int PRIV strncmp_c8(PCRE2_SPTR str1, const char *str2, size_t len)
int PRIV study(pcre2_real_code *re)
int PRIV valid_utf(PCRE2_SPTR string, PCRE2_SIZE length, PCRE2_SIZE *erroroffset)
BOOL PRIV xclass(uint32_t c, PCRE2_SPTR data, BOOL utf)
unsigned const char * end
PHP_JSON_API size_t int options
PCRE2_UCHAR * current_branch
struct branch_chain * outer
struct open_capitem * next
struct parsed_recurse_check * prev
void *(* malloc)(size_t, void *)
uint16_t newline_convention
CODE_BLOCKSIZE_TYPE blocksize
strncmp(string $string1, string $string2, int $length)
ZEND_API void(ZEND_FASTCALL *zend_touch_vm_stack_data)(void *vm_stack_data)