51 #define PSSTART start_subject
52 #define PSEND end_subject
63 #define match_condassert 0x01
64 #define match_cbegroup 0x02
70 #define MATCH_NOMATCH 0
75 #define MATCH_ACCEPT (-999)
76 #define MATCH_COMMIT (-998)
77 #define MATCH_PRUNE (-997)
78 #define MATCH_SKIP (-996)
79 #define MATCH_SKIP_ARG (-995)
80 #define MATCH_THEN (-994)
84 #define MRRETURN(ra) \
94 #define REC_STACK_SAVE_MAX 30
98 static const char rep_min[] = { 0, 0, 1, 1, 0, 0 };
99 static const char rep_max[] = { 0, 0, 0, 0, 1, 1 };
126 if (isprint(c = *(p++))) printf(
"%c", c);
else printf(
"\\x%02x", c);
151 unsigned long int ims)
157 printf(
"matching subject <null>");
160 printf(
"matching subject ");
161 pchars(eptr, length,
TRUE, md);
163 printf(
" against backref ");
164 pchars(p, length,
FALSE, md);
182 USPTR endptr = eptr + length;
183 while (eptr < endptr)
199 {
if (md->
lcc[*p++] != md->
lcc[*eptr++])
return FALSE; }
206 {
while (length-- > 0)
if (*p++ != *eptr++)
return FALSE; }
254 enum {
RM1=1,
RM2,
RM3,
RM4,
RM5,
RM6,
RM7,
RM8,
RM9,
RM10,
255 RM11,
RM12,
RM13,
RM14,
RM15,
RM16,
RM17,
RM18,
RM19,
RM20,
256 RM21,
RM22,
RM23,
RM24,
RM25,
RM26,
RM27,
RM28,
RM29,
RM30,
257 RM31,
RM32,
RM33,
RM34,
RM35,
RM36,
RM37,
RM38,
RM39,
RM40,
258 RM41,
RM42,
RM43,
RM44,
RM45,
RM46,
RM47,
RM48,
RM49,
RM50,
259 RM51,
RM52,
RM53,
RM54,
RM55,
RM56,
RM57,
RM58,
RM59,
RM60,
267 #define REGISTER register
270 #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \
272 printf("match() called in line %d\n", __LINE__); \
273 rrc = match(ra,rb,mstart,markptr,rc,rd,re,rf,rg,rdepth+1); \
274 printf("to line %d\n", __LINE__); \
276 #define RRETURN(ra) \
278 printf("match() returned %d from line %d ", ra, __LINE__); \
282 #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \
283 rrc = match(ra,rb,mstart,markptr,rc,rd,re,rf,rg,rdepth+1)
284 #define RRETURN(ra) return ra
296 #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw)\
298 heapframe *newframe = (heapframe *)(pcre_stack_malloc)(sizeof(heapframe));\
299 if (newframe == NULL) RRETURN(PCRE_ERROR_NOMEMORY);\
300 frame->Xwhere = rw; \
301 newframe->Xeptr = ra;\
302 newframe->Xecode = rb;\
303 newframe->Xmstart = mstart;\
304 newframe->Xmarkptr = markptr;\
305 newframe->Xoffset_top = rc;\
306 newframe->Xims = re;\
307 newframe->Xeptrb = rf;\
308 newframe->Xflags = rg;\
309 newframe->Xrdepth = frame->Xrdepth + 1;\
310 newframe->Xprevframe = frame;\
312 DPRINTF(("restarting from line %d\n", __LINE__));\
315 DPRINTF(("jumped back to line %d\n", __LINE__));\
320 heapframe *oldframe = frame;\
321 frame = oldframe->Xprevframe;\
322 (pcre_stack_free)(oldframe);\
334 typedef struct heapframe {
335 struct heapframe *Xprevframe;
347 unsigned int Xrdepth;
367 unsigned long int Xoriginal_ims;
372 int Xprop_fail_result;
390 int Xsave_capture_last;
391 int Xsave_offset1, Xsave_offset2, Xsave_offset3;
425 #define CHECK_PARTIAL()\
426 if (md->partial != 0 && eptr >= md->end_subject && \
427 eptr > md->start_used_ptr) \
430 if (md->partial > 1) MRRETURN(PCRE_ERROR_PARTIAL); \
433 #define SCHECK_PARTIAL()\
434 if (md->partial != 0 && eptr > md->start_used_ptr) \
437 if (md->partial > 1) MRRETURN(PCRE_ERROR_PARTIAL); \
472 const uschar *markptr,
int offset_top,
match_data *md,
unsigned long int ims,
473 eptrblock *eptrb,
int flags,
unsigned int rdepth)
481 register unsigned int c;
484 BOOL minimize, possessive;
495 frame->Xprevframe = NULL;
500 frame->Xecode = ecode;
501 frame->Xmstart = mstart;
502 frame->Xmarkptr = markptr;
503 frame->Xoffset_top = offset_top;
505 frame->Xeptrb = eptrb;
506 frame->Xflags = flags;
507 frame->Xrdepth = rdepth;
515 #define eptr frame->Xeptr
516 #define ecode frame->Xecode
517 #define mstart frame->Xmstart
518 #define markptr frame->Xmarkptr
519 #define offset_top frame->Xoffset_top
520 #define ims frame->Xims
521 #define eptrb frame->Xeptrb
522 #define flags frame->Xflags
523 #define rdepth frame->Xrdepth
528 #define charptr frame->Xcharptr
530 #define callpat frame->Xcallpat
531 #define codelink frame->Xcodelink
532 #define data frame->Xdata
533 #define next frame->Xnext
534 #define pp frame->Xpp
535 #define prev frame->Xprev
536 #define saved_eptr frame->Xsaved_eptr
538 #define new_recursive frame->Xnew_recursive
540 #define cur_is_word frame->Xcur_is_word
541 #define condition frame->Xcondition
542 #define prev_is_word frame->Xprev_is_word
544 #define original_ims frame->Xoriginal_ims
547 #define prop_type frame->Xprop_type
548 #define prop_value frame->Xprop_value
549 #define prop_fail_result frame->Xprop_fail_result
550 #define prop_category frame->Xprop_category
551 #define prop_chartype frame->Xprop_chartype
552 #define prop_script frame->Xprop_script
553 #define oclength frame->Xoclength
554 #define occhars frame->Xocchars
557 #define ctype frame->Xctype
558 #define fc frame->Xfc
559 #define fi frame->Xfi
560 #define length frame->Xlength
561 #define max frame->Xmax
562 #define min frame->Xmin
563 #define number frame->Xnumber
564 #define offset frame->Xoffset
565 #define op frame->Xop
566 #define save_capture_last frame->Xsave_capture_last
567 #define save_offset1 frame->Xsave_offset1
568 #define save_offset2 frame->Xsave_offset2
569 #define save_offset3 frame->Xsave_offset3
570 #define stacksave frame->Xstacksave
572 #define newptrb frame->Xnewptrb
599 unsigned long int original_ims;
604 int prop_fail_result;
620 int save_capture_last;
621 int save_offset1, save_offset2, save_offset3;
632 prop_fail_result = 0;
685 minimize = possessive =
FALSE;
693 ims, eptrb, flags,
RM55);
709 if (md->
mark == NULL) md->
mark = markptr;
719 ims, eptrb, flags,
RM52);
730 ims, eptrb, flags,
RM51);
736 ims, eptrb, flags,
RM56);
738 md->
mark = ecode + 2;
745 ims, eptrb, flags,
RM53);
753 ims, eptrb, flags,
RM57);
772 ims, eptrb, flags,
RM54);
779 offset_top, md, ims, eptrb, flags,
RM58);
801 number =
GET2(ecode, 1+LINK_SIZE);
802 offset = number << 1;
805 printf(
"start bracket %d\n", number);
807 pchars(eptr, 16,
TRUE, md);
811 if (offset < md->offset_max)
818 DPRINTF((
"saving %d %d %d\n", save_offset1, save_offset2, save_offset3));
822 flags = (op ==
OP_SCBRA)? match_cbegroup : 0;
826 ims, eptrb, flags,
RM1);
831 ecode += GET(ecode, 1);
835 DPRINTF((
"bracket %d failed\n", number));
851 DPRINTF((
"insufficient capture room: treat as non-capturing\n"));
864 DPRINTF((
"start non-capturing bracket\n"));
865 flags = (op >=
OP_SBRA)? match_cbegroup : 0;
868 if (ecode[GET(ecode, 1)] !=
OP_ALT)
873 DPRINTF((
"bracket 0 tail recursion\n"));
893 ecode += GET(ecode, 1);
905 codelink= GET(ecode, 1);
933 condcode = ecode[LINK_SIZE+1];
942 ecode += GET(ecode, 1);
946 int recno =
GET2(ecode, LINK_SIZE + 2);
959 if (
GET2(slotA, 0) == recno)
break;
967 if (i < md->name_count)
973 if (strcmp((
char *)slotA + 2, (
char *)slotB + 2) == 0)
976 if (condition)
break;
989 if (strcmp((
char *)slotA + 2, (
char *)slotB + 2) == 0)
992 if (condition)
break;
1002 ecode += condition? 3 : GET(ecode, 1);
1008 offset =
GET2(ecode, LINK_SIZE+2) << 1;
1009 condition = offset < offset_top && md->
offset_vector[offset] >= 0;
1016 if (!condition && condcode ==
OP_NCREF)
1018 int refno = offset >> 1;
1023 if (
GET2(slotA, 0) == refno)
break;
1031 if (i < md->name_count)
1037 if (strcmp((
char *)slotA + 2, (
char *)slotB + 2) == 0)
1039 offset =
GET2(slotB, 0) << 1;
1040 condition = offset < offset_top &&
1042 if (condition)
break;
1055 if (strcmp((
char *)slotA + 2, (
char *)slotB + 2) == 0)
1057 offset =
GET2(slotB, 0) << 1;
1058 condition = offset < offset_top &&
1060 if (condition)
break;
1070 ecode += condition? 3 : GET(ecode, 1);
1073 else if (condcode ==
OP_DEF)
1076 ecode += GET(ecode, 1);
1085 RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL,
1090 ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2);
1091 while (*ecode ==
OP_ALT) ecode += GET(ecode, 1);
1110 if (condition || *ecode ==
OP_ALT)
1115 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, match_cbegroup,
RM49);
1135 number =
GET2(ecode, 1);
1136 offset = number << 1;
1139 printf(
"end bracket %d at *ACCEPT", number);
1149 if (offset_top <= offset) offset_top = offset + 2;
1164 DPRINTF((
"End of pattern in a (?0) recursion\n"));
1179 if (eptr == mstart &&
1202 DPRINTF((
"ims set to %02lx\n", ims));
1215 RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,
1225 ecode += GET(ecode, 1);
1227 while (*ecode ==
OP_ALT);
1237 do ecode += GET(ecode,1);
while (*ecode ==
OP_ALT);
1250 RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,
1255 do ecode += GET(ecode,1);
while (*ecode ==
OP_ALT);
1261 ecode += GET(ecode,1);
1263 while (*ecode ==
OP_ALT);
1293 eptr -= GET(ecode, 1);
1352 GET2(callpat, 1 + LINK_SIZE);
1384 flags = (*callpat >=
OP_SBRA)? match_cbegroup : 0;
1388 md, ims, eptrb, flags,
RM6);
1391 DPRINTF((
"Recursion matched\n"));
1400 DPRINTF((
"Recursion gave error %d\n", rrc));
1409 callpat += GET(callpat, 1);
1411 while (*callpat ==
OP_ALT);
1413 DPRINTF((
"Recursion didn't match\n"));
1435 RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0,
RM7);
1444 ecode += GET(ecode,1);
1446 while (*ecode ==
OP_ALT);
1455 do ecode += GET(ecode, 1);
while (*ecode ==
OP_ALT);
1466 if (*ecode ==
OP_KET || eptr == saved_eptr)
1478 if (ecode[1+LINK_SIZE] ==
OP_OPT)
1480 ims = (ims & ~
PCRE_IMS) | ecode[4];
1481 DPRINTF((
"ims set to %02lx at group repeat\n", ims));
1486 RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0,
RM8);
1494 RMATCH(eptr, prev, offset_top, md, ims, eptrb, match_cbegroup,
RM9);
1506 do ecode += GET(ecode,1);
while (*ecode ==
OP_ALT);
1518 RMATCH(eptr, next, offset_top, md, ims, eptrb, 0,
RM10);
1520 do next += GET(next,1);
while (*next ==
OP_ALT);
1528 do next += GET(next, 1);
while (*next ==
OP_ALT);
1529 RMATCH(eptr, next + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0,
RM11);
1538 do next += GET(next,1);
while (*next ==
OP_ALT);
1548 prev = ecode - GET(ecode, 1);
1559 else saved_eptr = NULL;
1584 number =
GET2(prev, 1+LINK_SIZE);
1585 offset = number << 1;
1588 printf(
"end bracket %d", number);
1598 if (offset_top <= offset) offset_top = offset + 2;
1607 DPRINTF((
"Recursion (%d) succeeded - continuing\n", number));
1622 DPRINTF((
"ims reset to %02lx\n", ims));
1630 if (*ecode ==
OP_KET || eptr == saved_eptr)
1641 flags = (*prev >=
OP_SBRA)? match_cbegroup : 0;
1645 RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0,
RM12);
1649 RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags,
RM50);
1657 RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags,
RM13);
1704 if ((ims & PCRE_MULTILINE) != 0)
1706 if (eptr < md->end_subject)
1719 if (!md->
endonly)
goto ASSERT_NL_OR_EOS;
1736 if (eptr < md->end_subject &&
1764 USPTR lastptr = eptr - 1;
1765 while((*lastptr & 0xc0) == 0x80) lastptr--;
1771 if (c ==
'_') prev_is_word =
TRUE;
else
1774 prev_is_word = (cat ==
ucp_L || cat ==
ucp_N);
1787 cur_is_word =
FALSE;
1795 if (c ==
'_') cur_is_word =
TRUE;
else
1798 cur_is_word = (cat ==
ucp_L || cat ==
ucp_N);
1822 if (c ==
'_') prev_is_word =
TRUE;
else
1825 prev_is_word = (cat ==
ucp_L || cat ==
ucp_N);
1838 cur_is_word =
FALSE;
1845 if (c ==
'_') cur_is_word =
TRUE;
else
1848 cur_is_word = (cat ==
ucp_L || cat ==
ucp_N);
1859 cur_is_word == prev_is_word : cur_is_word != prev_is_word)
1876 if (utf8)
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
1920 (md->
ctypes[c] & ctype_digit) == 0
1954 (md->
ctypes[c] & ctype_space) == 0
1988 (md->
ctypes[c] & ctype_word) == 0
2005 if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
2230 while (eptr < md->end_subject)
2233 if (!utf8) c = *eptr;
else
2238 if (category !=
ucp_M)
break;
2257 offset =
GET2(ecode, 1) << 1;
2289 minimize = (c & 1) != 0;
2292 if (max == 0) max = INT_MAX;
2298 min =
GET2(ecode, 1);
2299 max =
GET2(ecode, 3);
2300 if (max == 0) max = INT_MAX;
2305 if (!match_ref(offset, eptr, length, md, ims))
2317 if (length == 0)
continue;
2323 for (i = 1; i <= min; i++)
2325 if (!match_ref(offset, eptr, length, md, ims))
2336 if (min == max)
continue;
2342 for (
fi = min;;
fi++)
2344 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM14);
2347 if (!match_ref(offset, eptr, length, md, ims))
2362 for (i = min; i < max; i++)
2364 if (!match_ref(offset, eptr, length, md, ims))
2373 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM15);
2408 minimize = (c & 1) != 0;
2411 if (max == 0) max = INT_MAX;
2417 min =
GET2(ecode, 1);
2418 max =
GET2(ecode, 3);
2419 if (max == 0) max = INT_MAX;
2434 for (i = 1; i <= min; i++)
2456 for (i = 1; i <= min; i++)
2471 if (min == max)
continue;
2482 for (
fi = min;;
fi++)
2484 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM16);
2507 for (
fi = min;;
fi++)
2509 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM17);
2534 for (i = min; i < max; i++)
2549 if ((data[c/8] & (1 << (c&7))) == 0)
break;
2555 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM18);
2557 if (eptr-- == pp)
break;
2565 for (i = min; i < max; i++)
2573 if ((data[c/8] & (1 << (c&7))) == 0)
break;
2578 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM19);
2598 ecode += GET(ecode, 1);
2609 minimize = (c & 1) != 0;
2612 if (max == 0) max = INT_MAX;
2618 min =
GET2(ecode, 1);
2619 max =
GET2(ecode, 3);
2620 if (max == 0) max = INT_MAX;
2631 for (i = 1; i <= min; i++)
2645 if (min == max)
continue;
2652 for (
fi = min;;
fi++)
2654 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM20);
2673 for (i = min; i < max; i++)
2681 GETCHARLENTEST(c, eptr, len);
2687 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM21);
2689 if (eptr-- == pp)
break;
2690 if (utf8) BACKCHAR(eptr);
2792 min = max =
GET2(ecode, 1);
2803 max =
GET2(ecode, 1);
2836 minimize = (c & 1) != 0;
2840 if (max == 0) max = INT_MAX;
2859 unsigned int othercase;
2860 if ((ims & PCRE_CASELESS) != 0 &&
2866 for (i = 1; i <= min; i++)
2868 if (eptr <= md->end_subject - length &&
2869 memcmp(eptr, charptr, length) == 0) eptr += length;
2871 else if (oclength > 0 &&
2872 eptr <= md->end_subject - oclength &&
2873 memcmp(eptr, occhars, oclength) == 0) eptr += oclength;
2882 if (min == max)
continue;
2886 for (
fi = min;;
fi++)
2888 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM22);
2891 if (eptr <= md->end_subject - length &&
2892 memcmp(eptr, charptr, length) == 0) eptr += length;
2894 else if (oclength > 0 &&
2895 eptr <= md->end_subject - oclength &&
2896 memcmp(eptr, occhars, oclength) == 0) eptr += oclength;
2910 for (i = min; i < max; i++)
2912 if (eptr <= md->end_subject - length &&
2913 memcmp(eptr, charptr, length) == 0) eptr += length;
2915 else if (oclength > 0 &&
2916 eptr <= md->end_subject - oclength &&
2917 memcmp(eptr, occhars, oclength) == 0) eptr += oclength;
2926 if (possessive)
continue;
2930 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM23);
2964 DPRINTF((
"matching %c{%d,%d} against subject %.*s\n",
fc, min, max,
2967 if ((ims & PCRE_CASELESS) != 0)
2970 for (i = 1; i <= min; i++)
2979 if (min == max)
continue;
2982 for (
fi = min;;
fi++)
2984 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM24);
2999 for (i = min; i < max; i++)
3006 if (
fc != md->
lcc[*eptr])
break;
3010 if (possessive)
continue;
3014 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM25);
3027 for (i = 1; i <= min; i++)
3037 if (min == max)
continue;
3041 for (
fi = min;;
fi++)
3043 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM26);
3058 for (i = min; i < max; i++)
3065 if (
fc != *eptr)
break;
3068 if (possessive)
continue;
3072 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM27);
3092 if ((ims & PCRE_CASELESS) != 0)
3114 min = max =
GET2(ecode, 1);
3121 max =
GET2(ecode, 1);
3150 max =
GET2(ecode, 1);
3161 minimize = (c & 1) != 0;
3164 if (max == 0) max = INT_MAX;
3179 DPRINTF((
"negative matching %c{%d,%d} against subject %.*s\n",
fc, min, max,
3182 if ((ims & PCRE_CASELESS) != 0)
3190 register unsigned int d;
3191 for (i = 1; i <= min; i++)
3199 if (d < 256) d = md->
lcc[d];
3208 for (i = 1; i <= min; i++)
3219 if (min == max)
continue;
3227 register unsigned int d;
3228 for (
fi = min;;
fi++)
3230 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM28);
3239 if (d < 256) d = md->
lcc[d];
3247 for (
fi = min;;
fi++)
3249 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM29);
3273 register unsigned int d;
3274 for (i = min; i < max; i++)
3283 if (d < 256) d = md->
lcc[d];
3287 if (possessive)
continue;
3290 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM30);
3292 if (eptr-- == pp)
break;
3300 for (i = min; i < max; i++)
3307 if (
fc == md->
lcc[*eptr])
break;
3310 if (possessive)
continue;
3313 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM31);
3332 register unsigned int d;
3333 for (i = 1; i <= min; i++)
3348 for (i = 1; i <= min; i++)
3359 if (min == max)
continue;
3367 register unsigned int d;
3368 for (
fi = min;;
fi++)
3370 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM32);
3386 for (
fi = min;;
fi++)
3388 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM33);
3412 register unsigned int d;
3413 for (i = min; i < max; i++)
3425 if (possessive)
continue;
3428 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM34);
3430 if (eptr-- == pp)
break;
3438 for (i = min; i < max; i++)
3445 if (
fc == *eptr)
break;
3448 if (possessive)
continue;
3451 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM35);
3467 min = max =
GET2(ecode, 1);
3475 max =
GET2(ecode, 1);
3504 max =
GET2(ecode, 1);
3515 minimize = (c & 1) != 0;
3518 if (max == 0) max = INT_MAX;
3531 prop_type = *ecode++;
3532 prop_value = *ecode++;
3534 else prop_type = -1;
3552 for (i = 1; i <= min; i++)
3564 for (i = 1; i <= min; i++)
3573 if ((prop_chartype ==
ucp_Lu ||
3574 prop_chartype ==
ucp_Ll ||
3575 prop_chartype ==
ucp_Lt) == prop_fail_result)
3581 for (i = 1; i <= min; i++)
3590 if ((prop_category == prop_value) == prop_fail_result)
3596 for (i = 1; i <= min; i++)
3605 if ((prop_chartype == prop_value) == prop_fail_result)
3611 for (i = 1; i <= min; i++)
3620 if ((prop_script == prop_value) == prop_fail_result)
3626 for (i = 1; i <= min; i++)
3635 if ((prop_category ==
ucp_L || prop_category ==
ucp_N)
3636 == prop_fail_result)
3642 for (i = 1; i <= min; i++)
3653 == prop_fail_result)
3659 for (i = 1; i <= min; i++)
3670 == prop_fail_result)
3676 for (i = 1; i <= min; i++)
3685 if ((prop_category ==
ucp_L || prop_category ==
ucp_N ||
3687 == prop_fail_result)
3704 for (i = 1; i <= min; i++)
3714 while (eptr < md->end_subject)
3717 if (!utf8) c = *eptr;
3720 if (prop_category !=
ucp_M)
break;
3732 if (utf8)
switch(ctype)
3735 for (i = 1; i <= min; i++)
3744 while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
3749 for (i = 1; i <= min; i++)
3757 while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
3767 for (i = 1; i <= min; i++)
3779 if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
3797 for (i = 1; i <= min; i++)
3833 for (i = 1; i <= min; i++)
3869 for (i = 1; i <= min; i++)
3893 for (i = 1; i <= min; i++)
3917 for (i = 1; i <= min; i++)
3925 if (c < 128 && (md->
ctypes[c] & ctype_digit) != 0)
3931 for (i = 1; i <= min; i++)
3938 if (*eptr >= 128 || (md->
ctypes[*eptr++] & ctype_digit) == 0)
3945 for (i = 1; i <= min; i++)
3952 if (*eptr < 128 && (md->
ctypes[*eptr] & ctype_space) != 0)
3954 while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);
3959 for (i = 1; i <= min; i++)
3966 if (*eptr >= 128 || (md->
ctypes[*eptr++] & ctype_space) == 0)
3973 for (i = 1; i <= min; i++)
3980 if (*eptr < 128 && (md->
ctypes[*eptr] & ctype_word) != 0)
3982 while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);
3987 for (i = 1; i <= min; i++)
3994 if (*eptr >= 128 || (md->
ctypes[*eptr++] & ctype_word) == 0)
4013 for (i = 1; i <= min; i++)
4044 for (i = 1; i <= min; i++)
4055 if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
4070 for (i = 1; i <= min; i++)
4089 for (i = 1; i <= min; i++)
4108 for (i = 1; i <= min; i++)
4129 for (i = 1; i <= min; i++)
4150 for (i = 1; i <= min; i++)
4162 for (i = 1; i <= min; i++)
4174 for (i = 1; i <= min; i++)
4186 for (i = 1; i <= min; i++)
4198 for (i = 1; i <= min; i++)
4205 if ((md->
ctypes[*eptr++] & ctype_word) != 0)
4211 for (i = 1; i <= min; i++)
4218 if ((md->
ctypes[*eptr++] & ctype_word) == 0)
4230 if (min == max)
continue;
4244 for (
fi = min;;
fi++)
4246 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM36);
4260 for (
fi = min;;
fi++)
4262 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM37);
4272 if ((prop_chartype ==
ucp_Lu ||
4273 prop_chartype ==
ucp_Ll ||
4274 prop_chartype ==
ucp_Lt) == prop_fail_result)
4280 for (
fi = min;;
fi++)
4282 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM38);
4292 if ((prop_category == prop_value) == prop_fail_result)
4298 for (
fi = min;;
fi++)
4300 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM39);
4310 if ((prop_chartype == prop_value) == prop_fail_result)
4316 for (
fi = min;;
fi++)
4318 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM40);
4328 if ((prop_script == prop_value) == prop_fail_result)
4334 for (
fi = min;;
fi++)
4336 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM59);
4346 if ((prop_category ==
ucp_L || prop_category ==
ucp_N)
4347 == prop_fail_result)
4353 for (
fi = min;;
fi++)
4355 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM60);
4367 == prop_fail_result)
4373 for (
fi = min;;
fi++)
4375 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM61);
4387 == prop_fail_result)
4393 for (
fi = min;;
fi++)
4395 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM62);
4405 if ((prop_category ==
ucp_L ||
4406 prop_category ==
ucp_N ||
4408 == prop_fail_result)
4425 for (
fi = min;;
fi++)
4427 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM41);
4438 while (eptr < md->end_subject)
4441 if (!utf8) c = *eptr;
4444 if (prop_category !=
ucp_M)
break;
4457 for (
fi = min;;
fi++)
4459 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM42);
4482 if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
4582 if (c < 256 && (md->
ctypes[c] & ctype_digit) != 0)
4587 if (c >= 256 || (md->
ctypes[c] & ctype_digit) == 0)
4592 if (c < 256 && (md->
ctypes[c] & ctype_space) != 0)
4597 if (c >= 256 || (md->
ctypes[c] & ctype_space) == 0)
4602 if (c < 256 && (md->
ctypes[c] & ctype_word) != 0)
4607 if (c >= 256 || (md->
ctypes[c] & ctype_word) == 0)
4620 for (
fi = min;;
fi++)
4622 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM43);
4645 if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
4753 for (i = min; i < max; i++)
4761 GETCHARLENTEST(c, eptr, len);
4762 if (prop_fail_result)
break;
4768 for (i = min; i < max; i++)
4776 GETCHARLENTEST(c, eptr, len);
4778 if ((prop_chartype ==
ucp_Lu ||
4779 prop_chartype ==
ucp_Ll ||
4780 prop_chartype ==
ucp_Lt) == prop_fail_result)
4787 for (i = min; i < max; i++)
4795 GETCHARLENTEST(c, eptr, len);
4797 if ((prop_category == prop_value) == prop_fail_result)
4804 for (i = min; i < max; i++)
4812 GETCHARLENTEST(c, eptr, len);
4814 if ((prop_chartype == prop_value) == prop_fail_result)
4821 for (i = min; i < max; i++)
4829 GETCHARLENTEST(c, eptr, len);
4831 if ((prop_script == prop_value) == prop_fail_result)
4838 for (i = min; i < max; i++)
4846 GETCHARLENTEST(c, eptr, len);
4848 if ((prop_category ==
ucp_L || prop_category ==
ucp_N)
4849 == prop_fail_result)
4856 for (i = min; i < max; i++)
4864 GETCHARLENTEST(c, eptr, len);
4868 == prop_fail_result)
4875 for (i = min; i < max; i++)
4883 GETCHARLENTEST(c, eptr, len);
4887 == prop_fail_result)
4894 for (i = min; i < max; i++)
4902 GETCHARLENTEST(c, eptr, len);
4904 if ((prop_category ==
ucp_L || prop_category ==
ucp_N ||
4917 if (possessive)
continue;
4920 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM44);
4922 if (eptr-- == pp)
break;
4923 if (utf8) BACKCHAR(eptr);
4932 for (i = min; i < max; i++)
4941 if (prop_category ==
ucp_M)
break;
4942 while (eptr < md->end_subject)
4945 if (!utf8) c = *eptr;
else
4950 if (prop_category !=
ucp_M)
break;
4957 if (possessive)
continue;
4961 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM45);
4963 if (eptr-- == pp)
break;
4967 if (!utf8) c = *eptr;
else
4973 if (prop_category !=
ucp_M)
break;
4992 for (i = min; i < max; i++)
5001 while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
5009 for (i = min; i < max; i++)
5018 while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
5026 for (i = min; i < max; i++)
5034 while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
5053 for (i = min; i < max; i++)
5065 if (*eptr == 0x000a) eptr++;
5071 (c != 0x000b && c != 0x000c &&
5072 c != 0x0085 && c != 0x2028 && c != 0x2029)))
5081 for (i = min; i < max; i++)
5093 default: gotspace =
FALSE;
break;
5123 for (i = min; i < max; i++)
5135 default: gotspace =
FALSE;
break;
5152 for (i = min; i < max; i++)
5161 if (c < 256 && (md->
ctypes[c] & ctype_digit) != 0)
break;
5167 for (i = min; i < max; i++)
5176 if (c >= 256 ||(md->
ctypes[c] & ctype_digit) == 0)
break;
5182 for (i = min; i < max; i++)
5191 if (c < 256 && (md->
ctypes[c] & ctype_space) != 0)
break;
5197 for (i = min; i < max; i++)
5206 if (c >= 256 ||(md->
ctypes[c] & ctype_space) == 0)
break;
5212 for (i = min; i < max; i++)
5221 if (c < 256 && (md->
ctypes[c] & ctype_word) != 0)
break;
5227 for (i = min; i < max; i++)
5236 if (c >= 256 || (md->
ctypes[c] & ctype_word) == 0)
break;
5247 if (possessive)
continue;
5250 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM46);
5252 if (eptr-- == pp)
break;
5264 for (i = min; i < max; i++)
5288 for (i = min; i < max; i++)
5299 if (*eptr == 0x000a) eptr++;
5305 (c != 0x000b && c != 0x000c && c != 0x0085)))
5313 for (i = min; i < max; i++)
5321 if (c == 0x09 || c == 0x20 || c == 0xa0)
break;
5327 for (i = min; i < max; i++)
5335 if (c != 0x09 && c != 0x20 && c != 0xa0)
break;
5341 for (i = min; i < max; i++)
5349 if (c == 0x0a || c == 0x0b || c == 0x0c || c == 0x0d || c == 0x85)
5356 for (i = min; i < max; i++)
5364 if (c != 0x0a && c != 0x0b && c != 0x0c && c != 0x0d && c != 0x85)
5371 for (i = min; i < max; i++)
5378 if ((md->
ctypes[*eptr] & ctype_digit) != 0)
break;
5384 for (i = min; i < max; i++)
5391 if ((md->
ctypes[*eptr] & ctype_digit) == 0)
break;
5397 for (i = min; i < max; i++)
5404 if ((md->
ctypes[*eptr] & ctype_space) != 0)
break;
5410 for (i = min; i < max; i++)
5417 if ((md->
ctypes[*eptr] & ctype_space) == 0)
break;
5423 for (i = min; i < max; i++)
5430 if ((md->
ctypes[*eptr] & ctype_word) != 0)
break;
5436 for (i = min; i < max; i++)
5443 if ((md->
ctypes[*eptr] & ctype_word) == 0)
break;
5454 if (possessive)
continue;
5457 RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0,
RM47);
5473 DPRINTF((
"Unknown opcode %d\n", *ecode));
5490 #define LBL(val) case val: goto L_RM##val;
5492 switch (frame->Xwhere)
5494 LBL( 1) LBL( 2) LBL( 3) LBL( 4) LBL( 5) LBL( 6) LBL( 7) LBL( 8)
5495 LBL( 9) LBL(10) LBL(11) LBL(12) LBL(13) LBL(14) LBL(15) LBL(17)
5496 LBL(19) LBL(24) LBL(25) LBL(26) LBL(27) LBL(29) LBL(31) LBL(33)
5497 LBL(35) LBL(43) LBL(47) LBL(48) LBL(49) LBL(50) LBL(51) LBL(52)
5498 LBL(53) LBL(54) LBL(55) LBL(56) LBL(57) LBL(58)
5500 LBL(16) LBL(18) LBL(20) LBL(21) LBL(22) LBL(23) LBL(28) LBL(30)
5501 LBL(32) LBL(34) LBL(42) LBL(46)
5503 LBL(36) LBL(37) LBL(38) LBL(39) LBL(40) LBL(41) LBL(44) LBL(45)
5504 LBL(59) LBL(60) LBL(61) LBL(62)
5508 DPRINTF((
"jump error in pcre match: label %d non-existent\n", frame->Xwhere));
5539 #undef new_recursive
5554 #undef save_capture_last
5600 PCRE_SPTR subject,
int length,
int start_offset,
int options,
int *offsets,
5603 int rc, resetcount, ocount;
5604 int first_byte = -1;
5608 unsigned long int ims;
5619 const uschar *start_bits = NULL;
5620 USPTR start_match = (
USPTR)subject + start_offset;
5622 USPTR start_partial = NULL;
5623 USPTR req_byte_ptr = start_match - 1;
5635 if (re == NULL || subject == NULL ||
5657 tables = external_re->
tables;
5659 if (extra_data != NULL)
5661 register unsigned int flags = extra_data->
flags;
5688 if (study != NULL) study = &internal_study;
5756 (pcre_uint32)options) & PCRE_NEWLINE_BITS)
5758 case 0: newline =
NEWLINE;
break;
5772 else if (newline < 0)
5782 md->
nl[0] = (newline >> 8) & 255;
5783 md->
nl[1] = newline & 255;
5788 md->
nl[0] = newline;
5807 return (tb == length && md->
partial > 1)?
5809 if (start_offset > 0 && start_offset < length)
5811 tb = ((
USPTR)subject)[start_offset] & 0xc0;
5828 ocount = offsetcount - (offsetcount % 3);
5835 using_temporary_offsets =
TRUE;
5836 DPRINTF((
"Got memory to hold back references\n"));
5850 if (resetcount > offsetcount) resetcount = ocount;
5859 register int *iend = iptr - resetcount/2 + 1;
5860 while (--iptr >= iend) *iptr = -1;
5875 first_byte = md->
lcc[first_byte];
5878 if (!startline && study != NULL &&
5901 USPTR save_end_subject = end_subject;
5902 USPTR new_start_match;
5909 register int *iend = iptr + resetcount;
5910 while (iptr < iend) *iptr++ = -1;
5921 USPTR t = start_match;
5925 while (t < md->end_subject && !
IS_NEWLINE(t))
5928 while (t < end_subject && (*t & 0xc0) == 0x80) t++;
5933 while (t < md->end_subject && !
IS_NEWLINE(t)) t++;
5947 if (first_byte >= 0)
5949 if (first_byte_caseless)
5950 while (start_match < end_subject && md->lcc[*start_match] != first_byte)
5953 while (start_match < end_subject && *start_match != first_byte)
5966 while (start_match < end_subject && !
WAS_NEWLINE(start_match))
5969 while(start_match < end_subject && (*start_match & 0xc0) == 0x80)
5975 while (start_match < end_subject && !
WAS_NEWLINE(start_match))
5982 if (start_match[-1] ==
CHAR_CR &&
5984 start_match < end_subject &&
5992 else if (start_bits != NULL)
5994 while (start_match < end_subject)
5996 register unsigned int c = *start_match;
5997 if ((start_bits[c/8] & (1 << (c&7))) == 0)
6002 while(start_match < end_subject && (*start_match & 0xc0) == 0x80)
6013 end_subject = save_end_subject;
6026 (pcre_uint32)(end_subject - start_match) < study->
minlength)
6046 if (req_byte >= 0 && end_subject - start_match <
REQ_BYTE_MAX)
6048 register USPTR p = start_match + ((first_byte >= 0)? 1 : 0);
6053 if (p > req_byte_ptr)
6055 if (req_byte_caseless)
6057 while (p < end_subject)
6059 register int pp = *p++;
6060 if (pp == req_byte || pp == req_byte2) { p--;
break; }
6065 while (p < end_subject)
6067 if (*p++ == req_byte) { p--;
break; }
6074 if (p >= end_subject)
6090 printf(
">>>> Match against: ");
6091 pchars(start_match, end_subject - start_match,
TRUE, md);
6101 rc = match(start_match, md->
start_code, start_match, NULL, 2, md, ims, NULL,
6130 new_start_match = start_match + 1;
6133 while(new_start_match < end_subject && (*new_start_match & 0xc0) == 0x80)
6159 if (firstline &&
IS_NEWLINE(start_match))
break;
6163 start_match = new_start_match;
6168 if (anchored || start_match > end_subject)
break;
6174 if (start_match[-1] ==
CHAR_CR &&
6175 start_match < end_subject &&
6210 if (using_temporary_offsets)
6212 if (offsetcount >= 4)
6215 (offsetcount - 2) *
sizeof(
int));
6216 DPRINTF((
"Copied offsets from temporary memory\n"));
6219 DPRINTF((
"Freeing temporary memory\n"));
6232 if (offsetcount < 2) rc = 0;
else
6238 DPRINTF((
">>>> returning %d\n", rc));
6245 if (using_temporary_offsets)
6247 DPRINTF((
"Freeing temporary memory\n"));
6255 DPRINTF((
">>>> error: returning %d\n", rc));
6261 if (start_partial != NULL)
6263 DPRINTF((
">>>> returning PCRE_ERROR_PARTIAL\n"));
6265 if (offsetcount > 1)
6267 offsets[0] = (int)(start_partial - (
USPTR)subject);
6268 offsets[1] = (int)(end_subject - (
USPTR)subject);
6277 DPRINTF((
">>>> returning PCRE_ERROR_NOMATCH\n"));
6286 *(extra_data->
mark) = (
unsigned char *)(md->
mark);