| 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-2009 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 */ |
| 52 |
|
|
| 53 |
#include "pcre_internal.h" |
#include "pcre_internal.h" |
| 54 |
|
|
| 55 |
/* The chain of eptrblocks for tail recursions uses memory in stack workspace, |
/* Undefine some potentially clashing cpp symbols */ |
|
obtained at top level, the size of which is defined by EPTR_WORK_SIZE. */ |
|
| 56 |
|
|
| 57 |
#define EPTR_WORK_SIZE (1000) |
#undef min |
| 58 |
|
#undef max |
| 59 |
|
|
| 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 |
|
|
| 220 |
obtained from malloc() instead instead of on the stack. Macros are used to |
obtained from malloc() instead instead of on the stack. Macros are used to |
| 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 |
| 225 |
|
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 |
| 227 |
|
provide a unique number for each call to RMATCH. There is no way of generating |
| 228 |
|
a sequence of numbers at compile time in C. I have given them names, to make |
| 229 |
|
them stand out more clearly. |
| 230 |
|
|
| 231 |
|
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 |
| 233 |
|
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 |
| 235 |
|
reduced because the result can be "passed back" by straight setting of the |
| 236 |
|
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 |
|
below must be updated in sync. */ |
| 242 |
|
|
| 243 |
|
enum { RM1=1, RM2, RM3, RM4, RM5, RM6, RM7, RM8, RM9, RM10, |
| 244 |
|
RM11, RM12, RM13, RM14, RM15, RM16, RM17, RM18, RM19, RM20, |
| 245 |
|
RM21, RM22, RM23, RM24, RM25, RM26, RM27, RM28, RM29, RM30, |
| 246 |
|
RM31, RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40, |
| 247 |
|
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. */ |
versions and production versions. Note that the "rw" argument of RMATCH isn't |
| 252 |
|
actuall used in this definition. */ |
| 253 |
|
|
| 254 |
#ifndef NO_RECURSE |
#ifndef NO_RECURSE |
| 255 |
#define REGISTER register |
#define REGISTER register |
| 256 |
|
|
| 257 |
#ifdef DEBUG |
#ifdef DEBUG |
| 258 |
#define RMATCH(rx,ra,rb,rc,rd,re,rf,rg) \ |
#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 |
rx = 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) \ |
| 267 |
return ra; \ |
return ra; \ |
| 268 |
} |
} |
| 269 |
#else |
#else |
| 270 |
#define RMATCH(rx,ra,rb,rc,rd,re,rf,rg) \ |
#define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \ |
| 271 |
rx = 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 |
|
|
| 275 |
#else |
#else |
| 276 |
|
|
| 277 |
|
|
| 278 |
/* These versions of the macros manage a private stack on the heap. Note |
/* These versions of the macros manage a private stack on the heap. Note that |
| 279 |
that the rd argument of RMATCH isn't actually used. It's the md argument of |
the "rd" argument of RMATCH isn't actually used in this definition. It's the md |
| 280 |
match(), which never changes. */ |
argument of match(), which never changes. */ |
| 281 |
|
|
| 282 |
#define REGISTER |
#define REGISTER |
| 283 |
|
|
| 284 |
#define RMATCH(rx,ra,rb,rc,rd,re,rf,rg)\ |
#define RMATCH(ra,rb,rc,rd,re,rf,rg,rw)\ |
| 285 |
{\ |
{\ |
| 286 |
heapframe *newframe = (pcre_stack_malloc)(sizeof(heapframe));\ |
heapframe *newframe = (pcre_stack_malloc)(sizeof(heapframe));\ |
| 287 |
if (setjmp(frame->Xwhere) == 0)\ |
frame->Xwhere = rw; \ |
| 288 |
{\ |
newframe->Xeptr = ra;\ |
| 289 |
newframe->Xeptr = ra;\ |
newframe->Xecode = rb;\ |
| 290 |
newframe->Xecode = rb;\ |
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;\ |
| 294 |
newframe->Xflags = rg;\ |
newframe->Xflags = rg;\ |
| 295 |
newframe->Xrdepth = frame->Xrdepth + 1;\ |
newframe->Xrdepth = frame->Xrdepth + 1;\ |
| 296 |
newframe->Xprevframe = frame;\ |
newframe->Xprevframe = frame;\ |
| 297 |
frame = newframe;\ |
frame = newframe;\ |
| 298 |
DPRINTF(("restarting from line %d\n", __LINE__));\ |
DPRINTF(("restarting from line %d\n", __LINE__));\ |
| 299 |
goto HEAP_RECURSE;\ |
goto HEAP_RECURSE;\ |
| 300 |
}\ |
L_##rw:\ |
| 301 |
else\ |
DPRINTF(("jumped back to line %d\n", __LINE__));\ |
|
{\ |
|
|
DPRINTF(("longjumped back to line %d\n", __LINE__));\ |
|
|
frame = md->thisframe;\ |
|
|
rx = frame->Xresult;\ |
|
|
}\ |
|
| 302 |
} |
} |
| 303 |
|
|
| 304 |
#define RRETURN(ra)\ |
#define RRETURN(ra)\ |
| 308 |
(pcre_stack_free)(newframe);\ |
(pcre_stack_free)(newframe);\ |
| 309 |
if (frame != NULL)\ |
if (frame != NULL)\ |
| 310 |
{\ |
{\ |
| 311 |
frame->Xresult = ra;\ |
rrc = ra;\ |
| 312 |
md->thisframe = frame;\ |
goto HEAP_RETURN;\ |
|
longjmp(frame->Xwhere, 1);\ |
|
| 313 |
}\ |
}\ |
| 314 |
return ra;\ |
return ra;\ |
| 315 |
} |
} |
| 322 |
|
|
| 323 |
/* Function arguments that may change */ |
/* Function arguments that may change */ |
| 324 |
|
|
| 325 |
const uschar *Xeptr; |
USPTR Xeptr; |
| 326 |
const uschar *Xecode; |
const uschar *Xecode; |
| 327 |
|
USPTR Xmstart; |
| 328 |
int Xoffset_top; |
int Xoffset_top; |
| 329 |
long int Xims; |
long int Xims; |
| 330 |
eptrblock *Xeptrb; |
eptrblock *Xeptrb; |
| 333 |
|
|
| 334 |
/* Function local variables */ |
/* Function local variables */ |
| 335 |
|
|
| 336 |
const uschar *Xcallpat; |
USPTR Xcallpat; |
| 337 |
const uschar *Xcharptr; |
#ifdef SUPPORT_UTF8 |
| 338 |
const uschar *Xdata; |
USPTR Xcharptr; |
| 339 |
const uschar *Xnext; |
#endif |
| 340 |
const uschar *Xpp; |
USPTR Xdata; |
| 341 |
const uschar *Xprev; |
USPTR Xnext; |
| 342 |
const uschar *Xsaved_eptr; |
USPTR Xpp; |
| 343 |
|
USPTR Xprev; |
| 344 |
|
USPTR Xsaved_eptr; |
| 345 |
|
|
| 346 |
recursion_info Xnew_recursive; |
recursion_info Xnew_recursive; |
| 347 |
|
|
| 362 |
uschar Xocchars[8]; |
uschar Xocchars[8]; |
| 363 |
#endif |
#endif |
| 364 |
|
|
| 365 |
|
int Xcodelink; |
| 366 |
int Xctype; |
int Xctype; |
| 367 |
unsigned int Xfc; |
unsigned int Xfc; |
| 368 |
int Xfi; |
int Xfi; |
| 378 |
|
|
| 379 |
eptrblock Xnewptrb; |
eptrblock Xnewptrb; |
| 380 |
|
|
| 381 |
/* Place to pass back result, and where to jump back to */ |
/* Where to jump back to */ |
| 382 |
|
|
| 383 |
int Xresult; |
int Xwhere; |
|
jmp_buf Xwhere; |
|
| 384 |
|
|
| 385 |
} heapframe; |
} heapframe; |
| 386 |
|
|
| 408 |
Arguments: |
Arguments: |
| 409 |
eptr pointer to current character in subject |
eptr pointer to current character in subject |
| 410 |
ecode pointer to current position in compiled code |
ecode pointer to current position in compiled code |
| 411 |
|
mstart pointer to the current match start position (can be modified |
| 412 |
|
by encountering \K) |
| 413 |
offset_top current top pointer |
offset_top current top pointer |
| 414 |
md pointer to "static" info for the match |
md pointer to "static" info for the match |
| 415 |
ims current /i, /m, and /s options |
ims current /i, /m, and /s options |
| 419 |
match_condassert - this is an assertion condition |
match_condassert - this is an assertion condition |
| 420 |
match_cbegroup - this is the start of an unlimited repeat |
match_cbegroup - this is the start of an unlimited repeat |
| 421 |
group that can match an empty string |
group that can match an empty string |
|
match_tail_recursed - this is a tail_recursed group |
|
| 422 |
rdepth the recursion depth |
rdepth the recursion depth |
| 423 |
|
|
| 424 |
Returns: MATCH_MATCH if matched ) these values are >= 0 |
Returns: MATCH_MATCH if matched ) these values are >= 0 |
| 428 |
*/ |
*/ |
| 429 |
|
|
| 430 |
static int |
static int |
| 431 |
match(REGISTER USPTR eptr, REGISTER const uschar *ecode, |
match(REGISTER USPTR eptr, REGISTER const uschar *ecode, USPTR mstart, |
| 432 |
int offset_top, match_data *md, unsigned long int ims, eptrblock *eptrb, |
int offset_top, match_data *md, unsigned long int ims, eptrblock *eptrb, |
| 433 |
int flags, unsigned int rdepth) |
int flags, unsigned int rdepth) |
| 434 |
{ |
{ |
| 442 |
register BOOL utf8; /* Local copy of UTF-8 flag for speed */ |
register BOOL utf8; /* Local copy of UTF-8 flag for speed */ |
| 443 |
|
|
| 444 |
BOOL minimize, possessive; /* Quantifier options */ |
BOOL minimize, possessive; /* Quantifier options */ |
| 445 |
|
int condcode; |
| 446 |
|
|
| 447 |
/* When recursion is not being used, all "local" variables that have to be |
/* When recursion is not being used, all "local" variables that have to be |
| 448 |
preserved over calls to RMATCH() are part of a "frame" which is obtained from |
preserved over calls to RMATCH() are part of a "frame" which is obtained from |
| 457 |
|
|
| 458 |
frame->Xeptr = eptr; |
frame->Xeptr = eptr; |
| 459 |
frame->Xecode = ecode; |
frame->Xecode = ecode; |
| 460 |
|
frame->Xmstart = mstart; |
| 461 |
frame->Xoffset_top = offset_top; |
frame->Xoffset_top = offset_top; |
| 462 |
frame->Xims = ims; |
frame->Xims = ims; |
| 463 |
frame->Xeptrb = eptrb; |
frame->Xeptrb = eptrb; |
| 472 |
|
|
| 473 |
#define eptr frame->Xeptr |
#define eptr frame->Xeptr |
| 474 |
#define ecode frame->Xecode |
#define ecode frame->Xecode |
| 475 |
|
#define mstart frame->Xmstart |
| 476 |
#define offset_top frame->Xoffset_top |
#define offset_top frame->Xoffset_top |
| 477 |
#define ims frame->Xims |
#define ims frame->Xims |
| 478 |
#define eptrb frame->Xeptrb |
#define eptrb frame->Xeptrb |
| 485 |
#define charptr frame->Xcharptr |
#define charptr frame->Xcharptr |
| 486 |
#endif |
#endif |
| 487 |
#define callpat frame->Xcallpat |
#define callpat frame->Xcallpat |
| 488 |
|
#define codelink frame->Xcodelink |
| 489 |
#define data frame->Xdata |
#define data frame->Xdata |
| 490 |
#define next frame->Xnext |
#define next frame->Xnext |
| 491 |
#define pp frame->Xpp |
#define pp frame->Xpp |
| 566 |
uschar occhars[8]; |
uschar occhars[8]; |
| 567 |
#endif |
#endif |
| 568 |
|
|
| 569 |
|
int codelink; |
| 570 |
int ctype; |
int ctype; |
| 571 |
int length; |
int length; |
| 572 |
int max; |
int max; |
| 605 |
complicated macro. It has to be used in one particular way. This shouldn't, |
complicated macro. It has to be used in one particular way. This shouldn't, |
| 606 |
however, impact performance when true recursion is being used. */ |
however, impact performance when true recursion is being used. */ |
| 607 |
|
|
| 608 |
|
#ifdef SUPPORT_UTF8 |
| 609 |
|
utf8 = md->utf8; /* Local copy of the flag */ |
| 610 |
|
#else |
| 611 |
|
utf8 = FALSE; |
| 612 |
|
#endif |
| 613 |
|
|
| 614 |
/* First check that we haven't called match() too many times, or that we |
/* First check that we haven't called match() too many times, or that we |
| 615 |
haven't exceeded the recursive call limit. */ |
haven't exceeded the recursive call limit. */ |
| 616 |
|
|
| 619 |
|
|
| 620 |
original_ims = ims; /* Save for resetting on ')' */ |
original_ims = ims; /* Save for resetting on ')' */ |
| 621 |
|
|
|
#ifdef SUPPORT_UTF8 |
|
|
utf8 = md->utf8; /* Local copy of the flag */ |
|
|
#else |
|
|
utf8 = FALSE; |
|
|
#endif |
|
|
|
|
| 622 |
/* At the start of a group with an unlimited repeat that may match an empty |
/* At the start of a group with an unlimited repeat that may match an empty |
| 623 |
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 |
| 624 |
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 |
| 625 |
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. |
| 626 |
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 |
| 627 |
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 |
| 628 |
already used. */ |
block that is used is on the stack, so a new one may be required for each |
| 629 |
|
match(). */ |
| 630 |
|
|
| 631 |
if ((flags & match_cbegroup) != 0) |
if ((flags & match_cbegroup) != 0) |
| 632 |
{ |
{ |
| 633 |
eptrblock *p; |
newptrb.epb_saved_eptr = eptr; |
| 634 |
if ((flags & match_tail_recursed) != 0) |
newptrb.epb_prev = eptrb; |
| 635 |
{ |
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; |
|
| 636 |
} |
} |
| 637 |
|
|
| 638 |
/* Now start processing the opcodes. */ |
/* Now start processing the opcodes. */ |
| 647 |
|
|
| 648 |
if (md->partial && |
if (md->partial && |
| 649 |
eptr >= md->end_subject && |
eptr >= md->end_subject && |
| 650 |
eptr > md->start_match) |
eptr > mstart) |
| 651 |
md->hitend = TRUE; |
md->hitend = TRUE; |
| 652 |
|
|
| 653 |
switch(op) |
switch(op) |
| 654 |
{ |
{ |
| 655 |
|
case OP_FAIL: |
| 656 |
|
RRETURN(MATCH_NOMATCH); |
| 657 |
|
|
| 658 |
|
case OP_PRUNE: |
| 659 |
|
RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
| 660 |
|
ims, eptrb, flags, RM51); |
| 661 |
|
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 662 |
|
RRETURN(MATCH_PRUNE); |
| 663 |
|
|
| 664 |
|
case OP_COMMIT: |
| 665 |
|
RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
| 666 |
|
ims, eptrb, flags, RM52); |
| 667 |
|
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 668 |
|
RRETURN(MATCH_COMMIT); |
| 669 |
|
|
| 670 |
|
case OP_SKIP: |
| 671 |
|
RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
| 672 |
|
ims, eptrb, flags, RM53); |
| 673 |
|
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 674 |
|
md->start_match_ptr = eptr; /* Pass back current position */ |
| 675 |
|
RRETURN(MATCH_SKIP); |
| 676 |
|
|
| 677 |
|
case OP_THEN: |
| 678 |
|
RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
| 679 |
|
ims, eptrb, flags, RM54); |
| 680 |
|
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 681 |
|
RRETURN(MATCH_THEN); |
| 682 |
|
|
| 683 |
/* 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 |
| 684 |
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. |
| 685 |
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 |
| 719 |
flags = (op == OP_SCBRA)? match_cbegroup : 0; |
flags = (op == OP_SCBRA)? match_cbegroup : 0; |
| 720 |
do |
do |
| 721 |
{ |
{ |
| 722 |
RMATCH(rrc, eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
| 723 |
ims, eptrb, flags); |
ims, eptrb, flags, RM1); |
| 724 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); |
| 725 |
md->capture_last = save_capture_last; |
md->capture_last = save_capture_last; |
| 726 |
ecode += GET(ecode, 1); |
ecode += GET(ecode, 1); |
| 727 |
} |
} |
| 736 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 737 |
} |
} |
| 738 |
|
|
| 739 |
/* Insufficient room for saving captured contents. Treat as a non-capturing |
/* FALL THROUGH ... Insufficient room for saving captured contents. Treat |
| 740 |
bracket. */ |
as a non-capturing bracket. */ |
| 741 |
|
|
| 742 |
|
/* VVVVVVVVVVVVVVVVVVVVVVVVV */ |
| 743 |
|
/* VVVVVVVVVVVVVVVVVVVVVVVVV */ |
| 744 |
|
|
| 745 |
DPRINTF(("insufficient capture room: treat as non-capturing\n")); |
DPRINTF(("insufficient capture room: treat as non-capturing\n")); |
| 746 |
|
|
| 747 |
|
/* VVVVVVVVVVVVVVVVVVVVVVVVV */ |
| 748 |
|
/* VVVVVVVVVVVVVVVVVVVVVVVVV */ |
| 749 |
|
|
| 750 |
/* 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 |
| 751 |
final alternative within the brackets, we would return the result of a |
final alternative within the brackets, we would return the result of a |
| 752 |
recursive call to match() whatever happened. We can reduce stack usage by |
recursive call to match() whatever happened. We can reduce stack usage by |
| 753 |
turning this into a tail recursion. */ |
turning this into a tail recursion, except in the case when match_cbegroup |
| 754 |
|
is set.*/ |
| 755 |
|
|
| 756 |
case OP_BRA: |
case OP_BRA: |
| 757 |
case OP_SBRA: |
case OP_SBRA: |
| 759 |
flags = (op >= OP_SBRA)? match_cbegroup : 0; |
flags = (op >= OP_SBRA)? match_cbegroup : 0; |
| 760 |
for (;;) |
for (;;) |
| 761 |
{ |
{ |
| 762 |
if (ecode[GET(ecode, 1)] != OP_ALT) |
if (ecode[GET(ecode, 1)] != OP_ALT) /* Final alternative */ |
| 763 |
{ |
{ |
| 764 |
ecode += _pcre_OP_lengths[*ecode]; |
if (flags == 0) /* Not a possibly empty group */ |
| 765 |
flags |= match_tail_recursed; |
{ |
| 766 |
DPRINTF(("bracket 0 tail recursion\n")); |
ecode += _pcre_OP_lengths[*ecode]; |
| 767 |
goto TAIL_RECURSE; |
DPRINTF(("bracket 0 tail recursion\n")); |
| 768 |
|
goto TAIL_RECURSE; |
| 769 |
|
} |
| 770 |
|
|
| 771 |
|
/* Possibly empty group; can't use tail recursion. */ |
| 772 |
|
|
| 773 |
|
RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims, |
| 774 |
|
eptrb, flags, RM48); |
| 775 |
|
RRETURN(rrc); |
| 776 |
} |
} |
| 777 |
|
|
| 778 |
/* For non-final alternatives, continue the loop for a NOMATCH result; |
/* For non-final alternatives, continue the loop for a NOMATCH result; |
| 779 |
otherwise return. */ |
otherwise return. */ |
| 780 |
|
|
| 781 |
RMATCH(rrc, eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims, |
RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims, |
| 782 |
eptrb, flags); |
eptrb, flags, RM2); |
| 783 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); |
| 784 |
ecode += GET(ecode, 1); |
ecode += GET(ecode, 1); |
| 785 |
} |
} |
| 786 |
/* Control never reaches here. */ |
/* Control never reaches here. */ |
| 793 |
|
|
| 794 |
case OP_COND: |
case OP_COND: |
| 795 |
case OP_SCOND: |
case OP_SCOND: |
| 796 |
if (ecode[LINK_SIZE+1] == OP_RREF) /* Recursion test */ |
codelink= GET(ecode, 1); |
| 797 |
|
|
| 798 |
|
/* Because of the way auto-callout works during compile, a callout item is |
| 799 |
|
inserted between OP_COND and an assertion condition. */ |
| 800 |
|
|
| 801 |
|
if (ecode[LINK_SIZE+1] == OP_CALLOUT) |
| 802 |
|
{ |
| 803 |
|
if (pcre_callout != NULL) |
| 804 |
|
{ |
| 805 |
|
pcre_callout_block cb; |
| 806 |
|
cb.version = 1; /* Version 1 of the callout block */ |
| 807 |
|
cb.callout_number = ecode[LINK_SIZE+2]; |
| 808 |
|
cb.offset_vector = md->offset_vector; |
| 809 |
|
cb.subject = (PCRE_SPTR)md->start_subject; |
| 810 |
|
cb.subject_length = md->end_subject - md->start_subject; |
| 811 |
|
cb.start_match = mstart - md->start_subject; |
| 812 |
|
cb.current_position = eptr - md->start_subject; |
| 813 |
|
cb.pattern_position = GET(ecode, LINK_SIZE + 3); |
| 814 |
|
cb.next_item_length = GET(ecode, 3 + 2*LINK_SIZE); |
| 815 |
|
cb.capture_top = offset_top/2; |
| 816 |
|
cb.capture_last = md->capture_last; |
| 817 |
|
cb.callout_data = md->callout_data; |
| 818 |
|
if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH); |
| 819 |
|
if (rrc < 0) RRETURN(rrc); |
| 820 |
|
} |
| 821 |
|
ecode += _pcre_OP_lengths[OP_CALLOUT]; |
| 822 |
|
} |
| 823 |
|
|
| 824 |
|
condcode = ecode[LINK_SIZE+1]; |
| 825 |
|
|
| 826 |
|
/* Now see what the actual condition is */ |
| 827 |
|
|
| 828 |
|
if (condcode == OP_RREF) /* Recursion test */ |
| 829 |
{ |
{ |
| 830 |
offset = GET2(ecode, LINK_SIZE + 2); /* Recursion group number*/ |
offset = GET2(ecode, LINK_SIZE + 2); /* Recursion group number*/ |
| 831 |
condition = md->recursive != NULL && |
condition = md->recursive != NULL && |
| 833 |
ecode += condition? 3 : GET(ecode, 1); |
ecode += condition? 3 : GET(ecode, 1); |
| 834 |
} |
} |
| 835 |
|
|
| 836 |
else if (ecode[LINK_SIZE+1] == OP_CREF) /* Group used test */ |
else if (condcode == OP_CREF) /* Group used test */ |
| 837 |
{ |
{ |
| 838 |
offset = GET2(ecode, LINK_SIZE+2) << 1; /* Doubled ref number */ |
offset = GET2(ecode, LINK_SIZE+2) << 1; /* Doubled ref number */ |
| 839 |
condition = offset < offset_top && md->offset_vector[offset] >= 0; |
condition = offset < offset_top && md->offset_vector[offset] >= 0; |
| 840 |
ecode += condition? 3 : GET(ecode, 1); |
ecode += condition? 3 : GET(ecode, 1); |
| 841 |
} |
} |
| 842 |
|
|
| 843 |
else if (ecode[LINK_SIZE+1] == OP_DEF) /* DEFINE - always false */ |
else if (condcode == OP_DEF) /* DEFINE - always false */ |
| 844 |
{ |
{ |
| 845 |
condition = FALSE; |
condition = FALSE; |
| 846 |
ecode += GET(ecode, 1); |
ecode += GET(ecode, 1); |
| 852 |
|
|
| 853 |
else |
else |
| 854 |
{ |
{ |
| 855 |
RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, |
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, |
| 856 |
match_condassert); |
match_condassert, RM3); |
| 857 |
if (rrc == MATCH_MATCH) |
if (rrc == MATCH_MATCH) |
| 858 |
{ |
{ |
| 859 |
condition = TRUE; |
condition = TRUE; |
| 860 |
ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2); |
ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2); |
| 861 |
while (*ecode == OP_ALT) ecode += GET(ecode, 1); |
while (*ecode == OP_ALT) ecode += GET(ecode, 1); |
| 862 |
} |
} |
| 863 |
else if (rrc != MATCH_NOMATCH) |
else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) |
| 864 |
{ |
{ |
| 865 |
RRETURN(rrc); /* Need braces because of following else */ |
RRETURN(rrc); /* Need braces because of following else */ |
| 866 |
} |
} |
| 867 |
else |
else |
| 868 |
{ |
{ |
| 869 |
condition = FALSE; |
condition = FALSE; |
| 870 |
ecode += GET(ecode, 1); |
ecode += codelink; |
| 871 |
} |
} |
| 872 |
} |
} |
| 873 |
|
|
| 874 |
/* 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, |
| 875 |
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 |
| 876 |
alternative doesn't exist, we can just plough on. */ |
match_cbegroup is required for an unlimited repeat of a possibly empty |
| 877 |
|
group. If the second alternative doesn't exist, we can just plough on. */ |
| 878 |
|
|
| 879 |
if (condition || *ecode == OP_ALT) |
if (condition || *ecode == OP_ALT) |
| 880 |
{ |
{ |
| 881 |
ecode += 1 + LINK_SIZE; |
ecode += 1 + LINK_SIZE; |
| 882 |
flags = match_tail_recursed | ((op == OP_SCOND)? match_cbegroup : 0); |
if (op == OP_SCOND) /* Possibly empty group */ |
| 883 |
goto TAIL_RECURSE; |
{ |
| 884 |
|
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, match_cbegroup, RM49); |
| 885 |
|
RRETURN(rrc); |
| 886 |
|
} |
| 887 |
|
else /* Group must match something */ |
| 888 |
|
{ |
| 889 |
|
flags = 0; |
| 890 |
|
goto TAIL_RECURSE; |
| 891 |
|
} |
| 892 |
} |
} |
| 893 |
else |
else /* Condition false & no alternative */ |
| 894 |
{ |
{ |
| 895 |
ecode += 1 + LINK_SIZE; |
ecode += 1 + LINK_SIZE; |
| 896 |
} |
} |
| 897 |
break; |
break; |
| 898 |
|
|
| 899 |
|
|
| 900 |
/* 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 |
| 901 |
restore the offsets appropriately and continue from after the call. */ |
recursion, we should restore the offsets appropriately and continue from |
| 902 |
|
after the call. */ |
| 903 |
|
|
| 904 |
|
case OP_ACCEPT: |
| 905 |
case OP_END: |
case OP_END: |
| 906 |
if (md->recursive != NULL && md->recursive->group_num == 0) |
if (md->recursive != NULL && md->recursive->group_num == 0) |
| 907 |
{ |
{ |
| 910 |
md->recursive = rec->prevrec; |
md->recursive = rec->prevrec; |
| 911 |
memmove(md->offset_vector, rec->offset_save, |
memmove(md->offset_vector, rec->offset_save, |
| 912 |
rec->saved_max * sizeof(int)); |
rec->saved_max * sizeof(int)); |
| 913 |
md->start_match = rec->save_start; |
mstart = rec->save_start; |
| 914 |
ims = original_ims; |
ims = original_ims; |
| 915 |
ecode = rec->after_call; |
ecode = rec->after_call; |
| 916 |
break; |
break; |
| 919 |
/* 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 |
| 920 |
string - backtracking will then try other alternatives, if any. */ |
string - backtracking will then try other alternatives, if any. */ |
| 921 |
|
|
| 922 |
if (md->notempty && eptr == md->start_match) RRETURN(MATCH_NOMATCH); |
if (md->notempty && eptr == mstart) RRETURN(MATCH_NOMATCH); |
| 923 |
md->end_match_ptr = eptr; /* Record where we ended */ |
md->end_match_ptr = eptr; /* Record where we ended */ |
| 924 |
md->end_offset_top = offset_top; /* and how many extracts were taken */ |
md->end_offset_top = offset_top; /* and how many extracts were taken */ |
| 925 |
|
md->start_match_ptr = mstart; /* and the start (\K can modify) */ |
| 926 |
RRETURN(MATCH_MATCH); |
RRETURN(MATCH_MATCH); |
| 927 |
|
|
| 928 |
/* Change option settings */ |
/* Change option settings */ |
| 943 |
case OP_ASSERTBACK: |
case OP_ASSERTBACK: |
| 944 |
do |
do |
| 945 |
{ |
{ |
| 946 |
RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0); |
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0, |
| 947 |
|
RM4); |
| 948 |
if (rrc == MATCH_MATCH) break; |
if (rrc == MATCH_MATCH) break; |
| 949 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); |
| 950 |
ecode += GET(ecode, 1); |
ecode += GET(ecode, 1); |
| 951 |
} |
} |
| 952 |
while (*ecode == OP_ALT); |
while (*ecode == OP_ALT); |
| 970 |
case OP_ASSERTBACK_NOT: |
case OP_ASSERTBACK_NOT: |
| 971 |
do |
do |
| 972 |
{ |
{ |
| 973 |
RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0); |
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0, |
| 974 |
|
RM5); |
| 975 |
if (rrc == MATCH_MATCH) RRETURN(MATCH_NOMATCH); |
if (rrc == MATCH_MATCH) RRETURN(MATCH_NOMATCH); |
| 976 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); |
| 977 |
ecode += GET(ecode,1); |
ecode += GET(ecode,1); |
| 978 |
} |
} |
| 979 |
while (*ecode == OP_ALT); |
while (*ecode == OP_ALT); |
| 997 |
{ |
{ |
| 998 |
eptr--; |
eptr--; |
| 999 |
if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH); |
if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH); |
| 1000 |
BACKCHAR(eptr) |
BACKCHAR(eptr); |
| 1001 |
} |
} |
| 1002 |
} |
} |
| 1003 |
else |
else |
| 1028 |
cb.offset_vector = md->offset_vector; |
cb.offset_vector = md->offset_vector; |
| 1029 |
cb.subject = (PCRE_SPTR)md->start_subject; |
cb.subject = (PCRE_SPTR)md->start_subject; |
| 1030 |
cb.subject_length = md->end_subject - md->start_subject; |
cb.subject_length = md->end_subject - md->start_subject; |
| 1031 |
cb.start_match = md->start_match - md->start_subject; |
cb.start_match = mstart - md->start_subject; |
| 1032 |
cb.current_position = eptr - md->start_subject; |
cb.current_position = eptr - md->start_subject; |
| 1033 |
cb.pattern_position = GET(ecode, 2); |
cb.pattern_position = GET(ecode, 2); |
| 1034 |
cb.next_item_length = GET(ecode, 2 + LINK_SIZE); |
cb.next_item_length = GET(ecode, 2 + LINK_SIZE); |
| 1090 |
|
|
| 1091 |
memcpy(new_recursive.offset_save, md->offset_vector, |
memcpy(new_recursive.offset_save, md->offset_vector, |
| 1092 |
new_recursive.saved_max * sizeof(int)); |
new_recursive.saved_max * sizeof(int)); |
| 1093 |
new_recursive.save_start = md->start_match; |
new_recursive.save_start = mstart; |
| 1094 |
md->start_match = eptr; |
mstart = eptr; |
| 1095 |
|
|
| 1096 |
/* 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 |
| 1097 |
restore the offset and recursion data. */ |
restore the offset and recursion data. */ |
| 1100 |
flags = (*callpat >= OP_SBRA)? match_cbegroup : 0; |
flags = (*callpat >= OP_SBRA)? match_cbegroup : 0; |
| 1101 |
do |
do |
| 1102 |
{ |
{ |
| 1103 |
RMATCH(rrc, eptr, callpat + _pcre_OP_lengths[*callpat], offset_top, |
RMATCH(eptr, callpat + _pcre_OP_lengths[*callpat], offset_top, |
| 1104 |
md, ims, eptrb, flags); |
md, ims, eptrb, flags, RM6); |
| 1105 |
if (rrc == MATCH_MATCH) |
if (rrc == MATCH_MATCH) |
| 1106 |
{ |
{ |
| 1107 |
DPRINTF(("Recursion matched\n")); |
DPRINTF(("Recursion matched\n")); |
| 1110 |
(pcre_free)(new_recursive.offset_save); |
(pcre_free)(new_recursive.offset_save); |
| 1111 |
RRETURN(MATCH_MATCH); |
RRETURN(MATCH_MATCH); |
| 1112 |
} |
} |
| 1113 |
else if (rrc != MATCH_NOMATCH) |
else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) |
| 1114 |
{ |
{ |
| 1115 |
DPRINTF(("Recursion gave error %d\n", rrc)); |
DPRINTF(("Recursion gave error %d\n", rrc)); |
| 1116 |
|
if (new_recursive.offset_save != stacksave) |
| 1117 |
|
(pcre_free)(new_recursive.offset_save); |
| 1118 |
RRETURN(rrc); |
RRETURN(rrc); |
| 1119 |
} |
} |
| 1120 |
|
|
| 1146 |
|
|
| 1147 |
do |
do |
| 1148 |
{ |
{ |
| 1149 |
RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, |
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM7); |
|
eptrb, 0); |
|
| 1150 |
if (rrc == MATCH_MATCH) break; |
if (rrc == MATCH_MATCH) break; |
| 1151 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); |
| 1152 |
ecode += GET(ecode,1); |
ecode += GET(ecode,1); |
| 1153 |
} |
} |
| 1154 |
while (*ecode == OP_ALT); |
while (*ecode == OP_ALT); |
| 1191 |
|
|
| 1192 |
if (*ecode == OP_KETRMIN) |
if (*ecode == OP_KETRMIN) |
| 1193 |
{ |
{ |
| 1194 |
RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM8); |
| 1195 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1196 |
ecode = prev; |
ecode = prev; |
| 1197 |
flags = match_tail_recursed; |
flags = 0; |
| 1198 |
goto TAIL_RECURSE; |
goto TAIL_RECURSE; |
| 1199 |
} |
} |
| 1200 |
else /* OP_KETRMAX */ |
else /* OP_KETRMAX */ |
| 1201 |
{ |
{ |
| 1202 |
RMATCH(rrc, eptr, prev, offset_top, md, ims, eptrb, match_cbegroup); |
RMATCH(eptr, prev, offset_top, md, ims, eptrb, match_cbegroup, RM9); |
| 1203 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1204 |
ecode += 1 + LINK_SIZE; |
ecode += 1 + LINK_SIZE; |
| 1205 |
flags = match_tail_recursed; |
flags = 0; |
| 1206 |
goto TAIL_RECURSE; |
goto TAIL_RECURSE; |
| 1207 |
} |
} |
| 1208 |
/* Control never gets here */ |
/* Control never gets here */ |
| 1214 |
do ecode += GET(ecode,1); while (*ecode == OP_ALT); |
do ecode += GET(ecode,1); while (*ecode == OP_ALT); |
| 1215 |
break; |
break; |
| 1216 |
|
|
| 1217 |
/* BRAZERO and BRAMINZERO occur just before a bracket group, indicating |
/* BRAZERO, BRAMINZERO and SKIPZERO occur just before a bracket group, |
| 1218 |
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 |
| 1219 |
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 |
| 1220 |
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 |
| 1221 |
preceded by BRAZERO or BRAMINZERO. */ |
optional ones preceded by BRAZERO or BRAMINZERO. */ |
| 1222 |
|
|
| 1223 |
case OP_BRAZERO: |
case OP_BRAZERO: |
| 1224 |
{ |
{ |
| 1225 |
next = ecode+1; |
next = ecode+1; |
| 1226 |
RMATCH(rrc, eptr, next, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, next, offset_top, md, ims, eptrb, 0, RM10); |
| 1227 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1228 |
do next += GET(next,1); while (*next == OP_ALT); |
do next += GET(next,1); while (*next == OP_ALT); |
| 1229 |
ecode = next + 1 + LINK_SIZE; |
ecode = next + 1 + LINK_SIZE; |
| 1234 |
{ |
{ |
| 1235 |
next = ecode+1; |
next = ecode+1; |
| 1236 |
do next += GET(next, 1); while (*next == OP_ALT); |
do next += GET(next, 1); while (*next == OP_ALT); |
| 1237 |
RMATCH(rrc, eptr, next + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, next + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0, RM11); |
| 1238 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1239 |
ecode++; |
ecode++; |
| 1240 |
} |
} |
| 1241 |
break; |
break; |
| 1242 |
|
|
| 1243 |
|
case OP_SKIPZERO: |
| 1244 |
|
{ |
| 1245 |
|
next = ecode+1; |
| 1246 |
|
do next += GET(next,1); while (*next == OP_ALT); |
| 1247 |
|
ecode = next + 1 + LINK_SIZE; |
| 1248 |
|
} |
| 1249 |
|
break; |
| 1250 |
|
|
| 1251 |
/* End of a group, repeated or non-repeating. */ |
/* End of a group, repeated or non-repeating. */ |
| 1252 |
|
|
| 1253 |
case OP_KET: |
case OP_KET: |
| 1312 |
recursion_info *rec = md->recursive; |
recursion_info *rec = md->recursive; |
| 1313 |
DPRINTF(("Recursion (%d) succeeded - continuing\n", number)); |
DPRINTF(("Recursion (%d) succeeded - continuing\n", number)); |
| 1314 |
md->recursive = rec->prevrec; |
md->recursive = rec->prevrec; |
| 1315 |
md->start_match = rec->save_start; |
mstart = rec->save_start; |
| 1316 |
memcpy(md->offset_vector, rec->offset_save, |
memcpy(md->offset_vector, rec->offset_save, |
| 1317 |
rec->saved_max * sizeof(int)); |
rec->saved_max * sizeof(int)); |
| 1318 |
ecode = rec->after_call; |
ecode = rec->after_call; |
| 1341 |
|
|
| 1342 |
/* 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 |
| 1343 |
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 |
| 1344 |
tail recursion to avoid using another stack frame. */ |
tail recursion to avoid using another stack frame, unless we have an |
| 1345 |
|
unlimited repeat of a group that can match an empty string. */ |
| 1346 |
|
|
| 1347 |
flags = (*prev >= OP_SBRA)? match_cbegroup : 0; |
flags = (*prev >= OP_SBRA)? match_cbegroup : 0; |
| 1348 |
|
|
| 1349 |
if (*ecode == OP_KETRMIN) |
if (*ecode == OP_KETRMIN) |
| 1350 |
{ |
{ |
| 1351 |
RMATCH(rrc, eptr, ecode + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM12); |
| 1352 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1353 |
|
if (flags != 0) /* Could match an empty string */ |
| 1354 |
|
{ |
| 1355 |
|
RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM50); |
| 1356 |
|
RRETURN(rrc); |
| 1357 |
|
} |
| 1358 |
ecode = prev; |
ecode = prev; |
|
flags |= match_tail_recursed; |
|
| 1359 |
goto TAIL_RECURSE; |
goto TAIL_RECURSE; |
| 1360 |
} |
} |
| 1361 |
else /* OP_KETRMAX */ |
else /* OP_KETRMAX */ |
| 1362 |
{ |
{ |
| 1363 |
RMATCH(rrc, eptr, prev, offset_top, md, ims, eptrb, flags); |
RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM13); |
| 1364 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1365 |
ecode += 1 + LINK_SIZE; |
ecode += 1 + LINK_SIZE; |
| 1366 |
flags = match_tail_recursed; |
flags = 0; |
| 1367 |
goto TAIL_RECURSE; |
goto TAIL_RECURSE; |
| 1368 |
} |
} |
| 1369 |
/* Control never gets here */ |
/* Control never gets here */ |
| 1396 |
ecode++; |
ecode++; |
| 1397 |
break; |
break; |
| 1398 |
|
|
| 1399 |
|
/* Reset the start of match point */ |
| 1400 |
|
|
| 1401 |
|
case OP_SET_SOM: |
| 1402 |
|
mstart = eptr; |
| 1403 |
|
ecode++; |
| 1404 |
|
break; |
| 1405 |
|
|
| 1406 |
/* Assert before internal newline if multiline, or before a terminating |
/* Assert before internal newline if multiline, or before a terminating |
| 1407 |
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. */ |
| 1408 |
|
|
| 1461 |
{ |
{ |
| 1462 |
if (eptr == md->start_subject) prev_is_word = FALSE; else |
if (eptr == md->start_subject) prev_is_word = FALSE; else |
| 1463 |
{ |
{ |
| 1464 |
const uschar *lastptr = eptr - 1; |
USPTR lastptr = eptr - 1; |
| 1465 |
while((*lastptr & 0xc0) == 0x80) lastptr--; |
while((*lastptr & 0xc0) == 0x80) lastptr--; |
| 1466 |
GETCHAR(c, lastptr); |
GETCHAR(c, lastptr); |
| 1467 |
prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; |
prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; |
| 1495 |
/* Match a single character type; inline for speed */ |
/* Match a single character type; inline for speed */ |
| 1496 |
|
|
| 1497 |
case OP_ANY: |
case OP_ANY: |
| 1498 |
if ((ims & PCRE_DOTALL) == 0) |
if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); |
| 1499 |
{ |
/* Fall through */ |
| 1500 |
if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); |
|
| 1501 |
} |
case OP_ALLANY: |
| 1502 |
if (eptr++ >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr++ >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 1503 |
if (utf8) |
if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
|
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
|
| 1504 |
ecode++; |
ecode++; |
| 1505 |
break; |
break; |
| 1506 |
|
|
| 1599 |
case 0x000d: |
case 0x000d: |
| 1600 |
if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 1601 |
break; |
break; |
| 1602 |
|
|
| 1603 |
case 0x000a: |
case 0x000a: |
| 1604 |
|
break; |
| 1605 |
|
|
| 1606 |
case 0x000b: |
case 0x000b: |
| 1607 |
case 0x000c: |
case 0x000c: |
| 1608 |
case 0x0085: |
case 0x0085: |
| 1609 |
case 0x2028: |
case 0x2028: |
| 1610 |
case 0x2029: |
case 0x2029: |
| 1611 |
|
if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); |
| 1612 |
|
break; |
| 1613 |
|
} |
| 1614 |
|
ecode++; |
| 1615 |
|
break; |
| 1616 |
|
|
| 1617 |
|
case OP_NOT_HSPACE: |
| 1618 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 1619 |
|
GETCHARINCTEST(c, eptr); |
| 1620 |
|
switch(c) |
| 1621 |
|
{ |
| 1622 |
|
default: break; |
| 1623 |
|
case 0x09: /* HT */ |
| 1624 |
|
case 0x20: /* SPACE */ |
| 1625 |
|
case 0xa0: /* NBSP */ |
| 1626 |
|
case 0x1680: /* OGHAM SPACE MARK */ |
| 1627 |
|
case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ |
| 1628 |
|
case 0x2000: /* EN QUAD */ |
| 1629 |
|
case 0x2001: /* EM QUAD */ |
| 1630 |
|
case 0x2002: /* EN SPACE */ |
| 1631 |
|
case 0x2003: /* EM SPACE */ |
| 1632 |
|
case 0x2004: /* THREE-PER-EM SPACE */ |
| 1633 |
|
case 0x2005: /* FOUR-PER-EM SPACE */ |
| 1634 |
|
case 0x2006: /* SIX-PER-EM SPACE */ |
| 1635 |
|
case 0x2007: /* FIGURE SPACE */ |
| 1636 |
|
case 0x2008: /* PUNCTUATION SPACE */ |
| 1637 |
|
case 0x2009: /* THIN SPACE */ |
| 1638 |
|
case 0x200A: /* HAIR SPACE */ |
| 1639 |
|
case 0x202f: /* NARROW NO-BREAK SPACE */ |
| 1640 |
|
case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ |
| 1641 |
|
case 0x3000: /* IDEOGRAPHIC SPACE */ |
| 1642 |
|
RRETURN(MATCH_NOMATCH); |
| 1643 |
|
} |
| 1644 |
|
ecode++; |
| 1645 |
|
break; |
| 1646 |
|
|
| 1647 |
|
case OP_HSPACE: |
| 1648 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 1649 |
|
GETCHARINCTEST(c, eptr); |
| 1650 |
|
switch(c) |
| 1651 |
|
{ |
| 1652 |
|
default: RRETURN(MATCH_NOMATCH); |
| 1653 |
|
case 0x09: /* HT */ |
| 1654 |
|
case 0x20: /* SPACE */ |
| 1655 |
|
case 0xa0: /* NBSP */ |
| 1656 |
|
case 0x1680: /* OGHAM SPACE MARK */ |
| 1657 |
|
case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ |
| 1658 |
|
case 0x2000: /* EN QUAD */ |
| 1659 |
|
case 0x2001: /* EM QUAD */ |
| 1660 |
|
case 0x2002: /* EN SPACE */ |
| 1661 |
|
case 0x2003: /* EM SPACE */ |
| 1662 |
|
case 0x2004: /* THREE-PER-EM SPACE */ |
| 1663 |
|
case 0x2005: /* FOUR-PER-EM SPACE */ |
| 1664 |
|
case 0x2006: /* SIX-PER-EM SPACE */ |
| 1665 |
|
case 0x2007: /* FIGURE SPACE */ |
| 1666 |
|
case 0x2008: /* PUNCTUATION SPACE */ |
| 1667 |
|
case 0x2009: /* THIN SPACE */ |
| 1668 |
|
case 0x200A: /* HAIR SPACE */ |
| 1669 |
|
case 0x202f: /* NARROW NO-BREAK SPACE */ |
| 1670 |
|
case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ |
| 1671 |
|
case 0x3000: /* IDEOGRAPHIC SPACE */ |
| 1672 |
|
break; |
| 1673 |
|
} |
| 1674 |
|
ecode++; |
| 1675 |
|
break; |
| 1676 |
|
|
| 1677 |
|
case OP_NOT_VSPACE: |
| 1678 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 1679 |
|
GETCHARINCTEST(c, eptr); |
| 1680 |
|
switch(c) |
| 1681 |
|
{ |
| 1682 |
|
default: break; |
| 1683 |
|
case 0x0a: /* LF */ |
| 1684 |
|
case 0x0b: /* VT */ |
| 1685 |
|
case 0x0c: /* FF */ |
| 1686 |
|
case 0x0d: /* CR */ |
| 1687 |
|
case 0x85: /* NEL */ |
| 1688 |
|
case 0x2028: /* LINE SEPARATOR */ |
| 1689 |
|
case 0x2029: /* PARAGRAPH SEPARATOR */ |
| 1690 |
|
RRETURN(MATCH_NOMATCH); |
| 1691 |
|
} |
| 1692 |
|
ecode++; |
| 1693 |
|
break; |
| 1694 |
|
|
| 1695 |
|
case OP_VSPACE: |
| 1696 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 1697 |
|
GETCHARINCTEST(c, eptr); |
| 1698 |
|
switch(c) |
| 1699 |
|
{ |
| 1700 |
|
default: RRETURN(MATCH_NOMATCH); |
| 1701 |
|
case 0x0a: /* LF */ |
| 1702 |
|
case 0x0b: /* VT */ |
| 1703 |
|
case 0x0c: /* FF */ |
| 1704 |
|
case 0x0d: /* CR */ |
| 1705 |
|
case 0x85: /* NEL */ |
| 1706 |
|
case 0x2028: /* LINE SEPARATOR */ |
| 1707 |
|
case 0x2029: /* PARAGRAPH SEPARATOR */ |
| 1708 |
break; |
break; |
| 1709 |
} |
} |
| 1710 |
ecode++; |
ecode++; |
| 1719 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 1720 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 1721 |
{ |
{ |
| 1722 |
int chartype, script; |
const ucd_record *prop = GET_UCD(c); |
|
int category = _pcre_ucp_findprop(c, &chartype, &script); |
|
| 1723 |
|
|
| 1724 |
switch(ecode[1]) |
switch(ecode[1]) |
| 1725 |
{ |
{ |
| 1728 |
break; |
break; |
| 1729 |
|
|
| 1730 |
case PT_LAMP: |
case PT_LAMP: |
| 1731 |
if ((chartype == ucp_Lu || |
if ((prop->chartype == ucp_Lu || |
| 1732 |
chartype == ucp_Ll || |
prop->chartype == ucp_Ll || |
| 1733 |
chartype == ucp_Lt) == (op == OP_NOTPROP)) |
prop->chartype == ucp_Lt) == (op == OP_NOTPROP)) |
| 1734 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 1735 |
break; |
break; |
| 1736 |
|
|
| 1737 |
case PT_GC: |
case PT_GC: |
| 1738 |
if ((ecode[2] != category) == (op == OP_PROP)) |
if ((ecode[2] != _pcre_ucp_gentype[prop->chartype]) == (op == OP_PROP)) |
| 1739 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 1740 |
break; |
break; |
| 1741 |
|
|
| 1742 |
case PT_PC: |
case PT_PC: |
| 1743 |
if ((ecode[2] != chartype) == (op == OP_PROP)) |
if ((ecode[2] != prop->chartype) == (op == OP_PROP)) |
| 1744 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 1745 |
break; |
break; |
| 1746 |
|
|
| 1747 |
case PT_SC: |
case PT_SC: |
| 1748 |
if ((ecode[2] != script) == (op == OP_PROP)) |
if ((ecode[2] != prop->script) == (op == OP_PROP)) |
| 1749 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 1750 |
break; |
break; |
| 1751 |
|
|
| 1764 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 1765 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 1766 |
{ |
{ |
| 1767 |
int chartype, script; |
int category = UCD_CATEGORY(c); |
|
int category = _pcre_ucp_findprop(c, &chartype, &script); |
|
| 1768 |
if (category == ucp_M) RRETURN(MATCH_NOMATCH); |
if (category == ucp_M) RRETURN(MATCH_NOMATCH); |
| 1769 |
while (eptr < md->end_subject) |
while (eptr < md->end_subject) |
| 1770 |
{ |
{ |
| 1773 |
{ |
{ |
| 1774 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 1775 |
} |
} |
| 1776 |
category = _pcre_ucp_findprop(c, &chartype, &script); |
category = UCD_CATEGORY(c); |
| 1777 |
if (category != ucp_M) break; |
if (category != ucp_M) break; |
| 1778 |
eptr += len; |
eptr += len; |
| 1779 |
} |
} |
| 1794 |
case OP_REF: |
case OP_REF: |
| 1795 |
{ |
{ |
| 1796 |
offset = GET2(ecode, 1) << 1; /* Doubled ref number */ |
offset = GET2(ecode, 1) << 1; /* Doubled ref number */ |
| 1797 |
ecode += 3; /* Advance past item */ |
ecode += 3; |
| 1798 |
|
|
| 1799 |
|
/* If the reference is unset, there are two possibilities: |
| 1800 |
|
|
| 1801 |
|
(a) In the default, Perl-compatible state, set the length to be longer |
| 1802 |
|
than the amount of subject left; this ensures that every attempt at a |
| 1803 |
|
match fails. We can't just fail here, because of the possibility of |
| 1804 |
|
quantifiers with zero minima. |
| 1805 |
|
|
| 1806 |
/* If the reference is unset, set the length to be longer than the amount |
(b) If the JavaScript compatibility flag is set, set the length to zero |
| 1807 |
of subject left; this ensures that every attempt at a match fails. We |
so that the back reference matches an empty string. |
| 1808 |
can't just fail here, because of the possibility of quantifiers with zero |
|
| 1809 |
minima. */ |
Otherwise, set the length to the length of what was matched by the |
| 1810 |
|
referenced subpattern. */ |
| 1811 |
length = (offset >= offset_top || md->offset_vector[offset] < 0)? |
|
| 1812 |
md->end_subject - eptr + 1 : |
if (offset >= offset_top || md->offset_vector[offset] < 0) |
| 1813 |
md->offset_vector[offset+1] - md->offset_vector[offset]; |
length = (md->jscript_compat)? 0 : md->end_subject - eptr + 1; |
| 1814 |
|
else |
| 1815 |
|
length = md->offset_vector[offset+1] - md->offset_vector[offset]; |
| 1816 |
|
|
| 1817 |
/* Set up for repetition, or handle the non-repeated case */ |
/* Set up for repetition, or handle the non-repeated case */ |
| 1818 |
|
|
| 1872 |
{ |
{ |
| 1873 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
| 1874 |
{ |
{ |
| 1875 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM14); |
| 1876 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1877 |
if (fi >= max || !match_ref(offset, eptr, length, md, ims)) |
if (fi >= max || !match_ref(offset, eptr, length, md, ims)) |
| 1878 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 1893 |
} |
} |
| 1894 |
while (eptr >= pp) |
while (eptr >= pp) |
| 1895 |
{ |
{ |
| 1896 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM15); |
| 1897 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1898 |
eptr -= length; |
eptr -= length; |
| 1899 |
} |
} |
| 1998 |
{ |
{ |
| 1999 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
| 2000 |
{ |
{ |
| 2001 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM16); |
| 2002 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2003 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 2004 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 2018 |
{ |
{ |
| 2019 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
| 2020 |
{ |
{ |
| 2021 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM17); |
| 2022 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2023 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 2024 |
c = *eptr++; |
c = *eptr++; |
| 2055 |
} |
} |
| 2056 |
for (;;) |
for (;;) |
| 2057 |
{ |
{ |
| 2058 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM18); |
| 2059 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2060 |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 2061 |
BACKCHAR(eptr); |
BACKCHAR(eptr); |
| 2074 |
} |
} |
| 2075 |
while (eptr >= pp) |
while (eptr >= pp) |
| 2076 |
{ |
{ |
| 2077 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM19); |
| 2078 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2079 |
eptr--; |
eptr--; |
| 2080 |
} |
} |
| 2087 |
|
|
| 2088 |
|
|
| 2089 |
/* Match an extended character class. This opcode is encountered only |
/* Match an extended character class. This opcode is encountered only |
| 2090 |
in UTF-8 mode, because that's the only time it is compiled. */ |
when UTF-8 mode mode is supported. Nevertheless, we may not be in UTF-8 |
| 2091 |
|
mode, because Unicode properties are supported in non-UTF-8 mode. */ |
| 2092 |
|
|
| 2093 |
#ifdef SUPPORT_UTF8 |
#ifdef SUPPORT_UTF8 |
| 2094 |
case OP_XCLASS: |
case OP_XCLASS: |
| 2130 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 2131 |
{ |
{ |
| 2132 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 2133 |
GETCHARINC(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 2134 |
if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH); |
if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH); |
| 2135 |
} |
} |
| 2136 |
|
|
| 2146 |
{ |
{ |
| 2147 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
| 2148 |
{ |
{ |
| 2149 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM20); |
| 2150 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2151 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 2152 |
GETCHARINC(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 2153 |
if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH); |
if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH); |
| 2154 |
} |
} |
| 2155 |
/* Control never gets here */ |
/* Control never gets here */ |
| 2164 |
{ |
{ |
| 2165 |
int len = 1; |
int len = 1; |
| 2166 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) break; |
| 2167 |
GETCHARLEN(c, eptr, len); |
GETCHARLENTEST(c, eptr, len); |
| 2168 |
if (!_pcre_xclass(c, data)) break; |
if (!_pcre_xclass(c, data)) break; |
| 2169 |
eptr += len; |
eptr += len; |
| 2170 |
} |
} |
| 2171 |
for(;;) |
for(;;) |
| 2172 |
{ |
{ |
| 2173 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM21); |
| 2174 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2175 |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 2176 |
BACKCHAR(eptr) |
if (utf8) BACKCHAR(eptr); |
| 2177 |
} |
} |
| 2178 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 2179 |
} |
} |
| 2239 |
if (fc != dc) |
if (fc != dc) |
| 2240 |
{ |
{ |
| 2241 |
#ifdef SUPPORT_UCP |
#ifdef SUPPORT_UCP |
| 2242 |
if (dc != _pcre_ucp_othercase(fc)) |
if (dc != UCD_OTHERCASE(fc)) |
| 2243 |
#endif |
#endif |
| 2244 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 2245 |
} |
} |
| 2330 |
#ifdef SUPPORT_UCP |
#ifdef SUPPORT_UCP |
| 2331 |
unsigned int othercase; |
unsigned int othercase; |
| 2332 |
if ((ims & PCRE_CASELESS) != 0 && |
if ((ims & PCRE_CASELESS) != 0 && |
| 2333 |
(othercase = _pcre_ucp_othercase(fc)) != NOTACHAR) |
(othercase = UCD_OTHERCASE(fc)) != fc) |
| 2334 |
oclength = _pcre_ord2utf8(othercase, occhars); |
oclength = _pcre_ord2utf8(othercase, occhars); |
| 2335 |
else oclength = 0; |
else oclength = 0; |
| 2336 |
#endif /* SUPPORT_UCP */ |
#endif /* SUPPORT_UCP */ |
| 2357 |
{ |
{ |
| 2358 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
| 2359 |
{ |
{ |
| 2360 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM22); |
| 2361 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2362 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 2363 |
if (memcmp(eptr, charptr, length) == 0) eptr += length; |
if (memcmp(eptr, charptr, length) == 0) eptr += length; |
| 2398 |
if (possessive) continue; |
if (possessive) continue; |
| 2399 |
for(;;) |
for(;;) |
| 2400 |
{ |
{ |
| 2401 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM23); |
| 2402 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2403 |
if (eptr == pp) RRETURN(MATCH_NOMATCH); |
if (eptr == pp) RRETURN(MATCH_NOMATCH); |
| 2404 |
#ifdef SUPPORT_UCP |
#ifdef SUPPORT_UCP |
| 2447 |
{ |
{ |
| 2448 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
| 2449 |
{ |
{ |
| 2450 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM24); |
| 2451 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2452 |
if (fi >= max || eptr >= md->end_subject || |
if (fi >= max || eptr >= md->end_subject || |
| 2453 |
fc != md->lcc[*eptr++]) |
fc != md->lcc[*eptr++]) |
| 2466 |
if (possessive) continue; |
if (possessive) continue; |
| 2467 |
while (eptr >= pp) |
while (eptr >= pp) |
| 2468 |
{ |
{ |
| 2469 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM25); |
| 2470 |
eptr--; |
eptr--; |
| 2471 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2472 |
} |
} |
| 2485 |
{ |
{ |
| 2486 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
| 2487 |
{ |
{ |
| 2488 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM26); |
| 2489 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2490 |
if (fi >= max || eptr >= md->end_subject || fc != *eptr++) |
if (fi >= max || eptr >= md->end_subject || fc != *eptr++) |
| 2491 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 2503 |
if (possessive) continue; |
if (possessive) continue; |
| 2504 |
while (eptr >= pp) |
while (eptr >= pp) |
| 2505 |
{ |
{ |
| 2506 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM27); |
| 2507 |
eptr--; |
eptr--; |
| 2508 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2509 |
} |
} |
| 2648 |
register unsigned int d; |
register unsigned int d; |
| 2649 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
| 2650 |
{ |
{ |
| 2651 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM28); |
| 2652 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2653 |
|
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 2654 |
GETCHARINC(d, eptr); |
GETCHARINC(d, eptr); |
| 2655 |
if (d < 256) d = md->lcc[d]; |
if (d < 256) d = md->lcc[d]; |
| 2656 |
if (fi >= max || eptr >= md->end_subject || fc == d) |
if (fc == d) RRETURN(MATCH_NOMATCH); |
| 2657 |
RRETURN(MATCH_NOMATCH); |
|
| 2658 |
} |
} |
| 2659 |
} |
} |
| 2660 |
else |
else |
| 2663 |
{ |
{ |
| 2664 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
| 2665 |
{ |
{ |
| 2666 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM29); |
| 2667 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2668 |
if (fi >= max || eptr >= md->end_subject || fc == md->lcc[*eptr++]) |
if (fi >= max || eptr >= md->end_subject || fc == md->lcc[*eptr++]) |
| 2669 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 2695 |
if (possessive) continue; |
if (possessive) continue; |
| 2696 |
for(;;) |
for(;;) |
| 2697 |
{ |
{ |
| 2698 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM30); |
| 2699 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2700 |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 2701 |
BACKCHAR(eptr); |
BACKCHAR(eptr); |
| 2713 |
if (possessive) continue; |
if (possessive) continue; |
| 2714 |
while (eptr >= pp) |
while (eptr >= pp) |
| 2715 |
{ |
{ |
| 2716 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM31); |
| 2717 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2718 |
eptr--; |
eptr--; |
| 2719 |
} |
} |
| 2758 |
register unsigned int d; |
register unsigned int d; |
| 2759 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
| 2760 |
{ |
{ |
| 2761 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM32); |
| 2762 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2763 |
|
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 2764 |
GETCHARINC(d, eptr); |
GETCHARINC(d, eptr); |
| 2765 |
if (fi >= max || eptr >= md->end_subject || fc == d) |
if (fc == d) RRETURN(MATCH_NOMATCH); |
|
RRETURN(MATCH_NOMATCH); |
|
| 2766 |
} |
} |
| 2767 |
} |
} |
| 2768 |
else |
else |
| 2771 |
{ |
{ |
| 2772 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
| 2773 |
{ |
{ |
| 2774 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM33); |
| 2775 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2776 |
if (fi >= max || eptr >= md->end_subject || fc == *eptr++) |
if (fi >= max || eptr >= md->end_subject || fc == *eptr++) |
| 2777 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 2802 |
if (possessive) continue; |
if (possessive) continue; |
| 2803 |
for(;;) |
for(;;) |
| 2804 |
{ |
{ |
| 2805 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM34); |
| 2806 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2807 |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 2808 |
BACKCHAR(eptr); |
BACKCHAR(eptr); |
| 2820 |
if (possessive) continue; |
if (possessive) continue; |
| 2821 |
while (eptr >= pp) |
while (eptr >= pp) |
| 2822 |
{ |
{ |
| 2823 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM35); |
| 2824 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2825 |
eptr--; |
eptr--; |
| 2826 |
} |
} |
| 2927 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 2928 |
{ |
{ |
| 2929 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 2930 |
GETCHARINC(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 2931 |
} |
} |
| 2932 |
break; |
break; |
| 2933 |
|
|
| 2935 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 2936 |
{ |
{ |
| 2937 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 2938 |
GETCHARINC(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 2939 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_chartype = UCD_CHARTYPE(c); |
| 2940 |
if ((prop_chartype == ucp_Lu || |
if ((prop_chartype == ucp_Lu || |
| 2941 |
prop_chartype == ucp_Ll || |
prop_chartype == ucp_Ll || |
| 2942 |
prop_chartype == ucp_Lt) == prop_fail_result) |
prop_chartype == ucp_Lt) == prop_fail_result) |
| 2948 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 2949 |
{ |
{ |
| 2950 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 2951 |
GETCHARINC(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 2952 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_category = UCD_CATEGORY(c); |
| 2953 |
if ((prop_category == prop_value) == prop_fail_result) |
if ((prop_category == prop_value) == prop_fail_result) |
| 2954 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 2955 |
} |
} |
| 2959 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 2960 |
{ |
{ |
| 2961 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 2962 |
GETCHARINC(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 2963 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_chartype = UCD_CHARTYPE(c); |
| 2964 |
if ((prop_chartype == prop_value) == prop_fail_result) |
if ((prop_chartype == prop_value) == prop_fail_result) |
| 2965 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 2966 |
} |
} |
| 2970 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 2971 |
{ |
{ |
| 2972 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 2973 |
GETCHARINC(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 2974 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_script = UCD_SCRIPT(c); |
| 2975 |
if ((prop_script == prop_value) == prop_fail_result) |
if ((prop_script == prop_value) == prop_fail_result) |
| 2976 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 2977 |
} |
} |
| 2990 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 2991 |
{ |
{ |
| 2992 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 2993 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_category = UCD_CATEGORY(c); |
| 2994 |
if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH); |
if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH); |
| 2995 |
while (eptr < md->end_subject) |
while (eptr < md->end_subject) |
| 2996 |
{ |
{ |
| 2999 |
{ |
{ |
| 3000 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 3001 |
} |
} |
| 3002 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_category = UCD_CATEGORY(c); |
| 3003 |
if (prop_category != ucp_M) break; |
if (prop_category != ucp_M) break; |
| 3004 |
eptr += len; |
eptr += len; |
| 3005 |
} |
} |
| 3017 |
case OP_ANY: |
case OP_ANY: |
| 3018 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3019 |
{ |
{ |
| 3020 |
if (eptr >= md->end_subject || |
if (eptr >= md->end_subject || IS_NEWLINE(eptr)) |
|
((ims & PCRE_DOTALL) == 0 && IS_NEWLINE(eptr))) |
|
| 3021 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 3022 |
eptr++; |
eptr++; |
| 3023 |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| 3024 |
} |
} |
| 3025 |
break; |
break; |
| 3026 |
|
|
| 3027 |
|
case OP_ALLANY: |
| 3028 |
|
for (i = 1; i <= min; i++) |
| 3029 |
|
{ |
| 3030 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3031 |
|
eptr++; |
| 3032 |
|
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| 3033 |
|
} |
| 3034 |
|
break; |
| 3035 |
|
|
| 3036 |
case OP_ANYBYTE: |
case OP_ANYBYTE: |
| 3037 |
eptr += min; |
eptr += min; |
| 3038 |
break; |
break; |
| 3048 |
case 0x000d: |
case 0x000d: |
| 3049 |
if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 3050 |
break; |
break; |
| 3051 |
|
|
| 3052 |
case 0x000a: |
case 0x000a: |
| 3053 |
|
break; |
| 3054 |
|
|
| 3055 |
case 0x000b: |
case 0x000b: |
| 3056 |
case 0x000c: |
case 0x000c: |
| 3057 |
case 0x0085: |
case 0x0085: |
| 3058 |
case 0x2028: |
case 0x2028: |
| 3059 |
case 0x2029: |
case 0x2029: |
| 3060 |
|
if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); |
| 3061 |
|
break; |
| 3062 |
|
} |
| 3063 |
|
} |
| 3064 |
|
break; |
| 3065 |
|
|
| 3066 |
|
case OP_NOT_HSPACE: |
| 3067 |
|
for (i = 1; i <= min; i++) |
| 3068 |
|
{ |
| 3069 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3070 |
|
GETCHARINC(c, eptr); |
| 3071 |
|
switch(c) |
| 3072 |
|
{ |
| 3073 |
|
default: break; |
| 3074 |
|
case 0x09: /* HT */ |
| 3075 |
|
case 0x20: /* SPACE */ |
| 3076 |
|
case 0xa0: /* NBSP */ |
| 3077 |
|
case 0x1680: /* OGHAM SPACE MARK */ |
| 3078 |
|
case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ |
| 3079 |
|
case 0x2000: /* EN QUAD */ |
| 3080 |
|
case 0x2001: /* EM QUAD */ |
| 3081 |
|
case 0x2002: /* EN SPACE */ |
| 3082 |
|
case 0x2003: /* EM SPACE */ |
| 3083 |
|
case 0x2004: /* THREE-PER-EM SPACE */ |
| 3084 |
|
case 0x2005: /* FOUR-PER-EM SPACE */ |
| 3085 |
|
case 0x2006: /* SIX-PER-EM SPACE */ |
| 3086 |
|
case 0x2007: /* FIGURE SPACE */ |
| 3087 |
|
case 0x2008: /* PUNCTUATION SPACE */ |
| 3088 |
|
case 0x2009: /* THIN SPACE */ |
| 3089 |
|
case 0x200A: /* HAIR SPACE */ |
| 3090 |
|
case 0x202f: /* NARROW NO-BREAK SPACE */ |
| 3091 |
|
case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ |
| 3092 |
|
case 0x3000: /* IDEOGRAPHIC SPACE */ |
| 3093 |
|
RRETURN(MATCH_NOMATCH); |
| 3094 |
|
} |
| 3095 |
|
} |
| 3096 |
|
break; |
| 3097 |
|
|
| 3098 |
|
case OP_HSPACE: |
| 3099 |
|
for (i = 1; i <= min; i++) |
| 3100 |
|
{ |
| 3101 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3102 |
|
GETCHARINC(c, eptr); |
| 3103 |
|
switch(c) |
| 3104 |
|
{ |
| 3105 |
|
default: RRETURN(MATCH_NOMATCH); |
| 3106 |
|
case 0x09: /* HT */ |
| 3107 |
|
case 0x20: /* SPACE */ |
| 3108 |
|
case 0xa0: /* NBSP */ |
| 3109 |
|
case 0x1680: /* OGHAM SPACE MARK */ |
| 3110 |
|
case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ |
| 3111 |
|
case 0x2000: /* EN QUAD */ |
| 3112 |
|
case 0x2001: /* EM QUAD */ |
| 3113 |
|
case 0x2002: /* EN SPACE */ |
| 3114 |
|
case 0x2003: /* EM SPACE */ |
| 3115 |
|
case 0x2004: /* THREE-PER-EM SPACE */ |
| 3116 |
|
case 0x2005: /* FOUR-PER-EM SPACE */ |
| 3117 |
|
case 0x2006: /* SIX-PER-EM SPACE */ |
| 3118 |
|
case 0x2007: /* FIGURE SPACE */ |
| 3119 |
|
case 0x2008: /* PUNCTUATION SPACE */ |
| 3120 |
|
case 0x2009: /* THIN SPACE */ |
| 3121 |
|
case 0x200A: /* HAIR SPACE */ |
| 3122 |
|
case 0x202f: /* NARROW NO-BREAK SPACE */ |
| 3123 |
|
case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ |
| 3124 |
|
case 0x3000: /* IDEOGRAPHIC SPACE */ |
| 3125 |
|
break; |
| 3126 |
|
} |
| 3127 |
|
} |
| 3128 |
|
break; |
| 3129 |
|
|
| 3130 |
|
case OP_NOT_VSPACE: |
| 3131 |
|
for (i = 1; i <= min; i++) |
| 3132 |
|
{ |
| 3133 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3134 |
|
GETCHARINC(c, eptr); |
| 3135 |
|
switch(c) |
| 3136 |
|
{ |
| 3137 |
|
default: break; |
| 3138 |
|
case 0x0a: /* LF */ |
| 3139 |
|
case 0x0b: /* VT */ |
| 3140 |
|
case 0x0c: /* FF */ |
| 3141 |
|
case 0x0d: /* CR */ |
| 3142 |
|
case 0x85: /* NEL */ |
| 3143 |
|
case 0x2028: /* LINE SEPARATOR */ |
| 3144 |
|
case 0x2029: /* PARAGRAPH SEPARATOR */ |
| 3145 |
|
RRETURN(MATCH_NOMATCH); |
| 3146 |
|
} |
| 3147 |
|
} |
| 3148 |
|
break; |
| 3149 |
|
|
| 3150 |
|
case OP_VSPACE: |
| 3151 |
|
for (i = 1; i <= min; i++) |
| 3152 |
|
{ |
| 3153 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3154 |
|
GETCHARINC(c, eptr); |
| 3155 |
|
switch(c) |
| 3156 |
|
{ |
| 3157 |
|
default: RRETURN(MATCH_NOMATCH); |
| 3158 |
|
case 0x0a: /* LF */ |
| 3159 |
|
case 0x0b: /* VT */ |
| 3160 |
|
case 0x0c: /* FF */ |
| 3161 |
|
case 0x0d: /* CR */ |
| 3162 |
|
case 0x85: /* NEL */ |
| 3163 |
|
case 0x2028: /* LINE SEPARATOR */ |
| 3164 |
|
case 0x2029: /* PARAGRAPH SEPARATOR */ |
| 3165 |
break; |
break; |
| 3166 |
} |
} |
| 3167 |
} |
} |
| 3191 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3192 |
{ |
{ |
| 3193 |
if (eptr >= md->end_subject || |
if (eptr >= md->end_subject || |
| 3194 |
(*eptr < 128 && (md->ctypes[*eptr++] & ctype_space) != 0)) |
(*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0)) |
| 3195 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 3196 |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80); |
| 3197 |
} |
} |
| 3198 |
break; |
break; |
| 3199 |
|
|
| 3211 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3212 |
{ |
{ |
| 3213 |
if (eptr >= md->end_subject || |
if (eptr >= md->end_subject || |
| 3214 |
(*eptr < 128 && (md->ctypes[*eptr++] & ctype_word) != 0)) |
(*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0)) |
| 3215 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 3216 |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80); |
| 3217 |
} |
} |
| 3218 |
break; |
break; |
| 3219 |
|
|
| 3241 |
switch(ctype) |
switch(ctype) |
| 3242 |
{ |
{ |
| 3243 |
case OP_ANY: |
case OP_ANY: |
| 3244 |
if ((ims & PCRE_DOTALL) == 0) |
for (i = 1; i <= min; i++) |
| 3245 |
{ |
{ |
| 3246 |
for (i = 1; i <= min; i++) |
if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); |
| 3247 |
{ |
eptr++; |
|
if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); |
|
|
eptr++; |
|
|
} |
|
| 3248 |
} |
} |
| 3249 |
else eptr += min; |
break; |
| 3250 |
|
|
| 3251 |
|
case OP_ALLANY: |
| 3252 |
|
eptr += min; |
| 3253 |
break; |
break; |
| 3254 |
|
|
| 3255 |
case OP_ANYBYTE: |
case OP_ANYBYTE: |
| 3270 |
if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 3271 |
break; |
break; |
| 3272 |
case 0x000a: |
case 0x000a: |
| 3273 |
|
break; |
| 3274 |
|
|
| 3275 |
case 0x000b: |
case 0x000b: |
| 3276 |
case 0x000c: |
case 0x000c: |
| 3277 |
case 0x0085: |
case 0x0085: |
| 3278 |
|
if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); |
| 3279 |
|
break; |
| 3280 |
|
} |
| 3281 |
|
} |
| 3282 |
|
break; |
| 3283 |
|
|
| 3284 |
|
case OP_NOT_HSPACE: |
| 3285 |
|
for (i = 1; i <= min; i++) |
| 3286 |
|
{ |
| 3287 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3288 |
|
switch(*eptr++) |
| 3289 |
|
{ |
| 3290 |
|
default: break; |
| 3291 |
|
case 0x09: /* HT */ |
| 3292 |
|
case 0x20: /* SPACE */ |
| 3293 |
|
case 0xa0: /* NBSP */ |
| 3294 |
|
RRETURN(MATCH_NOMATCH); |
| 3295 |
|
} |
| 3296 |
|
} |
| 3297 |
|
break; |
| 3298 |
|
|
| 3299 |
|
case OP_HSPACE: |
| 3300 |
|
for (i = 1; i <= min; i++) |
| 3301 |
|
{ |
| 3302 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3303 |
|
switch(*eptr++) |
| 3304 |
|
{ |
| 3305 |
|
default: RRETURN(MATCH_NOMATCH); |
| 3306 |
|
case 0x09: /* HT */ |
| 3307 |
|
case 0x20: /* SPACE */ |
| 3308 |
|
case 0xa0: /* NBSP */ |
| 3309 |
|
break; |
| 3310 |
|
} |
| 3311 |
|
} |
| 3312 |
|
break; |
| 3313 |
|
|
| 3314 |
|
case OP_NOT_VSPACE: |
| 3315 |
|
for (i = 1; i <= min; i++) |
| 3316 |
|
{ |
| 3317 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3318 |
|
switch(*eptr++) |
| 3319 |
|
{ |
| 3320 |
|
default: break; |
| 3321 |
|
case 0x0a: /* LF */ |
| 3322 |
|
case 0x0b: /* VT */ |
| 3323 |
|
case 0x0c: /* FF */ |
| 3324 |
|
case 0x0d: /* CR */ |
| 3325 |
|
case 0x85: /* NEL */ |
| 3326 |
|
RRETURN(MATCH_NOMATCH); |
| 3327 |
|
} |
| 3328 |
|
} |
| 3329 |
|
break; |
| 3330 |
|
|
| 3331 |
|
case OP_VSPACE: |
| 3332 |
|
for (i = 1; i <= min; i++) |
| 3333 |
|
{ |
| 3334 |
|
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3335 |
|
switch(*eptr++) |
| 3336 |
|
{ |
| 3337 |
|
default: RRETURN(MATCH_NOMATCH); |
| 3338 |
|
case 0x0a: /* LF */ |
| 3339 |
|
case 0x0b: /* VT */ |
| 3340 |
|
case 0x0c: /* FF */ |
| 3341 |
|
case 0x0d: /* CR */ |
| 3342 |
|
case 0x85: /* NEL */ |
| 3343 |
break; |
break; |
| 3344 |
} |
} |
| 3345 |
} |
} |
| 3400 |
case PT_ANY: |
case PT_ANY: |
| 3401 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
| 3402 |
{ |
{ |
| 3403 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM36); |
| 3404 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3405 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3406 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 3411 |
case PT_LAMP: |
case PT_LAMP: |
| 3412 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
| 3413 |
{ |
{ |
| 3414 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM37); |
| 3415 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3416 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3417 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 3418 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_chartype = UCD_CHARTYPE(c); |
| 3419 |
if ((prop_chartype == ucp_Lu || |
if ((prop_chartype == ucp_Lu || |
| 3420 |
prop_chartype == ucp_Ll || |
prop_chartype == ucp_Ll || |
| 3421 |
prop_chartype == ucp_Lt) == prop_fail_result) |
prop_chartype == ucp_Lt) == prop_fail_result) |
| 3426 |
case PT_GC: |
case PT_GC: |
| 3427 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
| 3428 |
{ |
{ |
| 3429 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM38); |
| 3430 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3431 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3432 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 3433 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_category = UCD_CATEGORY(c); |
| 3434 |
if ((prop_category == prop_value) == prop_fail_result) |
if ((prop_category == prop_value) == prop_fail_result) |
| 3435 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 3436 |
} |
} |
| 3439 |
case PT_PC: |
case PT_PC: |
| 3440 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
| 3441 |
{ |
{ |
| 3442 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM39); |
| 3443 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3444 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3445 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 3446 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_chartype = UCD_CHARTYPE(c); |
| 3447 |
if ((prop_chartype == prop_value) == prop_fail_result) |
if ((prop_chartype == prop_value) == prop_fail_result) |
| 3448 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 3449 |
} |
} |
| 3452 |
case PT_SC: |
case PT_SC: |
| 3453 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
| 3454 |
{ |
{ |
| 3455 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM40); |
| 3456 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3457 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3458 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 3459 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_script = UCD_SCRIPT(c); |
| 3460 |
if ((prop_script == prop_value) == prop_fail_result) |
if ((prop_script == prop_value) == prop_fail_result) |
| 3461 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 3462 |
} |
} |
| 3474 |
{ |
{ |
| 3475 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
| 3476 |
{ |
{ |
| 3477 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM41); |
| 3478 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3479 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
| 3480 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 3481 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_category = UCD_CATEGORY(c); |
| 3482 |
if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH); |
if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH); |
| 3483 |
while (eptr < md->end_subject) |
while (eptr < md->end_subject) |
| 3484 |
{ |
{ |
| 3487 |
{ |
{ |
| 3488 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 3489 |
} |
} |
| 3490 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_category = UCD_CATEGORY(c); |
| 3491 |
if (prop_category != ucp_M) break; |
if (prop_category != ucp_M) break; |
| 3492 |
eptr += len; |
eptr += len; |
| 3493 |
} |
} |
| 3503 |
{ |
{ |
| 3504 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
| 3505 |
{ |
{ |
| 3506 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM42); |
| 3507 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3508 |
if (fi >= max || eptr >= md->end_subject || |
if (fi >= max || eptr >= md->end_subject || |
| 3509 |
(ctype == OP_ANY && (ims & PCRE_DOTALL) == 0 && |
(ctype == OP_ANY && IS_NEWLINE(eptr))) |
|
IS_NEWLINE(eptr))) |
|
| 3510 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 3511 |
|
|
| 3512 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 3513 |
switch(ctype) |
switch(ctype) |
| 3514 |
{ |
{ |
| 3515 |
case OP_ANY: /* This is the DOTALL case */ |
case OP_ANY: /* This is the non-NL case */ |
| 3516 |
break; |
case OP_ALLANY: |
|
|
|
| 3517 |
case OP_ANYBYTE: |
case OP_ANYBYTE: |
| 3518 |
break; |
break; |
| 3519 |
|
|
| 3525 |
if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 3526 |
break; |
break; |
| 3527 |
case 0x000a: |
case 0x000a: |
| 3528 |
|
break; |
| 3529 |
|
|
| 3530 |
case 0x000b: |
case 0x000b: |
| 3531 |
case 0x000c: |
case 0x000c: |
| 3532 |
case 0x0085: |
case 0x0085: |
| 3533 |
case 0x2028: |
case 0x2028: |
| 3534 |
case 0x2029: |
case 0x2029: |
| 3535 |
|
if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); |
| 3536 |
|
break; |
| 3537 |
|
} |
| 3538 |
|
break; |
| 3539 |
|
|
| 3540 |
|
case OP_NOT_HSPACE: |
| 3541 |
|
switch(c) |
| 3542 |
|
{ |
| 3543 |
|
default: break; |
| 3544 |
|
case 0x09: /* HT */ |
| 3545 |
|
case 0x20: /* SPACE */ |
| 3546 |
|
case 0xa0: /* NBSP */ |
| 3547 |
|
case 0x1680: /* OGHAM SPACE MARK */ |
| 3548 |
|
case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ |
| 3549 |
|
case 0x2000: /* EN QUAD */ |
| 3550 |
|
case 0x2001: /* EM QUAD */ |
| 3551 |
|
case 0x2002: /* EN SPACE */ |
| 3552 |
|
case 0x2003: /* EM SPACE */ |
| 3553 |
|
case 0x2004: /* THREE-PER-EM SPACE */ |
| 3554 |
|
case 0x2005: /* FOUR-PER-EM SPACE */ |
| 3555 |
|
case 0x2006: /* SIX-PER-EM SPACE */ |
| 3556 |
|
case 0x2007: /* FIGURE SPACE */ |
| 3557 |
|
case 0x2008: /* PUNCTUATION SPACE */ |
| 3558 |
|
case 0x2009: /* THIN SPACE */ |
| 3559 |
|
case 0x200A: /* HAIR SPACE */ |
| 3560 |
|
case 0x202f: /* NARROW NO-BREAK SPACE */ |
| 3561 |
|
case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ |
| 3562 |
|
case 0x3000: /* IDEOGRAPHIC SPACE */ |
| 3563 |
|
RRETURN(MATCH_NOMATCH); |
| 3564 |
|
} |
| 3565 |
|
break; |
| 3566 |
|
|
| 3567 |
|
case OP_HSPACE: |
| 3568 |
|
switch(c) |
| 3569 |
|
{ |
| 3570 |
|
default: RRETURN(MATCH_NOMATCH); |
| 3571 |
|
case 0x09: /* HT */ |
| 3572 |
|
case 0x20: /* SPACE */ |
| 3573 |
|
case 0xa0: /* NBSP */ |
| 3574 |
|
case 0x1680: /* OGHAM SPACE MARK */ |
| 3575 |
|
case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ |
| 3576 |
|
case 0x2000: /* EN QUAD */ |
| 3577 |
|
case 0x2001: /* EM QUAD */ |
| 3578 |
|
case 0x2002: /* EN SPACE */ |
| 3579 |
|
case 0x2003: /* EM SPACE */ |
| 3580 |
|
case 0x2004: /* THREE-PER-EM SPACE */ |
| 3581 |
|
case 0x2005: /* FOUR-PER-EM SPACE */ |
| 3582 |
|
case 0x2006: /* SIX-PER-EM SPACE */ |
| 3583 |
|
case 0x2007: /* FIGURE SPACE */ |
| 3584 |
|
case 0x2008: /* PUNCTUATION SPACE */ |
| 3585 |
|
case 0x2009: /* THIN SPACE */ |
| 3586 |
|
case 0x200A: /* HAIR SPACE */ |
| 3587 |
|
case 0x202f: /* NARROW NO-BREAK SPACE */ |
| 3588 |
|
case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ |
| 3589 |
|
case 0x3000: /* IDEOGRAPHIC SPACE */ |
| 3590 |
|
break; |
| 3591 |
|
} |
| 3592 |
|
break; |
| 3593 |
|
|
| 3594 |
|
case OP_NOT_VSPACE: |
| 3595 |
|
switch(c) |
| 3596 |
|
{ |
| 3597 |
|
default: break; |
| 3598 |
|
case 0x0a: /* LF */ |
| 3599 |
|
case 0x0b: /* VT */ |
| 3600 |
|
case 0x0c: /* FF */ |
| 3601 |
|
case 0x0d: /* CR */ |
| 3602 |
|
case 0x85: /* NEL */ |
| 3603 |
|
case 0x2028: /* LINE SEPARATOR */ |
| 3604 |
|
case 0x2029: /* PARAGRAPH SEPARATOR */ |
| 3605 |
|
RRETURN(MATCH_NOMATCH); |
| 3606 |
|
} |
| 3607 |
|
break; |
| 3608 |
|
|
| 3609 |
|
case OP_VSPACE: |
| 3610 |
|
switch(c) |
| 3611 |
|
{ |
| 3612 |
|
default: RRETURN(MATCH_NOMATCH); |
| 3613 |
|
case 0x0a: /* LF */ |
| 3614 |
|
case 0x0b: /* VT */ |
| 3615 |
|
case 0x0c: /* FF */ |
| 3616 |
|
case 0x0d: /* CR */ |
| 3617 |
|
case 0x85: /* NEL */ |
| 3618 |
|
case 0x2028: /* LINE SEPARATOR */ |
| 3619 |
|
case 0x2029: /* PARAGRAPH SEPARATOR */ |
| 3620 |
break; |
break; |
| 3621 |
} |
} |
| 3622 |
break; |
break; |
| 3662 |
{ |
{ |
| 3663 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
| 3664 |
{ |
{ |
| 3665 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM43); |
| 3666 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3667 |
if (fi >= max || eptr >= md->end_subject || |
if (fi >= max || eptr >= md->end_subject || |
| 3668 |
((ims & PCRE_DOTALL) == 0 && IS_NEWLINE(eptr))) |
(ctype == OP_ANY && IS_NEWLINE(eptr))) |
| 3669 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 3670 |
|
|
| 3671 |
c = *eptr++; |
c = *eptr++; |
| 3672 |
switch(ctype) |
switch(ctype) |
| 3673 |
{ |
{ |
| 3674 |
case OP_ANY: /* This is the DOTALL case */ |
case OP_ANY: /* This is the non-NL case */ |
| 3675 |
break; |
case OP_ALLANY: |
|
|
|
| 3676 |
case OP_ANYBYTE: |
case OP_ANYBYTE: |
| 3677 |
break; |
break; |
| 3678 |
|
|
| 3683 |
case 0x000d: |
case 0x000d: |
| 3684 |
if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 3685 |
break; |
break; |
| 3686 |
|
|
| 3687 |
case 0x000a: |
case 0x000a: |
| 3688 |
|
break; |
| 3689 |
|
|
| 3690 |
case 0x000b: |
case 0x000b: |
| 3691 |
case 0x000c: |
case 0x000c: |
| 3692 |
case 0x0085: |
case 0x0085: |
| 3693 |
|
if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); |
| 3694 |
|
break; |
| 3695 |
|
} |
| 3696 |
|
break; |
| 3697 |
|
|
| 3698 |
|
case OP_NOT_HSPACE: |
| 3699 |
|
switch(c) |
| 3700 |
|
{ |
| 3701 |
|
default: break; |
| 3702 |
|
case 0x09: /* HT */ |
| 3703 |
|
case 0x20: /* SPACE */ |
| 3704 |
|
case 0xa0: /* NBSP */ |
| 3705 |
|
RRETURN(MATCH_NOMATCH); |
| 3706 |
|
} |
| 3707 |
|
break; |
| 3708 |
|
|
| 3709 |
|
case OP_HSPACE: |
| 3710 |
|
switch(c) |
| 3711 |
|
{ |
| 3712 |
|
default: RRETURN(MATCH_NOMATCH); |
| 3713 |
|
case 0x09: /* HT */ |
| 3714 |
|
case 0x20: /* SPACE */ |
| 3715 |
|
case 0xa0: /* NBSP */ |
| 3716 |
|
break; |
| 3717 |
|
} |
| 3718 |
|
break; |
| 3719 |
|
|
| 3720 |
|
case OP_NOT_VSPACE: |
| 3721 |
|
switch(c) |
| 3722 |
|
{ |
| 3723 |
|
default: break; |
| 3724 |
|
case 0x0a: /* LF */ |
| 3725 |
|
case 0x0b: /* VT */ |
| 3726 |
|
case 0x0c: /* FF */ |
| 3727 |
|
case 0x0d: /* CR */ |
| 3728 |
|
case 0x85: /* NEL */ |
| 3729 |
|
RRETURN(MATCH_NOMATCH); |
| 3730 |
|
} |
| 3731 |
|
break; |
| 3732 |
|
|
| 3733 |
|
case OP_VSPACE: |
| 3734 |
|
switch(c) |
| 3735 |
|
{ |
| 3736 |
|
default: RRETURN(MATCH_NOMATCH); |
| 3737 |
|
case 0x0a: /* LF */ |
| 3738 |
|
case 0x0b: /* VT */ |
| 3739 |
|
case 0x0c: /* FF */ |
| 3740 |
|
case 0x0d: /* CR */ |
| 3741 |
|
case 0x85: /* NEL */ |
| 3742 |
break; |
break; |
| 3743 |
} |
} |
| 3744 |
break; |
break; |
| 3805 |
int len = 1; |
int len = 1; |
| 3806 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) break; |
| 3807 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 3808 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_chartype = UCD_CHARTYPE(c); |
| 3809 |
if ((prop_chartype == ucp_Lu || |
if ((prop_chartype == ucp_Lu || |
| 3810 |
prop_chartype == ucp_Ll || |
prop_chartype == ucp_Ll || |
| 3811 |
prop_chartype == ucp_Lt) == prop_fail_result) |
prop_chartype == ucp_Lt) == prop_fail_result) |
| 3820 |
int len = 1; |
int len = 1; |
| 3821 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) break; |
| 3822 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 3823 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_category = UCD_CATEGORY(c); |
| 3824 |
if ((prop_category == prop_value) == prop_fail_result) |
if ((prop_category == prop_value) == prop_fail_result) |
| 3825 |
break; |
break; |
| 3826 |
eptr+= len; |
eptr+= len; |
| 3833 |
int len = 1; |
int len = 1; |
| 3834 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) break; |
| 3835 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 3836 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_chartype = UCD_CHARTYPE(c); |
| 3837 |
if ((prop_chartype == prop_value) == prop_fail_result) |
if ((prop_chartype == prop_value) == prop_fail_result) |
| 3838 |
break; |
break; |
| 3839 |
eptr+= len; |
eptr+= len; |
| 3846 |
int len = 1; |
int len = 1; |
| 3847 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) break; |
| 3848 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 3849 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_script = UCD_SCRIPT(c); |
| 3850 |
if ((prop_script == prop_value) == prop_fail_result) |
if ((prop_script == prop_value) == prop_fail_result) |
| 3851 |
break; |
break; |
| 3852 |
eptr+= len; |
eptr+= len; |
| 3859 |
if (possessive) continue; |
if (possessive) continue; |
| 3860 |
for(;;) |
for(;;) |
| 3861 |
{ |
{ |
| 3862 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM44); |
| 3863 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3864 |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 3865 |
BACKCHAR(eptr); |
if (utf8) BACKCHAR(eptr); |
| 3866 |
} |
} |
| 3867 |
} |
} |
| 3868 |
|
|
| 3875 |
{ |
{ |
| 3876 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) break; |
| 3877 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 3878 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_category = UCD_CATEGORY(c); |
| 3879 |
if (prop_category == ucp_M) break; |
if (prop_category == ucp_M) break; |
| 3880 |
while (eptr < md->end_subject) |
while (eptr < md->end_subject) |
| 3881 |
{ |
{ |
| 3884 |
{ |
{ |
| 3885 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 3886 |
} |
} |
| 3887 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_category = UCD_CATEGORY(c); |
| 3888 |
if (prop_category != ucp_M) break; |
if (prop_category != ucp_M) break; |
| 3889 |
eptr += len; |
eptr += len; |
| 3890 |
} |
} |
| 3895 |
if (possessive) continue; |
if (possessive) continue; |
| 3896 |
for(;;) |
for(;;) |
| 3897 |
{ |
{ |
| 3898 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM45); |
| 3899 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3900 |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 3901 |
for (;;) /* Move back over one extended */ |
for (;;) /* Move back over one extended */ |
| 3902 |
{ |
{ |
| 3903 |
int len = 1; |
int len = 1; |
|
BACKCHAR(eptr); |
|
| 3904 |
if (!utf8) c = *eptr; else |
if (!utf8) c = *eptr; else |
| 3905 |
{ |
{ |
| 3906 |
|
BACKCHAR(eptr); |
| 3907 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 3908 |
} |
} |
| 3909 |
prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); |
prop_category = UCD_CATEGORY(c); |
| 3910 |
if (prop_category != ucp_M) break; |
if (prop_category != ucp_M) break; |
| 3911 |
eptr--; |
eptr--; |
| 3912 |
} |
} |
| 3924 |
switch(ctype) |
switch(ctype) |
| 3925 |
{ |
{ |
| 3926 |
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. */ |
|
|
|
|
| 3927 |
if (max < INT_MAX) |
if (max < INT_MAX) |
| 3928 |
{ |
{ |
| 3929 |
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 |
|
| 3930 |
{ |
{ |
| 3931 |
for (i = min; i < max; i++) |
if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break; |
| 3932 |
{ |
eptr++; |
| 3933 |
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++; |
|
|
} |
|
| 3934 |
} |
} |
| 3935 |
} |
} |
| 3936 |
|
|
| 3938 |
|
|
| 3939 |
else |
else |
| 3940 |
{ |
{ |
| 3941 |
if ((ims & PCRE_DOTALL) == 0) |
for (i = min; i < max; i++) |
| 3942 |
{ |
{ |
| 3943 |
for (i = min; i < max; i++) |
if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break; |
| 3944 |
{ |
eptr++; |
| 3945 |
if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break; |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
|
eptr++; |
|
|
} |
|
|
break; |
|
| 3946 |
} |
} |
| 3947 |
else |
} |
| 3948 |
|
break; |
| 3949 |
|
|
| 3950 |
|
case OP_ALLANY: |
| 3951 |
|
if (max < INT_MAX) |
| 3952 |
|
{ |
| 3953 |
|
for (i = min; i < max; i++) |
| 3954 |
{ |
{ |
| 3955 |
c = max - min; |
if (eptr >= md->end_subject) break; |
| 3956 |
if (c > (unsigned int)(md->end_subject - eptr)) |
eptr++; |
| 3957 |
c = md->end_subject - eptr; |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
|
eptr += c; |
|
| 3958 |
} |
} |
| 3959 |
} |
} |
| 3960 |
|
else eptr = md->end_subject; /* Unlimited UTF-8 repeat */ |
| 3961 |
break; |
break; |
| 3962 |
|
|
| 3963 |
/* The byte case is the same as non-UTF8 */ |
/* The byte case is the same as non-UTF8 */ |
| 3982 |
} |
} |
| 3983 |
else |
else |
| 3984 |
{ |
{ |
| 3985 |
if (c != 0x000a && c != 0x000b && c != 0x000c && |
if (c != 0x000a && |
| 3986 |
c != 0x0085 && c != 0x2028 && c != 0x2029) |
(md->bsr_anycrlf || |
| 3987 |
|
(c != 0x000b && c != 0x000c && |
| 3988 |
|
c != 0x0085 && c != 0x2028 && c != 0x2029))) |
| 3989 |
break; |
break; |
| 3990 |
eptr += len; |
eptr += len; |
| 3991 |
} |
} |
| 3992 |
} |
} |
| 3993 |
break; |
break; |
| 3994 |
|
|
| 3995 |
|
case OP_NOT_HSPACE: |
| 3996 |
|
case OP_HSPACE: |
| 3997 |
|
for (i = min; i < max; i++) |
| 3998 |
|
{ |
| 3999 |
|
BOOL gotspace; |
| 4000 |
|
int len = 1; |
| 4001 |
|
if (eptr >= md->end_subject) break; |
| 4002 |
|
GETCHARLEN(c, eptr, len); |
| 4003 |
|
switch(c) |
| 4004 |
|
{ |
| 4005 |
|
default: gotspace = FALSE; break; |
| 4006 |
|
case 0x09: /* HT */ |
| 4007 |
|
case 0x20: /* SPACE */ |
| 4008 |
|
case 0xa0: /* NBSP */ |
| 4009 |
|
case 0x1680: /* OGHAM SPACE MARK */ |
| 4010 |
|
case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ |
| 4011 |
|
case 0x2000: /* EN QUAD */ |
| 4012 |
|
case 0x2001: /* EM QUAD */ |
| 4013 |
|
case 0x2002: /* EN SPACE */ |
| 4014 |
|
case 0x2003: /* EM SPACE */ |
| 4015 |
|
case 0x2004: /* THREE-PER-EM SPACE */ |
| 4016 |
|
case 0x2005: /* FOUR-PER-EM SPACE */ |
| 4017 |
|
case 0x2006: /* SIX-PER-EM SPACE */ |
| 4018 |
|
case 0x2007: /* FIGURE SPACE */ |
| 4019 |
|
case 0x2008: /* PUNCTUATION SPACE */ |
| 4020 |
|
case 0x2009: /* THIN SPACE */ |
| 4021 |
|
case 0x200A: /* HAIR SPACE */ |
| 4022 |
|
case 0x202f: /* NARROW NO-BREAK SPACE */ |
| 4023 |
|
case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ |
| 4024 |
|
case 0x3000: /* IDEOGRAPHIC SPACE */ |
| 4025 |
|
gotspace = TRUE; |
| 4026 |
|
break; |
| 4027 |
|
} |
| 4028 |
|
if (gotspace == (ctype == OP_NOT_HSPACE)) break; |
| 4029 |
|
eptr += len; |
| 4030 |
|
} |
| 4031 |
|
break; |
| 4032 |
|
|
| 4033 |
|
case OP_NOT_VSPACE: |
| 4034 |
|
case OP_VSPACE: |
| 4035 |
|
for (i = min; i < max; i++) |
| 4036 |
|
{ |
| 4037 |
|
BOOL gotspace; |
| 4038 |
|
int len = 1; |
| 4039 |
|
if (eptr >= md->end_subject) break; |
| 4040 |
|
GETCHARLEN(c, eptr, len); |
| 4041 |
|
switch(c) |
| 4042 |
|
{ |
| 4043 |
|
default: gotspace = FALSE; break; |
| 4044 |
|
case 0x0a: /* LF */ |
| 4045 |
|
case 0x0b: /* VT */ |
| 4046 |
|
case 0x0c: /* FF */ |
| 4047 |
|
case 0x0d: /* CR */ |
| 4048 |
|
case 0x85: /* NEL */ |
| 4049 |
|
case 0x2028: /* LINE SEPARATOR */ |
| 4050 |
|
case 0x2029: /* PARAGRAPH SEPARATOR */ |
| 4051 |
|
gotspace = TRUE; |
| 4052 |
|
break; |
| 4053 |
|
} |
| 4054 |
|
if (gotspace == (ctype == OP_NOT_VSPACE)) break; |
| 4055 |
|
eptr += len; |
| 4056 |
|
} |
| 4057 |
|
break; |
| 4058 |
|
|
| 4059 |
case OP_NOT_DIGIT: |
case OP_NOT_DIGIT: |
| 4060 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4061 |
{ |
{ |
| 4131 |
if (possessive) continue; |
if (possessive) continue; |
| 4132 |
for(;;) |
for(;;) |
| 4133 |
{ |
{ |
| 4134 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM46); |
| 4135 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4136 |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 4137 |
BACKCHAR(eptr); |
BACKCHAR(eptr); |
| 4138 |
} |
} |
| 4139 |
} |
} |
| 4140 |
else |
else |
| 4141 |
#endif |
#endif /* SUPPORT_UTF8 */ |
| 4142 |
|
|
| 4143 |
/* Not UTF-8 mode */ |
/* Not UTF-8 mode */ |
| 4144 |
{ |
{ |
| 4145 |
switch(ctype) |
switch(ctype) |
| 4146 |
{ |
{ |
| 4147 |
case OP_ANY: |
case OP_ANY: |
| 4148 |
if ((ims & PCRE_DOTALL) == 0) |
for (i = min; i < max; i++) |
| 4149 |
{ |
{ |
| 4150 |
for (i = min; i < max; i++) |
if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break; |
| 4151 |
{ |
eptr++; |
|
if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break; |
|
|
eptr++; |
|
|
} |
|
|
break; |
|
| 4152 |
} |
} |
| 4153 |
/* For DOTALL case, fall through and treat as \C */ |
break; |
| 4154 |
|
|
| 4155 |
|
case OP_ALLANY: |
| 4156 |
case OP_ANYBYTE: |
case OP_ANYBYTE: |
| 4157 |
c = max - min; |
c = max - min; |
| 4158 |
if (c > (unsigned int)(md->end_subject - eptr)) |
if (c > (unsigned int)(md->end_subject - eptr)) |
| 4172 |
} |
} |
| 4173 |
else |
else |
| 4174 |
{ |
{ |
| 4175 |
if (c != 0x000a && c != 0x000b && c != 0x000c && c != 0x0085) |
if (c != 0x000a && |
| 4176 |
|
(md->bsr_anycrlf || |
| 4177 |
|
(c != 0x000b && c != 0x000c && c != 0x0085))) |
| 4178 |
break; |
break; |
| 4179 |
eptr++; |
eptr++; |
| 4180 |
} |
} |
| 4181 |
} |
} |
| 4182 |
break; |
break; |
| 4183 |
|
|
| 4184 |
|
case OP_NOT_HSPACE: |
| 4185 |
|
for (i = min; i < max; i++) |
| 4186 |
|
{ |
| 4187 |
|
if (eptr >= md->end_subject) break; |
| 4188 |
|
c = *eptr; |
| 4189 |
|
if (c == 0x09 || c == 0x20 || c == 0xa0) break; |
| 4190 |
|
eptr++; |
| 4191 |
|
} |
| 4192 |
|
break; |
| 4193 |
|
|
| 4194 |
|
case OP_HSPACE: |
| 4195 |
|
for (i = min; i < max; i++) |
| 4196 |
|
{ |
| 4197 |
|
if (eptr >= md->end_subject) break; |
| 4198 |
|
c = *eptr; |
| 4199 |
|
if (c != 0x09 && c != 0x20 && c != 0xa0) break; |
| 4200 |
|
eptr++; |
| 4201 |
|
} |
| 4202 |
|
break; |
| 4203 |
|
|
| 4204 |
|
case OP_NOT_VSPACE: |
| 4205 |
|
for (i = min; i < max; i++) |
| 4206 |
|
{ |
| 4207 |
|
if (eptr >= md->end_subject) break; |
| 4208 |
|
c = *eptr; |
| 4209 |
|
if (c == 0x0a || c == 0x0b || c == 0x0c || c == 0x0d || c == 0x85) |
| 4210 |
|
break; |
| 4211 |
|
eptr++; |
| 4212 |
|
} |
| 4213 |
|
break; |
| 4214 |
|
|
| 4215 |
|
case OP_VSPACE: |
| 4216 |
|
for (i = min; i < max; i++) |
| 4217 |
|
{ |
| 4218 |
|
if (eptr >= md->end_subject) break; |
| 4219 |
|
c = *eptr; |
| 4220 |
|
if (c != 0x0a && c != 0x0b && c != 0x0c && c != 0x0d && c != 0x85) |
| 4221 |
|
break; |
| 4222 |
|
eptr++; |
| 4223 |
|
} |
| 4224 |
|
break; |
| 4225 |
|
|
| 4226 |
case OP_NOT_DIGIT: |
case OP_NOT_DIGIT: |
| 4227 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4228 |
{ |
{ |
| 4286 |
if (possessive) continue; |
if (possessive) continue; |
| 4287 |
while (eptr >= pp) |
while (eptr >= pp) |
| 4288 |
{ |
{ |
| 4289 |
RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM47); |
| 4290 |
eptr--; |
eptr--; |
| 4291 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4292 |
} |
} |
| 4312 |
|
|
| 4313 |
} /* End of main loop */ |
} /* End of main loop */ |
| 4314 |
/* Control never reaches here */ |
/* Control never reaches here */ |
| 4315 |
|
|
| 4316 |
|
|
| 4317 |
|
/* When compiling to use the heap rather than the stack for recursive calls to |
| 4318 |
|
match(), the RRETURN() macro jumps here. The number that is saved in |
| 4319 |
|
frame->Xwhere indicates which label we actually want to return to. */ |
| 4320 |
|
|
| 4321 |
|
#ifdef NO_RECURSE |
| 4322 |
|
#define LBL(val) case val: goto L_RM##val; |
| 4323 |
|
HEAP_RETURN: |
| 4324 |
|
switch (frame->Xwhere) |
| 4325 |
|
{ |
| 4326 |
|
LBL( 1) LBL( 2) LBL( 3) LBL( 4) LBL( 5) LBL( 6) LBL( 7) LBL( 8) |
| 4327 |
|
LBL( 9) LBL(10) LBL(11) LBL(12) LBL(13) LBL(14) LBL(15) LBL(17) |
| 4328 |
|
LBL(19) LBL(24) LBL(25) LBL(26) LBL(27) LBL(29) LBL(31) LBL(33) |
| 4329 |
|
LBL(35) LBL(43) LBL(47) LBL(48) LBL(49) LBL(50) LBL(51) LBL(52) |
| 4330 |
|
LBL(53) LBL(54) |
| 4331 |
|
#ifdef SUPPORT_UTF8 |
| 4332 |
|
LBL(16) LBL(18) LBL(20) LBL(21) LBL(22) LBL(23) LBL(28) LBL(30) |
| 4333 |
|
LBL(32) LBL(34) LBL(42) LBL(46) |
| 4334 |
|
#ifdef SUPPORT_UCP |
| 4335 |
|
LBL(36) LBL(37) LBL(38) LBL(39) LBL(40) LBL(41) LBL(44) LBL(45) |
| 4336 |
|
#endif /* SUPPORT_UCP */ |
| 4337 |
|
#endif /* SUPPORT_UTF8 */ |
| 4338 |
|
default: |
| 4339 |
|
DPRINTF(("jump error in pcre match: label %d non-existent\n", frame->Xwhere)); |
| 4340 |
|
return PCRE_ERROR_INTERNAL; |
| 4341 |
|
} |
| 4342 |
|
#undef LBL |
| 4343 |
|
#endif /* NO_RECURSE */ |
| 4344 |
} |
} |
| 4345 |
|
|
| 4346 |
|
|
| 4353 |
#ifdef NO_RECURSE |
#ifdef NO_RECURSE |
| 4354 |
#undef eptr |
#undef eptr |
| 4355 |
#undef ecode |
#undef ecode |
| 4356 |
|
#undef mstart |
| 4357 |
#undef offset_top |
#undef offset_top |
| 4358 |
#undef ims |
#undef ims |
| 4359 |
#undef eptrb |
#undef eptrb |
| 4426 |
< -1 => some kind of unexpected problem |
< -1 => some kind of unexpected problem |
| 4427 |
*/ |
*/ |
| 4428 |
|
|
| 4429 |
PCRE_DATA_SCOPE int |
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION |
| 4430 |
pcre_exec(const pcre *argument_re, const pcre_extra *extra_data, |
pcre_exec(const pcre *argument_re, const pcre_extra *extra_data, |
| 4431 |
PCRE_SPTR subject, int length, int start_offset, int options, int *offsets, |
PCRE_SPTR subject, int length, int start_offset, int options, int *offsets, |
| 4432 |
int offsetcount) |
int offsetcount) |
| 4451 |
USPTR start_match = (USPTR)subject + start_offset; |
USPTR start_match = (USPTR)subject + start_offset; |
| 4452 |
USPTR end_subject; |
USPTR end_subject; |
| 4453 |
USPTR req_byte_ptr = start_match - 1; |
USPTR req_byte_ptr = start_match - 1; |
|
eptrblock eptrchain[EPTR_WORK_SIZE]; |
|
| 4454 |
|
|
| 4455 |
pcre_study_data internal_study; |
pcre_study_data internal_study; |
| 4456 |
const pcre_study_data *study; |
const pcre_study_data *study; |
| 4513 |
/* Set up other data */ |
/* Set up other data */ |
| 4514 |
|
|
| 4515 |
anchored = ((re->options | options) & PCRE_ANCHORED) != 0; |
anchored = ((re->options | options) & PCRE_ANCHORED) != 0; |
| 4516 |
startline = (re->options & PCRE_STARTLINE) != 0; |
startline = (re->flags & PCRE_STARTLINE) != 0; |
| 4517 |
firstline = (re->options & PCRE_FIRSTLINE) != 0; |
firstline = (re->options & PCRE_FIRSTLINE) != 0; |
| 4518 |
|
|
| 4519 |
/* 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. */ |
| 4528 |
|
|
| 4529 |
md->endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0; |
md->endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0; |
| 4530 |
utf8 = md->utf8 = (re->options & PCRE_UTF8) != 0; |
utf8 = md->utf8 = (re->options & PCRE_UTF8) != 0; |
| 4531 |
|
md->jscript_compat = (re->options & PCRE_JAVASCRIPT_COMPAT) != 0; |
| 4532 |
|
|
| 4533 |
md->notbol = (options & PCRE_NOTBOL) != 0; |
md->notbol = (options & PCRE_NOTBOL) != 0; |
| 4534 |
md->noteol = (options & PCRE_NOTEOL) != 0; |
md->noteol = (options & PCRE_NOTEOL) != 0; |
| 4537 |
md->hitend = FALSE; |
md->hitend = FALSE; |
| 4538 |
|
|
| 4539 |
md->recursive = NULL; /* No recursion at top level */ |
md->recursive = NULL; /* No recursion at top level */ |
|
md->eptrchain = eptrchain; /* Make workspace generally available */ |
|
| 4540 |
|
|
| 4541 |
md->lcc = tables + lcc_offset; |
md->lcc = tables + lcc_offset; |
| 4542 |
md->ctypes = tables + ctypes_offset; |
md->ctypes = tables + ctypes_offset; |
| 4543 |
|
|
| 4544 |
|
/* Handle different \R options. */ |
| 4545 |
|
|
| 4546 |
|
switch (options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) |
| 4547 |
|
{ |
| 4548 |
|
case 0: |
| 4549 |
|
if ((re->options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) != 0) |
| 4550 |
|
md->bsr_anycrlf = (re->options & PCRE_BSR_ANYCRLF) != 0; |
| 4551 |
|
else |
| 4552 |
|
#ifdef BSR_ANYCRLF |
| 4553 |
|
md->bsr_anycrlf = TRUE; |
| 4554 |
|
#else |
| 4555 |
|
md->bsr_anycrlf = FALSE; |
| 4556 |
|
#endif |
| 4557 |
|
break; |
| 4558 |
|
|
| 4559 |
|
case PCRE_BSR_ANYCRLF: |
| 4560 |
|
md->bsr_anycrlf = TRUE; |
| 4561 |
|
break; |
| 4562 |
|
|
| 4563 |
|
case PCRE_BSR_UNICODE: |
| 4564 |
|
md->bsr_anycrlf = FALSE; |
| 4565 |
|
break; |
| 4566 |
|
|
| 4567 |
|
default: return PCRE_ERROR_BADNEWLINE; |
| 4568 |
|
} |
| 4569 |
|
|
| 4570 |
/* Handle different types of newline. The three bits give eight cases. If |
/* Handle different types of newline. The three bits give eight cases. If |
| 4571 |
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. */ |
| 4572 |
|
|
| 4573 |
switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options : options) & |
switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options : |
| 4574 |
PCRE_NEWLINE_BITS) |
(pcre_uint32)options) & PCRE_NEWLINE_BITS) |
| 4575 |
{ |
{ |
| 4576 |
case 0: newline = NEWLINE; break; /* Compile-time default */ |
case 0: newline = NEWLINE; break; /* Compile-time default */ |
| 4577 |
case PCRE_NEWLINE_CR: newline = '\r'; break; |
case PCRE_NEWLINE_CR: newline = CHAR_CR; break; |
| 4578 |
case PCRE_NEWLINE_LF: newline = '\n'; break; |
case PCRE_NEWLINE_LF: newline = CHAR_NL; break; |
| 4579 |
case PCRE_NEWLINE_CR+ |
case PCRE_NEWLINE_CR+ |
| 4580 |
PCRE_NEWLINE_LF: newline = ('\r' << 8) | '\n'; break; |
PCRE_NEWLINE_LF: newline = (CHAR_CR << 8) | CHAR_NL; break; |
| 4581 |
case PCRE_NEWLINE_ANY: newline = -1; break; |
case PCRE_NEWLINE_ANY: newline = -1; break; |
| 4582 |
|
case PCRE_NEWLINE_ANYCRLF: newline = -2; break; |
| 4583 |
default: return PCRE_ERROR_BADNEWLINE; |
default: return PCRE_ERROR_BADNEWLINE; |
| 4584 |
} |
} |
| 4585 |
|
|
| 4586 |
if (newline < 0) |
if (newline == -2) |
| 4587 |
|
{ |
| 4588 |
|
md->nltype = NLTYPE_ANYCRLF; |
| 4589 |
|
} |
| 4590 |
|
else if (newline < 0) |
| 4591 |
{ |
{ |
| 4592 |
md->nltype = NLTYPE_ANY; |
md->nltype = NLTYPE_ANY; |
| 4593 |
} |
} |
| 4610 |
/* 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 |
| 4611 |
moment. */ |
moment. */ |
| 4612 |
|
|
| 4613 |
if (md->partial && (re->options & PCRE_NOPARTIAL) != 0) |
if (md->partial && (re->flags & PCRE_NOPARTIAL) != 0) |
| 4614 |
return PCRE_ERROR_BADPARTIAL; |
return PCRE_ERROR_BADPARTIAL; |
| 4615 |
|
|
| 4616 |
/* 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 |
| 4619 |
#ifdef SUPPORT_UTF8 |
#ifdef SUPPORT_UTF8 |
| 4620 |
if (utf8 && (options & PCRE_NO_UTF8_CHECK) == 0) |
if (utf8 && (options & PCRE_NO_UTF8_CHECK) == 0) |
| 4621 |
{ |
{ |
| 4622 |
if (_pcre_valid_utf8((uschar *)subject, length) >= 0) |
if (_pcre_valid_utf8((USPTR)subject, length) >= 0) |
| 4623 |
return PCRE_ERROR_BADUTF8; |
return PCRE_ERROR_BADUTF8; |
| 4624 |
if (start_offset > 0 && start_offset < length) |
if (start_offset > 0 && start_offset < length) |
| 4625 |
{ |
{ |
| 4626 |
int tb = ((uschar *)subject)[start_offset]; |
int tb = ((USPTR)subject)[start_offset]; |
| 4627 |
if (tb > 127) |
if (tb > 127) |
| 4628 |
{ |
{ |
| 4629 |
tb &= 0xc0; |
tb &= 0xc0; |
| 4687 |
|
|
| 4688 |
if (!anchored) |
if (!anchored) |
| 4689 |
{ |
{ |
| 4690 |
if ((re->options & PCRE_FIRSTSET) != 0) |
if ((re->flags & PCRE_FIRSTSET) != 0) |
| 4691 |
{ |
{ |
| 4692 |
first_byte = re->first_byte & 255; |
first_byte = re->first_byte & 255; |
| 4693 |
if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == TRUE) |
if ((first_byte_caseless = ((re->first_byte & REQ_CASELESS) != 0)) == TRUE) |
| 4702 |
/* For anchored or unanchored matches, there may be a "last known required |
/* For anchored or unanchored matches, there may be a "last known required |
| 4703 |
character" set. */ |
character" set. */ |
| 4704 |
|
|
| 4705 |
if ((re->options & PCRE_REQCHSET) != 0) |
if ((re->flags & PCRE_REQCHSET) != 0) |
| 4706 |
{ |
{ |
| 4707 |
req_byte = re->req_byte & 255; |
req_byte = re->req_byte & 255; |
| 4708 |
req_byte_caseless = (re->req_byte & REQ_CASELESS) != 0; |
req_byte_caseless = (re->req_byte & REQ_CASELESS) != 0; |
| 4718 |
for(;;) |
for(;;) |
| 4719 |
{ |
{ |
| 4720 |
USPTR save_end_subject = end_subject; |
USPTR save_end_subject = end_subject; |
| 4721 |
|
USPTR new_start_match; |
| 4722 |
|
|
| 4723 |
/* Reset the maximum number of extractions we might see. */ |
/* Reset the maximum number of extractions we might see. */ |
| 4724 |
|
|
| 4729 |
while (iptr < iend) *iptr++ = -1; |
while (iptr < iend) *iptr++ = -1; |
| 4730 |
} |
} |
| 4731 |
|
|
| 4732 |
/* Advance to a unique first char if possible. If firstline is TRUE, the |
/* If firstline is TRUE, the start of the match is constrained to the first |
| 4733 |
start of the match is constrained to the first line of a multiline string. |
line of a multiline string. That is, the match must be before or at the first |
| 4734 |
That is, the match must be before or at the first newline. Implement this by |
newline. Implement this by temporarily adjusting end_subject so that we stop |
| 4735 |
temporarily adjusting end_subject so that we stop scanning at a newline. If |
scanning at a newline. If the match fails at the newline, later code breaks |
| 4736 |
the match fails at the newline, later code breaks this loop. */ |
this loop. */ |
| 4737 |
|
|
| 4738 |
if (firstline) |
if (firstline) |
| 4739 |
{ |
{ |
| 4740 |
USPTR t = start_match; |
USPTR t = start_match; |
| 4741 |
|
#ifdef SUPPORT_UTF8 |
| 4742 |
|
if (utf8) |
| 4743 |
|
{ |
| 4744 |
|
while (t < md->end_subject && !IS_NEWLINE(t)) |
| 4745 |
|
{ |
| 4746 |
|
t++; |
| 4747 |
|
while (t < end_subject && (*t & 0xc0) == 0x80) t++; |
| 4748 |
|
} |
| 4749 |
|
} |
| 4750 |
|
else |
| 4751 |
|
#endif |
| 4752 |
while (t < md->end_subject && !IS_NEWLINE(t)) t++; |
while (t < md->end_subject && !IS_NEWLINE(t)) t++; |
| 4753 |
end_subject = t; |
end_subject = t; |
| 4754 |
} |
} |
| 4755 |
|
|
| 4756 |
/* Now test for a unique first byte */ |
/* There are some optimizations that avoid running the match if a known |
| 4757 |
|
starting point is not found, or if a known later character is not present. |
| 4758 |
|
However, there is an option that disables these, for testing and for ensuring |
| 4759 |
|
that all callouts do actually occur. */ |
| 4760 |
|
|
| 4761 |
if (first_byte >= 0) |
if ((options & PCRE_NO_START_OPTIMIZE) == 0) |
| 4762 |
{ |
{ |
| 4763 |
if (first_byte_caseless) |
/* Advance to a unique first byte if there is one. */ |
| 4764 |
while (start_match < end_subject && |
|
| 4765 |
md->lcc[*start_match] != first_byte) |
if (first_byte >= 0) |
| 4766 |
start_match++; |
{ |
| 4767 |
else |
if (first_byte_caseless) |
| 4768 |
while (start_match < end_subject && *start_match != first_byte) |
while (start_match < end_subject && md->lcc[*start_match] != first_byte) |
| 4769 |
start_match++; |
start_match++; |
| 4770 |
} |
else |
| 4771 |
|
while (start_match < end_subject && *start_match != first_byte) |
| 4772 |
|
start_match++; |
| 4773 |
|
} |
| 4774 |
|
|
| 4775 |
/* Or to just after a linebreak for a multiline match if possible */ |
/* Or to just after a linebreak for a multiline match */ |
| 4776 |
|
|
| 4777 |
else if (startline) |
else if (startline) |
|
{ |
|
|
if (start_match > md->start_subject + start_offset) |
|
| 4778 |
{ |
{ |
| 4779 |
while (start_match <= end_subject && !WAS_NEWLINE(start_match)) |
if (start_match > md->start_subject + start_offset) |
| 4780 |
start_match++; |
{ |
| 4781 |
|
#ifdef SUPPORT_UTF8 |
| 4782 |
/* If we have just passed a CR and the newline option is ANY, and we are |
if (utf8) |
| 4783 |
now at a LF, advance the match position by one more character. */ |
{ |
| 4784 |
|
while (start_match < end_subject && !WAS_NEWLINE(start_match)) |
| 4785 |
if (start_match[-1] == '\r' && |
{ |
| 4786 |
md->nltype == NLTYPE_ANY && |
start_match++; |
| 4787 |
start_match < end_subject && |
while(start_match < end_subject && (*start_match & 0xc0) == 0x80) |
| 4788 |
*start_match == '\n') |
start_match++; |
| 4789 |
start_match++; |
} |
| 4790 |
|
} |
| 4791 |
|
else |
| 4792 |
|
#endif |
| 4793 |
|
while (start_match < end_subject && !WAS_NEWLINE(start_match)) |
| 4794 |
|
start_match++; |
| 4795 |
|
|
| 4796 |
|
/* If we have just passed a CR and the newline option is ANY or ANYCRLF, |
| 4797 |
|
and we are now at a LF, advance the match position by one more character. |
| 4798 |
|
*/ |
| 4799 |
|
|
| 4800 |
|
if (start_match[-1] == CHAR_CR && |
| 4801 |
|
(md->nltype == NLTYPE_ANY || md->nltype == NLTYPE_ANYCRLF) && |
| 4802 |
|
start_match < end_subject && |
| 4803 |
|
*start_match == CHAR_NL) |
| 4804 |
|
start_match++; |
| 4805 |
|
} |
| 4806 |
} |
} |
|
} |
|
| 4807 |
|
|
| 4808 |
/* Or to a non-unique first char after study */ |
/* Or to a non-unique first byte after study */ |
| 4809 |
|
|
| 4810 |
else if (start_bits != NULL) |
else if (start_bits != NULL) |
|
{ |
|
|
while (start_match < end_subject) |
|
| 4811 |
{ |
{ |
| 4812 |
register unsigned int c = *start_match; |
while (start_match < end_subject) |
| 4813 |
if ((start_bits[c/8] & (1 << (c&7))) == 0) start_match++; else break; |
{ |
| 4814 |
|
register unsigned int c = *start_match; |
| 4815 |
|
if ((start_bits[c/8] & (1 << (c&7))) == 0) start_match++; |
| 4816 |
|
else break; |
| 4817 |
|
} |
| 4818 |
} |
} |
| 4819 |
} |
} /* Starting optimizations */ |
| 4820 |
|
|
| 4821 |
/* Restore fudged end_subject */ |
/* Restore fudged end_subject */ |
| 4822 |
|
|
| 4828 |
printf("\n"); |
printf("\n"); |
| 4829 |
#endif |
#endif |
| 4830 |
|
|
| 4831 |
/* If req_byte is set, we know that that character must appear in the subject |
/* If req_byte is set, we know that that character must appear in the |
| 4832 |
for the match to succeed. If the first character is set, req_byte must be |
subject for the match to succeed. If the first character is set, req_byte |
| 4833 |
later in the subject; otherwise the test starts at the match point. This |
must be later in the subject; otherwise the test starts at the match point. |
| 4834 |
optimization can save a huge amount of backtracking in patterns with nested |
This optimization can save a huge amount of backtracking in patterns with |
| 4835 |
unlimited repeats that aren't going to match. Writing separate code for |
nested unlimited repeats that aren't going to match. Writing separate code |
| 4836 |
cased/caseless versions makes it go faster, as does using an autoincrement |
for cased/caseless versions makes it go faster, as does using an |
| 4837 |
and backing off on a match. |
autoincrement and backing off on a match. |
| 4838 |
|
|
| 4839 |
HOWEVER: when the subject string is very, very long, searching to its end can |
HOWEVER: when the subject string is very, very long, searching to its end |
| 4840 |
take a long time, and give bad performance on quite ordinary patterns. This |
can take a long time, and give bad performance on quite ordinary patterns. |
| 4841 |
showed up when somebody was matching something like /^\d+C/ on a 32-megabyte |
This showed up when somebody was matching something like /^\d+C/ on a |
| 4842 |
string... so we don't do this when the string is sufficiently long. |
32-megabyte string... so we don't do this when the string is sufficiently |
| 4843 |
|
long. |
| 4844 |
|
|
| 4845 |
ALSO: this processing is disabled when partial matching is requested. |
ALSO: this processing is disabled when partial matching is requested, or if |
| 4846 |
*/ |
disabling is explicitly requested. */ |
| 4847 |
|
|
| 4848 |
if (req_byte >= 0 && |
if ((options & PCRE_NO_START_OPTIMIZE) == 0 && |
| 4849 |
|
req_byte >= 0 && |
| 4850 |
end_subject - start_match < REQ_BYTE_MAX && |
end_subject - start_match < REQ_BYTE_MAX && |
| 4851 |
!md->partial) |
!md->partial) |
| 4852 |
{ |
{ |
| 4892 |
|
|
| 4893 |
/* OK, we can now run the match. */ |
/* OK, we can now run the match. */ |
| 4894 |
|
|
| 4895 |
md->start_match = start_match; |
md->start_match_ptr = start_match; |
| 4896 |
md->match_call_count = 0; |
md->match_call_count = 0; |
| 4897 |
md->eptrn = 0; /* Next free eptrchain slot */ |
rc = match(start_match, md->start_code, start_match, 2, md, ims, NULL, 0, 0); |
| 4898 |
rc = match(start_match, md->start_code, 2, md, ims, NULL, 0, 0); |
|
| 4899 |
|
switch(rc) |
| 4900 |
|
{ |
| 4901 |
|
/* NOMATCH and PRUNE advance by one character. THEN at this level acts |
| 4902 |
|
exactly like PRUNE. */ |
| 4903 |
|
|
| 4904 |
|
case MATCH_NOMATCH: |
| 4905 |
|
case MATCH_PRUNE: |
| 4906 |
|
case MATCH_THEN: |
| 4907 |
|
new_start_match = start_match + 1; |
| 4908 |
|
#ifdef SUPPORT_UTF8 |
| 4909 |
|
if (utf8) |
| 4910 |
|
while(new_start_match < end_subject && (*new_start_match & 0xc0) == 0x80) |
| 4911 |
|
new_start_match++; |
| 4912 |
|
#endif |
| 4913 |
|
break; |
| 4914 |
|
|
| 4915 |
|
/* SKIP passes back the next starting point explicitly. */ |
| 4916 |
|
|
| 4917 |
|
case MATCH_SKIP: |
| 4918 |
|
new_start_match = md->start_match_ptr; |
| 4919 |
|
break; |
| 4920 |
|
|
| 4921 |
|
/* COMMIT disables the bumpalong, but otherwise behaves as NOMATCH. */ |
| 4922 |
|
|
| 4923 |
/* Any return other than MATCH_NOMATCH breaks the loop. */ |
case MATCH_COMMIT: |
| 4924 |
|
rc = MATCH_NOMATCH; |
| 4925 |
|
goto ENDLOOP; |
| 4926 |
|
|
| 4927 |
if (rc != MATCH_NOMATCH) break; |
/* Any other return is some kind of error. */ |
| 4928 |
|
|
| 4929 |
|
default: |
| 4930 |
|
goto ENDLOOP; |
| 4931 |
|
} |
| 4932 |
|
|
| 4933 |
|
/* Control reaches here for the various types of "no match at this point" |
| 4934 |
|
result. Reset the code to MATCH_NOMATCH for subsequent checking. */ |
| 4935 |
|
|
| 4936 |
|
rc = MATCH_NOMATCH; |
| 4937 |
|
|
| 4938 |
/* 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 |
| 4939 |
newline in the subject (though it may continue over the newline). Therefore, |
newline in the subject (though it may continue over the newline). Therefore, |
| 4941 |
|
|
| 4942 |
if (firstline && IS_NEWLINE(start_match)) break; |
if (firstline && IS_NEWLINE(start_match)) break; |
| 4943 |
|
|
| 4944 |
/* Advance the match position by one character. */ |
/* Advance to new matching position */ |
| 4945 |
|
|
| 4946 |
start_match++; |
start_match = new_start_match; |
|
#ifdef SUPPORT_UTF8 |
|
|
if (utf8) |
|
|
while(start_match < end_subject && (*start_match & 0xc0) == 0x80) |
|
|
start_match++; |
|
|
#endif |
|
| 4947 |
|
|
| 4948 |
/* 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 |
| 4949 |
the subject. */ |
the subject. */ |
| 4950 |
|
|
| 4951 |
if (anchored || start_match > end_subject) break; |
if (anchored || start_match > end_subject) break; |
| 4952 |
|
|
| 4953 |
/* If we have just passed a CR and the newline option is CRLF or ANY, and we |
/* If we have just passed a CR and we are now at a LF, and the pattern does |
| 4954 |
are now at a LF, advance the match position by one more character. */ |
not contain any explicit matches for \r or \n, and the newline option is CRLF |
| 4955 |
|
or ANY or ANYCRLF, advance the match position by one more character. */ |
| 4956 |
if (start_match[-1] == '\r' && |
|
| 4957 |
(md->nltype == NLTYPE_ANY || md->nllen == 2) && |
if (start_match[-1] == CHAR_CR && |
| 4958 |
start_match < end_subject && |
start_match < end_subject && |
| 4959 |
*start_match == '\n') |
*start_match == CHAR_NL && |
| 4960 |
|
(re->flags & PCRE_HASCRORLF) == 0 && |
| 4961 |
|
(md->nltype == NLTYPE_ANY || |
| 4962 |
|
md->nltype == NLTYPE_ANYCRLF || |
| 4963 |
|
md->nllen == 2)) |
| 4964 |
start_match++; |
start_match++; |
| 4965 |
|
|
| 4966 |
} /* End of for(;;) "bumpalong" loop */ |
} /* End of for(;;) "bumpalong" loop */ |
| 4970 |
/* 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 |
| 4971 |
conditions is true: |
conditions is true: |
| 4972 |
|
|
| 4973 |
(1) The pattern is anchored; |
(1) The pattern is anchored or the match was failed by (*COMMIT); |
| 4974 |
|
|
| 4975 |
(2) We are past the end of the subject; |
(2) We are past the end of the subject; |
| 4976 |
|
|
| 4985 |
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 |
| 4986 |
capturing parentheses than vector slots. */ |
capturing parentheses than vector slots. */ |
| 4987 |
|
|
| 4988 |
|
ENDLOOP: |
| 4989 |
|
|
| 4990 |
if (rc == MATCH_MATCH) |
if (rc == MATCH_MATCH) |
| 4991 |
{ |
{ |
| 4992 |
if (using_temporary_offsets) |
if (using_temporary_offsets) |
| 5007 |
|
|
| 5008 |
rc = md->offset_overflow? 0 : md->end_offset_top/2; |
rc = md->offset_overflow? 0 : md->end_offset_top/2; |
| 5009 |
|
|
| 5010 |
/* 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 |
| 5011 |
|
md->start_match_ptr might be modified if \K was encountered on the success |
| 5012 |
|
matching path. */ |
| 5013 |
|
|
| 5014 |
if (offsetcount < 2) rc = 0; else |
if (offsetcount < 2) rc = 0; else |
| 5015 |
{ |
{ |
| 5016 |
offsets[0] = start_match - md->start_subject; |
offsets[0] = md->start_match_ptr - md->start_subject; |
| 5017 |
offsets[1] = md->end_match_ptr - md->start_subject; |
offsets[1] = md->end_match_ptr - md->start_subject; |
| 5018 |
} |
} |
| 5019 |
|
|