Parent Directory
|
Revision Log
|
Patch
| revision 137 by ph10, Thu Mar 29 13:56:00 2007 UTC | revision 462 by ph10, Sat Oct 17 19:55:02 2009 UTC | |
|---|---|---|
| # | Line 6 | Line 6 |
| 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 |
| # | Line 42 POSSIBILITY OF SUCH DAMAGE. | Line 42 POSSIBILITY OF SUCH DAMAGE. |
| 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 */ |
| # | Line 53 possible. There are also some static sup | Line 57 possible. There are also some static sup |
| 57 | #undef min | #undef min |
| 58 | #undef max | #undef max |
| 59 | ||
| /* The chain of eptrblocks for tail recursions uses memory in stack workspace, | ||
| obtained at top level, the size of which is defined by EPTR_WORK_SIZE. */ | ||
| #define EPTR_WORK_SIZE (1000) | ||
| 60 | /* Flag bits for the match() function */ | /* Flag bits for the match() function */ |
| 61 | ||
| 62 | #define match_condassert 0x01 /* Called to check a condition assertion */ | #define match_condassert 0x01 /* Called to check a condition assertion */ |
| 63 | #define match_cbegroup 0x02 /* Could-be-empty unlimited repeat group */ | #define match_cbegroup 0x02 /* Could-be-empty unlimited repeat group */ |
| #define match_tail_recursed 0x04 /* Tail recursive call */ | ||
| 64 | ||
| 65 | /* Non-error returns from the match() function. Error returns are externally | /* Non-error returns from the match() function. Error returns are externally |
| 66 | defined PCRE_ERROR_xxx codes, which are all negative. */ | defined PCRE_ERROR_xxx codes, which are all negative. */ |
| # | Line 70 defined PCRE_ERROR_xxx codes, which are | Line 68 defined PCRE_ERROR_xxx codes, which are |
| 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. */ |
| # | Line 152 printf("\n"); | Line 158 printf("\n"); |
| 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 | ||
| # | Line 188 calls by keeping local variables that ne | Line 220 calls by keeping local variables that ne |
| 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) \ |
| # | Line 210 versions and production versions. */ | Line 267 versions and production versions. */ |
| 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)\ |
| # | Line 256 match(), which never changes. */ | Line 308 match(), which never changes. */ |
| 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 | } | } |
| # | Line 271 typedef struct heapframe { | Line 322 typedef struct heapframe { |
| 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; |
| # | Line 281 typedef struct heapframe { | Line 333 typedef struct heapframe { |
| 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 | ||
| # | Line 308 typedef struct heapframe { | Line 362 typedef struct heapframe { |
| 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; |
| # | Line 323 typedef struct heapframe { | Line 378 typedef struct heapframe { |
| 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 | ||
| # | Line 344 typedef struct heapframe { | Line 398 typedef struct heapframe { |
| 398 | ||
| 399 | /* This function is called recursively in many circumstances. Whenever it | /* This function is called recursively in many circumstances. Whenever it |
| 400 | returns a negative (error) response, the outer incarnation must also return the | returns a negative (error) response, the outer incarnation must also return the |
| 401 | same response. | same response. */ |
| 402 | ||
| 403 | /* These macros pack up tests that are used for partial matching, and which | |
| 404 | appears several times in the code. We set the "hit end" flag if the pointer is | |
| 405 | at the end of the subject and also past the start of the subject (i.e. | |
| 406 | something has been matched). For hard partial matching, we then return | |
| 407 | immediately. The second one is used when we already know we are past the end of | |
| 408 | the subject. */ | |
| 409 | ||
| 410 | #define CHECK_PARTIAL()\ | |
| 411 | if (md->partial != 0 && eptr >= md->end_subject && eptr > mstart)\ | |
| 412 | {\ | |
| 413 | md->hitend = TRUE;\ | |
| 414 | if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);\ | |
| 415 | } | |
| 416 | ||
| 417 | Performance note: It might be tempting to extract commonly used fields from the | #define SCHECK_PARTIAL()\ |
| 418 | md structure (e.g. utf8, end_subject) into individual variables to improve | if (md->partial != 0 && eptr > mstart)\ |
| 419 | {\ | |
| 420 | md->hitend = TRUE;\ | |
| 421 | if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);\ | |
| 422 | } | |
| 423 | ||
| 424 | ||
| 425 | /* Performance note: It might be tempting to extract commonly used fields from | |
| 426 | the md structure (e.g. utf8, end_subject) into individual variables to improve | |
| 427 | performance. Tests using gcc on a SPARC disproved this; in the first case, it | performance. Tests using gcc on a SPARC disproved this; in the first case, it |
| 428 | made performance worse. | made performance worse. |
| 429 | ||
| 430 | Arguments: | Arguments: |
| 431 | eptr pointer to current character in subject | eptr pointer to current character in subject |
| 432 | ecode pointer to current position in compiled code | ecode pointer to current position in compiled code |
| 433 | mstart pointer to the current match start position (can be modified | |
| 434 | by encountering \K) | |
| 435 | offset_top current top pointer | offset_top current top pointer |
| 436 | md pointer to "static" info for the match | md pointer to "static" info for the match |
| 437 | ims current /i, /m, and /s options | ims current /i, /m, and /s options |
| # | Line 363 Arguments: | Line 441 Arguments: |
| 441 | match_condassert - this is an assertion condition | match_condassert - this is an assertion condition |
| 442 | match_cbegroup - this is the start of an unlimited repeat | match_cbegroup - this is the start of an unlimited repeat |
| 443 | group that can match an empty string | group that can match an empty string |
| match_tail_recursed - this is a tail_recursed group | ||
| 444 | rdepth the recursion depth | rdepth the recursion depth |
| 445 | ||
| 446 | Returns: MATCH_MATCH if matched ) these values are >= 0 | Returns: MATCH_MATCH if matched ) these values are >= 0 |
| # | Line 373 Returns: MATCH_MATCH if matched | Line 450 Returns: MATCH_MATCH if matched |
| 450 | */ | */ |
| 451 | ||
| 452 | static int | static int |
| 453 | match(REGISTER USPTR eptr, REGISTER const uschar *ecode, | match(REGISTER USPTR eptr, REGISTER const uschar *ecode, USPTR mstart, |
| 454 | int offset_top, match_data *md, unsigned long int ims, eptrblock *eptrb, | int offset_top, match_data *md, unsigned long int ims, eptrblock *eptrb, |
| 455 | int flags, unsigned int rdepth) | int flags, unsigned int rdepth) |
| 456 | { | { |
| # | Line 387 register unsigned int c; /* Character | Line 464 register unsigned int c; /* Character |
| 464 | register BOOL utf8; /* Local copy of UTF-8 flag for speed */ | register BOOL utf8; /* Local copy of UTF-8 flag for speed */ |
| 465 | ||
| 466 | BOOL minimize, possessive; /* Quantifier options */ | BOOL minimize, possessive; /* Quantifier options */ |
| 467 | int condcode; | |
| 468 | ||
| 469 | /* 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 |
| 470 | 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 |
| # | Line 401 frame->Xprevframe = NULL; /* | Line 479 frame->Xprevframe = NULL; /* |
| 479 | ||
| 480 | frame->Xeptr = eptr; | frame->Xeptr = eptr; |
| 481 | frame->Xecode = ecode; | frame->Xecode = ecode; |
| 482 | frame->Xmstart = mstart; | |
| 483 | frame->Xoffset_top = offset_top; | frame->Xoffset_top = offset_top; |
| 484 | frame->Xims = ims; | frame->Xims = ims; |
| 485 | frame->Xeptrb = eptrb; | frame->Xeptrb = eptrb; |
| # | Line 415 HEAP_RECURSE: | Line 494 HEAP_RECURSE: |
| 494 | ||
| 495 | #define eptr frame->Xeptr | #define eptr frame->Xeptr |
| 496 | #define ecode frame->Xecode | #define ecode frame->Xecode |
| 497 | #define mstart frame->Xmstart | |
| 498 | #define offset_top frame->Xoffset_top | #define offset_top frame->Xoffset_top |
| 499 | #define ims frame->Xims | #define ims frame->Xims |
| 500 | #define eptrb frame->Xeptrb | #define eptrb frame->Xeptrb |
| # | Line 427 HEAP_RECURSE: | Line 507 HEAP_RECURSE: |
| 507 | #define charptr frame->Xcharptr | #define charptr frame->Xcharptr |
| 508 | #endif | #endif |
| 509 | #define callpat frame->Xcallpat | #define callpat frame->Xcallpat |
| 510 | #define codelink frame->Xcodelink | |
| 511 | #define data frame->Xdata | #define data frame->Xdata |
| 512 | #define next frame->Xnext | #define next frame->Xnext |
| 513 | #define pp frame->Xpp | #define pp frame->Xpp |
| # | Line 507 int oclength; | Line 588 int oclength; |
| 588 | uschar occhars[8]; | uschar occhars[8]; |
| 589 | #endif | #endif |
| 590 | ||
| 591 | int codelink; | |
| 592 | int ctype; | int ctype; |
| 593 | int length; | int length; |
| 594 | int max; | int max; |
| # | Line 545 defined). However, RMATCH isn't like a f | Line 627 defined). However, RMATCH isn't like a f |
| 627 | 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, |
| 628 | however, impact performance when true recursion is being used. */ | however, impact performance when true recursion is being used. */ |
| 629 | ||
| 630 | #ifdef SUPPORT_UTF8 | |
| 631 | utf8 = md->utf8; /* Local copy of the flag */ | |
| 632 | #else | |
| 633 | utf8 = FALSE; | |
| 634 | #endif | |
| 635 | ||
| 636 | /* 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 |
| 637 | haven't exceeded the recursive call limit. */ | haven't exceeded the recursive call limit. */ |
| 638 | ||
| # | Line 553 if (rdepth >= md->match_limit_recursion) | Line 641 if (rdepth >= md->match_limit_recursion) |
| 641 | ||
| 642 | original_ims = ims; /* Save for resetting on ')' */ | original_ims = ims; /* Save for resetting on ')' */ |
| 643 | ||
| #ifdef SUPPORT_UTF8 | ||
| utf8 = md->utf8; /* Local copy of the flag */ | ||
| #else | ||
| utf8 = FALSE; | ||
| #endif | ||
| 644 | /* 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 |
| 645 | 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 |
| 646 | 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 |
| 647 | 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. |
| 648 | 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 |
| 649 | 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 |
| 650 | already used. */ | block that is used is on the stack, so a new one may be required for each |
| 651 | match(). */ | |
| 652 | ||
| 653 | if ((flags & match_cbegroup) != 0) | if ((flags & match_cbegroup) != 0) |
| 654 | { | { |
| 655 | eptrblock *p; | newptrb.epb_saved_eptr = eptr; |
| 656 | if ((flags & match_tail_recursed) != 0) | newptrb.epb_prev = eptrb; |
| 657 | { | 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; | ||
| 658 | } | } |
| 659 | ||
| 660 | /* Now start processing the opcodes. */ | /* Now start processing the opcodes. */ |
| # | Line 588 for (;;) | Line 664 for (;;) |
| 664 | minimize = possessive = FALSE; | minimize = possessive = FALSE; |
| 665 | op = *ecode; | op = *ecode; |
| 666 | ||
| /* For partial matching, remember if we ever hit the end of the subject after | ||
| matching at least one subject character. */ | ||
| if (md->partial && | ||
| eptr >= md->end_subject && | ||
| eptr > md->start_match) | ||
| md->hitend = TRUE; | ||
| 667 | switch(op) | switch(op) |
| 668 | { | { |
| 669 | case OP_FAIL: | |
| 670 | RRETURN(MATCH_NOMATCH); | |
| 671 | ||
| 672 | case OP_PRUNE: | |
| 673 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | |
| 674 | ims, eptrb, flags, RM51); | |
| 675 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | |
| 676 | RRETURN(MATCH_PRUNE); | |
| 677 | ||
| 678 | case OP_COMMIT: | |
| 679 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | |
| 680 | ims, eptrb, flags, RM52); | |
| 681 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | |
| 682 | RRETURN(MATCH_COMMIT); | |
| 683 | ||
| 684 | case OP_SKIP: | |
| 685 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | |
| 686 | ims, eptrb, flags, RM53); | |
| 687 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | |
| 688 | md->start_match_ptr = eptr; /* Pass back current position */ | |
| 689 | RRETURN(MATCH_SKIP); | |
| 690 | ||
| 691 | case OP_THEN: | |
| 692 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | |
| 693 | ims, eptrb, flags, RM54); | |
| 694 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | |
| 695 | RRETURN(MATCH_THEN); | |
| 696 | ||
| 697 | /* 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 |
| 698 | 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. |
| 699 | 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 |
| # | Line 637 for (;;) | Line 733 for (;;) |
| 733 | flags = (op == OP_SCBRA)? match_cbegroup : 0; | flags = (op == OP_SCBRA)? match_cbegroup : 0; |
| 734 | do | do |
| 735 | { | { |
| 736 | RMATCH(rrc, eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
| 737 | ims, eptrb, flags); | ims, eptrb, flags, RM1); |
| 738 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); |
| 739 | md->capture_last = save_capture_last; | md->capture_last = save_capture_last; |
| 740 | ecode += GET(ecode, 1); | ecode += GET(ecode, 1); |
| 741 | } | } |
| # | Line 654 for (;;) | Line 750 for (;;) |
| 750 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 751 | } | } |
| 752 | ||
| 753 | /* Insufficient room for saving captured contents. Treat as a non-capturing | /* FALL THROUGH ... Insufficient room for saving captured contents. Treat |
| 754 | bracket. */ | as a non-capturing bracket. */ |
| 755 | ||
| 756 | /* VVVVVVVVVVVVVVVVVVVVVVVVV */ | |
| 757 | /* VVVVVVVVVVVVVVVVVVVVVVVVV */ | |
| 758 | ||
| 759 | DPRINTF(("insufficient capture room: treat as non-capturing\n")); | DPRINTF(("insufficient capture room: treat as non-capturing\n")); |
| 760 | ||
| 761 | /* VVVVVVVVVVVVVVVVVVVVVVVVV */ | |
| 762 | /* VVVVVVVVVVVVVVVVVVVVVVVVV */ | |
| 763 | ||
| 764 | /* 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 |
| 765 | final alternative within the brackets, we would return the result of a | final alternative within the brackets, we would return the result of a |
| 766 | recursive call to match() whatever happened. We can reduce stack usage by | recursive call to match() whatever happened. We can reduce stack usage by |
| 767 | turning this into a tail recursion. */ | turning this into a tail recursion, except in the case when match_cbegroup |
| 768 | is set.*/ | |
| 769 | ||
| 770 | case OP_BRA: | case OP_BRA: |
| 771 | case OP_SBRA: | case OP_SBRA: |
| # | Line 670 for (;;) | Line 773 for (;;) |
| 773 | flags = (op >= OP_SBRA)? match_cbegroup : 0; | flags = (op >= OP_SBRA)? match_cbegroup : 0; |
| 774 | for (;;) | for (;;) |
| 775 | { | { |
| 776 | if (ecode[GET(ecode, 1)] != OP_ALT) | if (ecode[GET(ecode, 1)] != OP_ALT) /* Final alternative */ |
| 777 | { | { |
| 778 | ecode += _pcre_OP_lengths[*ecode]; | if (flags == 0) /* Not a possibly empty group */ |
| 779 | flags |= match_tail_recursed; | { |
| 780 | DPRINTF(("bracket 0 tail recursion\n")); | ecode += _pcre_OP_lengths[*ecode]; |
| 781 | goto TAIL_RECURSE; | DPRINTF(("bracket 0 tail recursion\n")); |
| 782 | goto TAIL_RECURSE; | |
| 783 | } | |
| 784 | ||
| 785 | /* Possibly empty group; can't use tail recursion. */ | |
| 786 | ||
| 787 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims, | |
| 788 | eptrb, flags, RM48); | |
| 789 | RRETURN(rrc); | |
| 790 | } | } |
| 791 | ||
| 792 | /* For non-final alternatives, continue the loop for a NOMATCH result; | /* For non-final alternatives, continue the loop for a NOMATCH result; |
| 793 | otherwise return. */ | otherwise return. */ |
| 794 | ||
| 795 | RMATCH(rrc, eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims, | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims, |
| 796 | eptrb, flags); | eptrb, flags, RM2); |
| 797 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); |
| 798 | ecode += GET(ecode, 1); | ecode += GET(ecode, 1); |
| 799 | } | } |
| 800 | /* Control never reaches here. */ | /* Control never reaches here. */ |
| # | Line 696 for (;;) | Line 807 for (;;) |
| 807 | ||
| 808 | case OP_COND: | case OP_COND: |
| 809 | case OP_SCOND: | case OP_SCOND: |
| 810 | if (ecode[LINK_SIZE+1] == OP_RREF) /* Recursion test */ | codelink= GET(ecode, 1); |
| 811 | ||
| 812 | /* Because of the way auto-callout works during compile, a callout item is | |
| 813 | inserted between OP_COND and an assertion condition. */ | |
| 814 | ||
| 815 | if (ecode[LINK_SIZE+1] == OP_CALLOUT) | |
| 816 | { | { |
| 817 | offset = GET2(ecode, LINK_SIZE + 2); /* Recursion group number*/ | if (pcre_callout != NULL) |
| 818 | condition = md->recursive != NULL && | { |
| 819 | (offset == RREF_ANY || offset == md->recursive->group_num); | pcre_callout_block cb; |
| 820 | ecode += condition? 3 : GET(ecode, 1); | cb.version = 1; /* Version 1 of the callout block */ |
| 821 | cb.callout_number = ecode[LINK_SIZE+2]; | |
| 822 | cb.offset_vector = md->offset_vector; | |
| 823 | cb.subject = (PCRE_SPTR)md->start_subject; | |
| 824 | cb.subject_length = md->end_subject - md->start_subject; | |
| 825 | cb.start_match = mstart - md->start_subject; | |
| 826 | cb.current_position = eptr - md->start_subject; | |
| 827 | cb.pattern_position = GET(ecode, LINK_SIZE + 3); | |
| 828 | cb.next_item_length = GET(ecode, 3 + 2*LINK_SIZE); | |
| 829 | cb.capture_top = offset_top/2; | |
| 830 | cb.capture_last = md->capture_last; | |
| 831 | cb.callout_data = md->callout_data; | |
| 832 | if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH); | |
| 833 | if (rrc < 0) RRETURN(rrc); | |
| 834 | } | |
| 835 | ecode += _pcre_OP_lengths[OP_CALLOUT]; | |
| 836 | } | |
| 837 | ||
| 838 | condcode = ecode[LINK_SIZE+1]; | |
| 839 | ||
| 840 | /* Now see what the actual condition is */ | |
| 841 | ||
| 842 | if (condcode == OP_RREF || condcode == OP_NRREF) /* Recursion test */ | |
| 843 | { | |
| 844 | if (md->recursive == NULL) /* Not recursing => FALSE */ | |
| 845 | { | |
| 846 | condition = FALSE; | |
| 847 | ecode += GET(ecode, 1); | |
| 848 | } | |
| 849 | else | |
| 850 | { | |
| 851 | int recno = GET2(ecode, LINK_SIZE + 2); /* Recursion group number*/ | |
| 852 | condition = (recno == RREF_ANY || recno == md->recursive->group_num); | |
| 853 | ||
| 854 | /* If the test is for recursion into a specific subpattern, and it is | |
| 855 | false, but the test was set up by name, scan the table to see if the | |
| 856 | name refers to any other numbers, and test them. The condition is true | |
| 857 | if any one is set. */ | |
| 858 | ||
| 859 | if (!condition && condcode == OP_NRREF && recno != RREF_ANY) | |
| 860 | { | |
| 861 | uschar *slotA = md->name_table; | |
| 862 | for (i = 0; i < md->name_count; i++) | |
| 863 | { | |
| 864 | if (GET2(slotA, 0) == recno) break; | |
| 865 | slotA += md->name_entry_size; | |
| 866 | } | |
| 867 | ||
| 868 | /* Found a name for the number - there can be only one; duplicate | |
| 869 | names for different numbers are allowed, but not vice versa. First | |
| 870 | scan down for duplicates. */ | |
| 871 | ||
| 872 | if (i < md->name_count) | |
| 873 | { | |
| 874 | uschar *slotB = slotA; | |
| 875 | while (slotB > md->name_table) | |
| 876 | { | |
| 877 | slotB -= md->name_entry_size; | |
| 878 | if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) | |
| 879 | { | |
| 880 | condition = GET2(slotB, 0) == md->recursive->group_num; | |
| 881 | if (condition) break; | |
| 882 | } | |
| 883 | else break; | |
| 884 | } | |
| 885 | ||
| 886 | /* Scan up for duplicates */ | |
| 887 | ||
| 888 | if (!condition) | |
| 889 | { | |
| 890 | slotB = slotA; | |
| 891 | for (i++; i < md->name_count; i++) | |
| 892 | { | |
| 893 | slotB += md->name_entry_size; | |
| 894 | if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) | |
| 895 | { | |
| 896 | condition = GET2(slotB, 0) == md->recursive->group_num; | |
| 897 | if (condition) break; | |
| 898 | } | |
| 899 | else break; | |
| 900 | } | |
| 901 | } | |
| 902 | } | |
| 903 | } | |
| 904 | ||
| 905 | /* Chose branch according to the condition */ | |
| 906 | ||
| 907 | ecode += condition? 3 : GET(ecode, 1); | |
| 908 | } | |
| 909 | } | } |
| 910 | ||
| 911 | else if (ecode[LINK_SIZE+1] == OP_CREF) /* Group used test */ | else if (condcode == OP_CREF || condcode == OP_NCREF) /* Group used test */ |
| 912 | { | { |
| 913 | offset = GET2(ecode, LINK_SIZE+2) << 1; /* Doubled ref number */ | offset = GET2(ecode, LINK_SIZE+2) << 1; /* Doubled ref number */ |
| 914 | condition = offset < offset_top && md->offset_vector[offset] >= 0; | condition = offset < offset_top && md->offset_vector[offset] >= 0; |
| 915 | ||
| 916 | /* If the numbered capture is unset, but the reference was by name, | |
| 917 | scan the table to see if the name refers to any other numbers, and test | |
| 918 | them. The condition is true if any one is set. This is tediously similar | |
| 919 | to the code above, but not close enough to try to amalgamate. */ | |
| 920 | ||
| 921 | if (!condition && condcode == OP_NCREF) | |
| 922 | { | |
| 923 | int refno = offset >> 1; | |
| 924 | uschar *slotA = md->name_table; | |
| 925 | ||
| 926 | for (i = 0; i < md->name_count; i++) | |
| 927 | { | |
| 928 | if (GET2(slotA, 0) == refno) break; | |
| 929 | slotA += md->name_entry_size; | |
| 930 | } | |
| 931 | ||
| 932 | /* Found a name for the number - there can be only one; duplicate names | |
| 933 | for different numbers are allowed, but not vice versa. First scan down | |
| 934 | for duplicates. */ | |
| 935 | ||
| 936 | if (i < md->name_count) | |
| 937 | { | |
| 938 | uschar *slotB = slotA; | |
| 939 | while (slotB > md->name_table) | |
| 940 | { | |
| 941 | slotB -= md->name_entry_size; | |
| 942 | if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) | |
| 943 | { | |
| 944 | offset = GET2(slotB, 0) << 1; | |
| 945 | condition = offset < offset_top && | |
| 946 | md->offset_vector[offset] >= 0; | |
| 947 | if (condition) break; | |
| 948 | } | |
| 949 | else break; | |
| 950 | } | |
| 951 | ||
| 952 | /* Scan up for duplicates */ | |
| 953 | ||
| 954 | if (!condition) | |
| 955 | { | |
| 956 | slotB = slotA; | |
| 957 | for (i++; i < md->name_count; i++) | |
| 958 | { | |
| 959 | slotB += md->name_entry_size; | |
| 960 | if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) | |
| 961 | { | |
| 962 | offset = GET2(slotB, 0) << 1; | |
| 963 | condition = offset < offset_top && | |
| 964 | md->offset_vector[offset] >= 0; | |
| 965 | if (condition) break; | |
| 966 | } | |
| 967 | else break; | |
| 968 | } | |
| 969 | } | |
| 970 | } | |
| 971 | } | |
| 972 | ||
| 973 | /* Chose branch according to the condition */ | |
| 974 | ||
| 975 | ecode += condition? 3 : GET(ecode, 1); | ecode += condition? 3 : GET(ecode, 1); |
| 976 | } | } |
| 977 | ||
| 978 | else if (ecode[LINK_SIZE+1] == OP_DEF) /* DEFINE - always false */ | else if (condcode == OP_DEF) /* DEFINE - always false */ |
| 979 | { | { |
| 980 | condition = FALSE; | condition = FALSE; |
| 981 | ecode += GET(ecode, 1); | ecode += GET(ecode, 1); |
| # | Line 723 for (;;) | Line 987 for (;;) |
| 987 | ||
| 988 | else | else |
| 989 | { | { |
| 990 | RMATCH(rrc, eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, |
| 991 | match_condassert); | match_condassert, RM3); |
| 992 | if (rrc == MATCH_MATCH) | if (rrc == MATCH_MATCH) |
| 993 | { | { |
| 994 | condition = TRUE; | condition = TRUE; |
| 995 | ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2); | ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2); |
| 996 | while (*ecode == OP_ALT) ecode += GET(ecode, 1); | while (*ecode == OP_ALT) ecode += GET(ecode, 1); |
| 997 | } | } |
| 998 | else if (rrc != MATCH_NOMATCH) | else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) |
| 999 | { | { |
| 1000 | RRETURN(rrc); /* Need braces because of following else */ | RRETURN(rrc); /* Need braces because of following else */ |
| 1001 | } | } |
| 1002 | else | else |
| 1003 | { | { |
| 1004 | condition = FALSE; | condition = FALSE; |
| 1005 | ecode += GET(ecode, 1); | ecode += codelink; |
| 1006 | } | } |
| 1007 | } | } |
| 1008 | ||
| 1009 | /* 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, |
| 1010 | 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 |
| 1011 | alternative doesn't exist, we can just plough on. */ | match_cbegroup is required for an unlimited repeat of a possibly empty |
| 1012 | group. If the second alternative doesn't exist, we can just plough on. */ | |
| 1013 | ||
| 1014 | if (condition || *ecode == OP_ALT) | if (condition || *ecode == OP_ALT) |
| 1015 | { | { |
| 1016 | ecode += 1 + LINK_SIZE; | ecode += 1 + LINK_SIZE; |
| 1017 | flags = match_tail_recursed | ((op == OP_SCOND)? match_cbegroup : 0); | if (op == OP_SCOND) /* Possibly empty group */ |
| 1018 | goto TAIL_RECURSE; | { |
| 1019 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, match_cbegroup, RM49); | |
| 1020 | RRETURN(rrc); | |
| 1021 | } | |
| 1022 | else /* Group must match something */ | |
| 1023 | { | |
| 1024 | flags = 0; | |
| 1025 | goto TAIL_RECURSE; | |
| 1026 | } | |
| 1027 | } | } |
| 1028 | else | else /* Condition false & no alternative */ |
| 1029 | { | { |
| 1030 | ecode += 1 + LINK_SIZE; | ecode += 1 + LINK_SIZE; |
| 1031 | } | } |
| 1032 | break; | break; |
| 1033 | ||
| 1034 | ||
| 1035 | /* End of the pattern. If we are in a top-level recursion, we should | /* Before OP_ACCEPT there may be any number of OP_CLOSE opcodes, |
| 1036 | restore the offsets appropriately and continue from after the call. */ | to close any currently open capturing brackets. */ |
| 1037 | ||
| 1038 | case OP_CLOSE: | |
| 1039 | number = GET2(ecode, 1); | |
| 1040 | offset = number << 1; | |
| 1041 | ||
| 1042 | #ifdef DEBUG | |
| 1043 | printf("end bracket %d at *ACCEPT", number); | |
| 1044 | printf("\n"); | |
| 1045 | #endif | |
| 1046 | ||
| 1047 | md->capture_last = number; | |
| 1048 | if (offset >= md->offset_max) md->offset_overflow = TRUE; else | |
| 1049 | { | |
| 1050 | md->offset_vector[offset] = | |
| 1051 | md->offset_vector[md->offset_end - number]; | |
| 1052 | md->offset_vector[offset+1] = eptr - md->start_subject; | |
| 1053 | if (offset_top <= offset) offset_top = offset + 2; | |
| 1054 | } | |
| 1055 | ecode += 3; | |
| 1056 | break; | |
| 1057 | ||
| 1058 | ||
| 1059 | /* End of the pattern, either real or forced. If we are in a top-level | |
| 1060 | recursion, we should restore the offsets appropriately and continue from | |
| 1061 | after the call. */ | |
| 1062 | ||
| 1063 | case OP_ACCEPT: | |
| 1064 | case OP_END: | case OP_END: |
| 1065 | if (md->recursive != NULL && md->recursive->group_num == 0) | if (md->recursive != NULL && md->recursive->group_num == 0) |
| 1066 | { | { |
| # | Line 770 for (;;) | Line 1069 for (;;) |
| 1069 | md->recursive = rec->prevrec; | md->recursive = rec->prevrec; |
| 1070 | memmove(md->offset_vector, rec->offset_save, | memmove(md->offset_vector, rec->offset_save, |
| 1071 | rec->saved_max * sizeof(int)); | rec->saved_max * sizeof(int)); |
| 1072 | md->start_match = rec->save_start; | offset_top = rec->save_offset_top; |
| 1073 | mstart = rec->save_start; | |
| 1074 | ims = original_ims; | ims = original_ims; |
| 1075 | ecode = rec->after_call; | ecode = rec->after_call; |
| 1076 | break; | break; |
| 1077 | } | } |
| 1078 | ||
| 1079 | /* Otherwise, if PCRE_NOTEMPTY is set, fail if we have matched an empty | /* Otherwise, if we have matched an empty string, fail if PCRE_NOTEMPTY is |
| 1080 | string - backtracking will then try other alternatives, if any. */ | set, or if PCRE_NOTEMPTY_ATSTART is set and we have matched at the start of |
| 1081 | the subject. In both cases, backtracking will then try other alternatives, | |
| 1082 | if any. */ | |
| 1083 | ||
| 1084 | if (eptr == mstart && | |
| 1085 | (md->notempty || | |
| 1086 | (md->notempty_atstart && | |
| 1087 | mstart == md->start_subject + md->start_offset))) | |
| 1088 | RRETURN(MATCH_NOMATCH); | |
| 1089 | ||
| 1090 | /* Otherwise, we have a match. */ | |
| 1091 | ||
| 1092 | if (md->notempty && eptr == md->start_match) RRETURN(MATCH_NOMATCH); | md->end_match_ptr = eptr; /* Record where we ended */ |
| 1093 | md->end_match_ptr = eptr; /* Record where we ended */ | md->end_offset_top = offset_top; /* and how many extracts were taken */ |
| 1094 | md->end_offset_top = offset_top; /* and how many extracts were taken */ | md->start_match_ptr = mstart; /* and the start (\K can modify) */ |
| 1095 | RRETURN(MATCH_MATCH); | RRETURN(MATCH_MATCH); |
| 1096 | ||
| 1097 | /* Change option settings */ | /* Change option settings */ |
| # | Line 802 for (;;) | Line 1112 for (;;) |
| 1112 | case OP_ASSERTBACK: | case OP_ASSERTBACK: |
| 1113 | do | do |
| 1114 | { | { |
| 1115 | 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, |
| 1116 | RM4); | |
| 1117 | if (rrc == MATCH_MATCH) break; | if (rrc == MATCH_MATCH) break; |
| 1118 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); |
| 1119 | ecode += GET(ecode, 1); | ecode += GET(ecode, 1); |
| 1120 | } | } |
| 1121 | while (*ecode == OP_ALT); | while (*ecode == OP_ALT); |
| # | Line 828 for (;;) | Line 1139 for (;;) |
| 1139 | case OP_ASSERTBACK_NOT: | case OP_ASSERTBACK_NOT: |
| 1140 | do | do |
| 1141 | { | { |
| 1142 | 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, |
| 1143 | RM5); | |
| 1144 | if (rrc == MATCH_MATCH) RRETURN(MATCH_NOMATCH); | if (rrc == MATCH_MATCH) RRETURN(MATCH_NOMATCH); |
| 1145 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); |
| 1146 | ecode += GET(ecode,1); | ecode += GET(ecode,1); |
| 1147 | } | } |
| 1148 | while (*ecode == OP_ALT); | while (*ecode == OP_ALT); |
| # | Line 854 for (;;) | Line 1166 for (;;) |
| 1166 | { | { |
| 1167 | eptr--; | eptr--; |
| 1168 | if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH); | if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH); |
| 1169 | BACKCHAR(eptr) | BACKCHAR(eptr); |
| 1170 | } | } |
| 1171 | } | } |
| 1172 | else | else |
| # | Line 867 for (;;) | Line 1179 for (;;) |
| 1179 | if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH); | if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH); |
| 1180 | } | } |
| 1181 | ||
| 1182 | /* Skip to next op code */ | /* Save the earliest consulted character, then skip to next op code */ |
| 1183 | ||
| 1184 | if (eptr < md->start_used_ptr) md->start_used_ptr = eptr; | |
| 1185 | ecode += 1 + LINK_SIZE; | ecode += 1 + LINK_SIZE; |
| 1186 | break; | break; |
| 1187 | ||
| # | Line 885 for (;;) | Line 1198 for (;;) |
| 1198 | cb.offset_vector = md->offset_vector; | cb.offset_vector = md->offset_vector; |
| 1199 | cb.subject = (PCRE_SPTR)md->start_subject; | cb.subject = (PCRE_SPTR)md->start_subject; |
| 1200 | cb.subject_length = md->end_subject - md->start_subject; | cb.subject_length = md->end_subject - md->start_subject; |
| 1201 | cb.start_match = md->start_match - md->start_subject; | cb.start_match = mstart - md->start_subject; |
| 1202 | cb.current_position = eptr - md->start_subject; | cb.current_position = eptr - md->start_subject; |
| 1203 | cb.pattern_position = GET(ecode, 2); | cb.pattern_position = GET(ecode, 2); |
| 1204 | cb.next_item_length = GET(ecode, 2 + LINK_SIZE); | cb.next_item_length = GET(ecode, 2 + LINK_SIZE); |
| # | Line 947 for (;;) | Line 1260 for (;;) |
| 1260 | ||
| 1261 | memcpy(new_recursive.offset_save, md->offset_vector, | memcpy(new_recursive.offset_save, md->offset_vector, |
| 1262 | new_recursive.saved_max * sizeof(int)); | new_recursive.saved_max * sizeof(int)); |
| 1263 | new_recursive.save_start = md->start_match; | new_recursive.save_start = mstart; |
| 1264 | md->start_match = eptr; | new_recursive.save_offset_top = offset_top; |
| 1265 | mstart = eptr; | |
| 1266 | ||
| 1267 | /* 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 |
| 1268 | restore the offset and recursion data. */ | restore the offset and recursion data. */ |
| # | Line 957 for (;;) | Line 1271 for (;;) |
| 1271 | flags = (*callpat >= OP_SBRA)? match_cbegroup : 0; | flags = (*callpat >= OP_SBRA)? match_cbegroup : 0; |
| 1272 | do | do |
| 1273 | { | { |
| 1274 | RMATCH(rrc, eptr, callpat + _pcre_OP_lengths[*callpat], offset_top, | RMATCH(eptr, callpat + _pcre_OP_lengths[*callpat], offset_top, |
| 1275 | md, ims, eptrb, flags); | md, ims, eptrb, flags, RM6); |
| 1276 | if (rrc == MATCH_MATCH) | if (rrc == MATCH_MATCH) |
| 1277 | { | { |
| 1278 | DPRINTF(("Recursion matched\n")); | DPRINTF(("Recursion matched\n")); |
| # | Line 967 for (;;) | Line 1281 for (;;) |
| 1281 | (pcre_free)(new_recursive.offset_save); | (pcre_free)(new_recursive.offset_save); |
| 1282 | RRETURN(MATCH_MATCH); | RRETURN(MATCH_MATCH); |
| 1283 | } | } |
| 1284 | else if (rrc != MATCH_NOMATCH) | else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) |
| 1285 | { | { |
| 1286 | DPRINTF(("Recursion gave error %d\n", rrc)); | DPRINTF(("Recursion gave error %d\n", rrc)); |
| 1287 | if (new_recursive.offset_save != stacksave) | |
| 1288 | (pcre_free)(new_recursive.offset_save); | |
| 1289 | RRETURN(rrc); | RRETURN(rrc); |
| 1290 | } | } |
| 1291 | ||
| # | Line 1001 for (;;) | Line 1317 for (;;) |
| 1317 | ||
| 1318 | do | do |
| 1319 | { | { |
| 1320 | 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); | ||
| 1321 | if (rrc == MATCH_MATCH) break; | if (rrc == MATCH_MATCH) break; |
| 1322 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); |
| 1323 | ecode += GET(ecode,1); | ecode += GET(ecode,1); |
| 1324 | } | } |
| 1325 | while (*ecode == OP_ALT); | while (*ecode == OP_ALT); |
| # | Line 1047 for (;;) | Line 1362 for (;;) |
| 1362 | ||
| 1363 | if (*ecode == OP_KETRMIN) | if (*ecode == OP_KETRMIN) |
| 1364 | { | { |
| 1365 | 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); |
| 1366 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1367 | ecode = prev; | ecode = prev; |
| 1368 | flags = match_tail_recursed; | flags = 0; |
| 1369 | goto TAIL_RECURSE; | goto TAIL_RECURSE; |
| 1370 | } | } |
| 1371 | else /* OP_KETRMAX */ | else /* OP_KETRMAX */ |
| 1372 | { | { |
| 1373 | RMATCH(rrc, eptr, prev, offset_top, md, ims, eptrb, match_cbegroup); | RMATCH(eptr, prev, offset_top, md, ims, eptrb, match_cbegroup, RM9); |
| 1374 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1375 | ecode += 1 + LINK_SIZE; | ecode += 1 + LINK_SIZE; |
| 1376 | flags = match_tail_recursed; | flags = 0; |
| 1377 | goto TAIL_RECURSE; | goto TAIL_RECURSE; |
| 1378 | } | } |
| 1379 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 1070 for (;;) | Line 1385 for (;;) |
| 1385 | do ecode += GET(ecode,1); while (*ecode == OP_ALT); | do ecode += GET(ecode,1); while (*ecode == OP_ALT); |
| 1386 | break; | break; |
| 1387 | ||
| 1388 | /* BRAZERO and BRAMINZERO occur just before a bracket group, indicating | /* BRAZERO, BRAMINZERO and SKIPZERO occur just before a bracket group, |
| 1389 | 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 |
| 1390 | 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 |
| 1391 | 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 |
| 1392 | preceded by BRAZERO or BRAMINZERO. */ | optional ones preceded by BRAZERO or BRAMINZERO. */ |
| 1393 | ||
| 1394 | case OP_BRAZERO: | case OP_BRAZERO: |
| 1395 | { | { |
| 1396 | next = ecode+1; | next = ecode+1; |
| 1397 | RMATCH(rrc, eptr, next, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, next, offset_top, md, ims, eptrb, 0, RM10); |
| 1398 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1399 | do next += GET(next,1); while (*next == OP_ALT); | do next += GET(next,1); while (*next == OP_ALT); |
| 1400 | ecode = next + 1 + LINK_SIZE; | ecode = next + 1 + LINK_SIZE; |
| # | Line 1090 for (;;) | Line 1405 for (;;) |
| 1405 | { | { |
| 1406 | next = ecode+1; | next = ecode+1; |
| 1407 | do next += GET(next, 1); while (*next == OP_ALT); | do next += GET(next, 1); while (*next == OP_ALT); |
| 1408 | 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); |
| 1409 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1410 | ecode++; | ecode++; |
| 1411 | } | } |
| 1412 | break; | break; |
| 1413 | ||
| 1414 | case OP_SKIPZERO: | |
| 1415 | { | |
| 1416 | next = ecode+1; | |
| 1417 | do next += GET(next,1); while (*next == OP_ALT); | |
| 1418 | ecode = next + 1 + LINK_SIZE; | |
| 1419 | } | |
| 1420 | break; | |
| 1421 | ||
| 1422 | /* End of a group, repeated or non-repeating. */ | /* End of a group, repeated or non-repeating. */ |
| 1423 | ||
| 1424 | case OP_KET: | case OP_KET: |
| # | Line 1160 for (;;) | Line 1483 for (;;) |
| 1483 | recursion_info *rec = md->recursive; | recursion_info *rec = md->recursive; |
| 1484 | DPRINTF(("Recursion (%d) succeeded - continuing\n", number)); | DPRINTF(("Recursion (%d) succeeded - continuing\n", number)); |
| 1485 | md->recursive = rec->prevrec; | md->recursive = rec->prevrec; |
| 1486 | md->start_match = rec->save_start; | mstart = rec->save_start; |
| 1487 | memcpy(md->offset_vector, rec->offset_save, | memcpy(md->offset_vector, rec->offset_save, |
| 1488 | rec->saved_max * sizeof(int)); | rec->saved_max * sizeof(int)); |
| 1489 | offset_top = rec->save_offset_top; | |
| 1490 | ecode = rec->after_call; | ecode = rec->after_call; |
| 1491 | ims = original_ims; | ims = original_ims; |
| 1492 | break; | break; |
| # | Line 1189 for (;;) | Line 1513 for (;;) |
| 1513 | ||
| 1514 | /* 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 |
| 1515 | 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 |
| 1516 | tail recursion to avoid using another stack frame. */ | tail recursion to avoid using another stack frame, unless we have an |
| 1517 | unlimited repeat of a group that can match an empty string. */ | |
| 1518 | ||
| 1519 | flags = (*prev >= OP_SBRA)? match_cbegroup : 0; | flags = (*prev >= OP_SBRA)? match_cbegroup : 0; |
| 1520 | ||
| 1521 | if (*ecode == OP_KETRMIN) | if (*ecode == OP_KETRMIN) |
| 1522 | { | { |
| 1523 | 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); |
| 1524 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1525 | if (flags != 0) /* Could match an empty string */ | |
| 1526 | { | |
| 1527 | RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM50); | |
| 1528 | RRETURN(rrc); | |
| 1529 | } | |
| 1530 | ecode = prev; | ecode = prev; |
| flags |= match_tail_recursed; | ||
| 1531 | goto TAIL_RECURSE; | goto TAIL_RECURSE; |
| 1532 | } | } |
| 1533 | else /* OP_KETRMAX */ | else /* OP_KETRMAX */ |
| 1534 | { | { |
| 1535 | RMATCH(rrc, eptr, prev, offset_top, md, ims, eptrb, flags); | RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM13); |
| 1536 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1537 | ecode += 1 + LINK_SIZE; | ecode += 1 + LINK_SIZE; |
| 1538 | flags = match_tail_recursed; | flags = 0; |
| 1539 | goto TAIL_RECURSE; | goto TAIL_RECURSE; |
| 1540 | } | } |
| 1541 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 1239 for (;;) | Line 1568 for (;;) |
| 1568 | ecode++; | ecode++; |
| 1569 | break; | break; |
| 1570 | ||
| 1571 | /* Reset the start of match point */ | |
| 1572 | ||
| 1573 | case OP_SET_SOM: | |
| 1574 | mstart = eptr; | |
| 1575 | ecode++; | |
| 1576 | break; | |
| 1577 | ||
| 1578 | /* Assert before internal newline if multiline, or before a terminating | /* Assert before internal newline if multiline, or before a terminating |
| 1579 | 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. */ |
| 1580 | ||
| # | Line 1290 for (;;) | Line 1626 for (;;) |
| 1626 | ||
| 1627 | /* Find out if the previous and current characters are "word" characters. | /* Find out if the previous and current characters are "word" characters. |
| 1628 | It takes a bit more work in UTF-8 mode. Characters > 255 are assumed to | It takes a bit more work in UTF-8 mode. Characters > 255 are assumed to |
| 1629 | be "non-word" characters. */ | be "non-word" characters. Remember the earliest consulted character for |
| 1630 | partial matching. */ | |
| 1631 | ||
| 1632 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| 1633 | if (utf8) | if (utf8) |
| 1634 | { | { |
| 1635 | if (eptr == md->start_subject) prev_is_word = FALSE; else | if (eptr == md->start_subject) prev_is_word = FALSE; else |
| 1636 | { | { |
| 1637 | const uschar *lastptr = eptr - 1; | USPTR lastptr = eptr - 1; |
| 1638 | while((*lastptr & 0xc0) == 0x80) lastptr--; | while((*lastptr & 0xc0) == 0x80) lastptr--; |
| 1639 | if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr; | |
| 1640 | GETCHAR(c, lastptr); | GETCHAR(c, lastptr); |
| 1641 | prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; | prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; |
| 1642 | } | } |
| 1643 | if (eptr >= md->end_subject) cur_is_word = FALSE; else | if (eptr >= md->end_subject) |
| 1644 | { | |
| 1645 | SCHECK_PARTIAL(); | |
| 1646 | cur_is_word = FALSE; | |
| 1647 | } | |
| 1648 | else | |
| 1649 | { | { |
| 1650 | GETCHAR(c, eptr); | GETCHAR(c, eptr); |
| 1651 | cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; | cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; |
| # | Line 1311 for (;;) | Line 1654 for (;;) |
| 1654 | else | else |
| 1655 | #endif | #endif |
| 1656 | ||
| 1657 | /* More streamlined when not in UTF-8 mode */ | /* Not in UTF-8 mode */ |
| 1658 | ||
| 1659 | { | { |
| 1660 | prev_is_word = (eptr != md->start_subject) && | if (eptr == md->start_subject) prev_is_word = FALSE; else |
| 1661 | ((md->ctypes[eptr[-1]] & ctype_word) != 0); | { |
| 1662 | cur_is_word = (eptr < md->end_subject) && | if (eptr <= md->start_used_ptr) md->start_used_ptr = eptr - 1; |
| 1663 | ((md->ctypes[*eptr] & ctype_word) != 0); | prev_is_word = ((md->ctypes[eptr[-1]] & ctype_word) != 0); |
| 1664 | } | |
| 1665 | if (eptr >= md->end_subject) | |
| 1666 | { | |
| 1667 | SCHECK_PARTIAL(); | |
| 1668 | cur_is_word = FALSE; | |
| 1669 | } | |
| 1670 | else cur_is_word = ((md->ctypes[*eptr] & ctype_word) != 0); | |
| 1671 | } | } |
| 1672 | ||
| 1673 | /* Now see if the situation is what we want */ | /* Now see if the situation is what we want */ |
| # | Line 1331 for (;;) | Line 1681 for (;;) |
| 1681 | /* Match a single character type; inline for speed */ | /* Match a single character type; inline for speed */ |
| 1682 | ||
| 1683 | case OP_ANY: | case OP_ANY: |
| 1684 | if ((ims & PCRE_DOTALL) == 0) | if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); |
| 1685 | /* Fall through */ | |
| 1686 | ||
| 1687 | case OP_ALLANY: | |
| 1688 | if (eptr++ >= md->end_subject) | |
| 1689 | { | { |
| 1690 | if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); | SCHECK_PARTIAL(); |
| 1691 | RRETURN(MATCH_NOMATCH); | |
| 1692 | } | } |
| 1693 | if (eptr++ >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| if (utf8) | ||
| while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | ||
| 1694 | ecode++; | ecode++; |
| 1695 | break; | break; |
| 1696 | ||
| # | Line 1345 for (;;) | Line 1698 for (;;) |
| 1698 | any byte, even newline, independent of the setting of PCRE_DOTALL. */ | any byte, even newline, independent of the setting of PCRE_DOTALL. */ |
| 1699 | ||
| 1700 | case OP_ANYBYTE: | case OP_ANYBYTE: |
| 1701 | if (eptr++ >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr++ >= md->end_subject) |
| 1702 | { | |
| 1703 | SCHECK_PARTIAL(); | |
| 1704 | RRETURN(MATCH_NOMATCH); | |
| 1705 | } | |
| 1706 | ecode++; | ecode++; |
| 1707 | break; | break; |
| 1708 | ||
| 1709 | case OP_NOT_DIGIT: | case OP_NOT_DIGIT: |
| 1710 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1711 | { | |
| 1712 | SCHECK_PARTIAL(); | |
| 1713 | RRETURN(MATCH_NOMATCH); | |
| 1714 | } | |
| 1715 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1716 | if ( | if ( |
| 1717 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| # | Line 1363 for (;;) | Line 1724 for (;;) |
| 1724 | break; | break; |
| 1725 | ||
| 1726 | case OP_DIGIT: | case OP_DIGIT: |
| 1727 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1728 | { | |
| 1729 | SCHECK_PARTIAL(); | |
| 1730 | RRETURN(MATCH_NOMATCH); | |
| 1731 | } | |
| 1732 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1733 | if ( | if ( |
| 1734 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| # | Line 1376 for (;;) | Line 1741 for (;;) |
| 1741 | break; | break; |
| 1742 | ||
| 1743 | case OP_NOT_WHITESPACE: | case OP_NOT_WHITESPACE: |
| 1744 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1745 | { | |
| 1746 | SCHECK_PARTIAL(); | |
| 1747 | RRETURN(MATCH_NOMATCH); | |
| 1748 | } | |
| 1749 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1750 | if ( | if ( |
| 1751 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| # | Line 1389 for (;;) | Line 1758 for (;;) |
| 1758 | break; | break; |
| 1759 | ||
| 1760 | case OP_WHITESPACE: | case OP_WHITESPACE: |
| 1761 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1762 | { | |
| 1763 | SCHECK_PARTIAL(); | |
| 1764 | RRETURN(MATCH_NOMATCH); | |
| 1765 | } | |
| 1766 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1767 | if ( | if ( |
| 1768 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| # | Line 1402 for (;;) | Line 1775 for (;;) |
| 1775 | break; | break; |
| 1776 | ||
| 1777 | case OP_NOT_WORDCHAR: | case OP_NOT_WORDCHAR: |
| 1778 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1779 | { | |
| 1780 | SCHECK_PARTIAL(); | |
| 1781 | RRETURN(MATCH_NOMATCH); | |
| 1782 | } | |
| 1783 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1784 | if ( | if ( |
| 1785 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| # | Line 1415 for (;;) | Line 1792 for (;;) |
| 1792 | break; | break; |
| 1793 | ||
| 1794 | case OP_WORDCHAR: | case OP_WORDCHAR: |
| 1795 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1796 | { | |
| 1797 | SCHECK_PARTIAL(); | |
| 1798 | RRETURN(MATCH_NOMATCH); | |
| 1799 | } | |
| 1800 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1801 | if ( | if ( |
| 1802 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| # | Line 1428 for (;;) | Line 1809 for (;;) |
| 1809 | break; | break; |
| 1810 | ||
| 1811 | case OP_ANYNL: | case OP_ANYNL: |
| 1812 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1813 | { | |
| 1814 | SCHECK_PARTIAL(); | |
| 1815 | RRETURN(MATCH_NOMATCH); | |
| 1816 | } | |
| 1817 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1818 | switch(c) | switch(c) |
| 1819 | { | { |
| # | Line 1436 for (;;) | Line 1821 for (;;) |
| 1821 | case 0x000d: | case 0x000d: |
| 1822 | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 1823 | break; | break; |
| 1824 | ||
| 1825 | case 0x000a: | case 0x000a: |
| 1826 | break; | |
| 1827 | ||
| 1828 | case 0x000b: | case 0x000b: |
| 1829 | case 0x000c: | case 0x000c: |
| 1830 | case 0x0085: | case 0x0085: |
| 1831 | case 0x2028: | case 0x2028: |
| 1832 | case 0x2029: | case 0x2029: |
| 1833 | if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); | |
| 1834 | break; | |
| 1835 | } | |
| 1836 | ecode++; | |
| 1837 | break; | |
| 1838 | ||
| 1839 | case OP_NOT_HSPACE: | |
| 1840 | if (eptr >= md->end_subject) | |
| 1841 | { | |
| 1842 | SCHECK_PARTIAL(); | |
| 1843 | RRETURN(MATCH_NOMATCH); | |
| 1844 | } | |
| 1845 | GETCHARINCTEST(c, eptr); | |
| 1846 | switch(c) | |
| 1847 | { | |
| 1848 | default: break; | |
| 1849 | case 0x09: /* HT */ | |
| 1850 | case 0x20: /* SPACE */ | |
| 1851 | case 0xa0: /* NBSP */ | |
| 1852 | case 0x1680: /* OGHAM SPACE MARK */ | |
| 1853 | case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ | |
| 1854 | case 0x2000: /* EN QUAD */ | |
| 1855 | case 0x2001: /* EM QUAD */ | |
| 1856 | case 0x2002: /* EN SPACE */ | |
| 1857 | case 0x2003: /* EM SPACE */ | |
| 1858 | case 0x2004: /* THREE-PER-EM SPACE */ | |
| 1859 | case 0x2005: /* FOUR-PER-EM SPACE */ | |
| 1860 | case 0x2006: /* SIX-PER-EM SPACE */ | |
| 1861 | case 0x2007: /* FIGURE SPACE */ | |
| 1862 | case 0x2008: /* PUNCTUATION SPACE */ | |
| 1863 | case 0x2009: /* THIN SPACE */ | |
| 1864 | case 0x200A: /* HAIR SPACE */ | |
| 1865 | case 0x202f: /* NARROW NO-BREAK SPACE */ | |
| 1866 | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ | |
| 1867 | case 0x3000: /* IDEOGRAPHIC SPACE */ | |
| 1868 | RRETURN(MATCH_NOMATCH); | |
| 1869 | } | |
| 1870 | ecode++; | |
| 1871 | break; | |
| 1872 | ||
| 1873 | case OP_HSPACE: | |
| 1874 | if (eptr >= md->end_subject) | |
| 1875 | { | |
| 1876 | SCHECK_PARTIAL(); | |
| 1877 | RRETURN(MATCH_NOMATCH); | |
| 1878 | } | |
| 1879 | GETCHARINCTEST(c, eptr); | |
| 1880 | switch(c) | |
| 1881 | { | |
| 1882 | default: RRETURN(MATCH_NOMATCH); | |
| 1883 | case 0x09: /* HT */ | |
| 1884 | case 0x20: /* SPACE */ | |
| 1885 | case 0xa0: /* NBSP */ | |
| 1886 | case 0x1680: /* OGHAM SPACE MARK */ | |
| 1887 | case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ | |
| 1888 | case 0x2000: /* EN QUAD */ | |
| 1889 | case 0x2001: /* EM QUAD */ | |
| 1890 | case 0x2002: /* EN SPACE */ | |
| 1891 | case 0x2003: /* EM SPACE */ | |
| 1892 | case 0x2004: /* THREE-PER-EM SPACE */ | |
| 1893 | case 0x2005: /* FOUR-PER-EM SPACE */ | |
| 1894 | case 0x2006: /* SIX-PER-EM SPACE */ | |
| 1895 | case 0x2007: /* FIGURE SPACE */ | |
| 1896 | case 0x2008: /* PUNCTUATION SPACE */ | |
| 1897 | case 0x2009: /* THIN SPACE */ | |
| 1898 | case 0x200A: /* HAIR SPACE */ | |
| 1899 | case 0x202f: /* NARROW NO-BREAK SPACE */ | |
| 1900 | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ | |
| 1901 | case 0x3000: /* IDEOGRAPHIC SPACE */ | |
| 1902 | break; | |
| 1903 | } | |
| 1904 | ecode++; | |
| 1905 | break; | |
| 1906 | ||
| 1907 | case OP_NOT_VSPACE: | |
| 1908 | if (eptr >= md->end_subject) | |
| 1909 | { | |
| 1910 | SCHECK_PARTIAL(); | |
| 1911 | RRETURN(MATCH_NOMATCH); | |
| 1912 | } | |
| 1913 | GETCHARINCTEST(c, eptr); | |
| 1914 | switch(c) | |
| 1915 | { | |
| 1916 | default: break; | |
| 1917 | case 0x0a: /* LF */ | |
| 1918 | case 0x0b: /* VT */ | |
| 1919 | case 0x0c: /* FF */ | |
| 1920 | case 0x0d: /* CR */ | |
| 1921 | case 0x85: /* NEL */ | |
| 1922 | case 0x2028: /* LINE SEPARATOR */ | |
| 1923 | case 0x2029: /* PARAGRAPH SEPARATOR */ | |
| 1924 | RRETURN(MATCH_NOMATCH); | |
| 1925 | } | |
| 1926 | ecode++; | |
| 1927 | break; | |
| 1928 | ||
| 1929 | case OP_VSPACE: | |
| 1930 | if (eptr >= md->end_subject) | |
| 1931 | { | |
| 1932 | SCHECK_PARTIAL(); | |
| 1933 | RRETURN(MATCH_NOMATCH); | |
| 1934 | } | |
| 1935 | GETCHARINCTEST(c, eptr); | |
| 1936 | switch(c) | |
| 1937 | { | |
| 1938 | default: RRETURN(MATCH_NOMATCH); | |
| 1939 | case 0x0a: /* LF */ | |
| 1940 | case 0x0b: /* VT */ | |
| 1941 | case 0x0c: /* FF */ | |
| 1942 | case 0x0d: /* CR */ | |
| 1943 | case 0x85: /* NEL */ | |
| 1944 | case 0x2028: /* LINE SEPARATOR */ | |
| 1945 | case 0x2029: /* PARAGRAPH SEPARATOR */ | |
| 1946 | break; | break; |
| 1947 | } | } |
| 1948 | ecode++; | ecode++; |
| # | Line 1453 for (;;) | Line 1954 for (;;) |
| 1954 | ||
| 1955 | case OP_PROP: | case OP_PROP: |
| 1956 | case OP_NOTPROP: | case OP_NOTPROP: |
| 1957 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1958 | { | |
| 1959 | SCHECK_PARTIAL(); | |
| 1960 | RRETURN(MATCH_NOMATCH); | |
| 1961 | } | |
| 1962 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1963 | { | { |
| 1964 | int chartype, script; | const ucd_record *prop = GET_UCD(c); |
| int category = _pcre_ucp_findprop(c, &chartype, &script); | ||
| 1965 | ||
| 1966 | switch(ecode[1]) | switch(ecode[1]) |
| 1967 | { | { |
| # | Line 1466 for (;;) | Line 1970 for (;;) |
| 1970 | break; | break; |
| 1971 | ||
| 1972 | case PT_LAMP: | case PT_LAMP: |
| 1973 | if ((chartype == ucp_Lu || | if ((prop->chartype == ucp_Lu || |
| 1974 | chartype == ucp_Ll || | prop->chartype == ucp_Ll || |
| 1975 | chartype == ucp_Lt) == (op == OP_NOTPROP)) | prop->chartype == ucp_Lt) == (op == OP_NOTPROP)) |
| 1976 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 1977 | break; | break; |
| 1978 | ||
| 1979 | case PT_GC: | case PT_GC: |
| 1980 | if ((ecode[2] != category) == (op == OP_PROP)) | if ((ecode[2] != _pcre_ucp_gentype[prop->chartype]) == (op == OP_PROP)) |
| 1981 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 1982 | break; | break; |
| 1983 | ||
| 1984 | case PT_PC: | case PT_PC: |
| 1985 | if ((ecode[2] != chartype) == (op == OP_PROP)) | if ((ecode[2] != prop->chartype) == (op == OP_PROP)) |
| 1986 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 1987 | break; | break; |
| 1988 | ||
| 1989 | case PT_SC: | case PT_SC: |
| 1990 | if ((ecode[2] != script) == (op == OP_PROP)) | if ((ecode[2] != prop->script) == (op == OP_PROP)) |
| 1991 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 1992 | break; | break; |
| 1993 | ||
| # | Line 1499 for (;;) | Line 2003 for (;;) |
| 2003 | is in the binary; otherwise a compile-time error occurs. */ | is in the binary; otherwise a compile-time error occurs. */ |
| 2004 | ||
| 2005 | case OP_EXTUNI: | case OP_EXTUNI: |
| 2006 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 2007 | { | |
| 2008 | SCHECK_PARTIAL(); | |
| 2009 | RRETURN(MATCH_NOMATCH); | |
| 2010 | } | |
| 2011 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2012 | { | { |
| 2013 | int chartype, script; | int category = UCD_CATEGORY(c); |
| int category = _pcre_ucp_findprop(c, &chartype, &script); | ||
| 2014 | if (category == ucp_M) RRETURN(MATCH_NOMATCH); | if (category == ucp_M) RRETURN(MATCH_NOMATCH); |
| 2015 | while (eptr < md->end_subject) | while (eptr < md->end_subject) |
| 2016 | { | { |
| # | Line 1512 for (;;) | Line 2019 for (;;) |
| 2019 | { | { |
| 2020 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 2021 | } | } |
| 2022 | category = _pcre_ucp_findprop(c, &chartype, &script); | category = UCD_CATEGORY(c); |
| 2023 | if (category != ucp_M) break; | if (category != ucp_M) break; |
| 2024 | eptr += len; | eptr += len; |
| 2025 | } | } |
| # | Line 1533 for (;;) | Line 2040 for (;;) |
| 2040 | case OP_REF: | case OP_REF: |
| 2041 | { | { |
| 2042 | offset = GET2(ecode, 1) << 1; /* Doubled ref number */ | offset = GET2(ecode, 1) << 1; /* Doubled ref number */ |
| 2043 | ecode += 3; /* Advance past item */ | ecode += 3; |
| 2044 | ||
| 2045 | /* If the reference is unset, there are two possibilities: | |
| 2046 | ||
| 2047 | (a) In the default, Perl-compatible state, set the length to be longer | |
| 2048 | than the amount of subject left; this ensures that every attempt at a | |
| 2049 | match fails. We can't just fail here, because of the possibility of | |
| 2050 | quantifiers with zero minima. | |
| 2051 | ||
| 2052 | (b) If the JavaScript compatibility flag is set, set the length to zero | |
| 2053 | so that the back reference matches an empty string. | |
| 2054 | ||
| 2055 | Otherwise, set the length to the length of what was matched by the | |
| 2056 | referenced subpattern. */ | |
| 2057 | ||
| 2058 | /* If the reference is unset, set the length to be longer than the amount | if (offset >= offset_top || md->offset_vector[offset] < 0) |
| 2059 | of subject left; this ensures that every attempt at a match fails. We | length = (md->jscript_compat)? 0 : md->end_subject - eptr + 1; |
| 2060 | can't just fail here, because of the possibility of quantifiers with zero | else |
| 2061 | minima. */ | length = md->offset_vector[offset+1] - md->offset_vector[offset]; |
| length = (offset >= offset_top || md->offset_vector[offset] < 0)? | ||
| md->end_subject - eptr + 1 : | ||
| md->offset_vector[offset+1] - md->offset_vector[offset]; | ||
| 2062 | ||
| 2063 | /* Set up for repetition, or handle the non-repeated case */ | /* Set up for repetition, or handle the non-repeated case */ |
| 2064 | ||
| # | Line 1571 for (;;) | Line 2087 for (;;) |
| 2087 | break; | break; |
| 2088 | ||
| 2089 | default: /* No repeat follows */ | default: /* No repeat follows */ |
| 2090 | if (!match_ref(offset, eptr, length, md, ims)) RRETURN(MATCH_NOMATCH); | if (!match_ref(offset, eptr, length, md, ims)) |
| 2091 | { | |
| 2092 | CHECK_PARTIAL(); | |
| 2093 | RRETURN(MATCH_NOMATCH); | |
| 2094 | } | |
| 2095 | eptr += length; | eptr += length; |
| 2096 | continue; /* With the main loop */ | continue; /* With the main loop */ |
| 2097 | } | } |
| # | Line 1587 for (;;) | Line 2107 for (;;) |
| 2107 | ||
| 2108 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 2109 | { | { |
| 2110 | if (!match_ref(offset, eptr, length, md, ims)) RRETURN(MATCH_NOMATCH); | if (!match_ref(offset, eptr, length, md, ims)) |
| 2111 | { | |
| 2112 | CHECK_PARTIAL(); | |
| 2113 | RRETURN(MATCH_NOMATCH); | |
| 2114 | } | |
| 2115 | eptr += length; | eptr += length; |
| 2116 | } | } |
| 2117 | ||
| # | Line 1602 for (;;) | Line 2126 for (;;) |
| 2126 | { | { |
| 2127 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 2128 | { | { |
| 2129 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM14); |
| 2130 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2131 | if (fi >= max || !match_ref(offset, eptr, length, md, ims)) | if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 2132 | if (!match_ref(offset, eptr, length, md, ims)) | |
| 2133 | { | |
| 2134 | CHECK_PARTIAL(); | |
| 2135 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 2136 | } | |
| 2137 | eptr += length; | eptr += length; |
| 2138 | } | } |
| 2139 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 1618 for (;;) | Line 2146 for (;;) |
| 2146 | pp = eptr; | pp = eptr; |
| 2147 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 2148 | { | { |
| 2149 | if (!match_ref(offset, eptr, length, md, ims)) break; | if (!match_ref(offset, eptr, length, md, ims)) |
| 2150 | { | |
| 2151 | CHECK_PARTIAL(); | |
| 2152 | break; | |
| 2153 | } | |
| 2154 | eptr += length; | eptr += length; |
| 2155 | } | } |
| 2156 | while (eptr >= pp) | while (eptr >= pp) |
| 2157 | { | { |
| 2158 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM15); |
| 2159 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2160 | eptr -= length; | eptr -= length; |
| 2161 | } | } |
| # | Line 1632 for (;;) | Line 2164 for (;;) |
| 2164 | } | } |
| 2165 | /* Control never gets here */ | /* Control never gets here */ |
| 2166 | ||
| 2167 | /* Match a bit-mapped character class, possibly repeatedly. This op code is | /* Match a bit-mapped character class, possibly repeatedly. This op code is |
| 2168 | used when all the characters in the class have values in the range 0-255, | used when all the characters in the class have values in the range 0-255, |
| 2169 | and either the matching is caseful, or the characters are in the range | and either the matching is caseful, or the characters are in the range |
| # | Line 1688 for (;;) | Line 2218 for (;;) |
| 2218 | { | { |
| 2219 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 2220 | { | { |
| 2221 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 2222 | { | |
| 2223 | SCHECK_PARTIAL(); | |
| 2224 | RRETURN(MATCH_NOMATCH); | |
| 2225 | } | |
| 2226 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 2227 | if (c > 255) | if (c > 255) |
| 2228 | { | { |
| # | Line 1706 for (;;) | Line 2240 for (;;) |
| 2240 | { | { |
| 2241 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 2242 | { | { |
| 2243 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 2244 | { | |
| 2245 | SCHECK_PARTIAL(); | |
| 2246 | RRETURN(MATCH_NOMATCH); | |
| 2247 | } | |
| 2248 | c = *eptr++; | c = *eptr++; |
| 2249 | if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH); | if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH); |
| 2250 | } | } |
| # | Line 1728 for (;;) | Line 2266 for (;;) |
| 2266 | { | { |
| 2267 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 2268 | { | { |
| 2269 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM16); |
| 2270 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2271 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 2272 | if (eptr >= md->end_subject) | |
| 2273 | { | |
| 2274 | SCHECK_PARTIAL(); | |
| 2275 | RRETURN(MATCH_NOMATCH); | |
| 2276 | } | |
| 2277 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 2278 | if (c > 255) | if (c > 255) |
| 2279 | { | { |
| # | Line 1748 for (;;) | Line 2291 for (;;) |
| 2291 | { | { |
| 2292 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 2293 | { | { |
| 2294 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM17); |
| 2295 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2296 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 2297 | if (eptr >= md->end_subject) | |
| 2298 | { | |
| 2299 | SCHECK_PARTIAL(); | |
| 2300 | RRETURN(MATCH_NOMATCH); | |
| 2301 | } | |
| 2302 | c = *eptr++; | c = *eptr++; |
| 2303 | if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH); | if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH); |
| 2304 | } | } |
| # | Line 1771 for (;;) | Line 2319 for (;;) |
| 2319 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 2320 | { | { |
| 2321 | int len = 1; | int len = 1; |
| 2322 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 2323 | { | |
| 2324 | SCHECK_PARTIAL(); | |
| 2325 | break; | |
| 2326 | } | |
| 2327 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 2328 | if (c > 255) | if (c > 255) |
| 2329 | { | { |
| # | Line 1785 for (;;) | Line 2337 for (;;) |
| 2337 | } | } |
| 2338 | for (;;) | for (;;) |
| 2339 | { | { |
| 2340 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM18); |
| 2341 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2342 | if (eptr-- == pp) break; /* Stop if tried at original pos */ | if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 2343 | BACKCHAR(eptr); | BACKCHAR(eptr); |
| # | Line 1797 for (;;) | Line 2349 for (;;) |
| 2349 | { | { |
| 2350 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 2351 | { | { |
| 2352 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 2353 | { | |
| 2354 | SCHECK_PARTIAL(); | |
| 2355 | break; | |
| 2356 | } | |
| 2357 | c = *eptr; | c = *eptr; |
| 2358 | if ((data[c/8] & (1 << (c&7))) == 0) break; | if ((data[c/8] & (1 << (c&7))) == 0) break; |
| 2359 | eptr++; | eptr++; |
| 2360 | } | } |
| 2361 | while (eptr >= pp) | while (eptr >= pp) |
| 2362 | { | { |
| 2363 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM19); |
| 2364 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2365 | eptr--; | eptr--; |
| 2366 | } | } |
| # | Line 1817 for (;;) | Line 2373 for (;;) |
| 2373 | ||
| 2374 | ||
| 2375 | /* Match an extended character class. This opcode is encountered only | /* Match an extended character class. This opcode is encountered only |
| 2376 | 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 |
| 2377 | mode, because Unicode properties are supported in non-UTF-8 mode. */ | |
| 2378 | ||
| 2379 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| 2380 | case OP_XCLASS: | case OP_XCLASS: |
| # | Line 1858 for (;;) | Line 2415 for (;;) |
| 2415 | ||
| 2416 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 2417 | { | { |
| 2418 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 2419 | GETCHARINC(c, eptr); | { |
| 2420 | SCHECK_PARTIAL(); | |
| 2421 | RRETURN(MATCH_NOMATCH); | |
| 2422 | } | |
| 2423 | GETCHARINCTEST(c, eptr); | |
| 2424 | if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH); | if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH); |
| 2425 | } | } |
| 2426 | ||
| # | Line 1875 for (;;) | Line 2436 for (;;) |
| 2436 | { | { |
| 2437 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 2438 | { | { |
| 2439 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM20); |
| 2440 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2441 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 2442 | GETCHARINC(c, eptr); | if (eptr >= md->end_subject) |
| 2443 | { | |
| 2444 | SCHECK_PARTIAL(); | |
| 2445 | RRETURN(MATCH_NOMATCH); | |
| 2446 | } | |
| 2447 | GETCHARINCTEST(c, eptr); | |
| 2448 | if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH); | if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH); |
| 2449 | } | } |
| 2450 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 1892 for (;;) | Line 2458 for (;;) |
| 2458 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 2459 | { | { |
| 2460 | int len = 1; | int len = 1; |
| 2461 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 2462 | GETCHARLEN(c, eptr, len); | { |
| 2463 | SCHECK_PARTIAL(); | |
| 2464 | break; | |
| 2465 | } | |
| 2466 | GETCHARLENTEST(c, eptr, len); | |
| 2467 | if (!_pcre_xclass(c, data)) break; | if (!_pcre_xclass(c, data)) break; |
| 2468 | eptr += len; | eptr += len; |
| 2469 | } | } |
| 2470 | for(;;) | for(;;) |
| 2471 | { | { |
| 2472 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM21); |
| 2473 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2474 | if (eptr-- == pp) break; /* Stop if tried at original pos */ | if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 2475 | BACKCHAR(eptr) | if (utf8) BACKCHAR(eptr); |
| 2476 | } | } |
| 2477 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 2478 | } | } |
| # | Line 1920 for (;;) | Line 2490 for (;;) |
| 2490 | length = 1; | length = 1; |
| 2491 | ecode++; | ecode++; |
| 2492 | GETCHARLEN(fc, ecode, length); | GETCHARLEN(fc, ecode, length); |
| 2493 | if (length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH); | if (length > md->end_subject - eptr) |
| 2494 | { | |
| 2495 | CHECK_PARTIAL(); /* Not SCHECK_PARTIAL() */ | |
| 2496 | RRETURN(MATCH_NOMATCH); | |
| 2497 | } | |
| 2498 | while (length-- > 0) if (*ecode++ != *eptr++) RRETURN(MATCH_NOMATCH); | while (length-- > 0) if (*ecode++ != *eptr++) RRETURN(MATCH_NOMATCH); |
| 2499 | } | } |
| 2500 | else | else |
| # | Line 1928 for (;;) | Line 2502 for (;;) |
| 2502 | ||
| 2503 | /* Non-UTF-8 mode */ | /* Non-UTF-8 mode */ |
| 2504 | { | { |
| 2505 | if (md->end_subject - eptr < 1) RRETURN(MATCH_NOMATCH); | if (md->end_subject - eptr < 1) |
| 2506 | { | |
| 2507 | SCHECK_PARTIAL(); /* This one can use SCHECK_PARTIAL() */ | |
| 2508 | RRETURN(MATCH_NOMATCH); | |
| 2509 | } | |
| 2510 | if (ecode[1] != *eptr++) RRETURN(MATCH_NOMATCH); | if (ecode[1] != *eptr++) RRETURN(MATCH_NOMATCH); |
| 2511 | ecode += 2; | ecode += 2; |
| 2512 | } | } |
| # | Line 1944 for (;;) | Line 2522 for (;;) |
| 2522 | ecode++; | ecode++; |
| 2523 | GETCHARLEN(fc, ecode, length); | GETCHARLEN(fc, ecode, length); |
| 2524 | ||
| 2525 | if (length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH); | if (length > md->end_subject - eptr) |
| 2526 | { | |
| 2527 | CHECK_PARTIAL(); /* Not SCHECK_PARTIAL() */ | |
| 2528 | RRETURN(MATCH_NOMATCH); | |
| 2529 | } | |
| 2530 | ||
| 2531 | /* If the pattern character's value is < 128, we have only one byte, and | /* If the pattern character's value is < 128, we have only one byte, and |
| 2532 | can use the fast lookup table. */ | can use the fast lookup table. */ |
| # | Line 1968 for (;;) | Line 2550 for (;;) |
| 2550 | if (fc != dc) | if (fc != dc) |
| 2551 | { | { |
| 2552 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 2553 | if (dc != _pcre_ucp_othercase(fc)) | if (dc != UCD_OTHERCASE(fc)) |
| 2554 | #endif | #endif |
| 2555 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 2556 | } | } |
| # | Line 1979 for (;;) | Line 2561 for (;;) |
| 2561 | ||
| 2562 | /* Non-UTF-8 mode */ | /* Non-UTF-8 mode */ |
| 2563 | { | { |
| 2564 | if (md->end_subject - eptr < 1) RRETURN(MATCH_NOMATCH); | if (md->end_subject - eptr < 1) |
| 2565 | { | |
| 2566 | SCHECK_PARTIAL(); /* This one can use SCHECK_PARTIAL() */ | |
| 2567 | RRETURN(MATCH_NOMATCH); | |
| 2568 | } | |
| 2569 | if (md->lcc[ecode[1]] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); | if (md->lcc[ecode[1]] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); |
| 2570 | ecode += 2; | ecode += 2; |
| 2571 | } | } |
| # | Line 2033 for (;;) | Line 2619 for (;;) |
| 2619 | case OP_MINQUERY: | case OP_MINQUERY: |
| 2620 | c = *ecode++ - OP_STAR; | c = *ecode++ - OP_STAR; |
| 2621 | minimize = (c & 1) != 0; | minimize = (c & 1) != 0; |
| 2622 | ||
| 2623 | min = rep_min[c]; /* Pick up values from tables; */ | min = rep_min[c]; /* Pick up values from tables; */ |
| 2624 | max = rep_max[c]; /* zero for max => infinity */ | max = rep_max[c]; /* zero for max => infinity */ |
| 2625 | if (max == 0) max = INT_MAX; | if (max == 0) max = INT_MAX; |
| 2626 | ||
| 2627 | /* Common code for all repeated single-character matches. We can give | /* Common code for all repeated single-character matches. */ |
| up quickly if there are fewer than the minimum number of characters left in | ||
| the subject. */ | ||
| 2628 | ||
| 2629 | REPEATCHAR: | REPEATCHAR: |
| 2630 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| # | Line 2048 for (;;) | Line 2633 for (;;) |
| 2633 | length = 1; | length = 1; |
| 2634 | charptr = ecode; | charptr = ecode; |
| 2635 | GETCHARLEN(fc, ecode, length); | GETCHARLEN(fc, ecode, length); |
| if (min * length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH); | ||
| 2636 | ecode += length; | ecode += length; |
| 2637 | ||
| 2638 | /* Handle multibyte character matching specially here. There is | /* Handle multibyte character matching specially here. There is |
| # | Line 2059 for (;;) | Line 2643 for (;;) |
| 2643 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 2644 | unsigned int othercase; | unsigned int othercase; |
| 2645 | if ((ims & PCRE_CASELESS) != 0 && | if ((ims & PCRE_CASELESS) != 0 && |
| 2646 | (othercase = _pcre_ucp_othercase(fc)) != NOTACHAR) | (othercase = UCD_OTHERCASE(fc)) != fc) |
| 2647 | oclength = _pcre_ord2utf8(othercase, occhars); | oclength = _pcre_ord2utf8(othercase, occhars); |
| 2648 | else oclength = 0; | else oclength = 0; |
| 2649 | #endif /* SUPPORT_UCP */ | #endif /* SUPPORT_UCP */ |
| 2650 | ||
| 2651 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 2652 | { | { |
| 2653 | if (memcmp(eptr, charptr, length) == 0) eptr += length; | if (eptr <= md->end_subject - length && |
| 2654 | memcmp(eptr, charptr, length) == 0) eptr += length; | |
| 2655 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 2656 | /* Need braces because of following else */ | else if (oclength > 0 && |
| 2657 | else if (oclength == 0) { RRETURN(MATCH_NOMATCH); } | eptr <= md->end_subject - oclength && |
| 2658 | memcmp(eptr, occhars, oclength) == 0) eptr += oclength; | |
| 2659 | #endif /* SUPPORT_UCP */ | |
| 2660 | else | else |
| 2661 | { | { |
| 2662 | if (memcmp(eptr, occhars, oclength) != 0) RRETURN(MATCH_NOMATCH); | CHECK_PARTIAL(); |
| 2663 | eptr += oclength; | RRETURN(MATCH_NOMATCH); |
| 2664 | } | } |
| #else /* without SUPPORT_UCP */ | ||
| else { RRETURN(MATCH_NOMATCH); } | ||
| #endif /* SUPPORT_UCP */ | ||
| 2665 | } | } |
| 2666 | ||
| 2667 | if (min == max) continue; | if (min == max) continue; |
| # | Line 2086 for (;;) | Line 2670 for (;;) |
| 2670 | { | { |
| 2671 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 2672 | { | { |
| 2673 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM22); |
| 2674 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2675 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 2676 | if (memcmp(eptr, charptr, length) == 0) eptr += length; | if (eptr <= md->end_subject - length && |
| 2677 | memcmp(eptr, charptr, length) == 0) eptr += length; | |
| 2678 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 2679 | /* Need braces because of following else */ | else if (oclength > 0 && |
| 2680 | else if (oclength == 0) { RRETURN(MATCH_NOMATCH); } | eptr <= md->end_subject - oclength && |
| 2681 | memcmp(eptr, occhars, oclength) == 0) eptr += oclength; | |
| 2682 | #endif /* SUPPORT_UCP */ | |
| 2683 | else | else |
| 2684 | { | { |
| 2685 | if (memcmp(eptr, occhars, oclength) != 0) RRETURN(MATCH_NOMATCH); | CHECK_PARTIAL(); |
| 2686 | eptr += oclength; | RRETURN(MATCH_NOMATCH); |
| 2687 | } | } |
| #else /* without SUPPORT_UCP */ | ||
| else { RRETURN (MATCH_NOMATCH); } | ||
| #endif /* SUPPORT_UCP */ | ||
| 2688 | } | } |
| 2689 | /* Control never gets here */ | /* Control never gets here */ |
| 2690 | } | } |
| # | Line 2110 for (;;) | Line 2694 for (;;) |
| 2694 | pp = eptr; | pp = eptr; |
| 2695 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 2696 | { | { |
| 2697 | if (eptr > md->end_subject - length) break; | if (eptr <= md->end_subject - length && |
| 2698 | if (memcmp(eptr, charptr, length) == 0) eptr += length; | memcmp(eptr, charptr, length) == 0) eptr += length; |
| 2699 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 2700 | else if (oclength == 0) break; | else if (oclength > 0 && |
| 2701 | else | eptr <= md->end_subject - oclength && |
| 2702 | { | memcmp(eptr, occhars, oclength) == 0) eptr += oclength; |
| if (memcmp(eptr, occhars, oclength) != 0) break; | ||
| eptr += oclength; | ||
| } | ||
| #else /* without SUPPORT_UCP */ | ||
| else break; | ||
| 2703 | #endif /* SUPPORT_UCP */ | #endif /* SUPPORT_UCP */ |
| 2704 | else | |
| 2705 | { | |
| 2706 | CHECK_PARTIAL(); | |
| 2707 | break; | |
| 2708 | } | |
| 2709 | } | } |
| 2710 | ||
| 2711 | if (possessive) continue; | if (possessive) continue; |
| 2712 | ||
| 2713 | for(;;) | for(;;) |
| 2714 | { | { |
| 2715 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM23); |
| 2716 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2717 | if (eptr == pp) RRETURN(MATCH_NOMATCH); | if (eptr == pp) { RRETURN(MATCH_NOMATCH); } |
| 2718 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 2719 | eptr--; | eptr--; |
| 2720 | BACKCHAR(eptr); | BACKCHAR(eptr); |
| 2721 | #else /* without SUPPORT_UCP */ | #else /* without SUPPORT_UCP */ |
| 2722 | eptr -= length; | eptr -= length; |
| 2723 | #endif /* SUPPORT_UCP */ | #endif /* SUPPORT_UCP */ |
| 2724 | } | } |
| 2725 | } | } |
| 2726 | /* Control never gets here */ | /* Control never gets here */ |
| 2727 | } | } |
| # | Line 2149 for (;;) | Line 2734 for (;;) |
| 2734 | #endif /* SUPPORT_UTF8 */ | #endif /* SUPPORT_UTF8 */ |
| 2735 | ||
| 2736 | /* When not in UTF-8 mode, load a single-byte character. */ | /* When not in UTF-8 mode, load a single-byte character. */ |
| 2737 | { | |
| 2738 | if (min > md->end_subject - eptr) RRETURN(MATCH_NOMATCH); | fc = *ecode++; |
| fc = *ecode++; | ||
| } | ||
| 2739 | ||
| 2740 | /* The value of fc at this point is always less than 256, though we may or | /* The value of fc at this point is always less than 256, though we may or |
| 2741 | may not be in UTF-8 mode. The code is duplicated for the caseless and | may not be in UTF-8 mode. The code is duplicated for the caseless and |
| # | Line 2170 for (;;) | Line 2753 for (;;) |
| 2753 | { | { |
| 2754 | fc = md->lcc[fc]; | fc = md->lcc[fc]; |
| 2755 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 2756 | { | |
| 2757 | if (eptr >= md->end_subject) | |
| 2758 | { | |
| 2759 | SCHECK_PARTIAL(); | |
| 2760 | RRETURN(MATCH_NOMATCH); | |
| 2761 | } | |
| 2762 | if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); | if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); |
| 2763 | } | |
| 2764 | if (min == max) continue; | if (min == max) continue; |
| 2765 | if (minimize) | if (minimize) |
| 2766 | { | { |
| 2767 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 2768 | { | { |
| 2769 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM24); |
| 2770 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2771 | if (fi >= max || eptr >= md->end_subject || | if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 2772 | fc != md->lcc[*eptr++]) | if (eptr >= md->end_subject) |
| 2773 | { | |
| 2774 | SCHECK_PARTIAL(); | |
| 2775 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 2776 | } | |
| 2777 | if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); | |
| 2778 | } | } |
| 2779 | /* Control never gets here */ | /* Control never gets here */ |
| 2780 | } | } |
| # | Line 2189 for (;;) | Line 2783 for (;;) |
| 2783 | pp = eptr; | pp = eptr; |
| 2784 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 2785 | { | { |
| 2786 | if (eptr >= md->end_subject || fc != md->lcc[*eptr]) break; | if (eptr >= md->end_subject) |
| 2787 | { | |
| 2788 | SCHECK_PARTIAL(); | |
| 2789 | break; | |
| 2790 | } | |
| 2791 | if (fc != md->lcc[*eptr]) break; | |
| 2792 | eptr++; | eptr++; |
| 2793 | } | } |
| 2794 | ||
| 2795 | if (possessive) continue; | if (possessive) continue; |
| 2796 | ||
| 2797 | while (eptr >= pp) | while (eptr >= pp) |
| 2798 | { | { |
| 2799 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM25); |
| 2800 | eptr--; | eptr--; |
| 2801 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2802 | } | } |
| # | Line 2208 for (;;) | Line 2809 for (;;) |
| 2809 | ||
| 2810 | else | else |
| 2811 | { | { |
| 2812 | for (i = 1; i <= min; i++) if (fc != *eptr++) RRETURN(MATCH_NOMATCH); | for (i = 1; i <= min; i++) |
| 2813 | { | |
| 2814 | if (eptr >= md->end_subject) | |
| 2815 | { | |
| 2816 | SCHECK_PARTIAL(); | |
| 2817 | RRETURN(MATCH_NOMATCH); | |
| 2818 | } | |
| 2819 | if (fc != *eptr++) RRETURN(MATCH_NOMATCH); | |
| 2820 | } | |
| 2821 | ||
| 2822 | if (min == max) continue; | if (min == max) continue; |
| 2823 | ||
| 2824 | if (minimize) | if (minimize) |
| 2825 | { | { |
| 2826 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 2827 | { | { |
| 2828 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM26); |
| 2829 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2830 | if (fi >= max || eptr >= md->end_subject || fc != *eptr++) | if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 2831 | if (eptr >= md->end_subject) | |
| 2832 | { | |
| 2833 | SCHECK_PARTIAL(); | |
| 2834 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 2835 | } | |
| 2836 | if (fc != *eptr++) RRETURN(MATCH_NOMATCH); | |
| 2837 | } | } |
| 2838 | /* Control never gets here */ | /* Control never gets here */ |
| 2839 | } | } |
| # | Line 2226 for (;;) | Line 2842 for (;;) |
| 2842 | pp = eptr; | pp = eptr; |
| 2843 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 2844 | { | { |
| 2845 | if (eptr >= md->end_subject || fc != *eptr) break; | if (eptr >= md->end_subject) |
| 2846 | { | |
| 2847 | SCHECK_PARTIAL(); | |
| 2848 | break; | |
| 2849 | } | |
| 2850 | if (fc != *eptr) break; | |
| 2851 | eptr++; | eptr++; |
| 2852 | } | } |
| 2853 | if (possessive) continue; | if (possessive) continue; |
| 2854 | ||
| 2855 | while (eptr >= pp) | while (eptr >= pp) |
| 2856 | { | { |
| 2857 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM27); |
| 2858 | eptr--; | eptr--; |
| 2859 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2860 | } | } |
| # | Line 2245 for (;;) | Line 2867 for (;;) |
| 2867 | checking can be multibyte. */ | checking can be multibyte. */ |
| 2868 | ||
| 2869 | case OP_NOT: | case OP_NOT: |
| 2870 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 2871 | { | |
| 2872 | SCHECK_PARTIAL(); | |
| 2873 | RRETURN(MATCH_NOMATCH); | |
| 2874 | } | |
| 2875 | ecode++; | ecode++; |
| 2876 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2877 | if ((ims & PCRE_CASELESS) != 0) | if ((ims & PCRE_CASELESS) != 0) |
| # | Line 2322 for (;;) | Line 2948 for (;;) |
| 2948 | max = rep_max[c]; /* zero for max => infinity */ | max = rep_max[c]; /* zero for max => infinity */ |
| 2949 | if (max == 0) max = INT_MAX; | if (max == 0) max = INT_MAX; |
| 2950 | ||
| 2951 | /* Common code for all repeated single-byte matches. We can give up quickly | /* Common code for all repeated single-byte matches. */ |
| if there are fewer than the minimum number of bytes left in the | ||
| subject. */ | ||
| 2952 | ||
| 2953 | REPEATNOTCHAR: | REPEATNOTCHAR: |
| if (min > md->end_subject - eptr) RRETURN(MATCH_NOMATCH); | ||
| 2954 | fc = *ecode++; | fc = *ecode++; |
| 2955 | ||
| 2956 | /* The code is duplicated for the caseless and caseful cases, for speed, | /* The code is duplicated for the caseless and caseful cases, for speed, |
| # | Line 2352 for (;;) | Line 2975 for (;;) |
| 2975 | register unsigned int d; | register unsigned int d; |
| 2976 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 2977 | { | { |
| 2978 | if (eptr >= md->end_subject) | |
| 2979 | { | |
| 2980 | SCHECK_PARTIAL(); | |
| 2981 | RRETURN(MATCH_NOMATCH); | |
| 2982 | } | |
| 2983 | GETCHARINC(d, eptr); | GETCHARINC(d, eptr); |
| 2984 | if (d < 256) d = md->lcc[d]; | if (d < 256) d = md->lcc[d]; |
| 2985 | if (fc == d) RRETURN(MATCH_NOMATCH); | if (fc == d) RRETURN(MATCH_NOMATCH); |
| # | Line 2363 for (;;) | Line 2991 for (;;) |
| 2991 | /* Not UTF-8 mode */ | /* Not UTF-8 mode */ |
| 2992 | { | { |
| 2993 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 2994 | { | |
| 2995 | if (eptr >= md->end_subject) | |
| 2996 | { | |
| 2997 | SCHECK_PARTIAL(); | |
| 2998 | RRETURN(MATCH_NOMATCH); | |
| 2999 | } | |
| 3000 | if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); | if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); |
| 3001 | } | |
| 3002 | } | } |
| 3003 | ||
| 3004 | if (min == max) continue; | if (min == max) continue; |
| # | Line 2377 for (;;) | Line 3012 for (;;) |
| 3012 | register unsigned int d; | register unsigned int d; |
| 3013 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 3014 | { | { |
| 3015 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM28); |
| 3016 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3017 | if (fi >= max) RRETURN(MATCH_NOMATCH); | |
| 3018 | if (eptr >= md->end_subject) | |
| 3019 | { | |
| 3020 | SCHECK_PARTIAL(); | |
| 3021 | RRETURN(MATCH_NOMATCH); | |
| 3022 | } | |
| 3023 | GETCHARINC(d, eptr); | GETCHARINC(d, eptr); |
| 3024 | if (d < 256) d = md->lcc[d]; | if (d < 256) d = md->lcc[d]; |
| 3025 | if (fi >= max || eptr >= md->end_subject || fc == d) | if (fc == d) RRETURN(MATCH_NOMATCH); |
| RRETURN(MATCH_NOMATCH); | ||
| 3026 | } | } |
| 3027 | } | } |
| 3028 | else | else |
| # | Line 2391 for (;;) | Line 3031 for (;;) |
| 3031 | { | { |
| 3032 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 3033 | { | { |
| 3034 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM29); |
| 3035 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3036 | if (fi >= max || eptr >= md->end_subject || fc == md->lcc[*eptr++]) | if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 3037 | if (eptr >= md->end_subject) | |
| 3038 | { | |
| 3039 | SCHECK_PARTIAL(); | |
| 3040 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 3041 | } | |
| 3042 | if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); | |
| 3043 | } | } |
| 3044 | } | } |
| 3045 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 2414 for (;;) | Line 3059 for (;;) |
| 3059 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 3060 | { | { |
| 3061 | int len = 1; | int len = 1; |
| 3062 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 3063 | { | |
| 3064 | SCHECK_PARTIAL(); | |
| 3065 | break; | |
| 3066 | } | |
| 3067 | GETCHARLEN(d, eptr, len); | GETCHARLEN(d, eptr, len); |
| 3068 | if (d < 256) d = md->lcc[d]; | if (d < 256) d = md->lcc[d]; |
| 3069 | if (fc == d) break; | if (fc == d) break; |
| # | Line 2423 for (;;) | Line 3072 for (;;) |
| 3072 | if (possessive) continue; | if (possessive) continue; |
| 3073 | for(;;) | for(;;) |
| 3074 | { | { |
| 3075 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM30); |
| 3076 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3077 | if (eptr-- == pp) break; /* Stop if tried at original pos */ | if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 3078 | BACKCHAR(eptr); | BACKCHAR(eptr); |
| # | Line 2435 for (;;) | Line 3084 for (;;) |
| 3084 | { | { |
| 3085 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 3086 | { | { |
| 3087 | if (eptr >= md->end_subject || fc == md->lcc[*eptr]) break; | if (eptr >= md->end_subject) |
| 3088 | { | |
| 3089 | SCHECK_PARTIAL(); | |
| 3090 | break; | |
| 3091 | } | |
| 3092 | if (fc == md->lcc[*eptr]) break; | |
| 3093 | eptr++; | eptr++; |
| 3094 | } | } |
| 3095 | if (possessive) continue; | if (possessive) continue; |
| 3096 | while (eptr >= pp) | while (eptr >= pp) |
| 3097 | { | { |
| 3098 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM31); |
| 3099 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3100 | eptr--; | eptr--; |
| 3101 | } | } |
| # | Line 2463 for (;;) | Line 3117 for (;;) |
| 3117 | register unsigned int d; | register unsigned int d; |
| 3118 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3119 | { | { |
| 3120 | if (eptr >= md->end_subject) | |
| 3121 | { | |
| 3122 | SCHECK_PARTIAL(); | |
| 3123 | RRETURN(MATCH_NOMATCH); | |
| 3124 | } | |
| 3125 | GETCHARINC(d, eptr); | GETCHARINC(d, eptr); |
| 3126 | if (fc == d) RRETURN(MATCH_NOMATCH); | if (fc == d) RRETURN(MATCH_NOMATCH); |
| 3127 | } | } |
| # | Line 2472 for (;;) | Line 3131 for (;;) |
| 3131 | /* Not UTF-8 mode */ | /* Not UTF-8 mode */ |
| 3132 | { | { |
| 3133 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3134 | { | |
| 3135 | if (eptr >= md->end_subject) | |
| 3136 | { | |
| 3137 | SCHECK_PARTIAL(); | |
| 3138 | RRETURN(MATCH_NOMATCH); | |
| 3139 | } | |
| 3140 | if (fc == *eptr++) RRETURN(MATCH_NOMATCH); | if (fc == *eptr++) RRETURN(MATCH_NOMATCH); |
| 3141 | } | |
| 3142 | } | } |
| 3143 | ||
| 3144 | if (min == max) continue; | if (min == max) continue; |
| # | Line 2486 for (;;) | Line 3152 for (;;) |
| 3152 | register unsigned int d; | register unsigned int d; |
| 3153 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 3154 | { | { |
| 3155 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM32); |
| 3156 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3157 | GETCHARINC(d, eptr); | if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 3158 | if (fi >= max || eptr >= md->end_subject || fc == d) | if (eptr >= md->end_subject) |
| 3159 | { | |
| 3160 | SCHECK_PARTIAL(); | |
| 3161 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 3162 | } | |
| 3163 | GETCHARINC(d, eptr); | |
| 3164 | if (fc == d) RRETURN(MATCH_NOMATCH); | |
| 3165 | } | } |
| 3166 | } | } |
| 3167 | else | else |
| # | Line 2499 for (;;) | Line 3170 for (;;) |
| 3170 | { | { |
| 3171 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 3172 | { | { |
| 3173 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM33); |
| 3174 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3175 | if (fi >= max || eptr >= md->end_subject || fc == *eptr++) | if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 3176 | if (eptr >= md->end_subject) | |
| 3177 | { | |
| 3178 | SCHECK_PARTIAL(); | |
| 3179 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 3180 | } | |
| 3181 | if (fc == *eptr++) RRETURN(MATCH_NOMATCH); | |
| 3182 | } | } |
| 3183 | } | } |
| 3184 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 2522 for (;;) | Line 3198 for (;;) |
| 3198 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 3199 | { | { |
| 3200 | int len = 1; | int len = 1; |
| 3201 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 3202 | { | |
| 3203 | SCHECK_PARTIAL(); | |
| 3204 | break; | |
| 3205 | } | |
| 3206 | GETCHARLEN(d, eptr, len); | GETCHARLEN(d, eptr, len); |
| 3207 | if (fc == d) break; | if (fc == d) break; |
| 3208 | eptr += len; | eptr += len; |
| # | Line 2530 for (;;) | Line 3210 for (;;) |
| 3210 | if (possessive) continue; | if (possessive) continue; |
| 3211 | for(;;) | for(;;) |
| 3212 | { | { |
| 3213 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM34); |
| 3214 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3215 | if (eptr-- == pp) break; /* Stop if tried at original pos */ | if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 3216 | BACKCHAR(eptr); | BACKCHAR(eptr); |
| # | Line 2542 for (;;) | Line 3222 for (;;) |
| 3222 | { | { |
| 3223 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 3224 | { | { |
| 3225 | if (eptr >= md->end_subject || fc == *eptr) break; | if (eptr >= md->end_subject) |
| 3226 | { | |
| 3227 | SCHECK_PARTIAL(); | |
| 3228 | break; | |
| 3229 | } | |
| 3230 | if (fc == *eptr) break; | |
| 3231 | eptr++; | eptr++; |
| 3232 | } | } |
| 3233 | if (possessive) continue; | if (possessive) continue; |
| 3234 | while (eptr >= pp) | while (eptr >= pp) |
| 3235 | { | { |
| 3236 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM35); |
| 3237 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3238 | eptr--; | eptr--; |
| 3239 | } | } |
| # | Line 2636 for (;;) | Line 3321 for (;;) |
| 3321 | ||
| 3322 | /* First, ensure the minimum number of matches are present. Use inline | /* First, ensure the minimum number of matches are present. Use inline |
| 3323 | code for maximizing the speed, and do the type test once at the start | code for maximizing the speed, and do the type test once at the start |
| 3324 | (i.e. keep it out of the loop). Also we can test that there are at least | (i.e. keep it out of the loop). Separate the UTF-8 code completely as that |
| the minimum number of bytes before we start. This isn't as effective in | ||
| UTF-8 mode, but it does no harm. Separate the UTF-8 code completely as that | ||
| 3325 | is tidier. Also separate the UCP code, which can be the same for both UTF-8 | is tidier. Also separate the UCP code, which can be the same for both UTF-8 |
| 3326 | and single-bytes. */ | and single-bytes. */ |
| 3327 | ||
| if (min > md->end_subject - eptr) RRETURN(MATCH_NOMATCH); | ||
| 3328 | if (min > 0) | if (min > 0) |
| 3329 | { | { |
| 3330 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| # | Line 2654 for (;;) | Line 3336 for (;;) |
| 3336 | if (prop_fail_result) RRETURN(MATCH_NOMATCH); | if (prop_fail_result) RRETURN(MATCH_NOMATCH); |
| 3337 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3338 | { | { |
| 3339 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3340 | GETCHARINC(c, eptr); | { |
| 3341 | SCHECK_PARTIAL(); | |
| 3342 | RRETURN(MATCH_NOMATCH); | |
| 3343 | } | |
| 3344 | GETCHARINCTEST(c, eptr); | |
| 3345 | } | } |
| 3346 | break; | break; |
| 3347 | ||
| 3348 | case PT_LAMP: | case PT_LAMP: |
| 3349 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3350 | { | { |
| 3351 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3352 | GETCHARINC(c, eptr); | { |
| 3353 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | SCHECK_PARTIAL(); |
| 3354 | RRETURN(MATCH_NOMATCH); | |
| 3355 | } | |
| 3356 | GETCHARINCTEST(c, eptr); | |
| 3357 | prop_chartype = UCD_CHARTYPE(c); | |
| 3358 | if ((prop_chartype == ucp_Lu || | if ((prop_chartype == ucp_Lu || |
| 3359 | prop_chartype == ucp_Ll || | prop_chartype == ucp_Ll || |
| 3360 | prop_chartype == ucp_Lt) == prop_fail_result) | prop_chartype == ucp_Lt) == prop_fail_result) |
| # | Line 2675 for (;;) | Line 3365 for (;;) |
| 3365 | case PT_GC: | case PT_GC: |
| 3366 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3367 | { | { |
| 3368 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3369 | GETCHARINC(c, eptr); | { |
| 3370 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | SCHECK_PARTIAL(); |
| 3371 | RRETURN(MATCH_NOMATCH); | |
| 3372 | } | |
| 3373 | GETCHARINCTEST(c, eptr); | |
| 3374 | prop_category = UCD_CATEGORY(c); | |
| 3375 | if ((prop_category == prop_value) == prop_fail_result) | if ((prop_category == prop_value) == prop_fail_result) |
| 3376 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 3377 | } | } |
| # | Line 2686 for (;;) | Line 3380 for (;;) |
| 3380 | case PT_PC: | case PT_PC: |
| 3381 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3382 | { | { |
| 3383 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3384 | GETCHARINC(c, eptr); | { |
| 3385 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | SCHECK_PARTIAL(); |
| 3386 | RRETURN(MATCH_NOMATCH); | |
| 3387 | } | |
| 3388 | GETCHARINCTEST(c, eptr); | |
| 3389 | prop_chartype = UCD_CHARTYPE(c); | |
| 3390 | if ((prop_chartype == prop_value) == prop_fail_result) | if ((prop_chartype == prop_value) == prop_fail_result) |
| 3391 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 3392 | } | } |
| # | Line 2697 for (;;) | Line 3395 for (;;) |
| 3395 | case PT_SC: | case PT_SC: |
| 3396 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3397 | { | { |
| 3398 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3399 | GETCHARINC(c, eptr); | { |
| 3400 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | SCHECK_PARTIAL(); |
| 3401 | RRETURN(MATCH_NOMATCH); | |
| 3402 | } | |
| 3403 | GETCHARINCTEST(c, eptr); | |
| 3404 | prop_script = UCD_SCRIPT(c); | |
| 3405 | if ((prop_script == prop_value) == prop_fail_result) | if ((prop_script == prop_value) == prop_fail_result) |
| 3406 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 3407 | } | } |
| # | Line 2717 for (;;) | Line 3419 for (;;) |
| 3419 | { | { |
| 3420 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3421 | { | { |
| 3422 | if (eptr >= md->end_subject) | |
| 3423 | { | |
| 3424 | SCHECK_PARTIAL(); | |
| 3425 | RRETURN(MATCH_NOMATCH); | |
| 3426 | } | |
| 3427 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3428 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_category = UCD_CATEGORY(c); |
| 3429 | if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH); | if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH); |
| 3430 | while (eptr < md->end_subject) | while (eptr < md->end_subject) |
| 3431 | { | { |
| 3432 | int len = 1; | int len = 1; |
| 3433 | if (!utf8) c = *eptr; else | if (!utf8) c = *eptr; |
| 3434 | { | else { GETCHARLEN(c, eptr, len); } |
| 3435 | GETCHARLEN(c, eptr, len); | prop_category = UCD_CATEGORY(c); |
| } | ||
| prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | ||
| 3436 | if (prop_category != ucp_M) break; | if (prop_category != ucp_M) break; |
| 3437 | eptr += len; | eptr += len; |
| 3438 | } | } |
| # | Line 2745 for (;;) | Line 3450 for (;;) |
| 3450 | case OP_ANY: | case OP_ANY: |
| 3451 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3452 | { | { |
| 3453 | if (eptr >= md->end_subject || | if (eptr >= md->end_subject) |
| 3454 | ((ims & PCRE_DOTALL) == 0 && IS_NEWLINE(eptr))) | { |
| 3455 | SCHECK_PARTIAL(); | |
| 3456 | RRETURN(MATCH_NOMATCH); | |
| 3457 | } | |
| 3458 | if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); | |
| 3459 | eptr++; | |
| 3460 | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | |
| 3461 | } | |
| 3462 | break; | |
| 3463 | ||
| 3464 | case OP_ALLANY: | |
| 3465 | for (i = 1; i <= min; i++) | |
| 3466 | { | |
| 3467 | if (eptr >= md->end_subject) | |
| 3468 | { | |
| 3469 | SCHECK_PARTIAL(); | |
| 3470 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 3471 | } | |
| 3472 | eptr++; | eptr++; |
| 3473 | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| 3474 | } | } |
| 3475 | break; | break; |
| 3476 | ||
| 3477 | case OP_ANYBYTE: | case OP_ANYBYTE: |
| 3478 | if (eptr > md->end_subject - min) RRETURN(MATCH_NOMATCH); | |
| 3479 | eptr += min; | eptr += min; |
| 3480 | break; | break; |
| 3481 | ||
| 3482 | case OP_ANYNL: | case OP_ANYNL: |
| 3483 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3484 | { | { |
| 3485 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3486 | { | |
| 3487 | SCHECK_PARTIAL(); | |
| 3488 | RRETURN(MATCH_NOMATCH); | |
| 3489 | } | |
| 3490 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 3491 | switch(c) | switch(c) |
| 3492 | { | { |
| # | Line 2768 for (;;) | Line 3494 for (;;) |
| 3494 | case 0x000d: | case 0x000d: |
| 3495 | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 3496 | break; | break; |
| 3497 | ||
| 3498 | case 0x000a: | case 0x000a: |
| 3499 | break; | |
| 3500 | ||
| 3501 | case 0x000b: | case 0x000b: |
| 3502 | case 0x000c: | case 0x000c: |
| 3503 | case 0x0085: | case 0x0085: |
| 3504 | case 0x2028: | case 0x2028: |
| 3505 | case 0x2029: | case 0x2029: |
| 3506 | if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); | |
| 3507 | break; | break; |
| 3508 | } | } |
| 3509 | } | } |
| 3510 | break; | break; |
| 3511 | ||
| 3512 | case OP_NOT_DIGIT: | case OP_NOT_HSPACE: |
| 3513 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3514 | { | { |
| 3515 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3516 | { | |
| 3517 | SCHECK_PARTIAL(); | |
| 3518 | RRETURN(MATCH_NOMATCH); | |
| 3519 | } | |
| 3520 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 3521 | if (c < 128 && (md->ctypes[c] & ctype_digit) != 0) | switch(c) |
| 3522 | { | |
| 3523 | default: break; | |
| 3524 | case 0x09: /* HT */ | |
| 3525 | case 0x20: /* SPACE */ | |
| 3526 | case 0xa0: /* NBSP */ | |
| 3527 | case 0x1680: /* OGHAM SPACE MARK */ | |
| 3528 | case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ | |
| 3529 | case 0x2000: /* EN QUAD */ | |
| 3530 | case 0x2001: /* EM QUAD */ | |
| 3531 | case 0x2002: /* EN SPACE */ | |
| 3532 | case 0x2003: /* EM SPACE */ | |
| 3533 | case 0x2004: /* THREE-PER-EM SPACE */ | |
| 3534 | case 0x2005: /* FOUR-PER-EM SPACE */ | |
| 3535 | case 0x2006: /* SIX-PER-EM SPACE */ | |
| 3536 | case 0x2007: /* FIGURE SPACE */ | |
| 3537 | case 0x2008: /* PUNCTUATION SPACE */ | |
| 3538 | case 0x2009: /* THIN SPACE */ | |
| 3539 | case 0x200A: /* HAIR SPACE */ | |
| 3540 | case 0x202f: /* NARROW NO-BREAK SPACE */ | |
| 3541 | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ | |
| 3542 | case 0x3000: /* IDEOGRAPHIC SPACE */ | |
| 3543 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 3544 | } | |
| 3545 | } | } |
| 3546 | break; | break; |
| 3547 | ||
| 3548 | case OP_DIGIT: | case OP_HSPACE: |
| 3549 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3550 | { | { |
| 3551 | if (eptr >= md->end_subject || | if (eptr >= md->end_subject) |
| 3552 | *eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0) | { |
| 3553 | SCHECK_PARTIAL(); | |
| 3554 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 3555 | /* No need to skip more bytes - we know it's a 1-byte character */ | } |
| 3556 | GETCHARINC(c, eptr); | |
| 3557 | switch(c) | |
| 3558 | { | |
| 3559 | default: RRETURN(MATCH_NOMATCH); | |
| 3560 | case 0x09: /* HT */ | |
| 3561 | case 0x20: /* SPACE */ | |
| 3562 | case 0xa0: /* NBSP */ | |
| 3563 | case 0x1680: /* OGHAM SPACE MARK */ | |
| 3564 | case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ | |
| 3565 | case 0x2000: /* EN QUAD */ | |
| 3566 | case 0x2001: /* EM QUAD */ | |
| 3567 | case 0x2002: /* EN SPACE */ | |
| 3568 | case 0x2003: /* EM SPACE */ | |
| 3569 | case 0x2004: /* THREE-PER-EM SPACE */ | |
| 3570 | case 0x2005: /* FOUR-PER-EM SPACE */ | |
| 3571 | case 0x2006: /* SIX-PER-EM SPACE */ | |
| 3572 | case 0x2007: /* FIGURE SPACE */ | |
| 3573 | case 0x2008: /* PUNCTUATION SPACE */ | |
| 3574 | case 0x2009: /* THIN SPACE */ | |
| 3575 | case 0x200A: /* HAIR SPACE */ | |
| 3576 | case 0x202f: /* NARROW NO-BREAK SPACE */ | |
| 3577 | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ | |
| 3578 | case 0x3000: /* IDEOGRAPHIC SPACE */ | |
| 3579 | break; | |
| 3580 | } | |
| 3581 | } | } |
| 3582 | break; | break; |
| 3583 | ||
| 3584 | case OP_NOT_WHITESPACE: | case OP_NOT_VSPACE: |
| 3585 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3586 | { | { |
| 3587 | if (eptr >= md->end_subject || | if (eptr >= md->end_subject) |
| 3588 | (*eptr < 128 && (md->ctypes[*eptr++] & ctype_space) != 0)) | { |
| 3589 | SCHECK_PARTIAL(); | |
| 3590 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 3591 | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | } |
| 3592 | GETCHARINC(c, eptr); | |
| 3593 | switch(c) | |
| 3594 | { | |
| 3595 | default: break; | |
| 3596 | case 0x0a: /* LF */ | |
| 3597 | case 0x0b: /* VT */ | |
| 3598 | case 0x0c: /* FF */ | |
| 3599 | case 0x0d: /* CR */ | |
| 3600 | case 0x85: /* NEL */ | |
| 3601 | case 0x2028: /* LINE SEPARATOR */ | |
| 3602 | case 0x2029: /* PARAGRAPH SEPARATOR */ | |
| 3603 | RRETURN(MATCH_NOMATCH); | |
| 3604 | } | |
| 3605 | } | } |
| 3606 | break; | break; |
| 3607 | ||
| 3608 | case OP_WHITESPACE: | case OP_VSPACE: |
| 3609 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3610 | { | { |
| 3611 | if (eptr >= md->end_subject || | if (eptr >= md->end_subject) |
| 3612 | *eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0) | { |
| 3613 | SCHECK_PARTIAL(); | |
| 3614 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 3615 | /* No need to skip more bytes - we know it's a 1-byte character */ | } |
| 3616 | GETCHARINC(c, eptr); | |
| 3617 | switch(c) | |
| 3618 | { | |
| 3619 | default: RRETURN(MATCH_NOMATCH); | |
| 3620 | case 0x0a: /* LF */ | |
| 3621 | case 0x0b: /* VT */ | |
| 3622 | case 0x0c: /* FF */ | |
| 3623 | case 0x0d: /* CR */ | |
| 3624 | case 0x85: /* NEL */ | |
| 3625 | case 0x2028: /* LINE SEPARATOR */ | |
| 3626 | case 0x2029: /* PARAGRAPH SEPARATOR */ | |
| 3627 | break; | |
| 3628 | } | |
| 3629 | } | } |
| 3630 | break; | break; |
| 3631 | ||
| 3632 | case OP_NOT_WORDCHAR: | case OP_NOT_DIGIT: |
| 3633 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3634 | { | { |
| 3635 | if (eptr >= md->end_subject || | if (eptr >= md->end_subject) |
| 3636 | (*eptr < 128 && (md->ctypes[*eptr++] & ctype_word) != 0)) | { |
| 3637 | SCHECK_PARTIAL(); | |
| 3638 | RRETURN(MATCH_NOMATCH); | |
| 3639 | } | |
| 3640 | GETCHARINC(c, eptr); | |
| 3641 | if (c < 128 && (md->ctypes[c] & ctype_digit) != 0) | |
| 3642 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | ||
| 3643 | } | } |
| 3644 | break; | break; |
| 3645 | ||
| 3646 | case OP_WORDCHAR: | case OP_DIGIT: |
| 3647 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3648 | { | { |
| 3649 | if (eptr >= md->end_subject || | if (eptr >= md->end_subject) |
| 3650 | *eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0) | { |
| 3651 | SCHECK_PARTIAL(); | |
| 3652 | RRETURN(MATCH_NOMATCH); | |
| 3653 | } | |
| 3654 | if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0) | |
| 3655 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 3656 | /* No need to skip more bytes - we know it's a 1-byte character */ | /* No need to skip more bytes - we know it's a 1-byte character */ |
| 3657 | } | } |
| 3658 | break; | break; |
| 3659 | ||
| 3660 | default: | case OP_NOT_WHITESPACE: |
| 3661 | RRETURN(PCRE_ERROR_INTERNAL); | for (i = 1; i <= min; i++) |
| 3662 | } /* End switch(ctype) */ | { |
| 3663 | if (eptr >= md->end_subject) | |
| 3664 | else | { |
| 3665 | #endif /* SUPPORT_UTF8 */ | SCHECK_PARTIAL(); |
| 3666 | RRETURN(MATCH_NOMATCH); | |
| 3667 | } | |
| 3668 | if (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0) | |
| 3669 | RRETURN(MATCH_NOMATCH); | |
| 3670 | while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80); | |
| 3671 | } | |
| 3672 | break; | |
| 3673 | ||
| 3674 | case OP_WHITESPACE: | |
| 3675 | for (i = 1; i <= min; i++) | |
| 3676 | { | |
| 3677 | if (eptr >= md->end_subject) | |
| 3678 | { | |
| 3679 | SCHECK_PARTIAL(); | |
| 3680 | RRETURN(MATCH_NOMATCH); | |
| 3681 | } | |
| 3682 | if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0) | |
| 3683 | RRETURN(MATCH_NOMATCH); | |
| 3684 | /* No need to skip more bytes - we know it's a 1-byte character */ | |
| 3685 | } | |
| 3686 | break; | |
| 3687 | ||
| 3688 | case OP_NOT_WORDCHAR: | |
| 3689 | for (i = 1; i <= min; i++) | |
| 3690 | { | |
| 3691 | if (eptr >= md->end_subject || | |
| 3692 | (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0)) | |
| 3693 | RRETURN(MATCH_NOMATCH); | |
| 3694 | while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80); | |
| 3695 | } | |
| 3696 | break; | |
| 3697 | ||
| 3698 | case OP_WORDCHAR: | |
| 3699 | for (i = 1; i <= min; i++) | |
| 3700 | { | |
| 3701 | if (eptr >= md->end_subject) | |
| 3702 | { | |
| 3703 | SCHECK_PARTIAL(); | |
| 3704 | RRETURN(MATCH_NOMATCH); | |
| 3705 | } | |
| 3706 | if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0) | |
| 3707 | RRETURN(MATCH_NOMATCH); | |
| 3708 | /* No need to skip more bytes - we know it's a 1-byte character */ | |
| 3709 | } | |
| 3710 | break; | |
| 3711 | ||
| 3712 | default: | |
| 3713 | RRETURN(PCRE_ERROR_INTERNAL); | |
| 3714 | } /* End switch(ctype) */ | |
| 3715 | ||
| 3716 | else | |
| 3717 | #endif /* SUPPORT_UTF8 */ | |
| 3718 | ||
| 3719 | /* Code for the non-UTF-8 case for minimum matching of operators other | /* Code for the non-UTF-8 case for minimum matching of operators other |
| 3720 | than OP_PROP and OP_NOTPROP. We can assume that there are the minimum | than OP_PROP and OP_NOTPROP. */ |
| number of bytes present, as this was tested above. */ | ||
| 3721 | ||
| 3722 | switch(ctype) | switch(ctype) |
| 3723 | { | { |
| 3724 | case OP_ANY: | case OP_ANY: |
| 3725 | if ((ims & PCRE_DOTALL) == 0) | for (i = 1; i <= min; i++) |
| 3726 | { | { |
| 3727 | for (i = 1; i <= min; i++) | if (eptr >= md->end_subject) |
| 3728 | { | { |
| 3729 | if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); | SCHECK_PARTIAL(); |
| 3730 | eptr++; | RRETURN(MATCH_NOMATCH); |
| 3731 | } | } |
| 3732 | if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); | |
| 3733 | eptr++; | |
| 3734 | } | } |
| else eptr += min; | ||
| 3735 | break; | break; |
| 3736 | ||
| 3737 | case OP_ANYBYTE: | case OP_ALLANY: |
| 3738 | if (eptr > md->end_subject - min) | |
| 3739 | { | |
| 3740 | SCHECK_PARTIAL(); | |
| 3741 | RRETURN(MATCH_NOMATCH); | |
| 3742 | } | |
| 3743 | eptr += min; | eptr += min; |
| 3744 | break; | break; |
| 3745 | ||
| 3746 | /* Because of the CRLF case, we can't assume the minimum number of | case OP_ANYBYTE: |
| 3747 | bytes are present in this case. */ | if (eptr > md->end_subject - min) |
| 3748 | { | |
| 3749 | SCHECK_PARTIAL(); | |
| 3750 | RRETURN(MATCH_NOMATCH); | |
| 3751 | } | |
| 3752 | eptr += min; | |
| 3753 | break; | |
| 3754 | ||
| 3755 | case OP_ANYNL: | case OP_ANYNL: |
| 3756 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3757 | { | { |
| 3758 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3759 | { | |
| 3760 | SCHECK_PARTIAL(); | |
| 3761 | RRETURN(MATCH_NOMATCH); | |
| 3762 | } | |
| 3763 | switch(*eptr++) | switch(*eptr++) |
| 3764 | { | { |
| 3765 | default: RRETURN(MATCH_NOMATCH); | default: RRETURN(MATCH_NOMATCH); |
| # | Line 2882 for (;;) | Line 3767 for (;;) |
| 3767 | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 3768 | break; | break; |
| 3769 | case 0x000a: | case 0x000a: |
| 3770 | break; | |
| 3771 | ||
| 3772 | case 0x000b: | case 0x000b: |
| 3773 | case 0x000c: | case 0x000c: |
| 3774 | case 0x0085: | case 0x0085: |
| 3775 | if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); | |
| 3776 | break; | |
| 3777 | } | |
| 3778 | } | |
| 3779 | break; | |
| 3780 | ||
| 3781 | case OP_NOT_HSPACE: | |
| 3782 | for (i = 1; i <= min; i++) | |
| 3783 | { | |
| 3784 | if (eptr >= md->end_subject) | |
| 3785 | { | |
| 3786 | SCHECK_PARTIAL(); | |
| 3787 | RRETURN(MATCH_NOMATCH); | |
| 3788 | } | |
| 3789 | switch(*eptr++) | |
| 3790 | { | |
| 3791 | default: break; | |
| 3792 | case 0x09: /* HT */ | |
| 3793 | case 0x20: /* SPACE */ | |
| 3794 | case 0xa0: /* NBSP */ | |
| 3795 | RRETURN(MATCH_NOMATCH); | |
| 3796 | } | |
| 3797 | } | |
| 3798 | break; | |
| 3799 | ||
| 3800 | case OP_HSPACE: | |
| 3801 | for (i = 1; i <= min; i++) | |
| 3802 | { | |
| 3803 | if (eptr >= md->end_subject) | |
| 3804 | { | |
| 3805 | SCHECK_PARTIAL(); | |
| 3806 | RRETURN(MATCH_NOMATCH); | |
| 3807 | } | |
| 3808 | switch(*eptr++) | |
| 3809 | { | |
| 3810 | default: RRETURN(MATCH_NOMATCH); | |
| 3811 | case 0x09: /* HT */ | |
| 3812 | case 0x20: /* SPACE */ | |
| 3813 | case 0xa0: /* NBSP */ | |
| 3814 | break; | |
| 3815 | } | |
| 3816 | } | |
| 3817 | break; | |
| 3818 | ||
| 3819 | case OP_NOT_VSPACE: | |
| 3820 | for (i = 1; i <= min; i++) | |
| 3821 | { | |
| 3822 | if (eptr >= md->end_subject) | |
| 3823 | { | |
| 3824 | SCHECK_PARTIAL(); | |
| 3825 | RRETURN(MATCH_NOMATCH); | |
| 3826 | } | |
| 3827 | switch(*eptr++) | |
| 3828 | { | |
| 3829 | default: break; | |
| 3830 | case 0x0a: /* LF */ | |
| 3831 | case 0x0b: /* VT */ | |
| 3832 | case 0x0c: /* FF */ | |
| 3833 | case 0x0d: /* CR */ | |
| 3834 | case 0x85: /* NEL */ | |
| 3835 | RRETURN(MATCH_NOMATCH); | |
| 3836 | } | |
| 3837 | } | |
| 3838 | break; | |
| 3839 | ||
| 3840 | case OP_VSPACE: | |
| 3841 | for (i = 1; i <= min; i++) | |
| 3842 | { | |
| 3843 | if (eptr >= md->end_subject) | |
| 3844 | { | |
| 3845 | SCHECK_PARTIAL(); | |
| 3846 | RRETURN(MATCH_NOMATCH); | |
| 3847 | } | |
| 3848 | switch(*eptr++) | |
| 3849 | { | |
| 3850 | default: RRETURN(MATCH_NOMATCH); | |
| 3851 | case 0x0a: /* LF */ | |
| 3852 | case 0x0b: /* VT */ | |
| 3853 | case 0x0c: /* FF */ | |
| 3854 | case 0x0d: /* CR */ | |
| 3855 | case 0x85: /* NEL */ | |
| 3856 | break; | break; |
| 3857 | } | } |
| 3858 | } | } |
| # | Line 2892 for (;;) | Line 3860 for (;;) |
| 3860 | ||
| 3861 | case OP_NOT_DIGIT: | case OP_NOT_DIGIT: |
| 3862 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3863 | { | |
| 3864 | if (eptr >= md->end_subject) | |
| 3865 | { | |
| 3866 | SCHECK_PARTIAL(); | |
| 3867 | RRETURN(MATCH_NOMATCH); | |
| 3868 | } | |
| 3869 | if ((md->ctypes[*eptr++] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[*eptr++] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH); |
| 3870 | } | |
| 3871 | break; | break; |
| 3872 | ||
| 3873 | case OP_DIGIT: | case OP_DIGIT: |
| 3874 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3875 | { | |
| 3876 | if (eptr >= md->end_subject) | |
| 3877 | { | |
| 3878 | SCHECK_PARTIAL(); | |
| 3879 | RRETURN(MATCH_NOMATCH); | |
| 3880 | } | |
| 3881 | if ((md->ctypes[*eptr++] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[*eptr++] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH); |
| 3882 | } | |
| 3883 | break; | break; |
| 3884 | ||
| 3885 | case OP_NOT_WHITESPACE: | case OP_NOT_WHITESPACE: |
| 3886 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3887 | { | |
| 3888 | if (eptr >= md->end_subject) | |
| 3889 | { | |
| 3890 | SCHECK_PARTIAL(); | |
| 3891 | RRETURN(MATCH_NOMATCH); | |
| 3892 | } | |
| 3893 | if ((md->ctypes[*eptr++] & ctype_space) != 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[*eptr++] & ctype_space) != 0) RRETURN(MATCH_NOMATCH); |
| 3894 | } | |
| 3895 | break; | break; |
| 3896 | ||
| 3897 | case OP_WHITESPACE: | case OP_WHITESPACE: |
| 3898 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3899 | { | |
| 3900 | if (eptr >= md->end_subject) | |
| 3901 | { | |
| 3902 | SCHECK_PARTIAL(); | |
| 3903 | RRETURN(MATCH_NOMATCH); | |
| 3904 | } | |
| 3905 | if ((md->ctypes[*eptr++] & ctype_space) == 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[*eptr++] & ctype_space) == 0) RRETURN(MATCH_NOMATCH); |
| 3906 | } | |
| 3907 | break; | break; |
| 3908 | ||
| 3909 | case OP_NOT_WORDCHAR: | case OP_NOT_WORDCHAR: |
| 3910 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3911 | { | |
| 3912 | if (eptr >= md->end_subject) | |
| 3913 | { | |
| 3914 | SCHECK_PARTIAL(); | |
| 3915 | RRETURN(MATCH_NOMATCH); | |
| 3916 | } | |
| 3917 | if ((md->ctypes[*eptr++] & ctype_word) != 0) | if ((md->ctypes[*eptr++] & ctype_word) != 0) |
| 3918 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 3919 | } | |
| 3920 | break; | break; |
| 3921 | ||
| 3922 | case OP_WORDCHAR: | case OP_WORDCHAR: |
| 3923 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3924 | { | |
| 3925 | if (eptr >= md->end_subject) | |
| 3926 | { | |
| 3927 | SCHECK_PARTIAL(); | |
| 3928 | RRETURN(MATCH_NOMATCH); | |
| 3929 | } | |
| 3930 | if ((md->ctypes[*eptr++] & ctype_word) == 0) | if ((md->ctypes[*eptr++] & ctype_word) == 0) |
| 3931 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 3932 | } | |
| 3933 | break; | break; |
| 3934 | ||
| 3935 | default: | default: |
| # | Line 2945 for (;;) | Line 3955 for (;;) |
| 3955 | case PT_ANY: | case PT_ANY: |
| 3956 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 3957 | { | { |
| 3958 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM36); |
| 3959 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3960 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 3961 | if (eptr >= md->end_subject) | |
| 3962 | { | |
| 3963 | SCHECK_PARTIAL(); | |
| 3964 | RRETURN(MATCH_NOMATCH); | |
| 3965 | } | |
| 3966 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 3967 | if (prop_fail_result) RRETURN(MATCH_NOMATCH); | if (prop_fail_result) RRETURN(MATCH_NOMATCH); |
| 3968 | } | } |
| # | Line 2956 for (;;) | Line 3971 for (;;) |
| 3971 | case PT_LAMP: | case PT_LAMP: |
| 3972 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 3973 | { | { |
| 3974 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM37); |
| 3975 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3976 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 3977 | if (eptr >= md->end_subject) | |
| 3978 | { | |
| 3979 | SCHECK_PARTIAL(); | |
| 3980 | RRETURN(MATCH_NOMATCH); | |
| 3981 | } | |
| 3982 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 3983 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_chartype = UCD_CHARTYPE(c); |
| 3984 | if ((prop_chartype == ucp_Lu || | if ((prop_chartype == ucp_Lu || |
| 3985 | prop_chartype == ucp_Ll || | prop_chartype == ucp_Ll || |
| 3986 | prop_chartype == ucp_Lt) == prop_fail_result) | prop_chartype == ucp_Lt) == prop_fail_result) |
| # | Line 2971 for (;;) | Line 3991 for (;;) |
| 3991 | case PT_GC: | case PT_GC: |
| 3992 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 3993 | { | { |
| 3994 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM38); |
| 3995 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3996 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 3997 | if (eptr >= md->end_subject) | |
| 3998 | { | |
| 3999 | SCHECK_PARTIAL(); | |
| 4000 | RRETURN(MATCH_NOMATCH); | |
| 4001 | } | |
| 4002 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 4003 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_category = UCD_CATEGORY(c); |
| 4004 | if ((prop_category == prop_value) == prop_fail_result) | if ((prop_category == prop_value) == prop_fail_result) |
| 4005 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 4006 | } | } |
| # | Line 2984 for (;;) | Line 4009 for (;;) |
| 4009 | case PT_PC: | case PT_PC: |
| 4010 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 4011 | { | { |
| 4012 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM39); |
| 4013 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4014 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 4015 | if (eptr >= md->end_subject) | |
| 4016 | { | |
| 4017 | SCHECK_PARTIAL(); | |
| 4018 | RRETURN(MATCH_NOMATCH); | |
| 4019 | } | |
| 4020 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 4021 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_chartype = UCD_CHARTYPE(c); |
| 4022 | if ((prop_chartype == prop_value) == prop_fail_result) | if ((prop_chartype == prop_value) == prop_fail_result) |
| 4023 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 4024 | } | } |
| # | Line 2997 for (;;) | Line 4027 for (;;) |
| 4027 | case PT_SC: | case PT_SC: |
| 4028 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 4029 | { | { |
| 4030 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM40); |
| 4031 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4032 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 4033 | if (eptr >= md->end_subject) | |
| 4034 | { | |
| 4035 | SCHECK_PARTIAL(); | |
| 4036 | RRETURN(MATCH_NOMATCH); | |
| 4037 | } | |
| 4038 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 4039 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_script = UCD_SCRIPT(c); |
| 4040 | if ((prop_script == prop_value) == prop_fail_result) | if ((prop_script == prop_value) == prop_fail_result) |
| 4041 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 4042 | } | } |
| # | Line 3019 for (;;) | Line 4054 for (;;) |
| 4054 | { | { |
| 4055 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 4056 | { | { |
| 4057 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM41); |
| 4058 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4059 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 4060 | if (eptr >= md->end_subject) | |
| 4061 | { | |
| 4062 | SCHECK_PARTIAL(); | |
| 4063 | RRETURN(MATCH_NOMATCH); | |
| 4064 | } | |
| 4065 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 4066 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_category = UCD_CATEGORY(c); |
| 4067 | if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH); | if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH); |
| 4068 | while (eptr < md->end_subject) | while (eptr < md->end_subject) |
| 4069 | { | { |
| 4070 | int len = 1; | int len = 1; |
| 4071 | if (!utf8) c = *eptr; else | if (!utf8) c = *eptr; |
| 4072 | { | else { GETCHARLEN(c, eptr, len); } |
| 4073 | GETCHARLEN(c, eptr, len); | prop_category = UCD_CATEGORY(c); |
| } | ||
| prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | ||
| 4074 | if (prop_category != ucp_M) break; | if (prop_category != ucp_M) break; |
| 4075 | eptr += len; | eptr += len; |
| 4076 | } | } |
| # | Line 3048 for (;;) | Line 4086 for (;;) |
| 4086 | { | { |
| 4087 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 4088 | { | { |
| 4089 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM42); |
| 4090 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4091 | if (fi >= max || eptr >= md->end_subject || | if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 4092 | (ctype == OP_ANY && (ims & PCRE_DOTALL) == 0 && | if (eptr >= md->end_subject) |
| 4093 | IS_NEWLINE(eptr))) | { |
| 4094 | SCHECK_PARTIAL(); | |
| 4095 | RRETURN(MATCH_NOMATCH); | |
| 4096 | } | |
| 4097 | if (ctype == OP_ANY && IS_NEWLINE(eptr)) | |
| 4098 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 4099 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 4100 | switch(ctype) | switch(ctype) |
| 4101 | { | { |
| 4102 | case OP_ANY: /* This is the DOTALL case */ | case OP_ANY: /* This is the non-NL case */ |
| 4103 | break; | case OP_ALLANY: |
| 4104 | case OP_ANYBYTE: | case OP_ANYBYTE: |
| 4105 | break; | break; |
| 4106 | ||
| # | Line 3072 for (;;) | Line 4112 for (;;) |
| 4112 | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 4113 | break; | break; |
| 4114 | case 0x000a: | case 0x000a: |
| 4115 | break; | |
| 4116 | ||
| 4117 | case 0x000b: | case 0x000b: |
| 4118 | case 0x000c: | case 0x000c: |
| 4119 | case 0x0085: | case 0x0085: |
| 4120 | case 0x2028: | case 0x2028: |
| 4121 | case 0x2029: | case 0x2029: |
| 4122 | if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); | |
| 4123 | break; | |
| 4124 | } | |
| 4125 | break; | |
| 4126 | ||
| 4127 | case OP_NOT_HSPACE: | |
| 4128 | switch(c) | |
| 4129 | { | |
| 4130 | default: break; | |
| 4131 | case 0x09: /* HT */ | |
| 4132 | case 0x20: /* SPACE */ | |
| 4133 | case 0xa0: /* NBSP */ | |
| 4134 | case 0x1680: /* OGHAM SPACE MARK */ | |
| 4135 | case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ | |
| 4136 | case 0x2000: /* EN QUAD */ | |
| 4137 | case 0x2001: /* EM QUAD */ | |
| 4138 | case 0x2002: /* EN SPACE */ | |
| 4139 | case 0x2003: /* EM SPACE */ | |
| 4140 | case 0x2004: /* THREE-PER-EM SPACE */ | |
| 4141 | case 0x2005: /* FOUR-PER-EM SPACE */ | |
| 4142 | case 0x2006: /* SIX-PER-EM SPACE */ | |
| 4143 | case 0x2007: /* FIGURE SPACE */ | |
| 4144 | case 0x2008: /* PUNCTUATION SPACE */ | |
| 4145 | case 0x2009: /* THIN SPACE */ | |
| 4146 | case 0x200A: /* HAIR SPACE */ | |
| 4147 | case 0x202f: /* NARROW NO-BREAK SPACE */ | |
| 4148 | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ | |
| 4149 | case 0x3000: /* IDEOGRAPHIC SPACE */ | |
| 4150 | RRETURN(MATCH_NOMATCH); | |
| 4151 | } | |
| 4152 | break; | |
| 4153 | ||
| 4154 | case OP_HSPACE: | |
| 4155 | switch(c) | |
| 4156 | { | |
| 4157 | default: RRETURN(MATCH_NOMATCH); | |
| 4158 | case 0x09: /* HT */ | |
| 4159 | case 0x20: /* SPACE */ | |
| 4160 | case 0xa0: /* NBSP */ | |
| 4161 | case 0x1680: /* OGHAM SPACE MARK */ | |
| 4162 | case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ | |
| 4163 | case 0x2000: /* EN QUAD */ | |
| 4164 | case 0x2001: /* EM QUAD */ | |
| 4165 | case 0x2002: /* EN SPACE */ | |
| 4166 | case 0x2003: /* EM SPACE */ | |
| 4167 | case 0x2004: /* THREE-PER-EM SPACE */ | |
| 4168 | case 0x2005: /* FOUR-PER-EM SPACE */ | |
| 4169 | case 0x2006: /* SIX-PER-EM SPACE */ | |
| 4170 | case 0x2007: /* FIGURE SPACE */ | |
| 4171 | case 0x2008: /* PUNCTUATION SPACE */ | |
| 4172 | case 0x2009: /* THIN SPACE */ | |
| 4173 | case 0x200A: /* HAIR SPACE */ | |
| 4174 | case 0x202f: /* NARROW NO-BREAK SPACE */ | |
| 4175 | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ | |
| 4176 | case 0x3000: /* IDEOGRAPHIC SPACE */ | |
| 4177 | break; | |
| 4178 | } | |
| 4179 | break; | |
| 4180 | ||
| 4181 | case OP_NOT_VSPACE: | |
| 4182 | switch(c) | |
| 4183 | { | |
| 4184 | default: break; | |
| 4185 | case 0x0a: /* LF */ | |
| 4186 | case 0x0b: /* VT */ | |
| 4187 | case 0x0c: /* FF */ | |
| 4188 | case 0x0d: /* CR */ | |
| 4189 | case 0x85: /* NEL */ | |
| 4190 | case 0x2028: /* LINE SEPARATOR */ | |
| 4191 | case 0x2029: /* PARAGRAPH SEPARATOR */ | |
| 4192 | RRETURN(MATCH_NOMATCH); | |
| 4193 | } | |
| 4194 | break; | |
| 4195 | ||
| 4196 | case OP_VSPACE: | |
| 4197 | switch(c) | |
| 4198 | { | |
| 4199 | default: RRETURN(MATCH_NOMATCH); | |
| 4200 | case 0x0a: /* LF */ | |
| 4201 | case 0x0b: /* VT */ | |
| 4202 | case 0x0c: /* FF */ | |
| 4203 | case 0x0d: /* CR */ | |
| 4204 | case 0x85: /* NEL */ | |
| 4205 | case 0x2028: /* LINE SEPARATOR */ | |
| 4206 | case 0x2029: /* PARAGRAPH SEPARATOR */ | |
| 4207 | break; | break; |
| 4208 | } | } |
| 4209 | break; | break; |
| # | Line 3122 for (;;) | Line 4249 for (;;) |
| 4249 | { | { |
| 4250 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 4251 | { | { |
| 4252 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM43); |
| 4253 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4254 | if (fi >= max || eptr >= md->end_subject || | if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 4255 | ((ims & PCRE_DOTALL) == 0 && IS_NEWLINE(eptr))) | if (eptr >= md->end_subject) |
| 4256 | { | |
| 4257 | SCHECK_PARTIAL(); | |
| 4258 | RRETURN(MATCH_NOMATCH); | |
| 4259 | } | |
| 4260 | if (ctype == OP_ANY && IS_NEWLINE(eptr)) | |
| 4261 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 4262 | c = *eptr++; | c = *eptr++; |
| 4263 | switch(ctype) | switch(ctype) |
| 4264 | { | { |
| 4265 | case OP_ANY: /* This is the DOTALL case */ | case OP_ANY: /* This is the non-NL case */ |
| 4266 | break; | case OP_ALLANY: |
| 4267 | case OP_ANYBYTE: | case OP_ANYBYTE: |
| 4268 | break; | break; |
| 4269 | ||
| # | Line 3144 for (;;) | Line 4274 for (;;) |
| 4274 | case 0x000d: | case 0x000d: |
| 4275 | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 4276 | break; | break; |
| 4277 | ||
| 4278 | case 0x000a: | case 0x000a: |
| 4279 | break; | |
| 4280 | ||
| 4281 | case 0x000b: | case 0x000b: |
| 4282 | case 0x000c: | case 0x000c: |
| 4283 | case 0x0085: | case 0x0085: |
| 4284 | if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); | |
| 4285 | break; | |
| 4286 | } | |
| 4287 | break; | |
| 4288 | ||
| 4289 | case OP_NOT_HSPACE: | |
| 4290 | switch(c) | |
| 4291 | { | |
| 4292 | default: break; | |
| 4293 | case 0x09: /* HT */ | |
| 4294 | case 0x20: /* SPACE */ | |
| 4295 | case 0xa0: /* NBSP */ | |
| 4296 | RRETURN(MATCH_NOMATCH); | |
| 4297 | } | |
| 4298 | break; | |
| 4299 | ||
| 4300 | case OP_HSPACE: | |
| 4301 | switch(c) | |
| 4302 | { | |
| 4303 | default: RRETURN(MATCH_NOMATCH); | |
| 4304 | case 0x09: /* HT */ | |
| 4305 | case 0x20: /* SPACE */ | |
| 4306 | case 0xa0: /* NBSP */ | |
| 4307 | break; | |
| 4308 | } | |
| 4309 | break; | |
| 4310 | ||
| 4311 | case OP_NOT_VSPACE: | |
| 4312 | switch(c) | |
| 4313 | { | |
| 4314 | default: break; | |
| 4315 | case 0x0a: /* LF */ | |
| 4316 | case 0x0b: /* VT */ | |
| 4317 | case 0x0c: /* FF */ | |
| 4318 | case 0x0d: /* CR */ | |
| 4319 | case 0x85: /* NEL */ | |
| 4320 | RRETURN(MATCH_NOMATCH); | |
| 4321 | } | |
| 4322 | break; | |
| 4323 | ||
| 4324 | case OP_VSPACE: | |
| 4325 | switch(c) | |
| 4326 | { | |
| 4327 | default: RRETURN(MATCH_NOMATCH); | |
| 4328 | case 0x0a: /* LF */ | |
| 4329 | case 0x0b: /* VT */ | |
| 4330 | case 0x0c: /* FF */ | |
| 4331 | case 0x0d: /* CR */ | |
| 4332 | case 0x85: /* NEL */ | |
| 4333 | break; | break; |
| 4334 | } | } |
| 4335 | break; | break; |
| # | Line 3201 for (;;) | Line 4383 for (;;) |
| 4383 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4384 | { | { |
| 4385 | int len = 1; | int len = 1; |
| 4386 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4387 | { | |
| 4388 | SCHECK_PARTIAL(); | |
| 4389 | break; | |
| 4390 | } | |
| 4391 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4392 | if (prop_fail_result) break; | if (prop_fail_result) break; |
| 4393 | eptr+= len; | eptr+= len; |
| # | Line 3212 for (;;) | Line 4398 for (;;) |
| 4398 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4399 | { | { |
| 4400 | int len = 1; | int len = 1; |
| 4401 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4402 | { | |
| 4403 | SCHECK_PARTIAL(); | |
| 4404 | break; | |
| 4405 | } | |
| 4406 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4407 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_chartype = UCD_CHARTYPE(c); |
| 4408 | if ((prop_chartype == ucp_Lu || | if ((prop_chartype == ucp_Lu || |
| 4409 | prop_chartype == ucp_Ll || | prop_chartype == ucp_Ll || |
| 4410 | prop_chartype == ucp_Lt) == prop_fail_result) | prop_chartype == ucp_Lt) == prop_fail_result) |
| # | Line 3227 for (;;) | Line 4417 for (;;) |
| 4417 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4418 | { | { |
| 4419 | int len = 1; | int len = 1; |
| 4420 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4421 | { | |
| 4422 | SCHECK_PARTIAL(); | |
| 4423 | break; | |
| 4424 | } | |
| 4425 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4426 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_category = UCD_CATEGORY(c); |
| 4427 | if ((prop_category == prop_value) == prop_fail_result) | if ((prop_category == prop_value) == prop_fail_result) |
| 4428 | break; | break; |
| 4429 | eptr+= len; | eptr+= len; |
| # | Line 3240 for (;;) | Line 4434 for (;;) |
| 4434 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4435 | { | { |
| 4436 | int len = 1; | int len = 1; |
| 4437 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4438 | { | |
| 4439 | SCHECK_PARTIAL(); | |
| 4440 | break; | |
| 4441 | } | |
| 4442 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4443 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_chartype = UCD_CHARTYPE(c); |
| 4444 | if ((prop_chartype == prop_value) == prop_fail_result) | if ((prop_chartype == prop_value) == prop_fail_result) |
| 4445 | break; | break; |
| 4446 | eptr+= len; | eptr+= len; |
| # | Line 3253 for (;;) | Line 4451 for (;;) |
| 4451 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4452 | { | { |
| 4453 | int len = 1; | int len = 1; |
| 4454 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4455 | { | |
| 4456 | SCHECK_PARTIAL(); | |
| 4457 | break; | |
| 4458 | } | |
| 4459 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4460 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_script = UCD_SCRIPT(c); |
| 4461 | if ((prop_script == prop_value) == prop_fail_result) | if ((prop_script == prop_value) == prop_fail_result) |
| 4462 | break; | break; |
| 4463 | eptr+= len; | eptr+= len; |
| # | Line 3268 for (;;) | Line 4470 for (;;) |
| 4470 | if (possessive) continue; | if (possessive) continue; |
| 4471 | for(;;) | for(;;) |
| 4472 | { | { |
| 4473 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM44); |
| 4474 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4475 | if (eptr-- == pp) break; /* Stop if tried at original pos */ | if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 4476 | BACKCHAR(eptr); | if (utf8) BACKCHAR(eptr); |
| 4477 | } | } |
| 4478 | } | } |
| 4479 | ||
| # | Line 3282 for (;;) | Line 4484 for (;;) |
| 4484 | { | { |
| 4485 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4486 | { | { |
| 4487 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4488 | { | |
| 4489 | SCHECK_PARTIAL(); | |
| 4490 | break; | |
| 4491 | } | |
| 4492 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 4493 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_category = UCD_CATEGORY(c); |
| 4494 | if (prop_category == ucp_M) break; | if (prop_category == ucp_M) break; |
| 4495 | while (eptr < md->end_subject) | while (eptr < md->end_subject) |
| 4496 | { | { |
| # | Line 3293 for (;;) | Line 4499 for (;;) |
| 4499 | { | { |
| 4500 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4501 | } | } |
| 4502 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_category = UCD_CATEGORY(c); |
| 4503 | if (prop_category != ucp_M) break; | if (prop_category != ucp_M) break; |
| 4504 | eptr += len; | eptr += len; |
| 4505 | } | } |
| # | Line 3302 for (;;) | Line 4508 for (;;) |
| 4508 | /* eptr is now past the end of the maximum run */ | /* eptr is now past the end of the maximum run */ |
| 4509 | ||
| 4510 | if (possessive) continue; | if (possessive) continue; |
| 4511 | ||
| 4512 | for(;;) | for(;;) |
| 4513 | { | { |
| 4514 | RMATCH(rrc, eptr, ecode, offset_top, md, ims, eptrb, 0); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM45); |
| 4515 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4516 | if (eptr-- == pp) break; /* Stop if tried at original pos */ | if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 4517 | for (;;) /* Move back over one extended */ | for (;;) /* Move back over one extended */ |
| 4518 | { | { |
| 4519 | int len = 1; | int len = 1; |
| BACKCHAR(eptr); | ||
| 4520 | if (!utf8) c = *eptr; else | if (!utf8) c = *eptr; else |
| 4521 | { | { |
| 4522 | BACKCHAR(eptr); | |
| 4523 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4524 | } | } |
| 4525 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_category = UCD_CATEGORY(c); |
| 4526 | if (prop_category != ucp_M) break; | if (prop_category != ucp_M) break; |
| 4527 | eptr--; | eptr--; |
| 4528 | } | } |
| # | Line 3333 for (;;) | Line 4540 for (;;) |
| 4540 | switch(ctype) | switch(ctype) |
| 4541 | { | { |
| 4542 | 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. */ | ||
| 4543 | if (max < INT_MAX) | if (max < INT_MAX) |
| 4544 | { | { |
| 4545 | 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 | ||
| 4546 | { | { |
| 4547 | for (i = min; i < max; i++) | if (eptr >= md->end_subject) |
| 4548 | { | { |
| 4549 | if (eptr >= md->end_subject) break; | SCHECK_PARTIAL(); |
| 4550 | eptr++; | break; |
| 4551 | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | } |
| 4552 | } | if (IS_NEWLINE(eptr)) break; |
| 4553 | eptr++; | |
| 4554 | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | |
| 4555 | } | } |
| 4556 | } | } |
| 4557 | ||
| # | Line 3364 for (;;) | Line 4559 for (;;) |
| 4559 | ||
| 4560 | else | else |
| 4561 | { | { |
| 4562 | if ((ims & PCRE_DOTALL) == 0) | for (i = min; i < max; i++) |
| 4563 | { | { |
| 4564 | for (i = min; i < max; i++) | if (eptr >= md->end_subject) |