| 6 |
and semantics are as close as possible to those of the Perl 5 language. |
and semantics are as close as possible to those of the Perl 5 language. |
| 7 |
|
|
| 8 |
Written by Philip Hazel |
Written by Philip Hazel |
| 9 |
Copyright (c) 1997-2007 University of Cambridge |
Copyright (c) 1997-2008 University of Cambridge |
| 10 |
|
|
| 11 |
----------------------------------------------------------------------------- |
----------------------------------------------------------------------------- |
| 12 |
Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
| 42 |
pattern matching using an NFA algorithm, trying to mimic Perl as closely as |
pattern matching using an NFA algorithm, trying to mimic Perl as closely as |
| 43 |
possible. There are also some static supporting functions. */ |
possible. There are also some static supporting functions. */ |
| 44 |
|
|
| 45 |
|
#ifdef HAVE_CONFIG_H |
| 46 |
|
#include "config.h" |
| 47 |
|
#endif |
| 48 |
|
|
| 49 |
#define NLBLOCK md /* Block containing newline information */ |
#define NLBLOCK md /* Block containing newline information */ |
| 50 |
#define PSSTART start_subject /* Field containing processed string start */ |
#define PSSTART start_subject /* Field containing processed string start */ |
| 51 |
#define PSEND end_subject /* Field containing processed string end */ |
#define PSEND end_subject /* Field containing processed string end */ |
| 57 |
#undef min |
#undef min |
| 58 |
#undef max |
#undef max |
| 59 |
|
|
|
/* The chain of eptrblocks for tail recursions uses memory in stack workspace, |
|
|
obtained at top level, the size of which is defined by EPTR_WORK_SIZE. */ |
|
|
|
|
|
#define EPTR_WORK_SIZE (1000) |
|
|
|
|
| 60 |
/* Flag bits for the match() function */ |
/* Flag bits for the match() function */ |
| 61 |
|
|
| 62 |
#define match_condassert 0x01 /* Called to check a condition assertion */ |
#define match_condassert 0x01 /* Called to check a condition assertion */ |
| 63 |
#define match_cbegroup 0x02 /* Could-be-empty unlimited repeat group */ |
#define match_cbegroup 0x02 /* Could-be-empty unlimited repeat group */ |
|
#define match_tail_recursed 0x04 /* Tail recursive call */ |
|
| 64 |
|
|
| 65 |
/* Non-error returns from the match() function. Error returns are externally |
/* Non-error returns from the match() function. Error returns are externally |
| 66 |
defined PCRE_ERROR_xxx codes, which are all negative. */ |
defined PCRE_ERROR_xxx codes, which are all negative. */ |
| 68 |
#define MATCH_MATCH 1 |
#define MATCH_MATCH 1 |
| 69 |
#define MATCH_NOMATCH 0 |
#define MATCH_NOMATCH 0 |
| 70 |
|
|
| 71 |
|
/* Special internal returns from the match() function. Make them sufficiently |
| 72 |
|
negative to avoid the external error codes. */ |
| 73 |
|
|
| 74 |
|
#define MATCH_COMMIT (-999) |
| 75 |
|
#define MATCH_PRUNE (-998) |
| 76 |
|
#define MATCH_SKIP (-997) |
| 77 |
|
#define MATCH_THEN (-996) |
| 78 |
|
|
| 79 |
/* Maximum number of ints of offset to save on the stack for recursive calls. |
/* Maximum number of ints of offset to save on the stack for recursive calls. |
| 80 |
If the offset vector is bigger, malloc is used. This should be a multiple of 3, |
If the offset vector is bigger, malloc is used. This should be a multiple of 3, |
| 81 |
because the offset vector is always a multiple of 3 long. */ |
because the offset vector is always a multiple of 3 long. */ |
| 158 |
|
|
| 159 |
if (length > md->end_subject - eptr) return FALSE; |
if (length > md->end_subject - eptr) return FALSE; |
| 160 |
|
|
| 161 |
/* Separate the caselesss case for speed */ |
/* Separate the caseless case for speed. In UTF-8 mode we can only do this |
| 162 |
|
properly if Unicode properties are supported. Otherwise, we can check only |
| 163 |
|
ASCII characters. */ |
| 164 |
|
|
| 165 |
if ((ims & PCRE_CASELESS) != 0) |
if ((ims & PCRE_CASELESS) != 0) |
| 166 |
{ |
{ |
| 167 |
|
#ifdef SUPPORT_UTF8 |
| 168 |
|
#ifdef SUPPORT_UCP |
| 169 |
|
if (md->utf8) |
| 170 |
|
{ |
| 171 |
|
USPTR endptr = eptr + length; |
| 172 |
|
while (eptr < endptr) |
| 173 |
|
{ |
| 174 |
|
int c, d; |
| 175 |
|
GETCHARINC(c, eptr); |
| 176 |
|
GETCHARINC(d, p); |
| 177 |
|
if (c != d && c != UCD_OTHERCASE(d)) return FALSE; |
| 178 |
|
} |
| 179 |
|
} |
| 180 |
|
else |
| 181 |
|
#endif |
| 182 |
|
#endif |
| 183 |
|
|
| 184 |
|
/* The same code works when not in UTF-8 mode and in UTF-8 mode when there |
| 185 |
|
is no UCP support. */ |
| 186 |
|
|
| 187 |
while (length-- > 0) |
while (length-- > 0) |
| 188 |
if (md->lcc[*p++] != md->lcc[*eptr++]) return FALSE; |
{ if (md->lcc[*p++] != md->lcc[*eptr++]) return FALSE; } |
| 189 |
} |
} |
| 190 |
|
|
| 191 |
|
/* In the caseful case, we can just compare the bytes, whether or not we |
| 192 |
|
are in UTF-8 mode. */ |
| 193 |
|
|
| 194 |
else |
else |
| 195 |
{ while (length-- > 0) if (*p++ != *eptr++) return FALSE; } |
{ while (length-- > 0) if (*p++ != *eptr++) return FALSE; } |
| 196 |
|
|
| 221 |
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 |
| 222 |
always used to. |
always used to. |
| 223 |
|
|
| 224 |
The original heap-recursive code used longjmp(). However, it seems that this |
The original heap-recursive code used longjmp(). However, it seems that this |
| 225 |
can be very slow on some operating systems. Following a suggestion from Stan |
can be very slow on some operating systems. Following a suggestion from Stan |
| 226 |
Switzer, the use of longjmp() has been abolished, at the cost of having to |
Switzer, the use of longjmp() has been abolished, at the cost of having to |
| 227 |
provide a unique number for each call to RMATCH. There is no way of generating |
provide a unique number for each call to RMATCH. There is no way of generating |
| 230 |
|
|
| 231 |
Crude tests on x86 Linux show a small speedup of around 5-8%. However, on |
Crude tests on x86 Linux show a small speedup of around 5-8%. However, on |
| 232 |
FreeBSD, avoiding longjmp() more than halves the time taken to run the standard |
FreeBSD, avoiding longjmp() more than halves the time taken to run the standard |
| 233 |
tests. Furthermore, not using longjmp() means that local dynamic variables |
tests. Furthermore, not using longjmp() means that local dynamic variables |
| 234 |
don't have indeterminate values; this has meant that the frame size can be |
don't have indeterminate values; this has meant that the frame size can be |
| 235 |
reduced because the result can be "passed back" by straight setting of the |
reduced because the result can be "passed back" by straight setting of the |
| 236 |
variable instead of being passed in the frame. |
variable instead of being passed in the frame. |
| 237 |
**************************************************************************** |
**************************************************************************** |
| 238 |
***************************************************************************/ |
***************************************************************************/ |
| 239 |
|
|
| 240 |
|
/* Numbers for RMATCH calls. When this list is changed, the code at HEAP_RETURN |
| 241 |
/* Numbers for RMATCH calls */ |
below must be updated in sync. */ |
| 242 |
|
|
| 243 |
enum { RM1=1, RM2, RM3, RM4, RM5, RM6, RM7, RM8, RM9, RM10, |
enum { RM1=1, RM2, RM3, RM4, RM5, RM6, RM7, RM8, RM9, RM10, |
| 244 |
RM11, RM12, RM13, RM14, RM15, RM16, RM17, RM18, RM19, RM20, |
RM11, RM12, RM13, RM14, RM15, RM16, RM17, RM18, RM19, RM20, |
| 245 |
RM21, RM22, RM23, RM24, RM25, RM26, RM27, RM28, RM29, RM30, |
RM21, RM22, RM23, RM24, RM25, RM26, RM27, RM28, RM29, RM30, |
| 246 |
RM31, RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40, |
RM31, RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40, |
| 247 |
RM41, RM42, RM43, RM44, RM45, RM46, RM47 }; |
RM41, RM42, RM43, RM44, RM45, RM46, RM47, RM48, RM49, RM50, |
| 248 |
|
RM51, RM52, RM53, RM54 }; |
| 249 |
|
|
| 250 |
/* 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 |
| 251 |
versions and production versions. Note that the "rw" argument of RMATCH isn't |
versions and production versions. Note that the "rw" argument of RMATCH isn't |
| 252 |
actuall used in this definition. */ |
actuall used in this definition. */ |
| 253 |
|
|
| 254 |
#ifndef NO_RECURSE |
#ifndef NO_RECURSE |
| 258 |
#define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \ |
#define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \ |
| 259 |
{ \ |
{ \ |
| 260 |
printf("match() called in line %d\n", __LINE__); \ |
printf("match() called in line %d\n", __LINE__); \ |
| 261 |
rrc = match(ra,rb,rc,rd,re,rf,rg,rdepth+1); \ |
rrc = match(ra,rb,mstart,rc,rd,re,rf,rg,rdepth+1); \ |
| 262 |
printf("to line %d\n", __LINE__); \ |
printf("to line %d\n", __LINE__); \ |
| 263 |
} |
} |
| 264 |
#define RRETURN(ra) \ |
#define RRETURN(ra) \ |
| 268 |
} |
} |
| 269 |
#else |
#else |
| 270 |
#define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \ |
#define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \ |
| 271 |
rrc = match(ra,rb,rc,rd,re,rf,rg,rdepth+1) |
rrc = match(ra,rb,mstart,rc,rd,re,rf,rg,rdepth+1) |
| 272 |
#define RRETURN(ra) return ra |
#define RRETURN(ra) return ra |
| 273 |
#endif |
#endif |
| 274 |
|
|
| 287 |
frame->Xwhere = rw; \ |
frame->Xwhere = rw; \ |
| 288 |
newframe->Xeptr = ra;\ |
newframe->Xeptr = ra;\ |
| 289 |
newframe->Xecode = rb;\ |
newframe->Xecode = rb;\ |
| 290 |
|
newframe->Xmstart = mstart;\ |
| 291 |
newframe->Xoffset_top = rc;\ |
newframe->Xoffset_top = rc;\ |
| 292 |
newframe->Xims = re;\ |
newframe->Xims = re;\ |
| 293 |
newframe->Xeptrb = rf;\ |
newframe->Xeptrb = rf;\ |
| 324 |
|
|
| 325 |
const uschar *Xeptr; |
const uschar *Xeptr; |
| 326 |
const uschar *Xecode; |
const uschar *Xecode; |
| 327 |
|
const uschar *Xmstart; |
| 328 |
int Xoffset_top; |
int Xoffset_top; |
| 329 |
long int Xims; |
long int Xims; |
| 330 |
eptrblock *Xeptrb; |
eptrblock *Xeptrb; |
| 378 |
/* Where to jump back to */ |
/* Where to jump back to */ |
| 379 |
|
|
| 380 |
int Xwhere; |
int Xwhere; |
| 381 |
|
|
| 382 |
} heapframe; |
} heapframe; |
| 383 |
|
|
| 384 |
#endif |
#endif |
| 405 |
Arguments: |
Arguments: |
| 406 |
eptr pointer to current character in subject |
eptr pointer to current character in subject |
| 407 |
ecode pointer to current position in compiled code |
ecode pointer to current position in compiled code |
| 408 |
|
mstart pointer to the current match start position (can be modified |
| 409 |
|
by encountering \K) |
| 410 |
offset_top current top pointer |
offset_top current top pointer |
| 411 |
md pointer to "static" info for the match |
md pointer to "static" info for the match |
| 412 |
ims current /i, /m, and /s options |
ims current /i, /m, and /s options |
| 416 |
match_condassert - this is an assertion condition |
match_condassert - this is an assertion condition |
| 417 |
match_cbegroup - this is the start of an unlimited repeat |
match_cbegroup - this is the start of an unlimited repeat |
| 418 |
group that can match an empty string |
group that can match an empty string |
|
match_tail_recursed - this is a tail_recursed group |
|
| 419 |
rdepth the recursion depth |
rdepth the recursion depth |
| 420 |
|
|
| 421 |
Returns: MATCH_MATCH if matched ) these values are >= 0 |
Returns: MATCH_MATCH if matched ) these values are >= 0 |
| 425 |
*/ |
*/ |
| 426 |
|
|
| 427 |
static int |
static int |
| 428 |
match(REGISTER USPTR eptr, REGISTER const uschar *ecode, |
match(REGISTER USPTR eptr, REGISTER const uschar *ecode, const uschar *mstart, |
| 429 |
int offset_top, match_data *md, unsigned long int ims, eptrblock *eptrb, |
int offset_top, match_data *md, unsigned long int ims, eptrblock *eptrb, |
| 430 |
int flags, unsigned int rdepth) |
int flags, unsigned int rdepth) |
| 431 |
{ |
{ |
| 453 |
|
|
| 454 |
frame->Xeptr = eptr; |
frame->Xeptr = eptr; |
| 455 |
frame->Xecode = ecode; |
frame->Xecode = ecode; |
| 456 |
|
frame->Xmstart = mstart; |
| 457 |
frame->Xoffset_top = offset_top; |
frame->Xoffset_top = offset_top; |
| 458 |
frame->Xims = ims; |
frame->Xims = ims; |
| 459 |
frame->Xeptrb = eptrb; |
frame->Xeptrb = eptrb; |
| 468 |
|
|
| 469 |
#define eptr frame->Xeptr |
#define eptr frame->Xeptr |
| 470 |
#define ecode frame->Xecode |
#define ecode frame->Xecode |
| 471 |
|
#define mstart frame->Xmstart |
| 472 |
#define offset_top frame->Xoffset_top |
#define offset_top frame->Xoffset_top |
| 473 |
#define ims frame->Xims |
#define ims frame->Xims |
| 474 |
#define eptrb frame->Xeptrb |
#define eptrb frame->Xeptrb |
| 617 |
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 |
| 618 |
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 |
| 619 |
hit the closing ket, in order to break infinite loops that match no characters. |
hit the closing ket, in order to break infinite loops that match no characters. |
| 620 |
When match() is called in other circumstances, don't add to the chain. If this |
When match() is called in other circumstances, don't add to the chain. The |
| 621 |
is a tail recursion, use a block from the workspace, as the one on the stack is |
match_cbegroup flag must NOT be used with tail recursion, because the memory |
| 622 |
already used. */ |
block that is used is on the stack, so a new one may be required for each |
| 623 |
|
match(). */ |
| 624 |
|
|
| 625 |
if ((flags & match_cbegroup) != 0) |
if ((flags & match_cbegroup) != 0) |
| 626 |
{ |
{ |
| 627 |
eptrblock *p; |
newptrb.epb_saved_eptr = eptr; |
| 628 |
if ((flags & match_tail_recursed) != 0) |
newptrb.epb_prev = eptrb; |
| 629 |
{ |
eptrb = &newptrb; |
|
if (md->eptrn >= EPTR_WORK_SIZE) RRETURN(PCRE_ERROR_NULLWSLIMIT); |
|
|
p = md->eptrchain + md->eptrn++; |
|
|
} |
|
|
else p = &newptrb; |
|
|
p->epb_saved_eptr = eptr; |
|
|
p->epb_prev = eptrb; |
|
|
eptrb = p; |
|
| 630 |
} |
} |
| 631 |
|
|
| 632 |
/* Now start processing the opcodes. */ |
/* Now start processing the opcodes. */ |
| 641 |
|
|
| 642 |
if (md->partial && |
if (md->partial && |
| 643 |
eptr >= md->end_subject && |
eptr >= md->end_subject && |
| 644 |
eptr > md->start_match) |
eptr > mstart) |
| 645 |
md->hitend = TRUE; |
md->hitend = TRUE; |
| 646 |
|
|
| 647 |
switch(op) |
switch(op) |
| 648 |
{ |
{ |
| 649 |
|
case OP_FAIL: |
| 650 |
|
RRETURN(MATCH_NOMATCH); |
| 651 |
|
|
| 652 |
|
case OP_PRUNE: |
| 653 |
|
RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
| 654 |
|
ims, eptrb, flags, RM51); |
| 655 |
|
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 656 |
|
RRETURN(MATCH_PRUNE); |
| 657 |
|
|
| 658 |
|
case OP_COMMIT: |
| 659 |
|
RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
| 660 |
|
ims, eptrb, flags, RM52); |
| 661 |
|
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 662 |
|
RRETURN(MATCH_COMMIT); |
| 663 |
|
|
| 664 |
|
case OP_SKIP: |
| 665 |
|
RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
| 666 |
|
ims, eptrb, flags, RM53); |
| 667 |
|
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 668 |
|
md->start_match_ptr = eptr; /* Pass back current position */ |
| 669 |
|
RRETURN(MATCH_SKIP); |
| 670 |
|
|
| 671 |
|
case OP_THEN: |
| 672 |
|
RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
| 673 |
|
ims, eptrb, flags, RM54); |
| 674 |
|
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 675 |
|
RRETURN(MATCH_THEN); |
| 676 |
|
|
| 677 |
/* Handle a capturing bracket. If there is space in the offset vector, save |
/* Handle a capturing bracket. If there is space in the offset vector, save |
| 678 |
the current subject position in the working slot at the top of the vector. |
the current subject position in the working slot at the top of the vector. |
| 679 |
We mustn't change the current values of the data slot, because they may be |
We mustn't change the current values of the data slot, because they may be |
| 715 |
{ |
{ |
| 716 |
RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
| 717 |
ims, eptrb, flags, RM1); |
ims, eptrb, flags, RM1); |
| 718 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); |
| 719 |
md->capture_last = save_capture_last; |
md->capture_last = save_capture_last; |
| 720 |
ecode += GET(ecode, 1); |
ecode += GET(ecode, 1); |
| 721 |
} |
} |
| 730 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 731 |
} |
} |
| 732 |
|
|
| 733 |
/* Insufficient room for saving captured contents. Treat as a non-capturing |
/* FALL THROUGH ... Insufficient room for saving captured contents. Treat |
| 734 |
bracket. */ |
as a non-capturing bracket. */ |
| 735 |
|
|
| 736 |
|
/* VVVVVVVVVVVVVVVVVVVVVVVVV */ |
| 737 |
|
/* VVVVVVVVVVVVVVVVVVVVVVVVV */ |
| 738 |
|
|
| 739 |
DPRINTF(("insufficient capture room: treat as non-capturing\n")); |
DPRINTF(("insufficient capture room: treat as non-capturing\n")); |
| 740 |
|
|
| 741 |
|
/* VVVVVVVVVVVVVVVVVVVVVVVVV */ |
| 742 |
|
/* VVVVVVVVVVVVVVVVVVVVVVVVV */ |
| 743 |
|
|
| 744 |
/* Non-capturing bracket. Loop for all the alternatives. When we get to the |
/* Non-capturing bracket. Loop for all the alternatives. When we get to the |
| 745 |
final alternative within the brackets, we would return the result of a |
final alternative within the brackets, we would return the result of a |
| 746 |
recursive call to match() whatever happened. We can reduce stack usage by |
recursive call to match() whatever happened. We can reduce stack usage by |
| 747 |
turning this into a tail recursion. */ |
turning this into a tail recursion, except in the case when match_cbegroup |
| 748 |
|
is set.*/ |
| 749 |
|
|
| 750 |
case OP_BRA: |
case OP_BRA: |
| 751 |
case OP_SBRA: |
case OP_SBRA: |
| 753 |
flags = (op >= OP_SBRA)? match_cbegroup : 0; |
flags = (op >= OP_SBRA)? match_cbegroup : 0; |
| 754 |
for (;;) |
for (;;) |
| 755 |
{ |
{ |
| 756 |
if (ecode[GET(ecode, 1)] != OP_ALT) |
if (ecode[GET(ecode, 1)] != OP_ALT) /* Final alternative */ |
| 757 |
{ |
{ |
| 758 |
ecode += _pcre_OP_lengths[*ecode]; |
if (flags == 0) /* Not a possibly empty group */ |
| 759 |
flags |= match_tail_recursed; |
{ |
| 760 |
DPRINTF(("bracket 0 tail recursion\n")); |
ecode += _pcre_OP_lengths[*ecode]; |
| 761 |
goto TAIL_RECURSE; |
DPRINTF(("bracket 0 tail recursion\n")); |
| 762 |
|
goto TAIL_RECURSE; |
| 763 |
|
} |
| 764 |
|
|
| 765 |
|
/* Possibly empty group; can't use tail recursion. */ |
| 766 |
|
|
| 767 |
|
RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims, |
| 768 |
|
eptrb, flags, RM48); |
| 769 |
|
RRETURN(rrc); |
| 770 |
} |
} |
| 771 |
|
|
| 772 |
/* For non-final alternatives, continue the loop for a NOMATCH result; |
/* For non-final alternatives, continue the loop for a NOMATCH result; |
| 774 |
|
|
| 775 |
RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims, |
RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims, |
| 776 |
eptrb, flags, RM2); |
eptrb, flags, RM2); |
| 777 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); |
| 778 |
ecode += GET(ecode, 1); |
ecode += GET(ecode, 1); |
| 779 |
} |
} |
| 780 |
/* Control never reaches here. */ |
/* Control never reaches here. */ |
| 822 |
ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2); |
ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2); |
| 823 |
while (*ecode == OP_ALT) ecode += GET(ecode, 1); |
while (*ecode == OP_ALT) ecode += GET(ecode, 1); |
| 824 |
} |
} |
| 825 |
else if (rrc != MATCH_NOMATCH) |
else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) |
| 826 |
{ |
{ |
| 827 |
RRETURN(rrc); /* Need braces because of following else */ |
RRETURN(rrc); /* Need braces because of following else */ |
| 828 |
} |
} |
| 834 |
} |
} |
| 835 |
|
|
| 836 |
/* We are now at the branch that is to be obeyed. As there is only one, |
/* We are now at the branch that is to be obeyed. As there is only one, |
| 837 |
we can use tail recursion to avoid using another stack frame. If the second |
we can use tail recursion to avoid using another stack frame, except when |
| 838 |
alternative doesn't exist, we can just plough on. */ |
match_cbegroup is required for an unlimited repeat of a possibly empty |
| 839 |
|
group. If the second alternative doesn't exist, we can just plough on. */ |
| 840 |
|
|
| 841 |
if (condition || *ecode == OP_ALT) |
if (condition || *ecode == OP_ALT) |
| 842 |
{ |
{ |
| 843 |
ecode += 1 + LINK_SIZE; |
ecode += 1 + LINK_SIZE; |
| 844 |
flags = match_tail_recursed | ((op == OP_SCOND)? match_cbegroup : 0); |
if (op == OP_SCOND) /* Possibly empty group */ |
| 845 |
goto TAIL_RECURSE; |
{ |
| 846 |
|
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, match_cbegroup, RM49); |
| 847 |
|
RRETURN(rrc); |
| 848 |
|
} |
| 849 |
|
else /* Group must match something */ |
| 850 |
|
{ |
| 851 |
|
flags = 0; |
| 852 |
|
goto TAIL_RECURSE; |
| 853 |
|
} |
| 854 |
} |
} |
| 855 |
else |
else /* Condition false & no 2nd alternative */ |
| 856 |
{ |
{ |
| 857 |
ecode += 1 + LINK_SIZE; |
ecode += 1 + LINK_SIZE; |
| 858 |
} |
} |
| 859 |
break; |
break; |
| 860 |
|
|
| 861 |
|
|
| 862 |
/* End of the pattern. If we are in a top-level recursion, we should |
/* End of the pattern, either real or forced. If we are in a top-level |
| 863 |
restore the offsets appropriately and continue from after the call. */ |
recursion, we should restore the offsets appropriately and continue from |
| 864 |
|
after the call. */ |
| 865 |
|
|
| 866 |
|
case OP_ACCEPT: |
| 867 |
case OP_END: |
case OP_END: |
| 868 |
if (md->recursive != NULL && md->recursive->group_num == 0) |
if (md->recursive != NULL && md->recursive->group_num == 0) |
| 869 |
{ |
{ |
| 872 |
md->recursive = rec->prevrec; |
md->recursive = rec->prevrec; |
| 873 |
memmove(md->offset_vector, rec->offset_save, |
memmove(md->offset_vector, rec->offset_save, |
| 874 |
rec->saved_max * sizeof(int)); |
rec->saved_max * sizeof(int)); |
| 875 |
md->start_match = rec->save_start; |
mstart = rec->save_start; |
| 876 |
ims = original_ims; |
ims = original_ims; |
| 877 |
ecode = rec->after_call; |
ecode = rec->after_call; |
| 878 |
break; |
break; |
| 881 |
/* Otherwise, if PCRE_NOTEMPTY is set, fail if we have matched an empty |
/* Otherwise, if PCRE_NOTEMPTY is set, fail if we have matched an empty |
| 882 |
string - backtracking will then try other alternatives, if any. */ |
string - backtracking will then try other alternatives, if any. */ |
| 883 |
|
|
| 884 |
if (md->notempty && eptr == md->start_match) RRETURN(MATCH_NOMATCH); |
if (md->notempty && eptr == mstart) RRETURN(MATCH_NOMATCH); |
| 885 |
md->end_match_ptr = eptr; /* Record where we ended */ |
md->end_match_ptr = eptr; /* Record where we ended */ |
| 886 |
md->end_offset_top = offset_top; /* and how many extracts were taken */ |
md->end_offset_top = offset_top; /* and how many extracts were taken */ |
| 887 |
|
md->start_match_ptr = mstart; /* and the start (\K can modify) */ |
| 888 |
RRETURN(MATCH_MATCH); |
RRETURN(MATCH_MATCH); |
| 889 |
|
|
| 890 |
/* Change option settings */ |
/* Change option settings */ |
| 908 |
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0, |
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0, |
| 909 |
RM4); |
RM4); |
| 910 |
if (rrc == MATCH_MATCH) break; |
if (rrc == MATCH_MATCH) break; |
| 911 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); |
| 912 |
ecode += GET(ecode, 1); |
ecode += GET(ecode, 1); |
| 913 |
} |
} |
| 914 |
while (*ecode == OP_ALT); |
while (*ecode == OP_ALT); |
| 935 |
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0, |
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0, |
| 936 |
RM5); |
RM5); |
| 937 |
if (rrc == MATCH_MATCH) RRETURN(MATCH_NOMATCH); |
if (rrc == MATCH_MATCH) RRETURN(MATCH_NOMATCH); |
| 938 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); |
| 939 |
ecode += GET(ecode,1); |
ecode += GET(ecode,1); |
| 940 |
} |
} |
| 941 |
while (*ecode == OP_ALT); |
while (*ecode == OP_ALT); |
| 959 |
{ |
{ |
| 960 |
eptr--; |
eptr--; |
| 961 |
if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH); |
if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH); |
| 962 |
BACKCHAR(eptr) |
BACKCHAR(eptr); |
| 963 |
} |
} |
| 964 |
} |
} |
| 965 |
else |
else |
| 990 |
cb.offset_vector = md->offset_vector; |
cb.offset_vector = md->offset_vector; |
| 991 |
cb.subject = (PCRE_SPTR)md->start_subject; |
cb.subject = (PCRE_SPTR)md->start_subject; |
| 992 |
cb.subject_length = md->end_subject - md->start_subject; |
cb.subject_length = md->end_subject - md->start_subject; |
| 993 |
cb.start_match = md->start_match - md->start_subject; |
cb.start_match = mstart - md->start_subject; |
| 994 |
cb.current_position = eptr - md->start_subject; |
cb.current_position = eptr - md->start_subject; |
| 995 |
cb.pattern_position = GET(ecode, 2); |
cb.pattern_position = GET(ecode, 2); |
| 996 |
cb.next_item_length = GET(ecode, 2 + LINK_SIZE); |
cb.next_item_length = GET(ecode, 2 + LINK_SIZE); |
| 1052 |
|
|
| 1053 |
memcpy(new_recursive.offset_save, md->offset_vector, |
memcpy(new_recursive.offset_save, md->offset_vector, |
| 1054 |
new_recursive.saved_max * sizeof(int)); |
new_recursive.saved_max * sizeof(int)); |
| 1055 |
new_recursive.save_start = md->start_match; |
new_recursive.save_start = mstart; |
| 1056 |
md->start_match = eptr; |
mstart = eptr; |
| 1057 |
|
|
| 1058 |
/* OK, now we can do the recursion. For each top-level alternative we |
/* OK, now we can do the recursion. For each top-level alternative we |
| 1059 |
restore the offset and recursion data. */ |
restore the offset and recursion data. */ |
| 1072 |
(pcre_free)(new_recursive.offset_save); |
(pcre_free)(new_recursive.offset_save); |
| 1073 |
RRETURN(MATCH_MATCH); |
RRETURN(MATCH_MATCH); |
| 1074 |
} |
} |
| 1075 |
else if (rrc != MATCH_NOMATCH) |
else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) |
| 1076 |
{ |
{ |
| 1077 |
DPRINTF(("Recursion gave error %d\n", rrc)); |
DPRINTF(("Recursion gave error %d\n", rrc)); |
| 1078 |
RRETURN(rrc); |
RRETURN(rrc); |
| 1106 |
|
|
| 1107 |
do |
do |
| 1108 |
{ |
{ |
| 1109 |
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, |
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM7); |
|
eptrb, 0, RM7); |
|
| 1110 |
if (rrc == MATCH_MATCH) break; |
if (rrc == MATCH_MATCH) break; |
| 1111 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); |
| 1112 |
ecode += GET(ecode,1); |
ecode += GET(ecode,1); |
| 1113 |
} |
} |
| 1114 |
while (*ecode == OP_ALT); |
while (*ecode == OP_ALT); |
| 1151 |
|
|
| 1152 |
if (*ecode == OP_KETRMIN) |
if (*ecode == OP_KETRMIN) |
| 1153 |
{ |
{ |
| 1154 |
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, |
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM8); |
|
RM8); |
|
| 1155 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1156 |
ecode = prev; |
ecode = prev; |
| 1157 |
flags = match_tail_recursed; |
flags = 0; |
| 1158 |
goto TAIL_RECURSE; |
goto TAIL_RECURSE; |
| 1159 |
} |
} |
| 1160 |
else /* OP_KETRMAX */ |
else /* OP_KETRMAX */ |
| 1162 |
RMATCH(eptr, prev, offset_top, md, ims, eptrb, match_cbegroup, RM9); |
RMATCH(eptr, prev, offset_top, md, ims, eptrb, match_cbegroup, RM9); |
| 1163 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1164 |
ecode += 1 + LINK_SIZE; |
ecode += 1 + LINK_SIZE; |
| 1165 |
flags = match_tail_recursed; |
flags = 0; |
| 1166 |
goto TAIL_RECURSE; |
goto TAIL_RECURSE; |
| 1167 |
} |
} |
| 1168 |
/* Control never gets here */ |
/* Control never gets here */ |
| 1174 |
do ecode += GET(ecode,1); while (*ecode == OP_ALT); |
do ecode += GET(ecode,1); while (*ecode == OP_ALT); |
| 1175 |
break; |
break; |
| 1176 |
|
|
| 1177 |
/* BRAZERO and BRAMINZERO occur just before a bracket group, indicating |
/* BRAZERO, BRAMINZERO and SKIPZERO occur just before a bracket group, |
| 1178 |
that it may occur zero times. It may repeat infinitely, or not at all - |
indicating that it may occur zero times. It may repeat infinitely, or not |
| 1179 |
i.e. it could be ()* or ()? in the pattern. Brackets with fixed upper |
at all - i.e. it could be ()* or ()? or even (){0} in the pattern. Brackets |
| 1180 |
repeat limits are compiled as a number of copies, with the optional ones |
with fixed upper repeat limits are compiled as a number of copies, with the |
| 1181 |
preceded by BRAZERO or BRAMINZERO. */ |
optional ones preceded by BRAZERO or BRAMINZERO. */ |
| 1182 |
|
|
| 1183 |
case OP_BRAZERO: |
case OP_BRAZERO: |
| 1184 |
{ |
{ |
| 1200 |
} |
} |
| 1201 |
break; |
break; |
| 1202 |
|
|
| 1203 |
|
case OP_SKIPZERO: |
| 1204 |
|
{ |
| 1205 |
|
next = ecode+1; |
| 1206 |
|
do next += GET(next,1); while (*next == OP_ALT); |
| 1207 |
|
ecode = next + 1 + LINK_SIZE; |
| 1208 |
|
} |
| 1209 |
|
break; |
| 1210 |
|
|
| 1211 |
/* End of a group, repeated or non-repeating. */ |
/* End of a group, repeated or non-repeating. */ |
| 1212 |
|
|
| 1213 |
case OP_KET: |
case OP_KET: |
| 1272 |
recursion_info *rec = md->recursive; |
recursion_info *rec = md->recursive; |
| 1273 |
DPRINTF(("Recursion (%d) succeeded - continuing\n", number)); |
DPRINTF(("Recursion (%d) succeeded - continuing\n", number)); |
| 1274 |
md->recursive = rec->prevrec; |
md->recursive = rec->prevrec; |
| 1275 |
md->start_match = rec->save_start; |
mstart = rec->save_start; |
| 1276 |
memcpy(md->offset_vector, rec->offset_save, |
memcpy(md->offset_vector, rec->offset_save, |
| 1277 |
rec->saved_max * sizeof(int)); |
rec->saved_max * sizeof(int)); |
| 1278 |
ecode = rec->after_call; |
ecode = rec->after_call; |
| 1301 |
|
|
| 1302 |
/* The repeating kets try the rest of the pattern or restart from the |
/* The repeating kets try the rest of the pattern or restart from the |
| 1303 |
preceding bracket, in the appropriate order. In the second case, we can use |
preceding bracket, in the appropriate order. In the second case, we can use |
| 1304 |
tail recursion to avoid using another stack frame. */ |
tail recursion to avoid using another stack frame, unless we have an |
| 1305 |
|
unlimited repeat of a group that can match an empty string. */ |
| 1306 |
|
|
| 1307 |
flags = (*prev >= OP_SBRA)? match_cbegroup : 0; |
flags = (*prev >= OP_SBRA)? match_cbegroup : 0; |
| 1308 |
|
|
| 1309 |
if (*ecode == OP_KETRMIN) |
if (*ecode == OP_KETRMIN) |
| 1310 |
{ |
{ |
| 1311 |
RMATCH(eptr, ecode + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0, |
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM12); |
|
RM12); |
|
| 1312 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1313 |
|
if (flags != 0) /* Could match an empty string */ |
| 1314 |
|
{ |
| 1315 |
|
RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM50); |
| 1316 |
|
RRETURN(rrc); |
| 1317 |
|
} |
| 1318 |
ecode = prev; |
ecode = prev; |
|
flags |= match_tail_recursed; |
|
| 1319 |
goto TAIL_RECURSE; |
goto TAIL_RECURSE; |
| 1320 |
} |
} |
| 1321 |
else /* OP_KETRMAX */ |
else /* OP_KETRMAX */ |
| 1323 |
RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM13); |
RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM13); |
| 1324 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1325 |
ecode += 1 + LINK_SIZE; |
ecode += 1 + LINK_SIZE; |
| 1326 |
flags = match_tail_recursed; |
flags = 0; |
| 1327 |
goto TAIL_RECURSE; |
goto TAIL_RECURSE; |
| 1328 |
} |
} |
| 1329 |
/* Control never gets here */ |
/* Control never gets here */ |
| 1356 |
ecode++; |
ecode++; |
| 1357 |
break; |
break; |
| 1358 |
|
|
| 1359 |
|
/* Reset the start of match point */ |
| 1360 |
|
|
| 1361 |
|
case OP_SET_SOM: |
| 1362 |
|
mstart = eptr; |
| 1363 |
|
ecode++; |
| 1364 |
|
break; |
| 1365 |
|
|
| 1366 |
/* Assert before internal newline if multiline, or before a terminating |
/* Assert before internal newline if multiline, or before a terminating |
| 1367 |
newline unless endonly is set, else end of subject unless noteol is set. */ |
newline unless endonly is set, else end of subject unless noteol is set. */ |
| 1368 |
|
|
| 1455 |
/* Match a single character type; inline for speed */ |
/* Match a single character type; inline for speed */ |
| 1456 |
|
|
| 1457 |
case OP_ANY: |
case OP_ANY: |
| 1458 |
if ((ims & PCRE_DOTALL) == 0) |
if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); |
| 1459 |
{ |
/* Fall through */ |
| 1460 |
if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); |
|
| 1461 |
} |
case OP_ALLANY: |
| 1462 |
if (eptr++ >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr++ >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 1463 |
if (utf8) |
if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
|
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
|
| 1464 |
ecode++; |
ecode++; |
| 1465 |
break; |
break; |
| 1466 |
|
|
| 1559 |
case 0x000d: |
case 0x000d: |
| 1560 |
if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 1561 |
break; |
break; |
| 1562 |
|
|
| 1563 |
case 0x000a: |
case 0x000a: |
| 1564 |
|
break; |
| 1565 |
|
|
| 1566 |
case 0x000b: |
case 0x000b: |
| 1567 |
case 0x000c: |
case 0x000c: |
| 1568 |
case 0x0085: |
case 0x0085: |
| 1569 |
case 0x2028: |
case 0x2028: |
| 1570 |
case 0x2029: |
case 0x2029: |
| 1571 |
|
if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); |
| 1572 |
|
break; |
| 1573 |
|
} |
| 1574 |
|
ecode++; |
| 1575 |
|
break; |
| 1576 |
|
|
| 1577 |
|
case OP_NOT_HSPACE: |
| 1578 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 1579 |
|
GETCHARINCTEST(c, eptr); |
| 1580 |
|
switch(c) |
| 1581 |
|
{ |
| 1582 |
|
default: break; |
| 1583 |
|
case 0x09: /* HT */ |
| 1584 |
|
case 0x20: /* SPACE */ |
| 1585 |
|
case 0xa0: /* NBSP */ |
| 1586 |
|
case 0x1680: /* OGHAM SPACE MARK */ |
| 1587 |
|
case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ |
| 1588 |
|
case 0x2000: /* EN QUAD */ |
| 1589 |
|
case 0x2001: /* EM QUAD */ |
| 1590 |
|
case 0x2002: /* EN SPACE */ |
| 1591 |
|
case 0x2003: /* EM SPACE */ |
| 1592 |
|
case 0x2004: /* THREE-PER-EM SPACE */ |
| 1593 |
|
case 0x2005: /* FOUR-PER-EM SPACE */ |
| 1594 |
|
case 0x2006: /* SIX-PER-EM SPACE */ |
| 1595 |
|
case 0x2007: /* FIGURE SPACE */ |
| 1596 |
|
case 0x2008: /* PUNCTUATION SPACE */ |
| 1597 |
|
case 0x2009: /* THIN SPACE */ |
| 1598 |
|
case 0x200A: /* HAIR SPACE */ |
| 1599 |
|
case 0x202f: /* NARROW NO-BREAK SPACE */ |
| 1600 |
|
case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ |
| 1601 |
|
case 0x3000: /* IDEOGRAPHIC SPACE */ |
| 1602 |
|
RRETURN(MATCH_NOMATCH); |
| 1603 |
|
} |
| 1604 |
|
ecode++; |
| 1605 |
|
break; |
| 1606 |
|
|
| 1607 |
|
case OP_HSPACE: |
| 1608 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 1609 |
|
GETCHARINCTEST(c, eptr); |
| 1610 |
|
switch(c) |
| 1611 |
|
{ |
| 1612 |
|
default: RRETURN(MATCH_NOMATCH); |
| 1613 |
|
case 0x09: /* HT */ |
| 1614 |
|
case 0x20: /* SPACE */ |
| 1615 |
|
case 0xa0: /* NBSP */ |
| 1616 |
|
case 0x1680: /* OGHAM SPACE MARK */ |
| 1617 |
|
case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ |
| 1618 |
|
case 0x2000: /* EN QUAD */ |
| 1619 |
|
case 0x2001: /* EM QUAD */ |
| 1620 |
|
case 0x2002: /* EN SPACE */ |
| 1621 |
|
case 0x2003: /* EM SPACE */ |
| 1622 |
|
case 0x2004: /* THREE-PER-EM SPACE */ |
| 1623 |
|
case 0x2005: /* FOUR-PER-EM SPACE */ |
| 1624 |
|
case 0x2006: /* SIX-PER-EM SPACE */ |
| 1625 |
|
case 0x2007: /* FIGURE SPACE */ |
| 1626 |
|
case 0x2008: /* PUNCTUATION SPACE */ |
| 1627 |
|
case 0x2009: /* THIN SPACE */ |
| 1628 |
|
case 0x200A: /* HAIR SPACE */ |
| 1629 |
|
case 0x202f: /* NARROW NO-BREAK SPACE */ |
| 1630 |
|
case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ |
| 1631 |
|
case 0x3000: /* IDEOGRAPHIC SPACE */ |
| 1632 |
|
break; |
| 1633 |
|
} |
| 1634 |
|
ecode++; |
| 1635 |
|
break; |
| 1636 |
|
|
| 1637 |
|
case OP_NOT_VSPACE: |
| 1638 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 1639 |
|
GETCHARINCTEST(c, eptr); |
| 1640 |
|
switch(c) |
| 1641 |
|
{ |
| 1642 |
|
default: break; |
| 1643 |
|
case 0x0a: /* LF */ |
| 1644 |
|
case 0x0b: /* VT */ |
| 1645 |
|
case 0x0c: /* FF */ |
| 1646 |
|
case 0x0d: /* CR */ |
| 1647 |
|
case 0x85: /* NEL */ |
| 1648 |
|
case 0x2028: /* LINE SEPARATOR */ |
| 1649 |
|
case 0x2029: /* PARAGRAPH SEPARATOR */ |
| 1650 |
|
RRETURN(MATCH_NOMATCH); |
| 1651 |
|
} |
| 1652 |
|
ecode++; |
| 1653 |
|
break; |
| 1654 |
|
|
| 1655 |
|
case OP_VSPACE: |
| 1656 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 1657 |
|
GETCHARINCTEST(c, eptr); |
| 1658 |
|
switch(c) |
| 1659 |
|
{ |
| 1660 |
|
default: RRETURN(MATCH_NOMATCH); |
| 1661 |
|
case 0x0a: /* LF */ |
| 1662 |
|
case 0x0b: /* VT */ |
| 1663 |
|
case 0x0c: /* FF */ |
| 1664 |
|
case 0x0d: /* CR */ |
| 1665 |
|
case 0x85: /* NEL */ |
| 1666 |
|
case 0x2028: /* LINE SEPARATOR */ |
| 1667 |
|
case 0x2029: /* PARAGRAPH SEPARATOR */ |
| 1668 |
break; |
break; |
| 1669 |
} |
} |
| 1670 |
ecode++; |
ecode++; |
| 1679 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 1680 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 1681 |
{ |
{ |
| 1682 |
int chartype, script; |
const ucd_record * prop = GET_UCD(c); |
|
int category = _pcre_ucp_findprop(c, &chartype, &script); |
|
| 1683 |
|
|
| 1684 |
switch(ecode[1]) |
switch(ecode[1]) |
| 1685 |
{ |
{ |
| 1688 |
break; |
break; |
| 1689 |
|
|
| 1690 |
case PT_LAMP: |
case PT_LAMP: |
| 1691 |
if ((chartype == ucp_Lu || |
if ((prop->chartype == ucp_Lu || |
| 1692 |
chartype == ucp_Ll || |
prop->chartype == ucp_Ll || |
| 1693 |
chartype == ucp_Lt) == (op == OP_NOTPROP)) |
prop->chartype == ucp_Lt) == (op == OP_NOTPROP)) |
| 1694 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 1695 |
break; |
break; |
| 1696 |
|
|
| 1697 |
case PT_GC: |
case PT_GC: |
| 1698 |
if ((ecode[2] != category) == (op == OP_PROP)) |
if ((ecode[2] != _pcre_ucp_gentype[prop->chartype]) == (op == OP_PROP)) |
| 1699 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 1700 |
break; |
break; |
| 1701 |
|
|
| 1702 |
case PT_PC: |
case PT_PC: |
| 1703 |
if ((ecode[2] != chartype) == (op == OP_PROP)) |
if ((ecode[2] != prop->chartype) == (op == OP_PROP)) |
| 1704 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 1705 |
break; |
break; |
| 1706 |
|
|
| 1707 |
case PT_SC: |
case PT_SC: |
| 1708 |
if ((ecode[2] != script) == (op == OP_PROP)) |
if ((ecode[2] != prop->script) == (op == OP_PROP)) |
| 1709 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 1710 |
break; |
break; |
| 1711 |
|
|
| 1724 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 1725 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 1726 |
{ |
{ |
| 1727 |
int chartype, script; |
int category = UCD_CATEGORY(c); |
|
int category = _pcre_ucp_findprop(c, &chartype, &script); |
|
| 1728 |
if (category == ucp_M) RRETURN(MATCH_NOMATCH); |
if (category == ucp_M) RRETURN(MATCH_NOMATCH); |
| 1729 |
while (eptr < md->end_subject) |
while (eptr < md->end_subject) |
| 1730 |
{ |
{ |
| 1733 |
{ |
{ |
| 1734 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 1735 |
} |
} |
| 1736 |
category = _pcre_ucp_findprop(c, &chartype, &script); |
category = UCD_CATEGORY(c); |
| 1737 |
if (category != ucp_M) break; |
if (category != ucp_M) break; |
| 1738 |
eptr += len; |
eptr += len; |
| 1739 |
} |
} |
| 1754 |
case OP_REF: |
case OP_REF: |
| 1755 |
{ |
{ |
| 1756 |
offset = GET2(ecode, 1) << 1; /* Doubled ref number */ |
offset = GET2(ecode, 1) << 1; /* Doubled ref number */ |
| 1757 |
ecode += 3; /* Advance past item */ |
ecode += 3; |
| 1758 |
|
|
| 1759 |
|
/* If the reference is unset, there are two possibilities: |
| 1760 |
|
|
| 1761 |
/* If the reference is unset, set the length to be longer than the amount |
(a) In the default, Perl-compatible state, set the length to be longer |
| 1762 |
of subject left; this ensures that every attempt at a match fails. We |
than the amount of subject left; this ensures that every attempt at a |
| 1763 |
can't just fail here, because of the possibility of quantifiers with zero |
match fails. We can't just fail here, because of the possibility of |
| 1764 |
minima. */ |
quantifiers with zero minima. |
| 1765 |
|
|
| 1766 |
length = (offset >= offset_top || md->offset_vector[offset] < 0)? |
(b) If the JavaScript compatibility flag is set, set the length to zero |
| 1767 |
md->end_subject - eptr + 1 : |
so that the back reference matches an empty string. |
| 1768 |
md->offset_vector[offset+1] - md->offset_vector[offset]; |
|
| 1769 |
|
Otherwise, set the length to the length of what was matched by the |
| 1770 |
|
referenced subpattern. */ |
| 1771 |
|
|
| 1772 |
|
if (offset >= offset_top || md->offset_vector[offset] < 0) |
| 1773 |
|
length = (md->jscript_compat)? 0 : md->end_subject - eptr + 1; |
| 1774 |
|
else |
| 1775 |
|
length = md->offset_vector[offset+1] - md->offset_vector[offset]; |
| 1776 |
|
|
| 1777 |
/* Set up for repetition, or handle the non-repeated case */ |
/* Set up for repetition, or handle the non-repeated case */ |
| 1778 |
|
|
| 2132 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM21); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM21); |
| 2133 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2134 |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 2135 |
BACKCHAR(eptr) |
if (utf8) BACKCHAR(eptr); |
| 2136 |
} |
} |
| 2137 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 2138 |
} |
} |
| 2198 |
if (fc != dc) |
if (fc != dc) |
| 2199 |
{ |
{ |
| 2200 |
#ifdef SUPPORT_UCP |
#ifdef SUPPORT_UCP |
| 2201 |
if (dc != _pcre_ucp_othercase(fc)) |
if (dc != UCD_OTHERCASE(fc)) |
| 2202 |
#endif |
#endif |
| 2203 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 2204 |
} |
} |
| 2289 |
#ifdef SUPPORT_UCP |
#ifdef SUPPORT_UCP |
| 2290 |
unsigned int othercase; |
unsigned int othercase; |
| 2291 |
if ((ims & PCRE_CASELESS) != 0 && |
if ((ims & PCRE_CASELESS) != 0 && |
| 2292 |
(othercase = _pcre_ucp_othercase(fc)) != NOTACHAR) |
(othercase = UCD_OTHERCASE(fc)) != fc) |
| 2293 |
oclength = _pcre_ord2utf8(othercase, occhars); |
oclength = _pcre_ord2utf8(othercase, occhars); |
| 2294 |
else oclength = 0; |
else oclength = 0; |
| 2295 |
#endif /* SUPPORT_UCP */ |
#endif /* SUPPORT_UCP */ |
| 2885 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 2886 |
{ |
{ |
| 2887 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 2888 |
GETCHARINC(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 2889 |
} |
} |
| 2890 |
break; |
break; |
| 2891 |
|
|
| 2893 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 2894 |
{ |
{ |
| 2895 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 2896 |
GETCHARINC(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 2897 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_chartype = UCD_CHARTYPE(c); |
| 2898 |
if ((prop_chartype == ucp_Lu || |
if ((prop_chartype == ucp_Lu || |
| 2899 |
prop_chartype == ucp_Ll || |
prop_chartype == ucp_Ll || |
| 2900 |
prop_chartype == ucp_Lt) == prop_fail_result) |
prop_chartype == ucp_Lt) == prop_fail_result) |
| 2906 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 2907 |
{ |
{ |
| 2908 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 2909 |
GETCHARINC(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 2910 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_category = UCD_CATEGORY(c); |
| 2911 |
if ((prop_category == prop_value) == prop_fail_result) |
if ((prop_category == prop_value) == prop_fail_result) |
| 2912 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 2913 |
} |
} |
| 2917 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 2918 |
{ |
{ |
| 2919 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 2920 |
GETCHARINC(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 2921 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_chartype = UCD_CHARTYPE(c); |
| 2922 |
if ((prop_chartype == prop_value) == prop_fail_result) |
if ((prop_chartype == prop_value) == prop_fail_result) |
| 2923 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 2924 |
} |
} |
| 2928 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 2929 |
{ |
{ |
| 2930 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 2931 |
GETCHARINC(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 2932 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_script = UCD_SCRIPT(c); |
| 2933 |
if ((prop_script == prop_value) == prop_fail_result) |
if ((prop_script == prop_value) == prop_fail_result) |
| 2934 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 2935 |
} |
} |
| 2948 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 2949 |
{ |
{ |
| 2950 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 2951 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_category = UCD_CATEGORY(c); |
| 2952 |
if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH); |
if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH); |
| 2953 |
while (eptr < md->end_subject) |
while (eptr < md->end_subject) |
| 2954 |
{ |
{ |
| 2957 |
{ |
{ |
| 2958 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 2959 |
} |
} |
| 2960 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_category = UCD_CATEGORY(c); |
| 2961 |
if (prop_category != ucp_M) break; |
if (prop_category != ucp_M) break; |
| 2962 |
eptr += len; |
eptr += len; |
| 2963 |
} |
} |
| 2975 |
case OP_ANY: |
case OP_ANY: |
| 2976 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 2977 |
{ |
{ |
| 2978 |
if (eptr >= md->end_subject || |
if (eptr >= md->end_subject || IS_NEWLINE(eptr)) |
|
((ims & PCRE_DOTALL) == 0 && IS_NEWLINE(eptr))) |
|
| 2979 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 2980 |
eptr++; |
eptr++; |
| 2981 |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| 2982 |
} |
} |
| 2983 |
break; |
break; |
| 2984 |
|
|
| 2985 |
|
case OP_ALLANY: |
| 2986 |
|
for (i = 1; i <= min; i++) |
| 2987 |
|
{ |
| 2988 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 2989 |
|
eptr++; |
| 2990 |
|
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| 2991 |
|
} |
| 2992 |
|
break; |
| 2993 |
|
|
| 2994 |
case OP_ANYBYTE: |
case OP_ANYBYTE: |
| 2995 |
eptr += min; |
eptr += min; |
| 2996 |
break; |
break; |
| 3006 |
case 0x000d: |
case 0x000d: |
| 3007 |
if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 3008 |
break; |
break; |
| 3009 |
|
|
| 3010 |
case 0x000a: |
case 0x000a: |
| 3011 |
|
break; |
| 3012 |
|
|
| 3013 |
case 0x000b: |
case 0x000b: |
| 3014 |
case 0x000c: |
case 0x000c: |
| 3015 |
case 0x0085: |
case 0x0085: |
| 3016 |
case 0x2028: |
case 0x2028: |
| 3017 |
case 0x2029: |
case 0x2029: |
| 3018 |
|
if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); |
| 3019 |
|
break; |
| 3020 |
|
} |
| 3021 |
|
} |
| 3022 |
|
break; |
| 3023 |
|
|
| 3024 |
|
case OP_NOT_HSPACE: |
| 3025 |
|
for (i = 1; i <= min; i++) |
| 3026 |
|
{ |
| 3027 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3028 |
|
GETCHARINC(c, eptr); |
| 3029 |
|
switch(c) |
| 3030 |
|
{ |
| 3031 |
|
default: break; |
| 3032 |
|
case 0x09: /* HT */ |
| 3033 |
|
case 0x20: /* SPACE */ |
| 3034 |
|
case 0xa0: /* NBSP */ |
| 3035 |
|
case 0x1680: /* OGHAM SPACE MARK */ |
| 3036 |
|
case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ |
| 3037 |
|
case 0x2000: /* EN QUAD */ |
| 3038 |
|
case 0x2001: /* EM QUAD */ |
| 3039 |
|
case 0x2002: /* EN SPACE */ |
| 3040 |
|
case 0x2003: /* EM SPACE */ |
| 3041 |
|
case 0x2004: /* THREE-PER-EM SPACE */ |
| 3042 |
|
case 0x2005: /* FOUR-PER-EM SPACE */ |
| 3043 |
|
case 0x2006: /* SIX-PER-EM SPACE */ |
| 3044 |
|
case 0x2007: /* FIGURE SPACE */ |
| 3045 |
|
case 0x2008: /* PUNCTUATION SPACE */ |
| 3046 |
|
case 0x2009: /* THIN SPACE */ |
| 3047 |
|
case 0x200A: /* HAIR SPACE */ |
| 3048 |
|
case 0x202f: /* NARROW NO-BREAK SPACE */ |
| 3049 |
|
case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ |
| 3050 |
|
case 0x3000: /* IDEOGRAPHIC SPACE */ |
| 3051 |
|
RRETURN(MATCH_NOMATCH); |
| 3052 |
|
} |
| 3053 |
|
} |
| 3054 |
|
break; |
| 3055 |
|
|
| 3056 |
|
case OP_HSPACE: |
| 3057 |
|
for (i = 1; i <= min; i++) |
| 3058 |
|
{ |
| 3059 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3060 |
|
GETCHARINC(c, eptr); |
| 3061 |
|
switch(c) |
| 3062 |
|
{ |
| 3063 |
|
default: RRETURN(MATCH_NOMATCH); |
| 3064 |
|
case 0x09: /* HT */ |
| 3065 |
|
case 0x20: /* SPACE */ |
| 3066 |
|
case 0xa0: /* NBSP */ |
| 3067 |
|
case 0x1680: /* OGHAM SPACE MARK */ |
| 3068 |
|
case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ |
| 3069 |
|
case 0x2000: /* EN QUAD */ |
| 3070 |
|
case 0x2001: /* EM QUAD */ |
| 3071 |
|
case 0x2002: /* EN SPACE */ |
| 3072 |
|
case 0x2003: /* EM SPACE */ |
| 3073 |
|
case 0x2004: /* THREE-PER-EM SPACE */ |
| 3074 |
|
case 0x2005: /* FOUR-PER-EM SPACE */ |
| 3075 |
|
case 0x2006: /* SIX-PER-EM SPACE */ |
| 3076 |
|
case 0x2007: /* FIGURE SPACE */ |
| 3077 |
|
case 0x2008: /* PUNCTUATION SPACE */ |
| 3078 |
|
case 0x2009: /* THIN SPACE */ |
| 3079 |
|
case 0x200A: /* HAIR SPACE */ |
| 3080 |
|
case 0x202f: /* NARROW NO-BREAK SPACE */ |
| 3081 |
|
case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ |
| 3082 |
|
case 0x3000: /* IDEOGRAPHIC SPACE */ |
| 3083 |
|
break; |
| 3084 |
|
} |
| 3085 |
|
} |
| 3086 |
|
break; |
| 3087 |
|
|
| 3088 |
|
case OP_NOT_VSPACE: |
| 3089 |
|
for (i = 1; i <= min; i++) |
| 3090 |
|
{ |
| 3091 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3092 |
|
GETCHARINC(c, eptr); |
| 3093 |
|
switch(c) |
| 3094 |
|
{ |
| 3095 |
|
default: break; |
| 3096 |
|
case 0x0a: /* LF */ |
| 3097 |
|
case 0x0b: /* VT */ |
| 3098 |
|
case 0x0c: /* FF */ |
| 3099 |
|
case 0x0d: /* CR */ |
| 3100 |
|
case 0x85: /* NEL */ |
| 3101 |
|
case 0x2028: /* LINE SEPARATOR */ |
| 3102 |
|
case 0x2029: /* PARAGRAPH SEPARATOR */ |
| 3103 |
|
RRETURN(MATCH_NOMATCH); |
| 3104 |
|
} |
| 3105 |
|
} |
| 3106 |
|
break; |
| 3107 |
|
|
| 3108 |
|
case OP_VSPACE: |
| 3109 |
|
for (i = 1; i <= min; i++) |
| 3110 |
|
{ |
| 3111 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3112 |
|
GETCHARINC(c, eptr); |
| 3113 |
|
switch(c) |
| 3114 |
|
{ |
| 3115 |
|
default: RRETURN(MATCH_NOMATCH); |
| 3116 |
|
case 0x0a: /* LF */ |
| 3117 |
|
case 0x0b: /* VT */ |
| 3118 |
|
case 0x0c: /* FF */ |
| 3119 |
|
case 0x0d: /* CR */ |
| 3120 |
|
case 0x85: /* NEL */ |
| 3121 |
|
case 0x2028: /* LINE SEPARATOR */ |
| 3122 |
|
case 0x2029: /* PARAGRAPH SEPARATOR */ |
| 3123 |
break; |
break; |
| 3124 |
} |
} |
| 3125 |
} |
} |
| 3149 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3150 |
{ |
{ |
| 3151 |
if (eptr >= md->end_subject || |
if (eptr >= md->end_subject || |
| 3152 |
(*eptr < 128 && (md->ctypes[*eptr++] & ctype_space) != 0)) |
(*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0)) |
| 3153 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 3154 |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80); |
| 3155 |
} |
} |
| 3156 |
break; |
break; |
| 3157 |
|
|
| 3169 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3170 |
{ |
{ |
| 3171 |
if (eptr >= md->end_subject || |
if (eptr >= md->end_subject || |
| 3172 |
(*eptr < 128 && (md->ctypes[*eptr++] & ctype_word) != 0)) |
(*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0)) |
| 3173 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 3174 |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80); |
| 3175 |
} |
} |
| 3176 |
break; |
break; |
| 3177 |
|
|
| 3199 |
switch(ctype) |
switch(ctype) |
| 3200 |
{ |
{ |
| 3201 |
case OP_ANY: |
case OP_ANY: |
| 3202 |
if ((ims & PCRE_DOTALL) == 0) |
for (i = 1; i <= min; i++) |
| 3203 |
{ |
{ |
| 3204 |
for (i = 1; i <= min; i++) |
if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); |
| 3205 |
{ |
eptr++; |
|
if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); |
|
|
eptr++; |
|
|
} |
|
| 3206 |
} |
} |
| 3207 |
else eptr += min; |
break; |
| 3208 |
|
|
| 3209 |
|
case OP_ALLANY: |
| 3210 |
|
eptr += min; |
| 3211 |
break; |
break; |
| 3212 |
|
|
| 3213 |
case OP_ANYBYTE: |
case OP_ANYBYTE: |
| 3228 |
if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 3229 |
break; |
break; |
| 3230 |
case 0x000a: |
case 0x000a: |
| 3231 |
|
break; |
| 3232 |
|
|
| 3233 |
case 0x000b: |
case 0x000b: |
| 3234 |
case 0x000c: |
case 0x000c: |
| 3235 |
case 0x0085: |
case 0x0085: |
| 3236 |
|
if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); |
| 3237 |
|
break; |
| 3238 |
|
} |
| 3239 |
|
} |
| 3240 |
|
break; |
| 3241 |
|
|
| 3242 |
|
case OP_NOT_HSPACE: |
| 3243 |
|
for (i = 1; i <= min; i++) |
| 3244 |
|
{ |
| 3245 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3246 |
|
switch(*eptr++) |
| 3247 |
|
{ |
| 3248 |
|
default: break; |
| 3249 |
|
case 0x09: /* HT */ |
| 3250 |
|
case 0x20: /* SPACE */ |
| 3251 |
|
case 0xa0: /* NBSP */ |
| 3252 |
|
RRETURN(MATCH_NOMATCH); |
| 3253 |
|
} |
| 3254 |
|
} |
| 3255 |
|
break; |
| 3256 |
|
|
| 3257 |
|
case OP_HSPACE: |
| 3258 |
|
for (i = 1; i <= min; i++) |
| 3259 |
|
{ |
| 3260 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3261 |
|
switch(*eptr++) |
| 3262 |
|
{ |
| 3263 |
|
default: RRETURN(MATCH_NOMATCH); |
| 3264 |
|
case 0x09: /* HT */ |
| 3265 |
|
case 0x20: /* SPACE */ |
| 3266 |
|
case 0xa0: /* NBSP */ |
| 3267 |
|
break; |
| 3268 |
|
} |
| 3269 |
|
} |
| 3270 |
|
break; |
| 3271 |
|
|
| 3272 |
|
case OP_NOT_VSPACE: |
| 3273 |
|
for (i = 1; i <= min; i++) |
| 3274 |
|
{ |
| 3275 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3276 |
|
switch(*eptr++) |
| 3277 |
|
{ |
| 3278 |
|
default: break; |
| 3279 |
|
case 0x0a: /* LF */ |
| 3280 |
|
case 0x0b: /* VT */ |
| 3281 |
|
case 0x0c: /* FF */ |
| 3282 |
|
case 0x0d: /* CR */ |
| 3283 |
|
case 0x85: /* NEL */ |
| 3284 |
|
RRETURN(MATCH_NOMATCH); |
| 3285 |
|
} |
| 3286 |
|
} |
| 3287 |
|
break; |
| 3288 |
|
|
| 3289 |
|
case OP_VSPACE: |
| 3290 |
|
for (i = 1; i <= min; i++) |
| 3291 |
|
{ |
| 3292 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3293 |
|
switch(*eptr++) |
| 3294 |
|
{ |
| 3295 |
|
default: RRETURN(MATCH_NOMATCH); |
| 3296 |
|
case 0x0a: /* LF */ |
| 3297 |
|
case 0x0b: /* VT */ |
| 3298 |
|
case 0x0c: /* FF */ |
| 3299 |
|
case 0x0d: /* CR */ |
| 3300 |
|
case 0x85: /* NEL */ |
| 3301 |
break; |
break; |
| 3302 |
} |
} |
| 3303 |
} |
} |
| 3373 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3374 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3375 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 3376 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_chartype = UCD_CHARTYPE(c); |
| 3377 |
if ((prop_chartype == ucp_Lu || |
if ((prop_chartype == ucp_Lu || |
| 3378 |
prop_chartype == ucp_Ll || |
prop_chartype == ucp_Ll || |
| 3379 |
prop_chartype == ucp_Lt) == prop_fail_result) |
prop_chartype == ucp_Lt) == prop_fail_result) |
| 3388 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3389 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3390 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 3391 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_category = UCD_CATEGORY(c); |
| 3392 |
if ((prop_category == prop_value) == prop_fail_result) |
if ((prop_category == prop_value) == prop_fail_result) |
| 3393 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 3394 |
} |
} |
| 3401 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3402 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3403 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 3404 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_chartype = UCD_CHARTYPE(c); |
| 3405 |
if ((prop_chartype == prop_value) == prop_fail_result) |
if ((prop_chartype == prop_value) == prop_fail_result) |
| 3406 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 3407 |
} |
} |
| 3414 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3415 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3416 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 3417 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_script = UCD_SCRIPT(c); |
| 3418 |
if ((prop_script == prop_value) == prop_fail_result) |
if ((prop_script == prop_value) == prop_fail_result) |
| 3419 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 3420 |
} |
} |
| 3436 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3437 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3438 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 3439 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_category = UCD_CATEGORY(c); |
| 3440 |
if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH); |
if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH); |
| 3441 |
while (eptr < md->end_subject) |
while (eptr < md->end_subject) |
| 3442 |
{ |
{ |
| 3445 |
{ |
{ |
| 3446 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 3447 |
} |
} |
| 3448 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_category = UCD_CATEGORY(c); |
| 3449 |
if (prop_category != ucp_M) break; |
if (prop_category != ucp_M) break; |
| 3450 |
eptr += len; |
eptr += len; |
| 3451 |
} |
} |
| 3464 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM42); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM42); |
| 3465 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3466 |
if (fi >= max || eptr >= md->end_subject || |
if (fi >= max || eptr >= md->end_subject || |
| 3467 |
(ctype == OP_ANY && (ims & PCRE_DOTALL) == 0 && |
(ctype == OP_ANY && IS_NEWLINE(eptr))) |
|
IS_NEWLINE(eptr))) |
|
| 3468 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 3469 |
|
|
| 3470 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 3471 |
switch(ctype) |
switch(ctype) |
| 3472 |
{ |
{ |
| 3473 |
case OP_ANY: /* This is the DOTALL case */ |
case OP_ANY: /* This is the non-NL case */ |
| 3474 |
break; |
case OP_ALLANY: |
|
|
|
| 3475 |
case OP_ANYBYTE: |
case OP_ANYBYTE: |
| 3476 |
break; |
break; |
| 3477 |
|
|
| 3483 |
if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 3484 |
break; |
break; |
| 3485 |
case 0x000a: |
case 0x000a: |
| 3486 |
|
break; |
| 3487 |
|
|
| 3488 |
case 0x000b: |
case 0x000b: |
| 3489 |
case 0x000c: |
case 0x000c: |
| 3490 |
case 0x0085: |
case 0x0085: |
| 3491 |
case 0x2028: |
case 0x2028: |
| 3492 |
case 0x2029: |
case 0x2029: |
| 3493 |
|
if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); |
| 3494 |
|
break; |
| 3495 |
|
} |
| 3496 |
|
break; |
| 3497 |
|
|
| 3498 |
|
case OP_NOT_HSPACE: |
| 3499 |
|
switch(c) |
| 3500 |
|
{ |
| 3501 |
|
default: break; |
| 3502 |
|
case 0x09: /* HT */ |
| 3503 |
|
case 0x20: /* SPACE */ |
| 3504 |
|
case 0xa0: /* NBSP */ |
| 3505 |
|
case 0x1680: /* OGHAM SPACE MARK */ |
| 3506 |
|
case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ |
| 3507 |
|
case 0x2000: /* EN QUAD */ |
| 3508 |
|
case 0x2001: /* EM QUAD */ |
| 3509 |
|
case 0x2002: /* EN SPACE */ |
| 3510 |
|
case 0x2003: /* EM SPACE */ |
| 3511 |
|
case 0x2004: /* THREE-PER-EM SPACE */ |
| 3512 |
|
case 0x2005: /* FOUR-PER-EM SPACE */ |
| 3513 |
|
case 0x2006: /* SIX-PER-EM SPACE */ |
| 3514 |
|
case 0x2007: /* FIGURE SPACE */ |
| 3515 |
|
case 0x2008: /* PUNCTUATION SPACE */ |
| 3516 |
|
case 0x2009: /* THIN SPACE */ |
| 3517 |
|
case 0x200A: /* HAIR SPACE */ |
| 3518 |
|
case 0x202f: /* NARROW NO-BREAK SPACE */ |
| 3519 |
|
case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ |
| 3520 |
|
case 0x3000: /* IDEOGRAPHIC SPACE */ |
| 3521 |
|
RRETURN(MATCH_NOMATCH); |
| 3522 |
|
} |
| 3523 |
|
break; |
| 3524 |
|
|
| 3525 |
|
case OP_HSPACE: |
| 3526 |
|
switch(c) |
| 3527 |
|
{ |
| 3528 |
|
default: RRETURN(MATCH_NOMATCH); |
| 3529 |
|
case 0x09: /* HT */ |
| 3530 |
|
case 0x20: /* SPACE */ |
| 3531 |
|
case 0xa0: /* NBSP */ |
| 3532 |
|
case 0x1680: /* OGHAM SPACE MARK */ |
| 3533 |
|
case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ |
| 3534 |
|
case 0x2000: /* EN QUAD */ |
| 3535 |
|
case 0x2001: /* EM QUAD */ |
| 3536 |
|
case 0x2002: /* EN SPACE */ |
| 3537 |
|
case 0x2003: /* EM SPACE */ |
| 3538 |
|
case 0x2004: /* THREE-PER-EM SPACE */ |
| 3539 |
|
case 0x2005: /* FOUR-PER-EM SPACE */ |
| 3540 |
|
case 0x2006: /* SIX-PER-EM SPACE */ |
| 3541 |
|
case 0x2007: /* FIGURE SPACE */ |
| 3542 |
|
case 0x2008: /* PUNCTUATION SPACE */ |
| 3543 |
|
case 0x2009: /* THIN SPACE */ |
| 3544 |
|
case 0x200A: /* HAIR SPACE */ |
| 3545 |
|
case 0x202f: /* NARROW NO-BREAK SPACE */ |
| 3546 |
|
case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ |
| 3547 |
|
case 0x3000: /* IDEOGRAPHIC SPACE */ |
| 3548 |
|
break; |
| 3549 |
|
} |
| 3550 |
|
break; |
| 3551 |
|
|
| 3552 |
|
case OP_NOT_VSPACE: |
| 3553 |
|
switch(c) |
| 3554 |
|
{ |
| 3555 |
|
default: break; |
| 3556 |
|
case 0x0a: /* LF */ |
| 3557 |
|
case 0x0b: /* VT */ |
| 3558 |
|
case 0x0c: /* FF */ |
| 3559 |
|
case 0x0d: /* CR */ |
| 3560 |
|
case 0x85: /* NEL */ |
| 3561 |
|
case 0x2028: /* LINE SEPARATOR */ |
| 3562 |
|
case 0x2029: /* PARAGRAPH SEPARATOR */ |
| 3563 |
|
RRETURN(MATCH_NOMATCH); |
| 3564 |
|
} |
| 3565 |
|
break; |
| 3566 |
|
|
| 3567 |
|
case OP_VSPACE: |
| 3568 |
|
switch(c) |
| 3569 |
|
{ |
| 3570 |
|
default: RRETURN(MATCH_NOMATCH); |
| 3571 |
|
case 0x0a: /* LF */ |
| 3572 |
|
case 0x0b: /* VT */ |
| 3573 |
|
case 0x0c: /* FF */ |
| 3574 |
|
case 0x0d: /* CR */ |
| 3575 |
|
case 0x85: /* NEL */ |
| 3576 |
|
case 0x2028: /* LINE SEPARATOR */ |
| 3577 |
|
case 0x2029: /* PARAGRAPH SEPARATOR */ |
| 3578 |
break; |
break; |
| 3579 |
} |
} |
| 3580 |
break; |
break; |
| 3623 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM43); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM43); |
| 3624 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3625 |
if (fi >= max || eptr >= md->end_subject || |
if (fi >= max || eptr >= md->end_subject || |
| 3626 |
((ims & PCRE_DOTALL) == 0 && IS_NEWLINE(eptr))) |
(ctype == OP_ANY && IS_NEWLINE(eptr))) |
| 3627 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 3628 |
|
|
| 3629 |
c = *eptr++; |
c = *eptr++; |
| 3630 |
switch(ctype) |
switch(ctype) |
| 3631 |
{ |
{ |
| 3632 |
case OP_ANY: /* This is the DOTALL case */ |
case OP_ANY: /* This is the non-NL case */ |
| 3633 |
break; |
case OP_ALLANY: |
|
|
|
| 3634 |
case OP_ANYBYTE: |
case OP_ANYBYTE: |
| 3635 |
break; |
break; |
| 3636 |
|
|
| 3641 |
case 0x000d: |
case 0x000d: |
| 3642 |
if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 3643 |
break; |
break; |
| 3644 |
|
|
| 3645 |
case 0x000a: |
case 0x000a: |
| 3646 |
|
break; |
| 3647 |
|
|
| 3648 |
case 0x000b: |
case 0x000b: |
| 3649 |
case 0x000c: |
case 0x000c: |
| 3650 |
case 0x0085: |
case 0x0085: |
| 3651 |
|
if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); |
| 3652 |
|
break; |
| 3653 |
|
} |
| 3654 |
|
break; |
| 3655 |
|
|
| 3656 |
|
case OP_NOT_HSPACE: |
| 3657 |
|
switch(c) |
| 3658 |
|
{ |
| 3659 |
|
default: break; |
| 3660 |
|
case 0x09: /* HT */ |
| 3661 |
|
case 0x20: /* SPACE */ |
| 3662 |
|
case 0xa0: /* NBSP */ |
| 3663 |
|
RRETURN(MATCH_NOMATCH); |
| 3664 |
|
} |
| 3665 |
|
break; |
| 3666 |
|
|
| 3667 |
|
case OP_HSPACE: |
| 3668 |
|
switch(c) |
| 3669 |
|
{ |
| 3670 |
|
default: RRETURN(MATCH_NOMATCH); |
| 3671 |
|
case 0x09: /* HT */ |
| 3672 |
|
case 0x20: /* SPACE */ |
| 3673 |
|
case 0xa0: /* NBSP */ |
| 3674 |
|
break; |
| 3675 |
|
} |
| 3676 |
|
break; |
| 3677 |
|
|
| 3678 |
|
case OP_NOT_VSPACE: |
| 3679 |
|
switch(c) |
| 3680 |
|
{ |
| 3681 |
|
default: break; |
| 3682 |
|
case 0x0a: /* LF */ |
| 3683 |
|
case 0x0b: /* VT */ |
| 3684 |
|
case 0x0c: /* FF */ |
| 3685 |
|
case 0x0d: /* CR */ |
| 3686 |
|
case 0x85: /* NEL */ |
| 3687 |
|
RRETURN(MATCH_NOMATCH); |
| 3688 |
|
} |
| 3689 |
|
break; |
| 3690 |
|
|
| 3691 |
|
case OP_VSPACE: |
| 3692 |
|
switch(c) |
| 3693 |
|
{ |
| 3694 |
|
default: RRETURN(MATCH_NOMATCH); |
| 3695 |
|
case 0x0a: /* LF */ |
| 3696 |
|
case 0x0b: /* VT */ |
| 3697 |
|
case 0x0c: /* FF */ |
| 3698 |
|
case 0x0d: /* CR */ |
| 3699 |
|
case 0x85: /* NEL */ |
| 3700 |
break; |
break; |
| 3701 |
} |
} |
| 3702 |
break; |
break; |
| 3763 |
int len = 1; |
int len = 1; |
| 3764 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) break; |
| 3765 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 3766 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_chartype = UCD_CHARTYPE(c); |
| 3767 |
if ((prop_chartype == ucp_Lu || |
if ((prop_chartype == ucp_Lu || |
| 3768 |
prop_chartype == ucp_Ll || |
prop_chartype == ucp_Ll || |
| 3769 |
prop_chartype == ucp_Lt) == prop_fail_result) |
prop_chartype == ucp_Lt) == prop_fail_result) |
| 3778 |
int len = 1; |
int len = 1; |
| 3779 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) break; |
| 3780 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 3781 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_category = UCD_CATEGORY(c); |
| 3782 |
if ((prop_category == prop_value) == prop_fail_result) |
if ((prop_category == prop_value) == prop_fail_result) |
| 3783 |
break; |
break; |
| 3784 |
eptr+= len; |
eptr+= len; |
| 3791 |
int len = 1; |
int len = 1; |
| 3792 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) break; |
| 3793 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 3794 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_chartype = UCD_CHARTYPE(c); |
| 3795 |
if ((prop_chartype == prop_value) == prop_fail_result) |
if ((prop_chartype == prop_value) == prop_fail_result) |
| 3796 |
break; |
break; |
| 3797 |
eptr+= len; |
eptr+= len; |
| 3804 |
int len = 1; |
int len = 1; |
| 3805 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) break; |
| 3806 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 3807 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_script = UCD_SCRIPT(c); |
| 3808 |
if ((prop_script == prop_value) == prop_fail_result) |
if ((prop_script == prop_value) == prop_fail_result) |
| 3809 |
break; |
break; |
| 3810 |
eptr+= len; |
eptr+= len; |
| 3820 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM44); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM44); |
| 3821 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3822 |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 3823 |
BACKCHAR(eptr); |
if (utf8) BACKCHAR(eptr); |
| 3824 |
} |
} |
| 3825 |
} |
} |
| 3826 |
|
|
| 3833 |
{ |
{ |
| 3834 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) break; |
| 3835 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 3836 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_category = UCD_CATEGORY(c); |
| 3837 |
if (prop_category == ucp_M) break; |
if (prop_category == ucp_M) break; |
| 3838 |
while (eptr < md->end_subject) |
while (eptr < md->end_subject) |
| 3839 |
{ |
{ |
| 3842 |
{ |
{ |
| 3843 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 3844 |
} |
} |
| 3845 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_category = UCD_CATEGORY(c); |
| 3846 |
if (prop_category != ucp_M) break; |
if (prop_category != ucp_M) break; |
| 3847 |
eptr += len; |
eptr += len; |
| 3848 |
} |
} |
| 3859 |
for (;;) /* Move back over one extended */ |
for (;;) /* Move back over one extended */ |
| 3860 |
{ |
{ |
| 3861 |
int len = 1; |
int len = 1; |
|
BACKCHAR(eptr); |
|
| 3862 |
if (!utf8) c = *eptr; else |
if (!utf8) c = *eptr; else |
| 3863 |
{ |
{ |
| 3864 |
|
BACKCHAR(eptr); |
| 3865 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 3866 |
} |
} |
| 3867 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_category = UCD_CATEGORY(c); |
| 3868 |
if (prop_category != ucp_M) break; |
if (prop_category != ucp_M) break; |
| 3869 |
eptr--; |
eptr--; |
| 3870 |
} |
} |
| 3882 |
switch(ctype) |
switch(ctype) |
| 3883 |
{ |
{ |
| 3884 |
case OP_ANY: |
case OP_ANY: |
|
|
|
|
/* Special code is required for UTF8, but when the maximum is |
|
|
unlimited we don't need it, so we repeat the non-UTF8 code. This is |
|
|
probably worth it, because .* is quite a common idiom. */ |
|
|
|
|
| 3885 |
if (max < INT_MAX) |
if (max < INT_MAX) |
| 3886 |
{ |
{ |
| 3887 |
if ((ims & PCRE_DOTALL) == 0) |
for (i = min; i < max; i++) |
|
{ |
|
|
for (i = min; i < max; i++) |
|
|
{ |
|
|
if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break; |
|
|
eptr++; |
|
|
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
|
|
} |
|
|
} |
|
|
else |
|
| 3888 |
{ |
{ |
| 3889 |
for (i = min; i < max; i++) |
if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break; |
| 3890 |
{ |
eptr++; |
| 3891 |
if (eptr >= md->end_subject) break; |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
|
eptr++; |
|
|
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
|
|
} |
|
| 3892 |
} |
} |
| 3893 |
} |
} |
| 3894 |
|
|
| 3896 |
|
|
| 3897 |
else |
else |
| 3898 |
{ |
{ |
| 3899 |
if ((ims & PCRE_DOTALL) == 0) |
for (i = min; i < max; i++) |
| 3900 |
{ |
{ |
| 3901 |
for (i = min; i < max; i++) |
if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break; |
| 3902 |
{ |
eptr++; |
| 3903 |
if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break; |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
|
eptr++; |
|
|
} |
|
|
break; |
|
| 3904 |
} |
} |
| 3905 |
else |
} |
| 3906 |
|
break; |
| 3907 |
|
|
| 3908 |
|
case OP_ALLANY: |
| 3909 |
|
if (max < INT_MAX) |
| 3910 |
|
{ |
| 3911 |
|
for (i = min; i < max; i++) |
| 3912 |
{ |
{ |
| 3913 |
c = max - min; |
if (eptr >= md->end_subject) break; |
| 3914 |
if (c > (unsigned int)(md->end_subject - eptr)) |
eptr++; |
| 3915 |
c = md->end_subject - eptr; |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
|
eptr += c; |
|
| 3916 |
} |
} |
| 3917 |
} |
} |
| 3918 |
|
else eptr = md->end_subject; /* Unlimited UTF-8 repeat */ |
| 3919 |
break; |
break; |
| 3920 |
|
|
| 3921 |
/* The byte case is the same as non-UTF8 */ |
/* The byte case is the same as non-UTF8 */ |
| 3940 |
} |
} |
| 3941 |
else |
else |
| 3942 |
{ |
{ |
| 3943 |
if (c != 0x000a && c != 0x000b && c != 0x000c && |
if (c != 0x000a && |
| 3944 |
c != 0x0085 && c != 0x2028 && c != 0x2029) |
(md->bsr_anycrlf || |
| 3945 |
|
(c != 0x000b && c != 0x000c && |
| 3946 |
|
c != 0x0085 && c != 0x2028 && c != 0x2029))) |
| 3947 |
break; |
break; |
| 3948 |
eptr += len; |
eptr += len; |
| 3949 |
} |
} |
| 3950 |
} |
} |
| 3951 |
break; |
break; |
| 3952 |
|
|
| 3953 |
|
case OP_NOT_HSPACE: |
| 3954 |
|
case OP_HSPACE: |
| 3955 |
|
for (i = min; i < max; i++) |
| 3956 |
|
{ |
| 3957 |
|
BOOL gotspace; |
| 3958 |
|
int len = 1; |
| 3959 |
|
if (eptr >= md->end_subject) break; |
| 3960 |
|
GETCHARLEN(c, eptr, len); |
| 3961 |
|
switch(c) |
| 3962 |
|
{ |
| 3963 |
|
default: gotspace = FALSE; break; |
| 3964 |
|
case 0x09: /* HT */ |
| 3965 |
|
case 0x20: /* SPACE */ |
| 3966 |
|
case 0xa0: /* NBSP */ |
| 3967 |
|
case 0x1680: /* OGHAM SPACE MARK */ |
| 3968 |
|
case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ |
| 3969 |
|
case 0x2000: /* EN QUAD */ |
| 3970 |
|
case 0x2001: /* EM QUAD */ |
| 3971 |
|
case 0x2002: /* EN SPACE */ |
| 3972 |
|
case 0x2003: /* EM SPACE */ |
| 3973 |
|
case 0x2004: /* THREE-PER-EM SPACE */ |
| 3974 |
|
case 0x2005: /* FOUR-PER-EM SPACE */ |
| 3975 |
|
case 0x2006: /* SIX-PER-EM SPACE */ |
| 3976 |
|
case 0x2007: /* FIGURE SPACE */ |
| 3977 |
|
case 0x2008: /* PUNCTUATION SPACE */ |
| 3978 |
|
case 0x2009: /* THIN SPACE */ |
| 3979 |
|
case 0x200A: /* HAIR SPACE */ |
| 3980 |
|
case 0x202f: /* NARROW NO-BREAK SPACE */ |
| 3981 |
|
case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ |
| 3982 |
|
case 0x3000: /* IDEOGRAPHIC SPACE */ |
| 3983 |
|
gotspace = TRUE; |
| 3984 |
|
break; |
| 3985 |
|
} |
| 3986 |
|
if (gotspace == (ctype == OP_NOT_HSPACE)) break; |
| 3987 |
|
eptr += len; |
| 3988 |
|
} |
| 3989 |
|
break; |
| 3990 |
|
|
| 3991 |
|
case OP_NOT_VSPACE: |
| 3992 |
|
case OP_VSPACE: |
| 3993 |
|
for (i = min; i < max; i++) |
| 3994 |
|
{ |
| 3995 |
|
BOOL gotspace; |
| 3996 |
|
int len = 1; |
| 3997 |
|
if (eptr >= md->end_subject) break; |
| 3998 |
|
GETCHARLEN(c, eptr, len); |
| 3999 |
|
switch(c) |
| 4000 |
|
{ |
| 4001 |
|
default: gotspace = FALSE; break; |
| 4002 |
|
case 0x0a: /* LF */ |
| 4003 |
|
case 0x0b: /* VT */ |
| 4004 |
|
case 0x0c: /* FF */ |
| 4005 |
|
case 0x0d: /* CR */ |
| 4006 |
|
case 0x85: /* NEL */ |
| 4007 |
|
case 0x2028: /* LINE SEPARATOR */ |
| 4008 |
|
case 0x2029: /* PARAGRAPH SEPARATOR */ |
| 4009 |
|
gotspace = TRUE; |
| 4010 |
|
break; |
| 4011 |
|
} |
| 4012 |
|
if (gotspace == (ctype == OP_NOT_VSPACE)) break; |
| 4013 |
|
eptr += len; |
| 4014 |
|
} |
| 4015 |
|
break; |
| 4016 |
|
|
| 4017 |
case OP_NOT_DIGIT: |
case OP_NOT_DIGIT: |
| 4018 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4019 |
{ |
{ |
| 4096 |
} |
} |
| 4097 |
} |
} |
| 4098 |
else |
else |
| 4099 |
#endif |
#endif /* SUPPORT_UTF8 */ |
| 4100 |
|
|
| 4101 |
/* Not UTF-8 mode */ |
/* Not UTF-8 mode */ |
| 4102 |
{ |
{ |
| 4103 |
switch(ctype) |
switch(ctype) |
| 4104 |
{ |
{ |
| 4105 |
case OP_ANY: |
case OP_ANY: |
| 4106 |
if ((ims & PCRE_DOTALL) == 0) |
for (i = min; i < max; i++) |
| 4107 |
{ |
{ |
| 4108 |
for (i = min; i < max; i++) |
if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break; |
| 4109 |
{ |
eptr++; |
|
if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break; |
|
|
eptr++; |
|
|
} |
|
|
break; |
|
| 4110 |
} |
} |
| 4111 |
/* For DOTALL case, fall through and treat as \C */ |
break; |
| 4112 |
|
|
| 4113 |
|
case OP_ALLANY: |
| 4114 |
case OP_ANYBYTE: |
case OP_ANYBYTE: |
| 4115 |
c = max - min; |
c = max - min; |
| 4116 |
if (c > (unsigned int)(md->end_subject - eptr)) |
if (c > (unsigned int)(md->end_subject - eptr)) |
| 4130 |
} |
} |
| 4131 |
else |
else |
| 4132 |
{ |
{ |
| 4133 |
if (c != 0x000a && c != 0x000b && c != 0x000c && c != 0x0085) |
if (c != 0x000a && |
| 4134 |
|
(md->bsr_anycrlf || |
| 4135 |
|
(c != 0x000b && c != 0x000c && c != 0x0085))) |
| 4136 |
break; |
break; |
| 4137 |
eptr++; |
eptr++; |
| 4138 |
} |
} |
| 4139 |
} |
} |
| 4140 |
break; |
break; |
| 4141 |
|
|
| 4142 |
|
case OP_NOT_HSPACE: |
| 4143 |
|
for (i = min; i < max; i++) |
| 4144 |
|
{ |
| 4145 |
|
if (eptr >= md->end_subject) break; |
| 4146 |
|
c = *eptr; |
| 4147 |
|
if (c == 0x09 || c == 0x20 || c == 0xa0) break; |
| 4148 |
|
eptr++; |
| 4149 |
|
} |
| 4150 |
|
break; |
| 4151 |
|
|
| 4152 |
|
case OP_HSPACE: |
| 4153 |
|
for (i = min; i < max; i++) |
| 4154 |
|
{ |
| 4155 |
|
if (eptr >= md->end_subject) break; |
| 4156 |
|
c = *eptr; |
| 4157 |
|
if (c != 0x09 && c != 0x20 && c != 0xa0) break; |
| 4158 |
|
eptr++; |
| 4159 |
|
} |
| 4160 |
|
break; |
| 4161 |
|
|
| 4162 |
|
case OP_NOT_VSPACE: |
| 4163 |
|
for (i = min; i < max; i++) |
| 4164 |
|
{ |
| 4165 |
|
if (eptr >= md->end_subject) break; |
| 4166 |
|
c = *eptr; |
| 4167 |
|
if (c == 0x0a || c == 0x0b || c == 0x0c || c == 0x0d || c == 0x85) |
| 4168 |
|
break; |
| 4169 |
|
eptr++; |
| 4170 |
|
} |
| 4171 |
|
break; |
| 4172 |
|
|
| 4173 |
|
case OP_VSPACE: |
| 4174 |
|
for (i = min; i < max; i++) |
| 4175 |
|
{ |
| 4176 |
|
if (eptr >= md->end_subject) break; |
| 4177 |
|
c = *eptr; |
| 4178 |
|
if (c != 0x0a && c != 0x0b && c != 0x0c && c != 0x0d && c != 0x85) |
| 4179 |
|
break; |
| 4180 |
|
eptr++; |
| 4181 |
|
} |
| 4182 |
|
break; |
| 4183 |
|
|
| 4184 |
case OP_NOT_DIGIT: |
case OP_NOT_DIGIT: |
| 4185 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4186 |
{ |
{ |
| 4272 |
/* Control never reaches here */ |
/* Control never reaches here */ |
| 4273 |
|
|
| 4274 |
|
|
| 4275 |
/* When compiling to use the heap rather than the stack for recursive calls to |
/* When compiling to use the heap rather than the stack for recursive calls to |
| 4276 |
match(), the RRETURN() macro jumps here. The number that is saved in |
match(), the RRETURN() macro jumps here. The number that is saved in |
| 4277 |
frame->Xwhere indicates which label we actually want to return to. */ |
frame->Xwhere indicates which label we actually want to return to. */ |
| 4278 |
|
|
| 4279 |
#ifdef NO_RECURSE |
#ifdef NO_RECURSE |
| 4282 |
switch (frame->Xwhere) |
switch (frame->Xwhere) |
| 4283 |
{ |
{ |
| 4284 |
LBL( 1) LBL( 2) LBL( 3) LBL( 4) LBL( 5) LBL( 6) LBL( 7) LBL( 8) |
LBL( 1) LBL( 2) LBL( 3) LBL( 4) LBL( 5) LBL( 6) LBL( 7) LBL( 8) |
| 4285 |
LBL( 9) LBL(10) LBL(11) LBL(12) LBL(13) LBL(14) LBL(15) LBL(16) |
LBL( 9) LBL(10) LBL(11) LBL(12) LBL(13) LBL(14) LBL(15) LBL(17) |
| 4286 |
LBL(17) LBL(18) LBL(19) LBL(20) LBL(21) LBL(22) LBL(23) LBL(24) |
LBL(19) LBL(24) LBL(25) LBL(26) LBL(27) LBL(29) LBL(31) LBL(33) |
| 4287 |
LBL(25) LBL(26) LBL(27) LBL(28) LBL(29) LBL(30) LBL(31) LBL(32) |
LBL(35) LBL(43) LBL(47) LBL(48) LBL(49) LBL(50) LBL(51) LBL(52) |
| 4288 |
LBL(33) LBL(34) LBL(35) LBL(36) LBL(37) LBL(38) LBL(39) LBL(40) |
LBL(53) LBL(54) |
| 4289 |
LBL(41) LBL(42) LBL(43) LBL(44) LBL(45) LBL(46) LBL(47) |
#ifdef SUPPORT_UTF8 |
| 4290 |
|
LBL(16) LBL(18) LBL(20) LBL(21) LBL(22) LBL(23) LBL(28) LBL(30) |
| 4291 |
|
LBL(32) LBL(34) LBL(42) LBL(46) |
| 4292 |
|
#ifdef SUPPORT_UCP |
| 4293 |
|
LBL(36) LBL(37) LBL(38) LBL(39) LBL(40) LBL(41) LBL(44) LBL(45) |
| 4294 |
|
#endif /* SUPPORT_UCP */ |
| 4295 |
|
#endif /* SUPPORT_UTF8 */ |
| 4296 |
default: |
default: |
| 4297 |
DPRINTF(("jump error in pcre match: label %d non-existent\n", frame->Xwhere)); |
DPRINTF(("jump error in pcre match: label %d non-existent\n", frame->Xwhere)); |
| 4298 |
return PCRE_ERROR_INTERNAL; |
return PCRE_ERROR_INTERNAL; |
| 4299 |
} |
} |
| 4300 |
#undef LBL |
#undef LBL |
| 4301 |
#endif /* NO_RECURSE */ |
#endif /* NO_RECURSE */ |
| 4302 |
} |
} |
| 4303 |
|
|
| 4311 |
#ifdef NO_RECURSE |
#ifdef NO_RECURSE |
| 4312 |
#undef eptr |
#undef eptr |
| 4313 |
#undef ecode |
#undef ecode |
| 4314 |
|
#undef mstart |
| 4315 |
#undef offset_top |
#undef offset_top |
| 4316 |
#undef ims |
#undef ims |
| 4317 |
#undef eptrb |
#undef eptrb |
| 4409 |
USPTR start_match = (USPTR)subject + start_offset; |
USPTR start_match = (USPTR)subject + start_offset; |
| 4410 |
USPTR end_subject; |
USPTR end_subject; |
| 4411 |
USPTR req_byte_ptr = start_match - 1; |
USPTR req_byte_ptr = start_match - 1; |
|
eptrblock eptrchain[EPTR_WORK_SIZE]; |
|
| 4412 |
|
|
| 4413 |
pcre_study_data internal_study; |
pcre_study_data internal_study; |
| 4414 |
const pcre_study_data *study; |
const pcre_study_data *study; |
| 4471 |
/* Set up other data */ |
/* Set up other data */ |
| 4472 |
|
|
| 4473 |
anchored = ((re->options | options) & PCRE_ANCHORED) != 0; |
anchored = ((re->options | options) & PCRE_ANCHORED) != 0; |
| 4474 |
startline = (re->options & PCRE_STARTLINE) != 0; |
startline = (re->flags & PCRE_STARTLINE) != 0; |
| 4475 |
firstline = (re->options & PCRE_FIRSTLINE) != 0; |
firstline = (re->options & PCRE_FIRSTLINE) != 0; |
| 4476 |
|
|
| 4477 |
/* The code starts after the real_pcre block and the capture name table. */ |
/* The code starts after the real_pcre block and the capture name table. */ |
| 4486 |
|
|
| 4487 |
md->endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0; |
md->endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0; |
| 4488 |
utf8 = md->utf8 = (re->options & PCRE_UTF8) != 0; |
utf8 = md->utf8 = (re->options & PCRE_UTF8) != 0; |
| 4489 |
|
md->jscript_compat = (re->options & PCRE_JAVASCRIPT_COMPAT) != 0; |
| 4490 |
|
|
| 4491 |
md->notbol = (options & PCRE_NOTBOL) != 0; |
md->notbol = (options & PCRE_NOTBOL) != 0; |
| 4492 |
md->noteol = (options & PCRE_NOTEOL) != 0; |
md->noteol = (options & PCRE_NOTEOL) != 0; |
| 4495 |
md->hitend = FALSE; |
md->hitend = FALSE; |
| 4496 |
|
|
| 4497 |
md->recursive = NULL; /* No recursion at top level */ |
md->recursive = NULL; /* No recursion at top level */ |
|
md->eptrchain = eptrchain; /* Make workspace generally available */ |
|
| 4498 |
|
|
| 4499 |
md->lcc = tables + lcc_offset; |
md->lcc = tables + lcc_offset; |
| 4500 |
md->ctypes = tables + ctypes_offset; |
md->ctypes = tables + ctypes_offset; |
| 4501 |
|
|
| 4502 |
|
/* Handle different \R options. */ |
| 4503 |
|
|
| 4504 |
|
switch (options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) |
| 4505 |
|
{ |
| 4506 |
|
case 0: |
| 4507 |
|
if ((re->options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) != 0) |
| 4508 |
|
md->bsr_anycrlf = (re->options & PCRE_BSR_ANYCRLF) != 0; |
| 4509 |
|
else |
| 4510 |
|
#ifdef BSR_ANYCRLF |
| 4511 |
|
md->bsr_anycrlf = TRUE; |
| 4512 |
|
#else |
| 4513 |
|
md->bsr_anycrlf = FALSE; |
| 4514 |
|
#endif |
| 4515 |
|
break; |
| 4516 |
|
|
| 4517 |
|
case PCRE_BSR_ANYCRLF: |
| 4518 |
|
md->bsr_anycrlf = TRUE; |
| 4519 |
|
break; |
| 4520 |
|
|
| 4521 |
|
case PCRE_BSR_UNICODE: |
| 4522 |
|
md->bsr_anycrlf = FALSE; |
| 4523 |
|
break; |
| 4524 |
|
|
| 4525 |
|
default: return PCRE_ERROR_BADNEWLINE; |
| 4526 |
|
} |
| 4527 |
|
|
| 4528 |
/* Handle different types of newline. The three bits give eight cases. If |
/* Handle different types of newline. The three bits give eight cases. If |
| 4529 |
nothing is set at run time, whatever was used at compile time applies. */ |
nothing is set at run time, whatever was used at compile time applies. */ |
| 4530 |
|
|
| 4531 |
switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options : (pcre_uint32)options) & |
switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options : |
| 4532 |
PCRE_NEWLINE_BITS) |
(pcre_uint32)options) & PCRE_NEWLINE_BITS) |
| 4533 |
{ |
{ |
| 4534 |
case 0: newline = NEWLINE; break; /* Compile-time default */ |
case 0: newline = NEWLINE; break; /* Compile-time default */ |
| 4535 |
case PCRE_NEWLINE_CR: newline = '\r'; break; |
case PCRE_NEWLINE_CR: newline = '\r'; break; |
| 4568 |
/* Partial matching is supported only for a restricted set of regexes at the |
/* Partial matching is supported only for a restricted set of regexes at the |
| 4569 |
moment. */ |
moment. */ |
| 4570 |
|
|
| 4571 |
if (md->partial && (re->options & PCRE_NOPARTIAL) != 0) |
if (md->partial && (re->flags & PCRE_NOPARTIAL) != 0) |
| 4572 |
return PCRE_ERROR_BADPARTIAL; |
return PCRE_ERROR_BADPARTIAL; |
| 4573 |
|
|
| 4574 |
/* Check a UTF-8 string if required. Unfortunately there's no way of passing |
/* Check a UTF-8 string if required. Unfortunately there's no way of passing |
| 4645 |
|
|
| 4646 |
if (!anchored) |
if (!anchored) |
| 4647 |
{ |
{ |
| 4648 |
if ((re->options & PCRE_FIRSTSET) != 0) |
if ((re->flags & PCRE_FIRSTSET) != 0) |
| 4649 |
{ |
{ |
| 4650 |
first_byte = re->first_byte & 255; |
first_byte = re->first_byte & 255; |
| 4651 |
if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == TRUE) |
if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == TRUE) |
| 4660 |
/* For anchored or unanchored matches, there may be a "last known required |
/* For anchored or unanchored matches, there may be a "last known required |
| 4661 |
character" set. */ |
character" set. */ |
| 4662 |
|
|
| 4663 |
if ((re->options & PCRE_REQCHSET) != 0) |
if ((re->flags & PCRE_REQCHSET) != 0) |
| 4664 |
{ |
{ |
| 4665 |
req_byte = re->req_byte & 255; |
req_byte = re->req_byte & 255; |
| 4666 |
req_byte_caseless = (re->req_byte & REQ_CASELESS) != 0; |
req_byte_caseless = (re->req_byte & REQ_CASELESS) != 0; |
| 4676 |
for(;;) |
for(;;) |
| 4677 |
{ |
{ |
| 4678 |
USPTR save_end_subject = end_subject; |
USPTR save_end_subject = end_subject; |
| 4679 |
|
USPTR new_start_match; |
| 4680 |
|
|
| 4681 |
/* Reset the maximum number of extractions we might see. */ |
/* Reset the maximum number of extractions we might see. */ |
| 4682 |
|
|
| 4707 |
if (first_byte_caseless) |
if (first_byte_caseless) |
| 4708 |
while (start_match < end_subject && |
while (start_match < end_subject && |
| 4709 |
md->lcc[*start_match] != first_byte) |
md->lcc[*start_match] != first_byte) |
| 4710 |
start_match++; |
{ NEXTCHAR(start_match); } |
| 4711 |
else |
else |
| 4712 |
while (start_match < end_subject && *start_match != first_byte) |
while (start_match < end_subject && *start_match != first_byte) |
| 4713 |
start_match++; |
{ NEXTCHAR(start_match); } |
| 4714 |
} |
} |
| 4715 |
|
|
| 4716 |
/* Or to just after a linebreak for a multiline match if possible */ |
/* Or to just after a linebreak for a multiline match if possible */ |
| 4720 |
if (start_match > md->start_subject + start_offset) |
if (start_match > md->start_subject + start_offset) |
| 4721 |
{ |
{ |
| 4722 |
while (start_match <= end_subject && !WAS_NEWLINE(start_match)) |
while (start_match <= end_subject && !WAS_NEWLINE(start_match)) |
| 4723 |
start_match++; |
{ NEXTCHAR(start_match); } |
| 4724 |
|
|
| 4725 |
/* If we have just passed a CR and the newline option is ANY or ANYCRLF, |
/* If we have just passed a CR and the newline option is ANY or ANYCRLF, |
| 4726 |
and we are now at a LF, advance the match position by one more character. |
and we are now at a LF, advance the match position by one more character. |
| 4741 |
while (start_match < end_subject) |
while (start_match < end_subject) |
| 4742 |
{ |
{ |
| 4743 |
register unsigned int c = *start_match; |
register unsigned int c = *start_match; |
| 4744 |
if ((start_bits[c/8] & (1 << (c&7))) == 0) start_match++; else break; |
if ((start_bits[c/8] & (1 << (c&7))) == 0) |
| 4745 |
|
{ NEXTCHAR(start_match); } |
| 4746 |
|
else break; |
| 4747 |
} |
} |
| 4748 |
} |
} |
| 4749 |
|
|
| 4819 |
|
|
| 4820 |
/* OK, we can now run the match. */ |
/* OK, we can now run the match. */ |
| 4821 |
|
|
| 4822 |
md->start_match = start_match; |
md->start_match_ptr = start_match; |
| 4823 |
md->match_call_count = 0; |
md->match_call_count = 0; |
| 4824 |
md->eptrn = 0; /* Next free eptrchain slot */ |
rc = match(start_match, md->start_code, start_match, 2, md, ims, NULL, 0, 0); |
| 4825 |
rc = match(start_match, md->start_code, 2, md, ims, NULL, 0, 0); |
|
| 4826 |
|
switch(rc) |
| 4827 |
|
{ |
| 4828 |
|
/* NOMATCH and PRUNE advance by one character. THEN at this level acts |
| 4829 |
|
exactly like PRUNE. */ |
| 4830 |
|
|
| 4831 |
|
case MATCH_NOMATCH: |
| 4832 |
|
case MATCH_PRUNE: |
| 4833 |
|
case MATCH_THEN: |
| 4834 |
|
new_start_match = start_match + 1; |
| 4835 |
|
#ifdef SUPPORT_UTF8 |
| 4836 |
|
if (utf8) |
| 4837 |
|
while(new_start_match < end_subject && (*new_start_match & 0xc0) == 0x80) |
| 4838 |
|
new_start_match++; |
| 4839 |
|
#endif |
| 4840 |
|
break; |
| 4841 |
|
|
| 4842 |
|
/* SKIP passes back the next starting point explicitly. */ |
| 4843 |
|
|
| 4844 |
|
case MATCH_SKIP: |
| 4845 |
|
new_start_match = md->start_match_ptr; |
| 4846 |
|
break; |
| 4847 |
|
|
| 4848 |
/* Any return other than MATCH_NOMATCH breaks the loop. */ |
/* COMMIT disables the bumpalong, but otherwise behaves as NOMATCH. */ |
| 4849 |
|
|
| 4850 |
if (rc != MATCH_NOMATCH) break; |
case MATCH_COMMIT: |
| 4851 |
|
rc = MATCH_NOMATCH; |
| 4852 |
|
goto ENDLOOP; |
| 4853 |
|
|
| 4854 |
|
/* Any other return is some kind of error. */ |
| 4855 |
|
|
| 4856 |
|
default: |
| 4857 |
|
goto ENDLOOP; |
| 4858 |
|
} |
| 4859 |
|
|
| 4860 |
|
/* Control reaches here for the various types of "no match at this point" |
| 4861 |
|
result. Reset the code to MATCH_NOMATCH for subsequent checking. */ |
| 4862 |
|
|
| 4863 |
|
rc = MATCH_NOMATCH; |
| 4864 |
|
|
| 4865 |
/* If PCRE_FIRSTLINE is set, the match must happen before or at the first |
/* If PCRE_FIRSTLINE is set, the match must happen before or at the first |
| 4866 |
newline in the subject (though it may continue over the newline). Therefore, |
newline in the subject (though it may continue over the newline). Therefore, |
| 4868 |
|
|
| 4869 |
if (firstline && IS_NEWLINE(start_match)) break; |
if (firstline && IS_NEWLINE(start_match)) break; |
| 4870 |
|
|
| 4871 |
/* Advance the match position by one character. */ |
/* Advance to new matching position */ |
| 4872 |
|
|
| 4873 |
start_match++; |
start_match = new_start_match; |
|
#ifdef SUPPORT_UTF8 |
|
|
if (utf8) |
|
|
while(start_match < end_subject && (*start_match & 0xc0) == 0x80) |
|
|
start_match++; |
|
|
#endif |
|
| 4874 |
|
|
| 4875 |
/* Break the loop if the pattern is anchored or if we have passed the end of |
/* Break the loop if the pattern is anchored or if we have passed the end of |
| 4876 |
the subject. */ |
the subject. */ |
| 4877 |
|
|
| 4878 |
if (anchored || start_match > end_subject) break; |
if (anchored || start_match > end_subject) break; |
| 4879 |
|
|
| 4880 |
/* If we have just passed a CR and the newline option is CRLF or ANY or |
/* If we have just passed a CR and we are now at a LF, and the pattern does |
| 4881 |
ANYCRLF, and we are now at a LF, advance the match position by one more |
not contain any explicit matches for \r or \n, and the newline option is CRLF |
| 4882 |
character. */ |
or ANY or ANYCRLF, advance the match position by one more character. */ |
| 4883 |
|
|
| 4884 |
if (start_match[-1] == '\r' && |
if (start_match[-1] == '\r' && |
| 4885 |
(md->nltype == NLTYPE_ANY || |
start_match < end_subject && |
| 4886 |
md->nltype == NLTYPE_ANYCRLF || |
*start_match == '\n' && |
| 4887 |
md->nllen == 2) && |
(re->flags & PCRE_HASCRORLF) == 0 && |
| 4888 |
start_match < end_subject && |
(md->nltype == NLTYPE_ANY || |
| 4889 |
*start_match == '\n') |
md->nltype == NLTYPE_ANYCRLF || |
| 4890 |
|
md->nllen == 2)) |
| 4891 |
start_match++; |
start_match++; |
| 4892 |
|
|
| 4893 |
} /* End of for(;;) "bumpalong" loop */ |
} /* End of for(;;) "bumpalong" loop */ |
| 4897 |
/* We reach here when rc is not MATCH_NOMATCH, or if one of the stopping |
/* We reach here when rc is not MATCH_NOMATCH, or if one of the stopping |
| 4898 |
conditions is true: |
conditions is true: |
| 4899 |
|
|
| 4900 |
(1) The pattern is anchored; |
(1) The pattern is anchored or the match was failed by (*COMMIT); |
| 4901 |
|
|
| 4902 |
(2) We are past the end of the subject; |
(2) We are past the end of the subject; |
| 4903 |
|
|
| 4912 |
certain parts of the pattern were not used, even though there are more |
certain parts of the pattern were not used, even though there are more |
| 4913 |
capturing parentheses than vector slots. */ |
capturing parentheses than vector slots. */ |
| 4914 |
|
|
| 4915 |
|
ENDLOOP: |
| 4916 |
|
|
| 4917 |
if (rc == MATCH_MATCH) |
if (rc == MATCH_MATCH) |
| 4918 |
{ |
{ |
| 4919 |
if (using_temporary_offsets) |
if (using_temporary_offsets) |
| 4934 |
|
|
| 4935 |
rc = md->offset_overflow? 0 : md->end_offset_top/2; |
rc = md->offset_overflow? 0 : md->end_offset_top/2; |
| 4936 |
|
|
| 4937 |
/* If there is space, set up the whole thing as substring 0. */ |
/* If there is space, set up the whole thing as substring 0. The value of |
| 4938 |
|
md->start_match_ptr might be modified if \K was encountered on the success |
| 4939 |
|
matching path. */ |
| 4940 |
|
|
| 4941 |
if (offsetcount < 2) rc = 0; else |
if (offsetcount < 2) rc = 0; else |
| 4942 |
{ |
{ |
| 4943 |
offsets[0] = start_match - md->start_subject; |
offsets[0] = md->start_match_ptr - md->start_subject; |
| 4944 |
offsets[1] = md->end_match_ptr - md->start_subject; |
offsets[1] = md->end_match_ptr - md->start_subject; |
| 4945 |
} |
} |
| 4946 |
|
|