188 |
obtained from malloc() instead instead of on the stack. Macros are used to |
obtained from malloc() instead instead of on the stack. Macros are used to |
189 |
achieve this so that the actual code doesn't look very different to what it |
achieve this so that the actual code doesn't look very different to what it |
190 |
always used to. |
always used to. |
191 |
|
|
192 |
|
The original heap-recursive code used longjmp(). However, it seems that this |
193 |
|
can be very slow on some operating systems. Following a suggestion from Stan |
194 |
|
Switzer, the use of longjmp() has been abolished, at the cost of having to |
195 |
|
provide a unique number for each call to RMATCH. There is no way of generating |
196 |
|
a sequence of numbers at compile time in C. I have given them names, to make |
197 |
|
them stand out more clearly. |
198 |
|
|
199 |
|
Crude tests on x86 Linux show a small speedup of around 5-8%. However, on |
200 |
|
FreeBSD, avoiding longjmp() more than halves the time taken to run the standard |
201 |
|
tests. Furthermore, not using longjmp() means that local dynamic variables |
202 |
|
don't have indeterminate values; this has meant that the frame size can be |
203 |
|
reduced because the result can be "passed back" by straight setting of the |
204 |
|
variable instead of being passed in the frame. |
205 |
**************************************************************************** |
**************************************************************************** |
206 |
***************************************************************************/ |
***************************************************************************/ |
207 |
|
|
208 |
|
|
209 |
|
/* Numbers for RMATCH calls */ |
210 |
|
|
211 |
|
enum { RM1=1, RM2, RM3, RM4, RM5, RM6, RM7, RM8, RM9, RM10, |
212 |
|
RM11, RM12, RM13, RM14, RM15, RM16, RM17, RM18, RM19, RM20, |
213 |
|
RM21, RM22, RM23, RM24, RM25, RM26, RM27, RM28, RM29, RM30, |
214 |
|
RM31, RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40, |
215 |
|
RM41, RM42, RM43, RM44, RM45, RM46, RM47 }; |
216 |
|
|
217 |
|
|
218 |
/* These versions of the macros use the stack, as normal. There are debugging |
/* These versions of the macros use the stack, as normal. There are debugging |
219 |
versions and production versions. */ |
versions and production versions. Note that the "rw" argument of RMATCH isn't |
220 |
|
actuall used in this definition. */ |
221 |
|
|
222 |
#ifndef NO_RECURSE |
#ifndef NO_RECURSE |
223 |
#define REGISTER register |
#define REGISTER register |
224 |
|
|
225 |
#ifdef DEBUG |
#ifdef DEBUG |
226 |
#define RMATCH(rx,ra,rb,rc,rd,re,rf,rg) \ |
#define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \ |
227 |
{ \ |
{ \ |
228 |
printf("match() called in line %d\n", __LINE__); \ |
printf("match() called in line %d\n", __LINE__); \ |
229 |
rx = match(ra,rb,rc,rd,re,rf,rg,rdepth+1); \ |
rrc = match(ra,rb,rc,rd,re,rf,rg,rdepth+1); \ |
230 |
printf("to line %d\n", __LINE__); \ |
printf("to line %d\n", __LINE__); \ |
231 |
} |
} |
232 |
#define RRETURN(ra) \ |
#define RRETURN(ra) \ |
235 |
return ra; \ |
return ra; \ |
236 |
} |
} |
237 |
#else |
#else |
238 |
#define RMATCH(rx,ra,rb,rc,rd,re,rf,rg) \ |
#define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \ |
239 |
rx = match(ra,rb,rc,rd,re,rf,rg,rdepth+1) |
rrc = match(ra,rb,rc,rd,re,rf,rg,rdepth+1) |
240 |
#define RRETURN(ra) return ra |
#define RRETURN(ra) return ra |
241 |
#endif |
#endif |
242 |
|
|
243 |
#else |
#else |
244 |
|
|
245 |
|
|
246 |
/* These versions of the macros manage a private stack on the heap. Note |
/* These versions of the macros manage a private stack on the heap. Note that |
247 |
that the rd argument of RMATCH isn't actually used. It's the md argument of |
the "rd" argument of RMATCH isn't actually used in this definition. It's the md |
248 |
match(), which never changes. */ |
argument of match(), which never changes. */ |
249 |
|
|
250 |
#define REGISTER |
#define REGISTER |
251 |
|
|
252 |
#define RMATCH(rx,ra,rb,rc,rd,re,rf,rg)\ |
#define RMATCH(ra,rb,rc,rd,re,rf,rg,rw)\ |
253 |
{\ |
{\ |
254 |
heapframe *newframe = (pcre_stack_malloc)(sizeof(heapframe));\ |
heapframe *newframe = (pcre_stack_malloc)(sizeof(heapframe));\ |
255 |
if (setjmp(frame->Xwhere) == 0)\ |
frame->Xwhere = rw; \ |
256 |
{\ |
newframe->Xeptr = ra;\ |
257 |
newframe->Xeptr = ra;\ |
newframe->Xecode = rb;\ |
258 |
newframe->Xecode = rb;\ |
newframe->Xoffset_top = rc;\ |
259 |
newframe->Xoffset_top = rc;\ |
newframe->Xims = re;\ |
260 |
newframe->Xims = re;\ |
newframe->Xeptrb = rf;\ |
261 |
newframe->Xeptrb = rf;\ |
newframe->Xflags = rg;\ |
262 |
newframe->Xflags = rg;\ |
newframe->Xrdepth = frame->Xrdepth + 1;\ |
263 |
newframe->Xrdepth = frame->Xrdepth + 1;\ |
newframe->Xprevframe = frame;\ |
264 |
newframe->Xprevframe = frame;\ |
frame = newframe;\ |
265 |
frame = newframe;\ |
DPRINTF(("restarting from line %d\n", __LINE__));\ |
266 |
DPRINTF(("restarting from line %d\n", __LINE__));\ |
goto HEAP_RECURSE;\ |
267 |
goto HEAP_RECURSE;\ |
L_##rw:\ |
268 |
}\ |
DPRINTF(("jumped back to line %d\n", __LINE__));\ |
|
else\ |
|
|
{\ |
|
|
DPRINTF(("longjumped back to line %d\n", __LINE__));\ |
|
|
frame = md->thisframe;\ |
|
|
rx = frame->Xresult;\ |
|
|
}\ |
|
269 |
} |
} |
270 |
|
|
271 |
#define RRETURN(ra)\ |
#define RRETURN(ra)\ |
275 |
(pcre_stack_free)(newframe);\ |
(pcre_stack_free)(newframe);\ |
276 |
if (frame != NULL)\ |
if (frame != NULL)\ |
277 |
{\ |
{\ |
278 |
frame->Xresult = ra;\ |
rrc = ra;\ |
279 |
md->thisframe = frame;\ |
goto HEAP_RETURN;\ |
|
longjmp(frame->Xwhere, 1);\ |
|
280 |
}\ |
}\ |
281 |
return ra;\ |
return ra;\ |
282 |
} |
} |
341 |
|
|
342 |
eptrblock Xnewptrb; |
eptrblock Xnewptrb; |
343 |
|
|
344 |
/* Place to pass back result, and where to jump back to */ |
/* Where to jump back to */ |
|
|
|
|
int Xresult; |
|
|
jmp_buf Xwhere; |
|
345 |
|
|
346 |
|
int Xwhere; |
347 |
|
|
348 |
} heapframe; |
} heapframe; |
349 |
|
|
350 |
#endif |
#endif |
562 |
complicated macro. It has to be used in one particular way. This shouldn't, |
complicated macro. It has to be used in one particular way. This shouldn't, |
563 |
however, impact performance when true recursion is being used. */ |
however, impact performance when true recursion is being used. */ |
564 |
|
|
565 |
|
#ifdef SUPPORT_UTF8 |
566 |
|
utf8 = md->utf8; /* Local copy of the flag */ |
567 |
|
#else |
568 |
|
utf8 = FALSE; |
569 |
|
#endif |
570 |
|
|
571 |
/* First check that we haven't called match() too many times, or that we |
/* First check that we haven't called match() too many times, or that we |
572 |
haven't exceeded the recursive call limit. */ |
haven't exceeded the recursive call limit. */ |
573 |
|
|
576 |
|
|
577 |
original_ims = ims; /* Save for resetting on ')' */ |
original_ims = ims; /* Save for resetting on ')' */ |
578 |
|
|
|
#ifdef SUPPORT_UTF8 |
|
|
utf8 = md->utf8; /* Local copy of the flag */ |
|
|
#else |
|
|
utf8 = FALSE; |
|
|
#endif |
|
|
|
|
579 |
/* At the start of a group with an unlimited repeat that may match an empty |
/* At the start of a group with an unlimited repeat that may match an empty |
580 |
string, the match_cbegroup flag is set. When this is the case, add the current |
string, the match_cbegroup flag is set. When this is the case, add the current |
581 |
subject pointer to the chain of such remembered pointers, to be checked when we |
subject pointer to the chain of such remembered pointers, to be checked when we |
654 |
flags = (op == OP_SCBRA)? match_cbegroup : 0; |
flags = (op == OP_SCBRA)? match_cbegroup : 0; |
655 |
do |
do |
656 |
{ |
{ |
657 |
RMATCH(rrc, eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
658 |
ims, eptrb, flags); |
ims, eptrb, flags, RM1); |
659 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
660 |
md->capture_last = save_capture_last; |
md->capture_last = save_capture_last; |
661 |
ecode += GET(ecode, 1); |
ecode += GET(ecode, 1); |
698 |
/* For non-final alternatives, continue the loop for a NOMATCH result; |
/* For non-final alternatives, continue the loop for a NOMATCH result; |
699 |
otherwise return. */ |
otherwise return. */ |
700 |
|
|
701 |
RMATCH(rrc, eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims, |
RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims, |
702 |
eptrb, flags); |
eptrb, flags, RM2); |
703 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
704 |
ecode += GET(ecode, 1); |
ecode += GET(ecode, 1); |
705 |
} |
} |
740 |
|
|
741 |
else |
else |
742 |
{ |
{ |
743 |
RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, |
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, |
744 |
match_condassert); |
match_condassert, RM3); |
745 |
if (rrc == MATCH_MATCH) |
if (rrc == MATCH_MATCH) |
746 |
{ |
{ |
747 |
condition = TRUE; |
condition = TRUE; |
819 |
case OP_ASSERTBACK: |
case OP_ASSERTBACK: |
820 |
do |
do |
821 |
{ |
{ |
822 |
RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0); |
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0, |
823 |
|
RM4); |
824 |
if (rrc == MATCH_MATCH) break; |
if (rrc == MATCH_MATCH) break; |
825 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
826 |
ecode += GET(ecode, 1); |
ecode += GET(ecode, 1); |
846 |
case OP_ASSERTBACK_NOT: |
case OP_ASSERTBACK_NOT: |
847 |
do |
do |
848 |
{ |
{ |
849 |
RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0); |
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0, |
850 |
|
RM5); |
851 |
if (rrc == MATCH_MATCH) RRETURN(MATCH_NOMATCH); |
if (rrc == MATCH_MATCH) RRETURN(MATCH_NOMATCH); |
852 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
853 |
ecode += GET(ecode,1); |
ecode += GET(ecode,1); |
976 |
flags = (*callpat >= OP_SBRA)? match_cbegroup : 0; |
flags = (*callpat >= OP_SBRA)? match_cbegroup : 0; |
977 |
do |
do |
978 |
{ |
{ |
979 |
RMATCH(rrc, eptr, callpat + _pcre_OP_lengths[*callpat], offset_top, |
RMATCH(eptr, callpat + _pcre_OP_lengths[*callpat], offset_top, |
980 |
md, ims, eptrb, flags); |
md, ims, eptrb, flags, RM6); |
981 |
if (rrc == MATCH_MATCH) |
if (rrc == MATCH_MATCH) |
982 |
{ |
{ |
983 |
DPRINTF(("Recursion matched\n")); |
DPRINTF(("Recursion matched\n")); |
1020 |
|
|
1021 |
do |
do |
1022 |
{ |
{ |
1023 |
RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, |
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, |
1024 |
eptrb, 0); |
eptrb, 0, RM7); |
1025 |
if (rrc == MATCH_MATCH) break; |
if (rrc == MATCH_MATCH) break; |
1026 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
1027 |
ecode += GET(ecode,1); |
ecode += GET(ecode,1); |
1066 |
|
|
1067 |
if (*ecode == OP_KETRMIN) |
if (*ecode == OP_KETRMIN) |
1068 |
{ |
{ |
1069 |
RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, |
1070 |
|
RM8); |
1071 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
1072 |
ecode = prev; |
ecode = prev; |
1073 |
flags = match_tail_recursed; |
flags = match_tail_recursed; |
1075 |
} |
} |
1076 |
else /* OP_KETRMAX */ |
else /* OP_KETRMAX */ |
1077 |
{ |
{ |
1078 |
RMATCH(rrc, eptr, prev, offset_top, md, ims, eptrb, match_cbegroup); |
RMATCH(eptr, prev, offset_top, md, ims, eptrb, match_cbegroup, RM9); |
1079 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
1080 |
ecode += 1 + LINK_SIZE; |
ecode += 1 + LINK_SIZE; |
1081 |
flags = match_tail_recursed; |
flags = match_tail_recursed; |
1099 |
case OP_BRAZERO: |
case OP_BRAZERO: |
1100 |
{ |
{ |
1101 |
next = ecode+1; |
next = ecode+1; |
1102 |
RMATCH(rrc, eptr, next, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, next, offset_top, md, ims, eptrb, 0, RM10); |
1103 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
1104 |
do next += GET(next,1); while (*next == OP_ALT); |
do next += GET(next,1); while (*next == OP_ALT); |
1105 |
ecode = next + 1 + LINK_SIZE; |
ecode = next + 1 + LINK_SIZE; |
1110 |
{ |
{ |
1111 |
next = ecode+1; |
next = ecode+1; |
1112 |
do next += GET(next, 1); while (*next == OP_ALT); |
do next += GET(next, 1); while (*next == OP_ALT); |
1113 |
RMATCH(rrc, eptr, next + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, next + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0, RM11); |
1114 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
1115 |
ecode++; |
ecode++; |
1116 |
} |
} |
1215 |
|
|
1216 |
if (*ecode == OP_KETRMIN) |
if (*ecode == OP_KETRMIN) |
1217 |
{ |
{ |
1218 |
RMATCH(rrc, eptr, ecode + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0, |
1219 |
|
RM12); |
1220 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
1221 |
ecode = prev; |
ecode = prev; |
1222 |
flags |= match_tail_recursed; |
flags |= match_tail_recursed; |
1224 |
} |
} |
1225 |
else /* OP_KETRMAX */ |
else /* OP_KETRMAX */ |
1226 |
{ |
{ |
1227 |
RMATCH(rrc, eptr, prev, offset_top, md, ims, eptrb, flags); |
RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM13); |
1228 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
1229 |
ecode += 1 + LINK_SIZE; |
ecode += 1 + LINK_SIZE; |
1230 |
flags = match_tail_recursed; |
flags = match_tail_recursed; |
1623 |
{ |
{ |
1624 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
1625 |
{ |
{ |
1626 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM14); |
1627 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
1628 |
if (fi >= max || !match_ref(offset, eptr, length, md, ims)) |
if (fi >= max || !match_ref(offset, eptr, length, md, ims)) |
1629 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
1644 |
} |
} |
1645 |
while (eptr >= pp) |
while (eptr >= pp) |
1646 |
{ |
{ |
1647 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM15); |
1648 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
1649 |
eptr -= length; |
eptr -= length; |
1650 |
} |
} |
1749 |
{ |
{ |
1750 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
1751 |
{ |
{ |
1752 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM16); |
1753 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
1754 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
1755 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
1769 |
{ |
{ |
1770 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
1771 |
{ |
{ |
1772 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM17); |
1773 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
1774 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
1775 |
c = *eptr++; |
c = *eptr++; |
1806 |
} |
} |
1807 |
for (;;) |
for (;;) |
1808 |
{ |
{ |
1809 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM18); |
1810 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
1811 |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
1812 |
BACKCHAR(eptr); |
BACKCHAR(eptr); |
1825 |
} |
} |
1826 |
while (eptr >= pp) |
while (eptr >= pp) |
1827 |
{ |
{ |
1828 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM19); |
1829 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
1830 |
eptr--; |
eptr--; |
1831 |
} |
} |
1896 |
{ |
{ |
1897 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
1898 |
{ |
{ |
1899 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM20); |
1900 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
1901 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
1902 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
1920 |
} |
} |
1921 |
for(;;) |
for(;;) |
1922 |
{ |
{ |
1923 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM21); |
1924 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
1925 |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
1926 |
BACKCHAR(eptr) |
BACKCHAR(eptr) |
2107 |
{ |
{ |
2108 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
2109 |
{ |
{ |
2110 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM22); |
2111 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
2112 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
2113 |
if (memcmp(eptr, charptr, length) == 0) eptr += length; |
if (memcmp(eptr, charptr, length) == 0) eptr += length; |
2148 |
if (possessive) continue; |
if (possessive) continue; |
2149 |
for(;;) |
for(;;) |
2150 |
{ |
{ |
2151 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM23); |
2152 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
2153 |
if (eptr == pp) RRETURN(MATCH_NOMATCH); |
if (eptr == pp) RRETURN(MATCH_NOMATCH); |
2154 |
#ifdef SUPPORT_UCP |
#ifdef SUPPORT_UCP |
2197 |
{ |
{ |
2198 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
2199 |
{ |
{ |
2200 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM24); |
2201 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
2202 |
if (fi >= max || eptr >= md->end_subject || |
if (fi >= max || eptr >= md->end_subject || |
2203 |
fc != md->lcc[*eptr++]) |
fc != md->lcc[*eptr++]) |
2216 |
if (possessive) continue; |
if (possessive) continue; |
2217 |
while (eptr >= pp) |
while (eptr >= pp) |
2218 |
{ |
{ |
2219 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM25); |
2220 |
eptr--; |
eptr--; |
2221 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
2222 |
} |
} |
2235 |
{ |
{ |
2236 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
2237 |
{ |
{ |
2238 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM26); |
2239 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
2240 |
if (fi >= max || eptr >= md->end_subject || fc != *eptr++) |
if (fi >= max || eptr >= md->end_subject || fc != *eptr++) |
2241 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
2253 |
if (possessive) continue; |
if (possessive) continue; |
2254 |
while (eptr >= pp) |
while (eptr >= pp) |
2255 |
{ |
{ |
2256 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM27); |
2257 |
eptr--; |
eptr--; |
2258 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
2259 |
} |
} |
2398 |
register unsigned int d; |
register unsigned int d; |
2399 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
2400 |
{ |
{ |
2401 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM28); |
2402 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
2403 |
GETCHARINC(d, eptr); |
GETCHARINC(d, eptr); |
2404 |
if (d < 256) d = md->lcc[d]; |
if (d < 256) d = md->lcc[d]; |
2412 |
{ |
{ |
2413 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
2414 |
{ |
{ |
2415 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM29); |
2416 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
2417 |
if (fi >= max || eptr >= md->end_subject || fc == md->lcc[*eptr++]) |
if (fi >= max || eptr >= md->end_subject || fc == md->lcc[*eptr++]) |
2418 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
2444 |
if (possessive) continue; |
if (possessive) continue; |
2445 |
for(;;) |
for(;;) |
2446 |
{ |
{ |
2447 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM30); |
2448 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
2449 |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
2450 |
BACKCHAR(eptr); |
BACKCHAR(eptr); |
2462 |
if (possessive) continue; |
if (possessive) continue; |
2463 |
while (eptr >= pp) |
while (eptr >= pp) |
2464 |
{ |
{ |
2465 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM31); |
2466 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
2467 |
eptr--; |
eptr--; |
2468 |
} |
} |
2507 |
register unsigned int d; |
register unsigned int d; |
2508 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
2509 |
{ |
{ |
2510 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM32); |
2511 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
2512 |
GETCHARINC(d, eptr); |
GETCHARINC(d, eptr); |
2513 |
if (fi >= max || eptr >= md->end_subject || fc == d) |
if (fi >= max || eptr >= md->end_subject || fc == d) |
2520 |
{ |
{ |
2521 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
2522 |
{ |
{ |
2523 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM33); |
2524 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
2525 |
if (fi >= max || eptr >= md->end_subject || fc == *eptr++) |
if (fi >= max || eptr >= md->end_subject || fc == *eptr++) |
2526 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
2551 |
if (possessive) continue; |
if (possessive) continue; |
2552 |
for(;;) |
for(;;) |
2553 |
{ |
{ |
2554 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM34); |
2555 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
2556 |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
2557 |
BACKCHAR(eptr); |
BACKCHAR(eptr); |
2569 |
if (possessive) continue; |
if (possessive) continue; |
2570 |
while (eptr >= pp) |
while (eptr >= pp) |
2571 |
{ |
{ |
2572 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM35); |
2573 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
2574 |
eptr--; |
eptr--; |
2575 |
} |
} |
2966 |
case PT_ANY: |
case PT_ANY: |
2967 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
2968 |
{ |
{ |
2969 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM36); |
2970 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
2971 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
2972 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
2977 |
case PT_LAMP: |
case PT_LAMP: |
2978 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
2979 |
{ |
{ |
2980 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM37); |
2981 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
2982 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
2983 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
2992 |
case PT_GC: |
case PT_GC: |
2993 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
2994 |
{ |
{ |
2995 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM38); |
2996 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
2997 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
2998 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
3005 |
case PT_PC: |
case PT_PC: |
3006 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
3007 |
{ |
{ |
3008 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM39); |
3009 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
3010 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
3011 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
3018 |
case PT_SC: |
case PT_SC: |
3019 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
3020 |
{ |
{ |
3021 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM40); |
3022 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
3023 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
3024 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
3040 |
{ |
{ |
3041 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
3042 |
{ |
{ |
3043 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM41); |
3044 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
3045 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
3046 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
3069 |
{ |
{ |
3070 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
3071 |
{ |
{ |
3072 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM42); |
3073 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
3074 |
if (fi >= max || eptr >= md->end_subject || |
if (fi >= max || eptr >= md->end_subject || |
3075 |
(ctype == OP_ANY && (ims & PCRE_DOTALL) == 0 && |
(ctype == OP_ANY && (ims & PCRE_DOTALL) == 0 && |
3143 |
{ |
{ |
3144 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
3145 |
{ |
{ |
3146 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM43); |
3147 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
3148 |
if (fi >= max || eptr >= md->end_subject || |
if (fi >= max || eptr >= md->end_subject || |
3149 |
((ims & PCRE_DOTALL) == 0 && IS_NEWLINE(eptr))) |
((ims & PCRE_DOTALL) == 0 && IS_NEWLINE(eptr))) |
3289 |
if (possessive) continue; |
if (possessive) continue; |
3290 |
for(;;) |
for(;;) |
3291 |
{ |
{ |
3292 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM44); |
3293 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
3294 |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
3295 |
BACKCHAR(eptr); |
BACKCHAR(eptr); |
3325 |
if (possessive) continue; |
if (possessive) continue; |
3326 |
for(;;) |
for(;;) |
3327 |
{ |
{ |
3328 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM45); |
3329 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
3330 |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
3331 |
for (;;) /* Move back over one extended */ |
for (;;) /* Move back over one extended */ |
3509 |
if (possessive) continue; |
if (possessive) continue; |
3510 |
for(;;) |
for(;;) |
3511 |
{ |
{ |
3512 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM46); |
3513 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
3514 |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
3515 |
BACKCHAR(eptr); |
BACKCHAR(eptr); |
3623 |
if (possessive) continue; |
if (possessive) continue; |
3624 |
while (eptr >= pp) |
while (eptr >= pp) |
3625 |
{ |
{ |
3626 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM47); |
3627 |
eptr--; |
eptr--; |
3628 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
3629 |
} |
} |
3649 |
|
|
3650 |
} /* End of main loop */ |
} /* End of main loop */ |
3651 |
/* Control never reaches here */ |
/* Control never reaches here */ |
3652 |
|
|
3653 |
|
|
3654 |
|
/* When compiling to use the heap rather than the stack for recursive calls to |
3655 |
|
match(), the RRETURN() macro jumps here. The number that is saved in |
3656 |
|
frame->Xwhere indicates which label we actually want to return to. */ |
3657 |
|
|
3658 |
|
#ifdef NO_RECURSE |
3659 |
|
#define LBL(val) case val: goto L_RM##val; |
3660 |
|
HEAP_RETURN: |
3661 |
|
switch (frame->Xwhere) |
3662 |
|
{ |
3663 |
|
LBL( 1) LBL( 2) LBL( 3) LBL( 4) LBL( 5) LBL( 6) LBL( 7) LBL( 8) |
3664 |
|
LBL( 9) LBL(10) LBL(11) LBL(12) LBL(13) LBL(14) LBL(15) LBL(16) |
3665 |
|
LBL(17) LBL(18) LBL(19) LBL(20) LBL(21) LBL(22) LBL(23) LBL(24) |
3666 |
|
LBL(25) LBL(26) LBL(27) LBL(28) LBL(29) LBL(30) LBL(31) LBL(32) |
3667 |
|
LBL(33) LBL(34) LBL(35) LBL(36) LBL(37) LBL(38) LBL(39) LBL(40) |
3668 |
|
LBL(41) LBL(42) LBL(43) LBL(44) LBL(45) LBL(46) LBL(47) |
3669 |
|
default: |
3670 |
|
DPRINTF(("jump error in pcre match: label %d non-existent\n", frame->Xwhere)); |
3671 |
|
return PCRE_ERROR_INTERNAL; |
3672 |
|
} |
3673 |
|
#undef LBL |
3674 |
|
#endif /* NO_RECURSE */ |
3675 |
} |
} |
3676 |
|
|
3677 |
|
|