50 #define PSSTART start_pattern
51 #define PSEND end_pattern
71 #define SETBIT(a,b) a[(b)/8] |= (1 << ((b)&7))
78 #define OFLOW_MAX (INT_MAX - 20)
84 const pcre_uint32 *,
unsigned int);
88 pcre_uint32 *, pcre_int32 *, pcre_uint32 *, pcre_int32 *,
branch_chain *,
115 #define COMPILE_WORK_SIZE (2048*LINK_SIZE)
116 #define COMPILE_WORK_SIZE_MAX (100*COMPILE_WORK_SIZE)
121 #define WORK_SIZE_SAFETY_MARGIN (100)
125 #define REQ_CASELESS (1 << 0)
126 #define REQ_VARY (1 << 1)
128 #define REQ_UNSET (-2)
129 #define REQ_NONE (-1)
133 #define UTF_LENGTH 0x10000000l
145 static const short int escapes[] = {
190 static const short int escapes[] = {
191 0, 0, 0,
'.',
'<',
'(',
'+',
'|',
192 '&', 0, 0, 0, 0, 0, 0, 0,
193 0, 0,
'!',
'$',
'*',
')',
';',
'~',
194 '-',
'/', 0, 0, 0, 0, 0, 0,
195 0, 0,
'|',
',',
'%',
'_',
'>',
'?',
196 0, 0, 0, 0, 0, 0, 0, 0,
197 0,
'`',
':',
'#',
'@',
'\'',
'=',
'"',
199 -
ESC_h, 0, 0,
'{', 0, 0, 0, 0,
201 0,
ESC_r, 0,
'}', 0, 0, 0, 0,
203 0,-
ESC_z, 0, 0, 0,
'[', 0, 0,
204 0, 0, 0, 0, 0, 0, 0, 0,
205 0, 0, 0, 0, 0,
']',
'=',
'-',
207 -
ESC_H, 0, 0, 0, 0, 0, 0, 0,
211 0,-
ESC_Z, 0, 0, 0, 0, 0, 0,
212 0, 0, 0, 0, 0, 0, 0, 0,
213 0, 0, 0, 0, 0, 0, 0, 0
230 static const char verbnames[] =
253 static const int verbcount =
sizeof(verbs)/
sizeof(
verbitem);
262 static const char posix_names[] =
268 static const pcre_uint8 posix_name_lengths[] = {
269 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 6, 0 };
281 static const int posix_class_maps[] = {
366 static const pcre_uchar *posix_substitutes[] = {
397 #define POSIX_SUBSIZE (sizeof(posix_substitutes) / sizeof(pcre_uchar *))
400 #define STRING(a) # a
401 #define XSTRING(s) STRING(s)
417 static const char error_texts[] =
419 "\\ at end of pattern\0"
420 "\\c at end of pattern\0"
421 "unrecognized character follows \\\0"
422 "numbers out of order in {} quantifier\0"
424 "number too big in {} quantifier\0"
425 "missing terminating ] for character class\0"
426 "invalid escape sequence in character class\0"
427 "range out of order in character class\0"
428 "nothing to repeat\0"
430 "operand of unlimited repeat could match the empty string\0"
431 "internal error: unexpected repeat\0"
432 "unrecognized character after (? or (?-\0"
433 "POSIX named classes are supported only within a class\0"
436 "reference to non-existent subpattern\0"
437 "erroffset passed as NULL\0"
438 "unknown option bit(s) set\0"
439 "missing ) after comment\0"
440 "parentheses nested too deeply\0"
442 "regular expression is too large\0"
443 "failed to get memory\0"
444 "unmatched parentheses\0"
445 "internal error: code overflow\0"
446 "unrecognized character after (?<\0"
448 "lookbehind assertion is not fixed length\0"
449 "malformed number or name after (?(\0"
450 "conditional group contains more than two branches\0"
451 "assertion expected after (?(\0"
452 "(?R or (?[+-]digits must be followed by )\0"
454 "unknown POSIX class name\0"
455 "POSIX collating elements are not supported\0"
456 "this version of PCRE is compiled without UTF support\0"
458 "character value in \\x{...} sequence is too large\0"
460 "invalid condition (?(0)\0"
461 "\\C not allowed in lookbehind assertion\0"
462 "PCRE does not support \\L, \\l, \\N{name}, \\U, or \\u\0"
463 "number after (?C is > 255\0"
464 "closing ) for (?C expected\0"
466 "recursive call could loop indefinitely\0"
467 "unrecognized character after (?P\0"
468 "syntax error in subpattern name (missing terminator)\0"
469 "two named subpatterns have the same name\0"
470 "invalid UTF-8 string\0"
472 "support for \\P, \\p, and \\X has not been compiled\0"
473 "malformed \\P or \\p sequence\0"
474 "unknown property name after \\P or \\p\0"
475 "subpattern name is too long (maximum " XSTRING(MAX_NAME_SIZE)
" characters)\0"
476 "too many named subpatterns (maximum " XSTRING(MAX_NAME_COUNT)
")\0"
478 "repeated subpattern is too long\0"
479 "octal value is greater than \\377 in 8-bit non-UTF-8 mode\0"
480 "internal error: overran compiling workspace\0"
481 "internal error: previously-checked referenced subpattern not found\0"
482 "DEFINE group contains more than one branch\0"
484 "repeating a DEFINE group is not allowed\0"
485 "inconsistent NEWLINE options\0"
486 "\\g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number\0"
487 "a numbered reference must not be zero\0"
488 "an argument is not allowed for (*ACCEPT), (*FAIL), or (*COMMIT)\0"
490 "(*VERB) not recognized\0"
491 "number is too big\0"
492 "subpattern name expected\0"
493 "digit expected after (?+\0"
494 "] is an invalid data character in JavaScript compatibility mode\0"
496 "different names for subpatterns of the same number are not allowed\0"
497 "(*MARK) must have an argument\0"
498 "this version of PCRE is not compiled with Unicode property support\0"
499 "\\c must be followed by an ASCII character\0"
500 "\\k is not followed by a braced, angle-bracketed, or quoted name\0"
502 "internal error: unknown opcode in find_fixedlength()\0"
503 "\\N is not supported in a class\0"
504 "too many forward references\0"
505 "disallowed Unicode code point (>= 0xd800 && <= 0xdfff)\0"
506 "invalid UTF-16 string\0"
508 "name is too long in (*MARK), (*PRUNE), (*SKIP), or (*THEN)\0"
509 "character value in \\u.... sequence is too large\0"
510 "invalid UTF-32 string\0"
533 #define IS_DIGIT(x) ((x) >= CHAR_0 && (x) <= CHAR_9)
542 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
543 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
544 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
545 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
546 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
547 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
548 0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,
549 0x0c,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,
550 0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00,
551 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
552 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
553 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
554 0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00,
555 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
556 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
557 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
558 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
559 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
560 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
561 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
562 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
563 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
564 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
565 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
566 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
567 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
568 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
569 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
570 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
571 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
572 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
573 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
581 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
582 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
583 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
584 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
585 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
586 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
587 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
588 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
589 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
590 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
591 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
592 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
593 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
594 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
595 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
596 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
597 0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00,
598 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
599 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
600 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
601 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
602 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
603 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
604 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
605 0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00,
606 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
607 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
608 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
609 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
610 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
611 0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,
612 0x0c,0x0c,0x00,0x00,0x00,0x00,0x00,0x00};
615 0x80,0x00,0x00,0x00,0x00,0x01,0x00,0x00,
616 0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,
617 0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,
618 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
619 0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,
620 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
621 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
622 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
623 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
624 0x00,0x00,0x00,0x80,0x00,0x80,0x80,0x80,
625 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
626 0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,
627 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
628 0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x80,
629 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
630 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
631 0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12,
632 0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00,
633 0x00,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
634 0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00,
635 0x00,0x00,0x12,0x12,0x12,0x12,0x12,0x12,
636 0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00,
637 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
638 0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,
639 0x80,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12,
640 0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00,
641 0x00,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
642 0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00,
643 0x00,0x00,0x12,0x12,0x12,0x12,0x12,0x12,
644 0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00,
645 0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,
646 0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x00};
665 find_error_text(
int n)
667 const char *s = error_texts;
671 if (*s ==
CHAR_NULL)
return "Error text not found (please report)";
702 if (newspace == NULL)
return ERR21;
776 check_escape(
const pcre_uchar **ptrptr, pcre_uint32 *chptr,
int *errorcodeptr,
777 int bracount,
int options,
BOOL isclass)
780 BOOL utf = (options & PCRE_UTF8) != 0;
799 else if (c < CHAR_0 || c >
CHAR_z) {}
800 else if ((i = escapes[c -
CHAR_0]) != 0) {
if (i > 0) c = (pcre_uint32)i;
else escape = -i; }
804 else if (c <
CHAR_a || (!
MAX_255(c) || (ebcdic_chartab[c] & 0x0E) == 0)) {}
805 else if ((i = escapes[c - 0x48]) != 0) {
if (i > 0) c = (pcre_uint32)i;
else escape = -i; }
813 BOOL braced, negated, overflow;
823 *errorcodeptr =
ERR37;
827 if ((options & PCRE_JAVASCRIPT_COMPAT) != 0)
837 for (i = 0; i < 4; ++i)
839 register pcre_uint32 cc = *(++ptr);
841 if (cc >=
CHAR_a) cc -= 32;
844 if (cc >=
CHAR_a && cc <= CHAR_z) cc += 64;
849 #if defined COMPILE_PCRE8
850 if (c > (utf ? 0x10ffff : 0xff))
852 if (c > (utf ? 0x10ffff : 0xffff))
854 if (utf && c > 0x10ffff)
857 *errorcodeptr =
ERR76;
859 else if (utf && c >= 0xd800 && c <= 0xdfff) *errorcodeptr =
ERR73;
863 *errorcodeptr =
ERR37;
868 if ((options & PCRE_JAVASCRIPT_COMPAT) == 0) *errorcodeptr =
ERR37;
918 else negated =
FALSE;
925 if (s > INT_MAX / 10 - 1)
930 s = s * 10 + (int)(*(++ptr) -
CHAR_0);
936 *errorcodeptr =
ERR61;
942 *errorcodeptr =
ERR57;
948 *errorcodeptr =
ERR58;
956 *errorcodeptr =
ERR15;
959 s = bracount - (s - 1);
988 if (s > INT_MAX / 10 - 1)
993 s = s * 10 + (int)(*(++ptr) -
CHAR_0);
999 *errorcodeptr =
ERR61;
1002 if (s < 10 || s <= bracount)
1014 if ((c = *ptr) >=
CHAR_8)
1030 c = c * 8 + *(++ptr) -
CHAR_0;
1031 #ifdef COMPILE_PCRE8
1032 if (!utf && c > 0xff) *errorcodeptr =
ERR51;
1041 if ((options & PCRE_JAVASCRIPT_COMPAT) != 0)
1049 for (i = 0; i < 2; ++i)
1051 register pcre_uint32 cc = *(++ptr);
1053 if (cc >=
CHAR_a) cc -= 32;
1056 if (cc >=
CHAR_a && cc <= CHAR_z) cc += 64;
1072 register pcre_uint32 cc = *pt++;
1073 if (c == 0 && cc ==
CHAR_0)
continue;
1075 #ifdef COMPILE_PCRE32
1076 if (c >= 0x10000000l) { overflow =
TRUE;
break; }
1080 if (cc >=
CHAR_a) cc -= 32;
1083 if (cc >=
CHAR_a && cc <= CHAR_z) cc += 64;
1087 #if defined COMPILE_PCRE8
1088 if (c > (utf ? 0x10ffff : 0xff)) { overflow =
TRUE;
break; }
1089 #elif defined COMPILE_PCRE16
1090 if (c > (utf ? 0x10ffff : 0xffff)) { overflow =
TRUE;
break; }
1091 #elif defined COMPILE_PCRE32
1092 if (utf && c > 0x10ffff) { overflow =
TRUE;
break; }
1099 *errorcodeptr =
ERR34;
1104 if (utf && c >= 0xd800 && c <= 0xdfff) *errorcodeptr =
ERR73;
1121 if (cc >=
CHAR_a) cc -= 32;
1124 if (cc <= CHAR_z) cc += 64;
1139 *errorcodeptr =
ERR2;
1145 *errorcodeptr =
ERR68;
1148 if (c >=
CHAR_a && c <= CHAR_z) c -= 32;
1151 if (c >=
CHAR_a && c <= CHAR_z) c += 64;
1163 if ((options & PCRE_EXTRA) != 0)
switch(c)
1166 *errorcodeptr =
ERR3;
1178 !is_counted_repeat(ptr+2))
1179 *errorcodeptr =
ERR37;
1183 if ((options & PCRE_UCP) != 0 && escape >=
ESC_D && escape <=
ESC_w)
1214 get_ucp(
const pcre_uchar **ptrptr,
BOOL *negptr,
unsigned int *ptypeptr,
1215 unsigned int *pdataptr,
int *errorcodeptr)
1237 for (i = 0; i < (int)(
sizeof(name) /
sizeof(
pcre_uchar)) - 1; i++)
1261 top =
PRIV(utt_size);
1266 i = (bot + top) >> 1;
1270 *ptypeptr =
PRIV(utt)[i].type;
1271 *pdataptr =
PRIV(utt)[i].value;
1274 if (r > 0) bot = i + 1;
else top = i;
1277 *errorcodeptr =
ERR47;
1282 *errorcodeptr =
ERR46;
1311 read_repeat_counts(
const pcre_uchar *p,
int *minp,
int *maxp,
int *errorcodeptr)
1320 if (min < 0 || min > 65535)
1322 *errorcodeptr =
ERR5;
1335 if (max < 0 || max > 65535)
1337 *errorcodeptr =
ERR5;
1342 *errorcodeptr =
ERR4;
1400 int start_count = *count;
1401 int hwm_count = start_count;
1418 if (name == NULL && *count == lorn)
return *count;
1435 for (ptr += 3; *ptr !=
CHAR_NULL; ptr++)
1459 if (*ptr ==
CHAR_P) ptr++;
1469 if (name == NULL && *count == lorn)
return *count;
1473 while (*ptr != term) ptr++;
1474 if (name != NULL && lorn == (
int)(ptr - thisname) &&
1493 if (*(++ptr) ==
CHAR_NULL)
goto FAIL_EXIT;
1494 if (*ptr ==
CHAR_Q)
for (;;)
1498 if (*(++ptr) ==
CHAR_E)
break;
1526 negate_class =
TRUE;
1544 if (*(++ptr) ==
CHAR_NULL)
goto FAIL_EXIT;
1545 if (*ptr ==
CHAR_Q)
for (;;)
1549 if (*(++ptr) ==
CHAR_E)
break;
1567 if (utf) FORWARDCHAR(ptr);
1578 int rc = find_parens_sub(&ptr, cd, name, lorn, xmode, utf, count);
1579 if (rc > 0)
return rc;
1585 if (dup_parens && *count < hwm_count) *count = hwm_count;
1591 if (*count > hwm_count) hwm_count = *count;
1592 *count = start_count;
1644 rc = find_parens_sub(&ptr, cd, name, lorn, xmode, utf, &count);
1645 if (rc > 0 || *ptr++ ==
CHAR_NULL)
break;
1681 if (!skipassert)
return code;
1682 do code += GET(code, 1);
while (*code ==
OP_ALT);
1683 code +=
PRIV(OP_lengths)[*code];
1688 if (!skipassert)
return code;
1697 code +=
PRIV(OP_lengths)[*code];
1743 register int branchlength = 0;
1744 register pcre_uchar *cc = code + 1 + LINK_SIZE;
1767 d = find_fixedlength(cc + ((op ==
OP_CBRA)?
IMM2_SIZE : 0), utf, atend, cd);
1768 if (d < 0)
return d;
1770 do cc += GET(cc, 1);
while (*cc ==
OP_ALT);
1771 cc += 1 + LINK_SIZE;
1785 if (length < 0) length = branchlength;
1786 else if (length != branchlength)
return -1;
1787 if (*cc !=
OP_ALT)
return length;
1788 cc += 1 + LINK_SIZE;
1797 if (!atend)
return -3;
1799 do ce += GET(ce, 1);
while (*ce ==
OP_ALT);
1800 if (cc > cs && cc < ce)
return -1;
1801 d = find_fixedlength(cs +
IMM2_SIZE, utf, atend, cd);
1802 if (d < 0)
return d;
1804 cc += 1 + LINK_SIZE;
1813 do cc += GET(cc, 1);
while (*cc ==
OP_ALT);
1814 cc +=
PRIV(OP_lengths)[*cc];
1823 cc += cc[1] +
PRIV(OP_lengths)[*cc];
1850 cc +=
PRIV(OP_lengths)[*cc];
1862 if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
1873 branchlength += (int)
GET2(cc,1);
1876 if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
1881 branchlength +=
GET2(cc,1);
1920 #if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1945 branchlength += (int)
GET2(cc,1);
2074 if (c ==
OP_END)
return NULL;
2080 if (c ==
OP_XCLASS) code += GET(code, 1);
2087 code +=
PRIV(OP_lengths)[c];
2095 int n = (int)
GET2(code, 1+LINK_SIZE);
2097 code +=
PRIV(OP_lengths)[c];
2142 code +=
PRIV(OP_lengths)[c];
2148 #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
2179 if (HAS_EXTRALEN(code[-1])) code += GET_EXTRALEN(code[-1]);
2211 if (c ==
OP_END)
return NULL;
2218 if (c ==
OP_XCLASS) code += GET(code, 1);
2262 code +=
PRIV(OP_lengths)[c];
2268 #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
2327 if (HAS_EXTRALEN(code[-1])) code += GET_EXTRALEN(code[-1]);
2365 for (code = first_significant_code(code +
PRIV(OP_lengths)[*code],
TRUE);
2367 code = first_significant_code(code +
PRIV(OP_lengths)[c],
TRUE))
2378 do code += GET(code, 1);
while (*code ==
OP_ALT);
2397 for (scode = cd->
start_workspace; scode < cd->hwm; scode += LINK_SIZE)
2398 if ((
int)GET(scode, 0) == (
int)(code + 1 - cd->
start_code))
return TRUE;
2402 empty_branch =
FALSE;
2404 if (GET(scode, 1) == 0)
return TRUE;
2410 if (could_be_empty_branch(scode, endcode, utf, cd))
2412 empty_branch =
TRUE;
2415 scode += GET(scode, 1);
2417 while (*scode ==
OP_ALT);
2419 if (!empty_branch)
return FALSE;
2428 code +=
PRIV(OP_lengths)[c];
2429 do code += GET(code, 1);
while (*code ==
OP_ALT);
2440 do code += GET(code, 1);
while (*code ==
OP_ALT);
2453 if (GET(code, 1) == 0)
return TRUE;
2460 code += GET(code, 1);
2463 empty_branch =
FALSE;
2466 if (!empty_branch && could_be_empty_branch(code, endcode, utf, cd))
2467 empty_branch =
TRUE;
2468 code += GET(code, 1);
2471 if (!empty_branch)
return FALSE;
2488 #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
2490 ccode = code += GET(code, 1);
2491 goto CHECK_CLASS_REPEAT;
2498 #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
2587 #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
2600 if (utf && HAS_EXTRALEN(code[1])) code += GET_EXTRALEN(code[1]);
2609 if (utf && HAS_EXTRALEN(code[1 +
IMM2_SIZE])) code += GET_EXTRALEN(code[1 +
IMM2_SIZE]);
2665 if (!could_be_empty_branch(bcptr->
current_branch, endcode, utf, cd))
2667 bcptr = bcptr->
outer;
2720 terminator = *(++ptr);
2736 check_posix_syntax(ptr, endptr))
2761 check_posix_name(
const pcre_uchar *ptr,
int len)
2763 const char *pn = posix_names;
2764 register int yield = 0;
2765 while (posix_name_lengths[yield] != 0)
2767 if (len == posix_name_lengths[yield] &&
2768 STRNCMP_UC_C8(ptr, pn, (
unsigned int)len) == 0)
return yield;
2769 pn += posix_name_lengths[yield] + 1;
2813 while ((ptr = (
pcre_uchar *)find_recurse(ptr, utf)) != NULL)
2821 for (hc = save_hwm; hc < cd->
hwm; hc += LINK_SIZE)
2823 offset = (int)GET(hc, 0);
2826 PUT(hc, 0, offset + adjust);
2836 offset = (int)GET(ptr, 1);
2837 if (cd->
start_code + offset >= group) PUT(ptr, 1, offset + adjust);
2840 ptr += 1 + LINK_SIZE;
2867 PUT(code, LINK_SIZE, 0);
2868 return code + 2 * LINK_SIZE;
2892 int length = (int)(ptr - cd->
start_pattern - GET(previous_callout, 2));
2893 PUT(previous_callout, 2 + LINK_SIZE, length);
2922 get_othercase_range(pcre_uint32 *cptr, pcre_uint32 d, pcre_uint32 *ocptr,
2925 pcre_uint32 c, othercase, next;
2931 for (c = *cptr; c <= d; c++)
2933 if ((co = UCD_CASESET(c)) != 0)
2939 if ((othercase = UCD_OTHERCASE(c)) != c)
break;
2942 if (c > d)
return -1;
2945 next = othercase + 1;
2947 for (++c; c <= d; c++)
2949 if (UCD_OTHERCASE(c) != next)
break;
2977 check_char_prop(pcre_uint32 c,
unsigned int ptype,
unsigned int pdata,
BOOL negated)
2980 const pcre_uint32 *p;
2993 return (pdata ==
PRIV(ucp_gentype)[prop->
chartype]) == negated;
2996 return (pdata == prop->
chartype) == negated;
2999 return (pdata == prop->
script) == negated;
3028 if (c < *p)
return !negated;
3029 if (c == *p++)
return negated;
3070 if ((options & PCRE_EXTENDED) != 0)
3083 if (utf) FORWARDCHAR(ptr);
3096 int temperrorcode = 0;
3097 escape = check_escape(&ptr, &next, &temperrorcode, cd->
bracount, options,
FALSE);
3098 if (temperrorcode != 0)
return FALSE;
3113 if ((options & PCRE_EXTENDED) != 0)
3117 while (
MAX_255(*ptr) && (cd->
ctypes[*ptr] & ctype_space) != 0) ptr++;
3126 if (utf) FORWARDCHAR(ptr);
3161 if (utf && c !=
NOTACHAR && (options & PCRE_CASELESS) != 0)
3163 unsigned int ocs = UCD_CASESET(next);
3164 if (ocs > 0)
return check_char_prop(c,
PT_CLIST, ocs, op_code >=
OP_NOT);
3179 if (c == next)
return FALSE;
3183 pcre_uint32 othercase;
3184 if (next < 128) othercase = cd->
fcc[next];
else
3186 othercase = UCD_OTHERCASE(next);
3190 return c != othercase;
3200 if (c == next)
return TRUE;
3204 pcre_uint32 othercase;
3205 if (next < 128) othercase = cd->
fcc[next];
else
3207 othercase = UCD_OTHERCASE(next);
3211 return c == othercase;
3263 return check_char_prop(next, previous[0], previous[1],
FALSE);
3266 return check_char_prop(next, previous[0], previous[1],
TRUE);
3309 return escape !=
ESC_h;
3312 return escape ==
ESC_h;
3320 return escape !=
ESC_v;
3323 return escape ==
ESC_v;
3338 int temperrorcode = 0;
3339 ptr = substitutes[escape -
ESC_DU];
3340 escape = check_escape(&ptr, &next, &temperrorcode, 0, options,
FALSE);
3341 if (temperrorcode != 0)
return FALSE;
3349 unsigned int ptype = 0, pdata = 0;
3354 if (!get_ucp(&ptr, &negated, &ptype, &pdata, &errorcodeptr))
3368 return check_char_prop(c, ptype, pdata, (escape ==
ESC_P) != negated);
3387 return escape ==
ESC_d;
3400 return escape ==
ESC_h;
3459 if ((options & PCRE_CASELESS) != 0)
3462 if ((options & PCRE_UTF8) != 0)
3467 options &= ~PCRE_CASELESS;
3470 while ((rc = get_othercase_range(&c, end, &oc, &od)) >= 0)
3474 if (rc > 0) n8 += add_list_to_class(classbits, uchardptr, options, cd,
3475 PRIV(ucd_caseless_sets) + rc, oc);
3479 else if (oc >= start && od <= end)
continue;
3485 else if (oc < start && od >= start - 1) start = oc;
3486 else if (od > end && oc <= end + 1) end = od;
3487 else n8 += add_to_class(classbits, uchardptr, options, cd, oc, od);
3495 for (c = start; c <= end && c < 256; c++)
3506 #if defined COMPILE_PCRE8
3508 if ((options & PCRE_UTF8) == 0)
3510 if (end > 0xff) end = 0xff;
3512 #elif defined COMPILE_PCRE16
3514 if ((options & PCRE_UTF16) == 0)
3516 if (end > 0xffff) end = 0xffff;
3525 for (c = start; c <= end; c++)
3537 if ((options & PCRE_UTF8) != 0)
3545 else if (start == end)
3557 #ifdef COMPILE_PCRE8
3563 *uchardata++ = start;
3566 else if (start == end)
3569 *uchardata++ = start;
3573 *uchardptr = uchardata;
3608 compile_data *cd,
const pcre_uint32 *p,
unsigned int except)
3616 while(p[n+1] == p[0] + n + 1) n++;
3617 n8 += add_to_class(classbits, uchardptr, options, cd, p[0], p[n]);
3648 BOOL utf = (options & PCRE_UTF8) != 0;
3651 n8 += add_to_class(classbits, uchardptr, options, cd, 0, p[0] - 1);
3654 while (p[1] == p[0] + 1) p++;
3655 n8 += add_to_class(classbits, uchardptr, options, cd, p[0] + 1,
3656 (p[1] ==
NOTACHAR) ? (utf ? 0x10ffffu : 0xffffffffu) : p[1] - 1);
3694 compile_branch(
int *optionsptr,
pcre_uchar **codeptr,
3695 const pcre_uchar **ptrptr,
int *errorcodeptr,
3696 pcre_uint32 *firstcharptr, pcre_int32 *firstcharflagsptr,
3697 pcre_uint32 *reqcharptr, pcre_int32 *reqcharflagsptr,
3701 int repeat_type, op_type;
3702 int repeat_min = 0, repeat_max = 0;
3704 int greedy_default, greedy_non_default;
3705 pcre_uint32 firstchar, reqchar;
3706 pcre_int32 firstcharflags, reqcharflags;
3707 pcre_uint32 zeroreqchar, zerofirstchar;
3708 pcre_int32 zeroreqcharflags, zerofirstcharflags;
3709 pcre_int32 req_caseopt, reqvary, tempreqvary;
3710 int options = *optionsptr;
3711 int after_manual_callout = 0;
3712 int length_prevgroup = 0;
3713 register pcre_uint32 c;
3735 BOOL utf = (options & PCRE_UTF8) != 0;
3736 #ifndef COMPILE_PCRE32
3749 #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
3755 if (lengthptr != NULL)
DPRINTF((
">> start branch\n"));
3760 greedy_default = ((options & PCRE_UNGREEDY) != 0);
3761 greedy_non_default = greedy_default ^ 1;
3773 firstchar = reqchar = zerofirstchar = zeroreqchar = 0;
3774 firstcharflags = reqcharflags = zerofirstcharflags = zeroreqcharflags =
REQ_UNSET;
3782 req_caseopt = ((options & PCRE_CASELESS) != 0)?
REQ_CASELESS:0;
3789 BOOL should_flip_negation;
3790 BOOL possessive_quantifier;
3793 BOOL reset_bracount;
3794 int class_has_8bitchar;
3800 pcre_uint32 subreqchar, subfirstchar;
3801 pcre_int32 subreqcharflags, subfirstcharflags;
3803 unsigned int mclength;
3804 unsigned int tempbracount;
3825 if (lengthptr != NULL)
3828 if (code > cd->
hwm) cd->
hwm = code;
3833 *errorcodeptr =
ERR52;
3843 if (code < last_code) code = last_code;
3847 if (
OFLOW_MAX - *lengthptr < code - last_code)
3849 *errorcodeptr =
ERR20;
3853 *lengthptr += (int)(code - last_code);
3854 DPRINTF((
"length=%d added %d c=%c (0x%x)\n", *lengthptr,
3855 (
int)(code - last_code), c, c));
3861 if (previous != NULL)
3863 if (previous > orig_code)
3866 code -= previous - orig_code;
3867 previous = orig_code;
3870 else code = orig_code;
3884 *errorcodeptr =
ERR52;
3900 if (previous_callout != NULL)
3902 if (lengthptr == NULL)
3903 complete_callout(previous_callout, ptr, cd);
3904 previous_callout = NULL;
3906 if ((options & PCRE_AUTO_CALLOUT) != 0)
3908 previous_callout = code;
3909 code = auto_callout(code, ptr, cd);
3922 if (!is_quantifier && previous_callout != NULL &&
3923 after_manual_callout-- <= 0)
3925 if (lengthptr == NULL)
3926 complete_callout(previous_callout, ptr, cd);
3927 previous_callout = NULL;
3932 if ((options & PCRE_EXTENDED) != 0)
3934 if (
MAX_255(*ptr) && (cd->
ctypes[c] & ctype_space) != 0)
continue;
3943 if (utf) FORWARDCHAR(ptr);
3955 if ((options & PCRE_AUTO_CALLOUT) != 0 && !is_quantifier)
3957 previous_callout = code;
3958 code = auto_callout(code, ptr, cd);
3967 *firstcharptr = firstchar;
3968 *firstcharflagsptr = firstcharflags;
3969 *reqcharptr = reqchar;
3970 *reqcharflagsptr = reqcharflags;
3973 if (lengthptr != NULL)
3975 if (
OFLOW_MAX - *lengthptr < code - last_code)
3977 *errorcodeptr =
ERR20;
3980 *lengthptr += (int)(code - last_code);
3992 if ((options & PCRE_MULTILINE) != 0)
4010 zerofirstchar = firstchar;
4011 zerofirstcharflags = firstcharflags;
4012 zeroreqchar = reqchar;
4013 zeroreqcharflags = reqcharflags;
4037 *errorcodeptr =
ERR64;
4050 check_posix_syntax(ptr, &tempptr))
4060 negate_class =
FALSE;
4074 negate_class =
TRUE;
4088 zerofirstchar = firstchar;
4089 zerofirstcharflags = firstcharflags;
4097 should_flip_negation =
FALSE;
4104 class_has_8bitchar = 0;
4112 memset(classbits, 0, 32 *
sizeof(
pcre_uint8));
4114 #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
4116 class_uchardata = code + LINK_SIZE + 2;
4117 class_uchardata_base = class_uchardata;
4129 if (utf && HAS_EXTRALEN(c))
4135 #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
4142 if (lengthptr != NULL && class_uchardata > class_uchardata_base)
4145 *lengthptr += class_uchardata - class_uchardata_base;
4146 class_uchardata = class_uchardata_base;
4174 int posix_class, taboffset, tabopt;
4180 *errorcodeptr =
ERR31;
4187 local_negate =
TRUE;
4188 should_flip_negation =
TRUE;
4192 posix_class = check_posix_name(ptr, (
int)(tempptr - ptr));
4193 if (posix_class < 0)
4195 *errorcodeptr =
ERR30;
4203 if ((options & PCRE_CASELESS) != 0 && posix_class <= 2)
4210 if ((options & PCRE_UCP) != 0)
4212 int pc = posix_class + ((local_negate)? POSIX_SUBSIZE/2 : 0);
4213 if (posix_substitutes[pc] != NULL)
4215 nestptr = tempptr + 1;
4216 ptr = posix_substitutes[pc] - 1;
4230 memcpy(pbits, cbits + posix_class_maps[posix_class],
4235 taboffset = posix_class_maps[posix_class + 1];
4236 tabopt = posix_class_maps[posix_class + 2];
4241 for (c = 0; c < 32; c++) pbits[c] |= cbits[c + taboffset];
4243 for (c = 0; c < 32; c++) pbits[c] &= ~cbits[c + taboffset];
4249 if (tabopt < 0) tabopt = -tabopt;
4250 if (tabopt == 1) pbits[1] &= ~0x3c;
4251 else if (tabopt == 2) pbits[11] &= 0x7f;
4257 for (c = 0; c < 32; c++) classbits[c] |= ~pbits[c];
4259 for (c = 0; c < 32; c++) classbits[c] |= pbits[c];
4263 class_has_8bitchar = 1;
4280 escape = check_escape(&ptr, &ec, errorcodeptr, cd->
bracount, options,
TRUE);
4282 if (*errorcodeptr != 0)
goto FAILED;
4287 else if (escape ==
ESC_N)
4289 *errorcodeptr =
ERR71;
4292 else if (escape ==
ESC_Q)
4301 else if (escape ==
ESC_E)
continue;
4307 class_has_8bitchar++;
4309 class_one_char += 2;
4321 ptr = substitutes[escape -
ESC_DU] - 1;
4322 class_has_8bitchar--;
4326 for (c = 0; c < 32; c++) classbits[c] |= cbits[c+
cbit_digit];
4330 should_flip_negation =
TRUE;
4331 for (c = 0; c < 32; c++) classbits[c] |= ~cbits[c+
cbit_digit];
4335 for (c = 0; c < 32; c++) classbits[c] |= cbits[c+
cbit_word];
4339 should_flip_negation =
TRUE;
4340 for (c = 0; c < 32; c++) classbits[c] |= ~cbits[c+
cbit_word];
4351 for (c = 2; c < 32; c++) classbits[c] |= cbits[c+
cbit_space];
4355 should_flip_negation =
TRUE;
4356 for (c = 0; c < 32; c++) classbits[c] |= ~cbits[c+
cbit_space];
4357 classbits[1] |= 0x08;
4363 (void)add_list_to_class(classbits, &class_uchardata, options, cd,
4368 (void)add_not_list_to_class(classbits, &class_uchardata, options,
4369 cd,
PRIV(hspace_list));
4373 (void)add_list_to_class(classbits, &class_uchardata, options, cd,
4378 (void)add_not_list_to_class(classbits, &class_uchardata, options,
4379 cd,
PRIV(vspace_list));
4387 unsigned int ptype = 0, pdata = 0;
4388 if (!get_ucp(&ptr, &negated, &ptype, &pdata, errorcodeptr))
4390 *class_uchardata++ = ((escape ==
ESC_p) != negated)?
4392 *class_uchardata++ = ptype;
4393 *class_uchardata++ = pdata;
4394 class_has_8bitchar--;
4403 if ((options & PCRE_EXTRA) != 0)
4405 *errorcodeptr =
ERR7;
4408 class_has_8bitchar--;
4409 class_one_char -= 2;
4454 { ptr += 2;
continue; }
4465 goto CLASS_SINGLE_CHARACTER;
4486 descape = check_escape(&ptr, &d, errorcodeptr, cd->
bracount, options,
TRUE);
4487 if (*errorcodeptr != 0)
goto FAILED;
4496 goto CLASS_SINGLE_CHARACTER;
4506 *errorcodeptr =
ERR8;
4509 if (d == c)
goto CLASS_SINGLE_CHARACTER;
4521 class_has_8bitchar +=
4522 add_to_class(classbits, &class_uchardata, options, cd, c, d);
4533 CLASS_SINGLE_CHARACTER:
4534 if (class_one_char < 2) class_one_char++;
4548 zeroreqchar = reqchar;
4549 zeroreqcharflags = reqcharflags;
4557 zerofirstchar = firstchar;
4558 zerofirstcharflags = firstcharflags;
4565 if (utf && (options & PCRE_CASELESS) != 0 &&
4566 (d = UCD_CASESET(c)) != 0)
4577 *code++ = ((options & PCRE_CASELESS) != 0)?
OP_NOTI:
OP_NOT;
4578 #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4579 if (utf && c > MAX_VALUE_FOR_SINGLE_CHAR)
4594 #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4595 if (utf && c > MAX_VALUE_FOR_SINGLE_CHAR)
4609 class_has_8bitchar +=
4610 add_to_class(classbits, &class_uchardata, options, cd, c, c);
4619 (ptr = nestptr, nestptr = NULL, c = *(++ptr)) !=
CHAR_NULL)) &&
4626 *errorcodeptr =
ERR6;
4638 #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
4639 if (class_uchardata > class_uchardata_base) xclass =
TRUE;
4647 zerofirstchar = firstchar;
4648 zerofirstcharflags = firstcharflags;
4649 zeroreqchar = reqchar;
4650 zeroreqcharflags = reqcharflags;
4661 if (xclass && (!should_flip_negation || (options & PCRE_UCP) != 0))
4662 #elif !defined COMPILE_PCRE8
4663 if (xclass && !should_flip_negation)
4665 #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
4670 *code = negate_class?
XCL_NOT:0;
4675 if (class_has_8bitchar > 0)
4680 memcpy(code, classbits, 32);
4681 code = class_uchardata + (32 /
sizeof(
pcre_uchar));
4683 else code = class_uchardata;
4687 PUT(previous, 1, (
int)(code - previous));
4699 if (lengthptr == NULL)
4702 for (c = 0; c < 32; c++) classbits[c] = ~classbits[c];
4703 memcpy(code, classbits, 32);
4716 if (!is_quantifier)
goto NORMAL_CHAR;
4717 ptr = read_repeat_counts(ptr+1, &repeat_min, &repeat_max, errorcodeptr);
4718 if (*errorcodeptr != 0)
goto FAILED;
4736 if (previous == NULL)
4738 *errorcodeptr =
ERR9;
4742 if (repeat_min == 0)
4744 firstchar = zerofirstchar;
4745 firstcharflags = zerofirstcharflags;
4746 reqchar = zeroreqchar;
4747 reqcharflags = zeroreqcharflags;
4752 reqvary = (repeat_min == repeat_max)? 0 :
REQ_VARY;
4755 possessive_quantifier =
FALSE;
4760 tempcode = previous;
4771 possessive_quantifier =
TRUE;
4776 repeat_type = greedy_non_default;
4779 else repeat_type = greedy_default;
4791 PUT(previous, 1, 2 + 2*LINK_SIZE);
4792 previous[2 + 2*LINK_SIZE] =
OP_KET;
4793 PUT(previous, 3 + 2*LINK_SIZE, 2 + 2*LINK_SIZE);
4794 code += 2 + 2 * LINK_SIZE;
4795 length_prevgroup = 3 + 3*LINK_SIZE;
4802 int offset = GET(cd->
hwm, -LINK_SIZE);
4804 PUT(cd->
hwm, -LINK_SIZE, offset + 1 + LINK_SIZE);
4833 #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4834 if (utf && NOT_FIRSTCHAR(code[-1]))
4838 c = (int)(code - lastchar);
4839 memcpy(utf_chars, lastchar,
IN_UCHARS(c));
4849 if (*previous <= OP_CHARI && repeat_min > 1)
4861 if (!possessive_quantifier &&
4863 check_auto_possessive(previous, utf, ptr + 1, options, cd))
4866 possessive_quantifier =
TRUE;
4869 goto OUTPUT_SINGLE_REPEAT;
4882 int prop_type, prop_value;
4886 if (!possessive_quantifier &&
4888 check_auto_possessive(previous, utf, ptr + 1, options, cd))
4891 possessive_quantifier =
TRUE;
4894 OUTPUT_SINGLE_REPEAT:
4897 prop_type = previous[1];
4898 prop_value = previous[2];
4900 else prop_type = prop_value = -1;
4908 if (repeat_max == 0)
goto END_REPEAT;
4922 repeat_type += op_type;
4927 if (repeat_min == 0)
4929 if (repeat_max == -1) *code++ = OP_STAR + repeat_type;
4930 else if (repeat_max == 1) *code++ =
OP_QUERY + repeat_type;
4933 *code++ =
OP_UPTO + repeat_type;
4943 else if (repeat_min == 1)
4945 if (repeat_max == -1)
4946 *code++ =
OP_PLUS + repeat_type;
4950 if (repeat_max == 1)
goto END_REPEAT;
4951 *code++ =
OP_UPTO + repeat_type;
4952 PUT2INC(code, 0, repeat_max - 1);
4972 #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4975 memcpy(code, utf_chars,
IN_UCHARS(c & 7));
4984 *code++ = prop_type;
4985 *code++ = prop_value;
4988 *code++ = OP_STAR + repeat_type;
4995 else if (repeat_max != repeat_min)
4997 #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
4998 if (utf && (c & UTF_LENGTH) != 0)
5000 memcpy(code, utf_chars,
IN_UCHARS(c & 7));
5008 *code++ = prop_type;
5009 *code++ = prop_value;
5011 repeat_max -= repeat_min;
5013 if (repeat_max == 1)
5019 *code++ =
OP_UPTO + repeat_type;
5027 #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
5028 if (utf && (c & UTF_LENGTH) != 0)
5030 memcpy(code, utf_chars,
IN_UCHARS(c & 7));
5043 *code++ = prop_type;
5044 *code++ = prop_value;
5060 if (repeat_max == 0)
5076 if (repeat_min == 0 && repeat_max == -1)
5078 else if (repeat_min == 1 && repeat_max == -1)
5080 else if (repeat_min == 0 && repeat_max == 1)
5086 if (repeat_max == -1) repeat_max = 0;
5102 int len = (int)(code - previous);
5109 if (*previous ==
OP_COND && previous[LINK_SIZE+1] ==
OP_DEF)
5119 if (repeat_min > 0)
goto END_REPEAT;
5120 if (repeat_max < 0 || repeat_max > 1) repeat_max = 1;
5130 if (repeat_min == 0)
5154 if (repeat_max <= 1)
5157 adjust_recurse(previous, 1, utf, cd, save_hwm);
5160 if (repeat_max == 0)
5165 brazeroptr = previous;
5181 adjust_recurse(previous, 2 + LINK_SIZE, utf, cd, save_hwm);
5183 code += 2 + LINK_SIZE;
5190 offset = (bralink == NULL)? 0 : (
int)(previous - bralink);
5192 PUTINC(previous, 0, offset);
5214 if (lengthptr != NULL)
5216 int delta = (repeat_min - 1)*length_prevgroup;
5222 *errorcodeptr =
ERR20;
5225 *lengthptr += delta;
5235 if (groupsetfirstchar && reqcharflags < 0)
5237 reqchar = firstchar;
5238 reqcharflags = firstcharflags;
5241 for (i = 1; i < repeat_min; i++)
5252 *errorcodeptr = expand_workspace(cd);
5253 if (*errorcodeptr != 0)
goto FAILED;
5258 for (hc = save_hwm; hc < this_hwm; hc += LINK_SIZE)
5260 PUT(cd->
hwm, 0, GET(hc, 0) + len);
5261 cd->
hwm += LINK_SIZE;
5263 save_hwm = this_hwm;
5269 if (repeat_max > 0) repeat_max -= repeat_min;
5279 if (repeat_max >= 0)
5288 if (lengthptr != NULL && repeat_max > 0)
5290 int delta = repeat_max * (length_prevgroup + 1 + 2 + 2*LINK_SIZE) -
5297 *errorcodeptr =
ERR20;
5300 *lengthptr += delta;
5305 else for (i = repeat_max - 1; i >= 0; i--)
5319 offset = (bralink == NULL)? 0 : (
int)(code - bralink);
5334 *errorcodeptr = expand_workspace(cd);
5335 if (*errorcodeptr != 0)
goto FAILED;
5340 for (hc = save_hwm; hc < this_hwm; hc += LINK_SIZE)
5342 PUT(cd->
hwm, 0, GET(hc, 0) + len + ((i != 0)? 2+LINK_SIZE : 1));
5343 cd->
hwm += LINK_SIZE;
5345 save_hwm = this_hwm;
5352 while (bralink != NULL)
5355 int offset = (int)(code - bralink + 1);
5357 oldlinkoffset = GET(bra, 1);
5358 bralink = (oldlinkoffset == 0)? NULL : bralink - oldlinkoffset;
5361 PUT(bra, 1, offset);
5393 pcre_uchar *bracode = ketcode - GET(ketcode, 1);
5398 possessive_quantifier) *bracode =
OP_BRA;
5413 if (lengthptr == NULL)
5418 if (could_be_empty_branch(scode, ketcode, utf, cd))
5423 scode += GET(scode, 1);
5425 while (*scode ==
OP_ALT);
5430 if (possessive_quantifier)
5439 int nlen = (int)(code - bracode);
5441 adjust_recurse(bracode, 1 + LINK_SIZE, utf, cd, save_hwm);
5443 code += 1 + LINK_SIZE;
5444 nlen += 1 + LINK_SIZE;
5448 PUT(bracode, 1, nlen);
5463 if (repeat_min < 2) possessive_quantifier =
FALSE;
5478 else if (*previous ==
OP_FAIL)
goto END_REPEAT;
5484 *errorcodeptr =
ERR11;
5506 if (possessive_quantifier)
5511 tempcode +=
PRIV(OP_lengths)[*tempcode] +
5517 tempcode +=
PRIV(OP_lengths)[*tempcode];
5519 if (utf && HAS_EXTRALEN(tempcode[-1]))
5520 tempcode += GET_EXTRALEN(tempcode[-1]);
5524 len = (int)(code - tempcode);
5525 if (len > 0)
switch (*tempcode)
5557 adjust_recurse(tempcode, 1 + LINK_SIZE, utf, cd, save_hwm);
5559 code += 1 + LINK_SIZE;
5560 len += 1 + LINK_SIZE;
5564 PUT(tempcode, 1, len);
5585 newoptions = options;
5589 reset_bracount =
FALSE;
5599 const char *vn = verbnames;
5604 while (
MAX_255(*ptr) && (cd->
ctypes[*ptr] & ctype_letter) != 0) ptr++;
5605 namelen = (int)(ptr - name);
5615 arglen = (int)(ptr - arg);
5616 if ((
unsigned int)arglen >
MAX_MARK)
5618 *errorcodeptr =
ERR75;
5625 *errorcodeptr =
ERR60;
5631 for (i = 0; i < verbcount; i++)
5633 if (namelen == verbs[i].len &&
5646 *errorcodeptr =
ERR59;
5664 else if (arglen == 0)
5666 if (verbs[i].op < 0)
5668 *errorcodeptr =
ERR66;
5671 setverb = *code++ = verbs[i].
op;
5676 if (verbs[i].op_arg < 0)
5678 *errorcodeptr =
ERR59;
5681 setverb = *code++ = verbs[i].
op_arg;
5706 vn += verbs[i].
len + 1;
5709 if (i < verbcount)
continue;
5710 *errorcodeptr =
ERR60;
5719 int i, set, unset, namelen;
5731 *errorcodeptr =
ERR18;
5739 reset_bracount =
TRUE;
5814 *errorcodeptr =
ERR28;
5825 recno = (
IS_DIGIT(*ptr))? recno * 10 + (
int)(*ptr -
CHAR_0) : -1;
5828 namelen = (int)(ptr - name);
5830 if ((terminator > 0 && *ptr++ != (
pcre_uchar)terminator) ||
5834 *errorcodeptr =
ERR26;
5840 if (lengthptr != NULL)
break;
5850 *errorcodeptr =
ERR58;
5857 *errorcodeptr =
ERR15;
5860 PUT2(code, 2+LINK_SIZE, recno);
5879 if (i < cd->names_found)
5881 recno =
GET2(slot, 0);
5882 PUT2(code, 2+LINK_SIZE, recno);
5883 code[1+LINK_SIZE]++;
5888 else if ((i = find_parens(cd, name, namelen,
5889 (options & PCRE_EXTENDED) != 0, utf)) > 0)
5891 PUT2(code, 2+LINK_SIZE, i);
5892 code[1+LINK_SIZE]++;
5903 *errorcodeptr =
ERR15;
5910 else if (*name ==
CHAR_R)
5913 for (i = 1; i < namelen; i++)
5917 *errorcodeptr =
ERR15;
5920 recno = recno * 10 + name[i] -
CHAR_0;
5924 PUT2(code, 2+LINK_SIZE, recno);
5932 code[1+LINK_SIZE] =
OP_DEF;
5939 else if (recno > 0 && recno <= cd->final_bracount)
5941 PUT2(code, 2+LINK_SIZE, recno);
5996 *errorcodeptr =
ERR24;
6011 previous_callout = code;
6012 after_manual_callout = 1;
6018 n = n * 10 + *ptr++ -
CHAR_0;
6021 *errorcodeptr =
ERR39;
6026 *errorcodeptr =
ERR38;
6031 PUT(code, LINK_SIZE, 0);
6032 code += 2 * LINK_SIZE;