307 |
|
|
308 |
#define RMATCH(ra,rb,rc,rd,re,rw)\ |
#define RMATCH(ra,rb,rc,rd,re,rw)\ |
309 |
{\ |
{\ |
310 |
heapframe *newframe = (heapframe *)(pcre_stack_malloc)(sizeof(heapframe));\ |
heapframe *newframe = (heapframe *)(PUBL(stack_malloc))(sizeof(heapframe));\ |
311 |
if (newframe == NULL) RRETURN(PCRE_ERROR_NOMEMORY);\ |
if (newframe == NULL) RRETURN(PCRE_ERROR_NOMEMORY);\ |
312 |
frame->Xwhere = rw; \ |
frame->Xwhere = rw; \ |
313 |
newframe->Xeptr = ra;\ |
newframe->Xeptr = ra;\ |
328 |
{\ |
{\ |
329 |
heapframe *oldframe = frame;\ |
heapframe *oldframe = frame;\ |
330 |
frame = oldframe->Xprevframe;\ |
frame = oldframe->Xprevframe;\ |
331 |
(pcre_stack_free)(oldframe);\ |
(PUBL(stack_free))(oldframe);\ |
332 |
if (frame != NULL)\ |
if (frame != NULL)\ |
333 |
{\ |
{\ |
334 |
rrc = ra;\ |
rrc = ra;\ |
486 |
heap whenever RMATCH() does a "recursion". See the macro definitions above. */ |
heap whenever RMATCH() does a "recursion". See the macro definitions above. */ |
487 |
|
|
488 |
#ifdef NO_RECURSE |
#ifdef NO_RECURSE |
489 |
heapframe *frame = (heapframe *)(pcre_stack_malloc)(sizeof(heapframe)); |
heapframe *frame = (heapframe *)(PUBL(stack_malloc))(sizeof(heapframe)); |
490 |
if (frame == NULL) RRETURN(PCRE_ERROR_NOMEMORY); |
if (frame == NULL) RRETURN(PCRE_ERROR_NOMEMORY); |
491 |
frame->Xprevframe = NULL; /* Marks the top level */ |
frame->Xprevframe = NULL; /* Marks the top level */ |
492 |
|
|
1217 |
|
|
1218 |
if (ecode[LINK_SIZE+1] == OP_CALLOUT) |
if (ecode[LINK_SIZE+1] == OP_CALLOUT) |
1219 |
{ |
{ |
1220 |
if (pcre_callout != NULL) |
if (PUBL(callout) != NULL) |
1221 |
{ |
{ |
1222 |
pcre_callout_block cb; |
pcre_callout_block cb; |
1223 |
cb.version = 2; /* Version 1 of the callout block */ |
cb.version = 2; /* Version 1 of the callout block */ |
1233 |
cb.capture_last = md->capture_last; |
cb.capture_last = md->capture_last; |
1234 |
cb.callout_data = md->callout_data; |
cb.callout_data = md->callout_data; |
1235 |
cb.mark = md->nomatch_mark; |
cb.mark = md->nomatch_mark; |
1236 |
if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH); |
if ((rrc = (*PUBL(callout))(&cb)) > 0) RRETURN(MATCH_NOMATCH); |
1237 |
if (rrc < 0) RRETURN(rrc); |
if (rrc < 0) RRETURN(rrc); |
1238 |
} |
} |
1239 |
ecode += PRIV(OP_lengths)[OP_CALLOUT]; |
ecode += PRIV(OP_lengths)[OP_CALLOUT]; |
1627 |
function is able to force a failure. */ |
function is able to force a failure. */ |
1628 |
|
|
1629 |
case OP_CALLOUT: |
case OP_CALLOUT: |
1630 |
if (pcre_callout != NULL) |
if (PUBL(callout) != NULL) |
1631 |
{ |
{ |
1632 |
pcre_callout_block cb; |
pcre_callout_block cb; |
1633 |
cb.version = 2; /* Version 1 of the callout block */ |
cb.version = 2; /* Version 1 of the callout block */ |
1643 |
cb.capture_last = md->capture_last; |
cb.capture_last = md->capture_last; |
1644 |
cb.callout_data = md->callout_data; |
cb.callout_data = md->callout_data; |
1645 |
cb.mark = md->nomatch_mark; |
cb.mark = md->nomatch_mark; |
1646 |
if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH); |
if ((rrc = (*PUBL(callout))(&cb)) > 0) RRETURN(MATCH_NOMATCH); |
1647 |
if (rrc < 0) RRETURN(rrc); |
if (rrc < 0) RRETURN(rrc); |
1648 |
} |
} |
1649 |
ecode += 2 + 2*LINK_SIZE; |
ecode += 2 + 2*LINK_SIZE; |
1702 |
else |
else |
1703 |
{ |
{ |
1704 |
new_recursive.offset_save = |
new_recursive.offset_save = |
1705 |
(int *)(pcre_malloc)(new_recursive.saved_max * sizeof(int)); |
(int *)(PUBL(malloc))(new_recursive.saved_max * sizeof(int)); |
1706 |
if (new_recursive.offset_save == NULL) RRETURN(PCRE_ERROR_NOMEMORY); |
if (new_recursive.offset_save == NULL) RRETURN(PCRE_ERROR_NOMEMORY); |
1707 |
} |
} |
1708 |
memcpy(new_recursive.offset_save, md->offset_vector, |
memcpy(new_recursive.offset_save, md->offset_vector, |
1726 |
{ |
{ |
1727 |
DPRINTF(("Recursion matched\n")); |
DPRINTF(("Recursion matched\n")); |
1728 |
if (new_recursive.offset_save != stacksave) |
if (new_recursive.offset_save != stacksave) |
1729 |
(pcre_free)(new_recursive.offset_save); |
(PUBL(free))(new_recursive.offset_save); |
1730 |
|
|
1731 |
/* Set where we got to in the subject, and reset the start in case |
/* Set where we got to in the subject, and reset the start in case |
1732 |
it was changed by \K. This *is* propagated back out of a recursion, |
it was changed by \K. This *is* propagated back out of a recursion, |
1744 |
{ |
{ |
1745 |
DPRINTF(("Recursion gave error %d\n", rrc)); |
DPRINTF(("Recursion gave error %d\n", rrc)); |
1746 |
if (new_recursive.offset_save != stacksave) |
if (new_recursive.offset_save != stacksave) |
1747 |
(pcre_free)(new_recursive.offset_save); |
(PUBL(free))(new_recursive.offset_save); |
1748 |
RRETURN(rrc); |
RRETURN(rrc); |
1749 |
} |
} |
1750 |
|
|
1756 |
DPRINTF(("Recursion didn't match\n")); |
DPRINTF(("Recursion didn't match\n")); |
1757 |
md->recursive = new_recursive.prevrec; |
md->recursive = new_recursive.prevrec; |
1758 |
if (new_recursive.offset_save != stacksave) |
if (new_recursive.offset_save != stacksave) |
1759 |
(pcre_free)(new_recursive.offset_save); |
(PUBL(free))(new_recursive.offset_save); |
1760 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
1761 |
} |
} |
1762 |
|
|
2141 |
} |
} |
2142 |
else |
else |
2143 |
#endif |
#endif |
2144 |
prev_is_word = ((md->ctypes[eptr[-1]] & ctype_word) != 0); |
prev_is_word = MAX_255(eptr[-1]) |
2145 |
|
&& ((md->ctypes[eptr[-1]] & ctype_word) != 0); |
2146 |
} |
} |
2147 |
|
|
2148 |
/* Get status of next character */ |
/* Get status of next character */ |
2165 |
} |
} |
2166 |
else |
else |
2167 |
#endif |
#endif |
2168 |
cur_is_word = ((md->ctypes[*eptr] & ctype_word) != 0); |
cur_is_word = MAX_255(*eptr) |
2169 |
|
&& ((md->ctypes[*eptr] & ctype_word) != 0); |
2170 |
} |
} |
2171 |
|
|
2172 |
/* Now see if the situation is what we want */ |
/* Now see if the situation is what we want */ |
4334 |
SCHECK_PARTIAL(); |
SCHECK_PARTIAL(); |
4335 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
4336 |
} |
} |
4337 |
if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0) |
if (*eptr >= 128 || (md->ctypes[*eptr] & ctype_digit) == 0) |
4338 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
4339 |
|
eptr++; |
4340 |
/* No need to skip more bytes - we know it's a 1-byte character */ |
/* No need to skip more bytes - we know it's a 1-byte character */ |
4341 |
} |
} |
4342 |
break; |
break; |
4364 |
SCHECK_PARTIAL(); |
SCHECK_PARTIAL(); |
4365 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
4366 |
} |
} |
4367 |
if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0) |
if (*eptr >= 128 || (md->ctypes[*eptr] & ctype_space) == 0) |
4368 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
4369 |
|
eptr++; |
4370 |
/* No need to skip more bytes - we know it's a 1-byte character */ |
/* No need to skip more bytes - we know it's a 1-byte character */ |
4371 |
} |
} |
4372 |
break; |
break; |
4394 |
SCHECK_PARTIAL(); |
SCHECK_PARTIAL(); |
4395 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
4396 |
} |
} |
4397 |
if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0) |
if (*eptr >= 128 || (md->ctypes[*eptr] & ctype_word) == 0) |
4398 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
4399 |
|
eptr++; |
4400 |
/* No need to skip more bytes - we know it's a 1-byte character */ |
/* No need to skip more bytes - we know it's a 1-byte character */ |
4401 |
} |
} |
4402 |
break; |
break; |
4560 |
SCHECK_PARTIAL(); |
SCHECK_PARTIAL(); |
4561 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
4562 |
} |
} |
4563 |
if ((md->ctypes[*eptr++] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH); |
if (MAX_255(*eptr) && (md->ctypes[*eptr] & ctype_digit) != 0) |
4564 |
|
RRETURN(MATCH_NOMATCH); |
4565 |
|
eptr++; |
4566 |
} |
} |
4567 |
break; |
break; |
4568 |
|
|
4574 |
SCHECK_PARTIAL(); |
SCHECK_PARTIAL(); |
4575 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
4576 |
} |
} |
4577 |
if ((md->ctypes[*eptr++] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH); |
if (!MAX_255(*eptr) || (md->ctypes[*eptr] & ctype_digit) == 0) |
4578 |
|
RRETURN(MATCH_NOMATCH); |
4579 |
|
eptr++; |
4580 |
} |
} |
4581 |
break; |
break; |
4582 |
|
|
4588 |
SCHECK_PARTIAL(); |
SCHECK_PARTIAL(); |
4589 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
4590 |
} |
} |
4591 |
if ((md->ctypes[*eptr++] & ctype_space) != 0) RRETURN(MATCH_NOMATCH); |
if (MAX_255(*eptr) && (md->ctypes[*eptr] & ctype_space) != 0) |
4592 |
|
RRETURN(MATCH_NOMATCH); |
4593 |
|
eptr++; |
4594 |
} |
} |
4595 |
break; |
break; |
4596 |
|
|
4602 |
SCHECK_PARTIAL(); |
SCHECK_PARTIAL(); |
4603 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
4604 |
} |
} |
4605 |
if ((md->ctypes[*eptr++] & ctype_space) == 0) RRETURN(MATCH_NOMATCH); |
if (!MAX_255(*eptr) || (md->ctypes[*eptr] & ctype_space) == 0) |
4606 |
|
RRETURN(MATCH_NOMATCH); |
4607 |
|
eptr++; |
4608 |
} |
} |
4609 |
break; |
break; |
4610 |
|
|
4616 |
SCHECK_PARTIAL(); |
SCHECK_PARTIAL(); |
4617 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
4618 |
} |
} |
4619 |
if ((md->ctypes[*eptr++] & ctype_word) != 0) |
if (MAX_255(*eptr) && (md->ctypes[*eptr] & ctype_word) != 0) |
4620 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
4621 |
|
eptr++; |
4622 |
} |
} |
4623 |
break; |
break; |
4624 |
|
|
4630 |
SCHECK_PARTIAL(); |
SCHECK_PARTIAL(); |
4631 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
4632 |
} |
} |
4633 |
if ((md->ctypes[*eptr++] & ctype_word) == 0) |
if (!MAX_255(*eptr) || (md->ctypes[*eptr] & ctype_word) == 0) |
4634 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
4635 |
|
eptr++; |
4636 |
} |
} |
4637 |
break; |
break; |
4638 |
|
|
5002 |
break; |
break; |
5003 |
|
|
5004 |
case OP_WHITESPACE: |
case OP_WHITESPACE: |
5005 |
if (c >= 256 || (md->ctypes[c] & ctype_space) == 0) |
if (c >= 256 || (md->ctypes[c] & ctype_space) == 0) |
5006 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
5007 |
break; |
break; |
5008 |
|
|
5113 |
break; |
break; |
5114 |
|
|
5115 |
case OP_NOT_DIGIT: |
case OP_NOT_DIGIT: |
5116 |
if ((md->ctypes[c] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH); |
if (MAX_255(c) && (md->ctypes[c] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH); |
5117 |
break; |
break; |
5118 |
|
|
5119 |
case OP_DIGIT: |
case OP_DIGIT: |
5120 |
if ((md->ctypes[c] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH); |
if (!MAX_255(c) || (md->ctypes[c] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH); |
5121 |
break; |
break; |
5122 |
|
|
5123 |
case OP_NOT_WHITESPACE: |
case OP_NOT_WHITESPACE: |
5124 |
if ((md->ctypes[c] & ctype_space) != 0) RRETURN(MATCH_NOMATCH); |
if (MAX_255(c) && (md->ctypes[c] & ctype_space) != 0) RRETURN(MATCH_NOMATCH); |
5125 |
break; |
break; |
5126 |
|
|
5127 |
case OP_WHITESPACE: |
case OP_WHITESPACE: |
5128 |
if ((md->ctypes[c] & ctype_space) == 0) RRETURN(MATCH_NOMATCH); |
if (!MAX_255(c) || (md->ctypes[c] & ctype_space) == 0) RRETURN(MATCH_NOMATCH); |
5129 |
break; |
break; |
5130 |
|
|
5131 |
case OP_NOT_WORDCHAR: |
case OP_NOT_WORDCHAR: |
5132 |
if ((md->ctypes[c] & ctype_word) != 0) RRETURN(MATCH_NOMATCH); |
if (MAX_255(c) && (md->ctypes[c] & ctype_word) != 0) RRETURN(MATCH_NOMATCH); |
5133 |
break; |
break; |
5134 |
|
|
5135 |
case OP_WORDCHAR: |
case OP_WORDCHAR: |
5136 |
if ((md->ctypes[c] & ctype_word) == 0) RRETURN(MATCH_NOMATCH); |
if (!MAX_255(c) || (md->ctypes[c] & ctype_word) == 0) RRETURN(MATCH_NOMATCH); |
5137 |
break; |
break; |
5138 |
|
|
5139 |
default: |
default: |
5779 |
SCHECK_PARTIAL(); |
SCHECK_PARTIAL(); |
5780 |
break; |
break; |
5781 |
} |
} |
5782 |
if ((md->ctypes[*eptr] & ctype_digit) != 0) break; |
if (MAX_255(*eptr) && (md->ctypes[*eptr] & ctype_digit) != 0) break; |
5783 |
eptr++; |
eptr++; |
5784 |
} |
} |
5785 |
break; |
break; |
5792 |
SCHECK_PARTIAL(); |
SCHECK_PARTIAL(); |
5793 |
break; |
break; |
5794 |
} |
} |
5795 |
if ((md->ctypes[*eptr] & ctype_digit) == 0) break; |
if (!MAX_255(*eptr) || (md->ctypes[*eptr] & ctype_digit) == 0) break; |
5796 |
eptr++; |
eptr++; |
5797 |
} |
} |
5798 |
break; |
break; |
5805 |
SCHECK_PARTIAL(); |
SCHECK_PARTIAL(); |
5806 |
break; |
break; |
5807 |
} |
} |
5808 |
if ((md->ctypes[*eptr] & ctype_space) != 0) break; |
if (MAX_255(*eptr) && (md->ctypes[*eptr] & ctype_space) != 0) break; |
5809 |
eptr++; |
eptr++; |
5810 |
} |
} |
5811 |
break; |
break; |
5818 |
SCHECK_PARTIAL(); |
SCHECK_PARTIAL(); |
5819 |
break; |
break; |
5820 |
} |
} |
5821 |
if ((md->ctypes[*eptr] & ctype_space) == 0) break; |
if (!MAX_255(*eptr) || (md->ctypes[*eptr] & ctype_space) == 0) break; |
5822 |
eptr++; |
eptr++; |
5823 |
} |
} |
5824 |
break; |
break; |
5831 |
SCHECK_PARTIAL(); |
SCHECK_PARTIAL(); |
5832 |
break; |
break; |
5833 |
} |
} |
5834 |
if ((md->ctypes[*eptr] & ctype_word) != 0) break; |
if (MAX_255(*eptr) && (md->ctypes[*eptr] & ctype_word) != 0) break; |
5835 |
eptr++; |
eptr++; |
5836 |
} |
} |
5837 |
break; |
break; |
5844 |
SCHECK_PARTIAL(); |
SCHECK_PARTIAL(); |
5845 |
break; |
break; |
5846 |
} |
} |
5847 |
if ((md->ctypes[*eptr] & ctype_word) == 0) break; |
if (!MAX_255(*eptr) || (md->ctypes[*eptr] & ctype_word) == 0) break; |
5848 |
eptr++; |
eptr++; |
5849 |
} |
} |
5850 |
break; |
break; |
6282 |
if (re->top_backref > 0 && re->top_backref >= ocount/3) |
if (re->top_backref > 0 && re->top_backref >= ocount/3) |
6283 |
{ |
{ |
6284 |
ocount = re->top_backref * 3 + 3; |
ocount = re->top_backref * 3 + 3; |
6285 |
md->offset_vector = (int *)(pcre_malloc)(ocount * sizeof(int)); |
md->offset_vector = (int *)(PUBL(malloc))(ocount * sizeof(int)); |
6286 |
if (md->offset_vector == NULL) return PCRE_ERROR_NOMEMORY; |
if (md->offset_vector == NULL) return PCRE_ERROR_NOMEMORY; |
6287 |
using_temporary_offsets = TRUE; |
using_temporary_offsets = TRUE; |
6288 |
DPRINTF(("Got memory to hold back references\n")); |
DPRINTF(("Got memory to hold back references\n")); |
6685 |
} |
} |
6686 |
if (md->end_offset_top > arg_offset_max) md->offset_overflow = TRUE; |
if (md->end_offset_top > arg_offset_max) md->offset_overflow = TRUE; |
6687 |
DPRINTF(("Freeing temporary memory\n")); |
DPRINTF(("Freeing temporary memory\n")); |
6688 |
(pcre_free)(md->offset_vector); |
(PUBL(free))(md->offset_vector); |
6689 |
} |
} |
6690 |
|
|
6691 |
/* Set the return code to the number of captured strings, or 0 if there were |
/* Set the return code to the number of captured strings, or 0 if there were |
6737 |
if (using_temporary_offsets) |
if (using_temporary_offsets) |
6738 |
{ |
{ |
6739 |
DPRINTF(("Freeing temporary memory\n")); |
DPRINTF(("Freeing temporary memory\n")); |
6740 |
(pcre_free)(md->offset_vector); |
(PUBL(free))(md->offset_vector); |
6741 |
} |
} |
6742 |
|
|
6743 |
/* For anything other than nomatch or partial match, just return the code. */ |
/* For anything other than nomatch or partial match, just return the code. */ |