Parent Directory
|
Revision Log
|
Patch
| revision 207 by ph10, Mon Aug 6 09:32:14 2007 UTC | revision 511 by ph10, Mon Mar 29 09:25:38 2010 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-2010 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 43 pattern matching using an NFA algorithm, | Line 43 pattern matching using an NFA algorithm, |
| 43 | possible. There are also some static supporting functions. */ | possible. There are also some static supporting functions. */ |
| 44 | ||
| 45 | #ifdef HAVE_CONFIG_H | #ifdef HAVE_CONFIG_H |
| 46 | #include <config.h> | #include "config.h" |
| 47 | #endif | #endif |
| 48 | ||
| 49 | #define NLBLOCK md /* Block containing newline information */ | #define NLBLOCK md /* Block containing newline information */ |
| # | Line 68 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_ACCEPT (-999) | |
| 75 | #define MATCH_COMMIT (-998) | |
| 76 | #define MATCH_PRUNE (-997) | |
| 77 | #define MATCH_SKIP (-996) | |
| 78 | #define MATCH_SKIP_ARG (-995) | |
| 79 | #define MATCH_THEN (-994) | |
| 80 | ||
| 81 | /* This is a convenience macro for code that occurs many times. */ | |
| 82 | ||
| 83 | #define MRRETURN(ra) \ | |
| 84 | { \ | |
| 85 | md->mark = markptr; \ | |
| 86 | RRETURN(ra); \ | |
| 87 | } | |
| 88 | ||
| 89 | /* 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. |
| 90 | 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, |
| 91 | because the offset vector is always a multiple of 3 long. */ | because the offset vector is always a multiple of 3 long. */ |
| # | Line 81 static const char rep_max[] = { 0, 0, 0, | Line 99 static const char rep_max[] = { 0, 0, 0, |
| 99 | ||
| 100 | ||
| 101 | ||
| 102 | #ifdef DEBUG | #ifdef PCRE_DEBUG |
| 103 | /************************************************* | /************************************************* |
| 104 | * Debugging function to print chars * | * Debugging function to print chars * |
| 105 | *************************************************/ | *************************************************/ |
| # | Line 133 match_ref(int offset, register USPTR ept | Line 151 match_ref(int offset, register USPTR ept |
| 151 | { | { |
| 152 | USPTR p = md->start_subject + md->offset_vector[offset]; | USPTR p = md->start_subject + md->offset_vector[offset]; |
| 153 | ||
| 154 | #ifdef DEBUG | #ifdef PCRE_DEBUG |
| 155 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 156 | printf("matching subject <null>"); | printf("matching subject <null>"); |
| 157 | else | else |
| # | Line 150 printf("\n"); | Line 168 printf("\n"); |
| 168 | ||
| 169 | if (length > md->end_subject - eptr) return FALSE; | if (length > md->end_subject - eptr) return FALSE; |
| 170 | ||
| 171 | /* Separate the caselesss case for speed */ | /* Separate the caseless case for speed. In UTF-8 mode we can only do this |
| 172 | properly if Unicode properties are supported. Otherwise, we can check only | |
| 173 | ASCII characters. */ | |
| 174 | ||
| 175 | if ((ims & PCRE_CASELESS) != 0) | if ((ims & PCRE_CASELESS) != 0) |
| 176 | { | { |
| 177 | #ifdef SUPPORT_UTF8 | |
| 178 | #ifdef SUPPORT_UCP | |
| 179 | if (md->utf8) | |
| 180 | { | |
| 181 | USPTR endptr = eptr + length; | |
| 182 | while (eptr < endptr) | |
| 183 | { | |
| 184 | int c, d; | |
| 185 | GETCHARINC(c, eptr); | |
| 186 | GETCHARINC(d, p); | |
| 187 | if (c != d && c != UCD_OTHERCASE(d)) return FALSE; | |
| 188 | } | |
| 189 | } | |
| 190 | else | |
| 191 | #endif | |
| 192 | #endif | |
| 193 | ||
| 194 | /* The same code works when not in UTF-8 mode and in UTF-8 mode when there | |
| 195 | is no UCP support. */ | |
| 196 | ||
| 197 | while (length-- > 0) | while (length-- > 0) |
| 198 | if (md->lcc[*p++] != md->lcc[*eptr++]) return FALSE; | { if (md->lcc[*p++] != md->lcc[*eptr++]) return FALSE; } |
| 199 | } | } |
| 200 | ||
| 201 | /* In the caseful case, we can just compare the bytes, whether or not we | |
| 202 | are in UTF-8 mode. */ | |
| 203 | ||
| 204 | else | else |
| 205 | { while (length-- > 0) if (*p++ != *eptr++) return FALSE; } | { while (length-- > 0) if (*p++ != *eptr++) return FALSE; } |
| 206 | ||
| # | Line 203 variable instead of being passed in the | Line 247 variable instead of being passed in the |
| 247 | **************************************************************************** | **************************************************************************** |
| 248 | ***************************************************************************/ | ***************************************************************************/ |
| 249 | ||
| 250 | /* Numbers for RMATCH calls. When this list is changed, the code at HEAP_RETURN | |
| 251 | /* Numbers for RMATCH calls */ | below must be updated in sync. */ |
| 252 | ||
| 253 | enum { RM1=1, RM2, RM3, RM4, RM5, RM6, RM7, RM8, RM9, RM10, | enum { RM1=1, RM2, RM3, RM4, RM5, RM6, RM7, RM8, RM9, RM10, |
| 254 | RM11, RM12, RM13, RM14, RM15, RM16, RM17, RM18, RM19, RM20, | RM11, RM12, RM13, RM14, RM15, RM16, RM17, RM18, RM19, RM20, |
| 255 | RM21, RM22, RM23, RM24, RM25, RM26, RM27, RM28, RM29, RM30, | RM21, RM22, RM23, RM24, RM25, RM26, RM27, RM28, RM29, RM30, |
| 256 | RM31, RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40, | RM31, RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40, |
| 257 | RM41, RM42, RM43, RM44, RM45, RM46, RM47, RM48, RM49, RM50 }; | RM41, RM42, RM43, RM44, RM45, RM46, RM47, RM48, RM49, RM50, |
| 258 | RM51, RM52, RM53, RM54 }; | |
| 259 | ||
| 260 | /* 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 |
| 261 | versions and production versions. Note that the "rw" argument of RMATCH isn't | versions and production versions. Note that the "rw" argument of RMATCH isn't |
| 262 | actuall used in this definition. */ | actually used in this definition. */ |
| 263 | ||
| 264 | #ifndef NO_RECURSE | #ifndef NO_RECURSE |
| 265 | #define REGISTER register | #define REGISTER register |
| 266 | ||
| 267 | #ifdef DEBUG | #ifdef PCRE_DEBUG |
| 268 | #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \ | #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \ |
| 269 | { \ | { \ |
| 270 | printf("match() called in line %d\n", __LINE__); \ | printf("match() called in line %d\n", __LINE__); \ |
| 271 | rrc = match(ra,rb,mstart,rc,rd,re,rf,rg,rdepth+1); \ | rrc = match(ra,rb,mstart,markptr,rc,rd,re,rf,rg,rdepth+1); \ |
| 272 | printf("to line %d\n", __LINE__); \ | printf("to line %d\n", __LINE__); \ |
| 273 | } | } |
| 274 | #define RRETURN(ra) \ | #define RRETURN(ra) \ |
| # | Line 234 actuall used in this definition. */ | Line 278 actuall used in this definition. */ |
| 278 | } | } |
| 279 | #else | #else |
| 280 | #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \ | #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \ |
| 281 | rrc = match(ra,rb,mstart,rc,rd,re,rf,rg,rdepth+1) | rrc = match(ra,rb,mstart,markptr,rc,rd,re,rf,rg,rdepth+1) |
| 282 | #define RRETURN(ra) return ra | #define RRETURN(ra) return ra |
| 283 | #endif | #endif |
| 284 | ||
| # | Line 254 argument of match(), which never changes | Line 298 argument of match(), which never changes |
| 298 | newframe->Xeptr = ra;\ | newframe->Xeptr = ra;\ |
| 299 | newframe->Xecode = rb;\ | newframe->Xecode = rb;\ |
| 300 | newframe->Xmstart = mstart;\ | newframe->Xmstart = mstart;\ |
| 301 | newframe->Xmarkptr = markptr;\ | |
| 302 | newframe->Xoffset_top = rc;\ | newframe->Xoffset_top = rc;\ |
| 303 | newframe->Xims = re;\ | newframe->Xims = re;\ |
| 304 | newframe->Xeptrb = rf;\ | newframe->Xeptrb = rf;\ |
| # | Line 288 typedef struct heapframe { | Line 333 typedef struct heapframe { |
| 333 | ||
| 334 | /* Function arguments that may change */ | /* Function arguments that may change */ |
| 335 | ||
| 336 | const uschar *Xeptr; | USPTR Xeptr; |
| 337 | const uschar *Xecode; | const uschar *Xecode; |
| 338 | const uschar *Xmstart; | USPTR Xmstart; |
| 339 | USPTR Xmarkptr; | |
| 340 | int Xoffset_top; | int Xoffset_top; |
| 341 | long int Xims; | long int Xims; |
| 342 | eptrblock *Xeptrb; | eptrblock *Xeptrb; |
| # | Line 299 typedef struct heapframe { | Line 345 typedef struct heapframe { |
| 345 | ||
| 346 | /* Function local variables */ | /* Function local variables */ |
| 347 | ||
| 348 | const uschar *Xcallpat; | USPTR Xcallpat; |
| 349 | const uschar *Xcharptr; | #ifdef SUPPORT_UTF8 |
| 350 | const uschar *Xdata; | USPTR Xcharptr; |
| 351 | const uschar *Xnext; | #endif |
| 352 | const uschar *Xpp; | USPTR Xdata; |
| 353 | const uschar *Xprev; | USPTR Xnext; |
| 354 | const uschar *Xsaved_eptr; | USPTR Xpp; |
| 355 | USPTR Xprev; | |
| 356 | USPTR Xsaved_eptr; | |
| 357 | ||
| 358 | recursion_info Xnew_recursive; | recursion_info Xnew_recursive; |
| 359 | ||
| # | Line 326 typedef struct heapframe { | Line 374 typedef struct heapframe { |
| 374 | uschar Xocchars[8]; | uschar Xocchars[8]; |
| 375 | #endif | #endif |
| 376 | ||
| 377 | int Xcodelink; | |
| 378 | int Xctype; | int Xctype; |
| 379 | unsigned int Xfc; | unsigned int Xfc; |
| 380 | int Xfi; | int Xfi; |
| # | Line 361 typedef struct heapframe { | Line 410 typedef struct heapframe { |
| 410 | ||
| 411 | /* This function is called recursively in many circumstances. Whenever it | /* This function is called recursively in many circumstances. Whenever it |
| 412 | returns a negative (error) response, the outer incarnation must also return the | returns a negative (error) response, the outer incarnation must also return the |
| 413 | same response. | same response. */ |
| 414 | ||
| 415 | /* These macros pack up tests that are used for partial matching, and which | |
| 416 | appears several times in the code. We set the "hit end" flag if the pointer is | |
| 417 | at the end of the subject and also past the start of the subject (i.e. | |
| 418 | something has been matched). For hard partial matching, we then return | |
| 419 | immediately. The second one is used when we already know we are past the end of | |
| 420 | the subject. */ | |
| 421 | ||
| 422 | Performance note: It might be tempting to extract commonly used fields from the | #define CHECK_PARTIAL()\ |
| 423 | md structure (e.g. utf8, end_subject) into individual variables to improve | if (md->partial != 0 && eptr >= md->end_subject && eptr > mstart)\ |
| 424 | {\ | |
| 425 | md->hitend = TRUE;\ | |
| 426 | if (md->partial > 1) MRRETURN(PCRE_ERROR_PARTIAL);\ | |
| 427 | } | |
| 428 | ||
| 429 | #define SCHECK_PARTIAL()\ | |
| 430 | if (md->partial != 0 && eptr > mstart)\ | |
| 431 | {\ | |
| 432 | md->hitend = TRUE;\ | |
| 433 | if (md->partial > 1) MRRETURN(PCRE_ERROR_PARTIAL);\ | |
| 434 | } | |
| 435 | ||
| 436 | ||
| 437 | /* Performance note: It might be tempting to extract commonly used fields from | |
| 438 | the md structure (e.g. utf8, end_subject) into individual variables to improve | |
| 439 | 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 |
| 440 | made performance worse. | made performance worse. |
| 441 | ||
| # | Line 373 Arguments: | Line 444 Arguments: |
| 444 | ecode pointer to current position in compiled code | ecode pointer to current position in compiled code |
| 445 | mstart pointer to the current match start position (can be modified | mstart pointer to the current match start position (can be modified |
| 446 | by encountering \K) | by encountering \K) |
| 447 | markptr pointer to the most recent MARK name, or NULL | |
| 448 | offset_top current top pointer | offset_top current top pointer |
| 449 | md pointer to "static" info for the match | md pointer to "static" info for the match |
| 450 | ims current /i, /m, and /s options | ims current /i, /m, and /s options |
| # | Line 386 Arguments: | Line 458 Arguments: |
| 458 | ||
| 459 | Returns: MATCH_MATCH if matched ) these values are >= 0 | Returns: MATCH_MATCH if matched ) these values are >= 0 |
| 460 | MATCH_NOMATCH if failed to match ) | MATCH_NOMATCH if failed to match ) |
| 461 | a negative MATCH_xxx value for PRUNE, SKIP, etc | |
| 462 | a negative PCRE_ERROR_xxx value if aborted by an error condition | a negative PCRE_ERROR_xxx value if aborted by an error condition |
| 463 | (e.g. stopped by repeated call or recursion limit) | (e.g. stopped by repeated call or recursion limit) |
| 464 | */ | */ |
| 465 | ||
| 466 | static int | static int |
| 467 | match(REGISTER USPTR eptr, REGISTER const uschar *ecode, const uschar *mstart, | match(REGISTER USPTR eptr, REGISTER const uschar *ecode, USPTR mstart, |
| 468 | int offset_top, match_data *md, unsigned long int ims, eptrblock *eptrb, | const uschar *markptr, int offset_top, match_data *md, unsigned long int ims, |
| 469 | int flags, unsigned int rdepth) | eptrblock *eptrb, int flags, unsigned int rdepth) |
| 470 | { | { |
| 471 | /* These variables do not need to be preserved over recursion in this function, | /* These variables do not need to be preserved over recursion in this function, |
| 472 | so they can be ordinary variables in all cases. Mark some of them with | so they can be ordinary variables in all cases. Mark some of them with |
| # | Line 405 register unsigned int c; /* Character | Line 478 register unsigned int c; /* Character |
| 478 | register BOOL utf8; /* Local copy of UTF-8 flag for speed */ | register BOOL utf8; /* Local copy of UTF-8 flag for speed */ |
| 479 | ||
| 480 | BOOL minimize, possessive; /* Quantifier options */ | BOOL minimize, possessive; /* Quantifier options */ |
| 481 | int condcode; | |
| 482 | ||
| 483 | /* 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 |
| 484 | 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 420 frame->Xprevframe = NULL; /* | Line 494 frame->Xprevframe = NULL; /* |
| 494 | frame->Xeptr = eptr; | frame->Xeptr = eptr; |
| 495 | frame->Xecode = ecode; | frame->Xecode = ecode; |
| 496 | frame->Xmstart = mstart; | frame->Xmstart = mstart; |
| 497 | frame->Xmarkptr = markptr; | |
| 498 | frame->Xoffset_top = offset_top; | frame->Xoffset_top = offset_top; |
| 499 | frame->Xims = ims; | frame->Xims = ims; |
| 500 | frame->Xeptrb = eptrb; | frame->Xeptrb = eptrb; |
| # | Line 435 HEAP_RECURSE: | Line 510 HEAP_RECURSE: |
| 510 | #define eptr frame->Xeptr | #define eptr frame->Xeptr |
| 511 | #define ecode frame->Xecode | #define ecode frame->Xecode |
| 512 | #define mstart frame->Xmstart | #define mstart frame->Xmstart |
| 513 | #define markptr frame->Xmarkptr | |
| 514 | #define offset_top frame->Xoffset_top | #define offset_top frame->Xoffset_top |
| 515 | #define ims frame->Xims | #define ims frame->Xims |
| 516 | #define eptrb frame->Xeptrb | #define eptrb frame->Xeptrb |
| # | Line 447 HEAP_RECURSE: | Line 523 HEAP_RECURSE: |
| 523 | #define charptr frame->Xcharptr | #define charptr frame->Xcharptr |
| 524 | #endif | #endif |
| 525 | #define callpat frame->Xcallpat | #define callpat frame->Xcallpat |
| 526 | #define codelink frame->Xcodelink | |
| 527 | #define data frame->Xdata | #define data frame->Xdata |
| 528 | #define next frame->Xnext | #define next frame->Xnext |
| 529 | #define pp frame->Xpp | #define pp frame->Xpp |
| # | Line 527 int oclength; | Line 604 int oclength; |
| 604 | uschar occhars[8]; | uschar occhars[8]; |
| 605 | #endif | #endif |
| 606 | ||
| 607 | int codelink; | |
| 608 | int ctype; | int ctype; |
| 609 | int length; | int length; |
| 610 | int max; | int max; |
| # | Line 560 TAIL_RECURSE: | Line 638 TAIL_RECURSE: |
| 638 | /* OK, now we can get on with the real code of the function. Recursive calls | /* OK, now we can get on with the real code of the function. Recursive calls |
| 639 | are specified by the macro RMATCH and RRETURN is used to return. When | are specified by the macro RMATCH and RRETURN is used to return. When |
| 640 | NO_RECURSE is *not* defined, these just turn into a recursive call to match() | NO_RECURSE is *not* defined, these just turn into a recursive call to match() |
| 641 | and a "return", respectively (possibly with some debugging if DEBUG is | and a "return", respectively (possibly with some debugging if PCRE_DEBUG is |
| 642 | defined). However, RMATCH isn't like a function call because it's quite a | defined). However, RMATCH isn't like a function call because it's quite a |
| 643 | 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, |
| 644 | however, impact performance when true recursion is being used. */ | however, impact performance when true recursion is being used. */ |
| # | Line 602 for (;;) | Line 680 for (;;) |
| 680 | minimize = possessive = FALSE; | minimize = possessive = FALSE; |
| 681 | op = *ecode; | op = *ecode; |
| 682 | ||
| /* 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 > mstart) | ||
| md->hitend = TRUE; | ||
| 683 | switch(op) | switch(op) |
| 684 | { | { |
| 685 | case OP_MARK: | |
| 686 | markptr = ecode + 2; | |
| 687 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md, | |
| 688 | ims, eptrb, flags, RM51); | |
| 689 | ||
| 690 | /* A return of MATCH_SKIP_ARG means that matching failed at SKIP with an | |
| 691 | argument, and we must check whether that argument matches this MARK's | |
| 692 | argument. It is passed back in md->start_match_ptr (an overloading of that | |
| 693 | variable). If it does match, we reset that variable to the current subject | |
| 694 | position and return MATCH_SKIP. Otherwise, pass back the return code | |
| 695 | unaltered. */ | |
| 696 | ||
| 697 | if (rrc == MATCH_SKIP_ARG && | |
| 698 | strcmp((char *)markptr, (char *)(md->start_match_ptr)) == 0) | |
| 699 | { | |
| 700 | md->start_match_ptr = eptr; | |
| 701 | RRETURN(MATCH_SKIP); | |
| 702 | } | |
| 703 | ||
| 704 | if (md->mark == NULL) md->mark = markptr; | |
| 705 | RRETURN(rrc); | |
| 706 | ||
| 707 | case OP_FAIL: | |
| 708 | MRRETURN(MATCH_NOMATCH); | |
| 709 | ||
| 710 | case OP_COMMIT: | |
| 711 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | |
| 712 | ims, eptrb, flags, RM52); | |
| 713 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | |
| 714 | MRRETURN(MATCH_COMMIT); | |
| 715 | ||
| 716 | case OP_PRUNE: | |
| 717 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | |
| 718 | ims, eptrb, flags, RM51); | |
| 719 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | |
| 720 | MRRETURN(MATCH_PRUNE); | |
| 721 | ||
| 722 | case OP_PRUNE_ARG: | |
| 723 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md, | |
| 724 | ims, eptrb, flags, RM51); | |
| 725 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | |
| 726 | md->mark = ecode + 2; | |
| 727 | RRETURN(MATCH_PRUNE); | |
| 728 | ||
| 729 | case OP_SKIP: | |
| 730 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | |
| 731 | ims, eptrb, flags, RM53); | |
| 732 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | |
| 733 | md->start_match_ptr = eptr; /* Pass back current position */ | |
| 734 | MRRETURN(MATCH_SKIP); | |
| 735 | ||
| 736 | case OP_SKIP_ARG: | |
| 737 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md, | |
| 738 | ims, eptrb, flags, RM53); | |
| 739 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | |
| 740 | ||
| 741 | /* Pass back the current skip name by overloading md->start_match_ptr and | |
| 742 | returning the special MATCH_SKIP_ARG return code. This will either be | |
| 743 | caught by a matching MARK, or get to the top, where it is treated the same | |
| 744 | as PRUNE. */ | |
| 745 | ||
| 746 | md->start_match_ptr = ecode + 2; | |
| 747 | RRETURN(MATCH_SKIP_ARG); | |
| 748 | ||
| 749 | case OP_THEN: | |
| 750 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | |
| 751 | ims, eptrb, flags, RM54); | |
| 752 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | |
| 753 | MRRETURN(MATCH_THEN); | |
| 754 | ||
| 755 | case OP_THEN_ARG: | |
| 756 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md, | |
| 757 | ims, eptrb, flags, RM54); | |
| 758 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | |
| 759 | md->mark = ecode + 2; | |
| 760 | RRETURN(MATCH_THEN); | |
| 761 | ||
| 762 | /* 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 |
| 763 | 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. |
| 764 | 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 631 for (;;) | Line 778 for (;;) |
| 778 | number = GET2(ecode, 1+LINK_SIZE); | number = GET2(ecode, 1+LINK_SIZE); |
| 779 | offset = number << 1; | offset = number << 1; |
| 780 | ||
| 781 | #ifdef DEBUG | #ifdef PCRE_DEBUG |
| 782 | printf("start bracket %d\n", number); | printf("start bracket %d\n", number); |
| 783 | printf("subject="); | printf("subject="); |
| 784 | pchars(eptr, 16, TRUE, md); | pchars(eptr, 16, TRUE, md); |
| # | Line 653 for (;;) | Line 800 for (;;) |
| 800 | { | { |
| 801 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
| 802 | ims, eptrb, flags, RM1); | ims, eptrb, flags, RM1); |
| 803 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); |
| 804 | md->capture_last = save_capture_last; | md->capture_last = save_capture_last; |
| 805 | ecode += GET(ecode, 1); | ecode += GET(ecode, 1); |
| 806 | } | } |
| # | Line 665 for (;;) | Line 812 for (;;) |
| 812 | md->offset_vector[offset+1] = save_offset2; | md->offset_vector[offset+1] = save_offset2; |
| 813 | md->offset_vector[md->offset_end - number] = save_offset3; | md->offset_vector[md->offset_end - number] = save_offset3; |
| 814 | ||
| 815 | if (rrc != MATCH_THEN) md->mark = markptr; | |
| 816 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 817 | } | } |
| 818 | ||
| # | Line 704 for (;;) | Line 852 for (;;) |
| 852 | ||
| 853 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims, | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims, |
| 854 | eptrb, flags, RM48); | eptrb, flags, RM48); |
| 855 | RRETURN(rrc); | if (rrc == MATCH_NOMATCH) md->mark = markptr; |
| 856 | RRETURN(rrc); | |
| 857 | } | } |
| 858 | ||
| 859 | /* For non-final alternatives, continue the loop for a NOMATCH result; | /* For non-final alternatives, continue the loop for a NOMATCH result; |
| # | Line 712 for (;;) | Line 861 for (;;) |
| 861 | ||
| 862 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims, | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims, |
| 863 | eptrb, flags, RM2); | eptrb, flags, RM2); |
| 864 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); |
| 865 | ecode += GET(ecode, 1); | ecode += GET(ecode, 1); |
| 866 | } | } |
| 867 | /* Control never reaches here. */ | /* Control never reaches here. */ |
| # | Line 725 for (;;) | Line 874 for (;;) |
| 874 | ||
| 875 | case OP_COND: | case OP_COND: |
| 876 | case OP_SCOND: | case OP_SCOND: |
| 877 | if (ecode[LINK_SIZE+1] == OP_RREF) /* Recursion test */ | codelink= GET(ecode, 1); |
| 878 | ||
| 879 | /* Because of the way auto-callout works during compile, a callout item is | |
| 880 | inserted between OP_COND and an assertion condition. */ | |
| 881 | ||
| 882 | if (ecode[LINK_SIZE+1] == OP_CALLOUT) | |
| 883 | { | { |
| 884 | offset = GET2(ecode, LINK_SIZE + 2); /* Recursion group number*/ | if (pcre_callout != NULL) |
| 885 | condition = md->recursive != NULL && | { |
| 886 | (offset == RREF_ANY || offset == md->recursive->group_num); | pcre_callout_block cb; |
| 887 | ecode += condition? 3 : GET(ecode, 1); | cb.version = 1; /* Version 1 of the callout block */ |
| 888 | cb.callout_number = ecode[LINK_SIZE+2]; | |
| 889 | cb.offset_vector = md->offset_vector; | |
| 890 | cb.subject = (PCRE_SPTR)md->start_subject; | |
| 891 | cb.subject_length = md->end_subject - md->start_subject; | |
| 892 | cb.start_match = mstart - md->start_subject; | |
| 893 | cb.current_position = eptr - md->start_subject; | |
| 894 | cb.pattern_position = GET(ecode, LINK_SIZE + 3); | |
| 895 | cb.next_item_length = GET(ecode, 3 + 2*LINK_SIZE); | |
| 896 | cb.capture_top = offset_top/2; | |
| 897 | cb.capture_last = md->capture_last; | |
| 898 | cb.callout_data = md->callout_data; | |
| 899 | if ((rrc = (*pcre_callout)(&cb)) > 0) MRRETURN(MATCH_NOMATCH); | |
| 900 | if (rrc < 0) RRETURN(rrc); | |
| 901 | } | |
| 902 | ecode += _pcre_OP_lengths[OP_CALLOUT]; | |
| 903 | } | |
| 904 | ||
| 905 | condcode = ecode[LINK_SIZE+1]; | |
| 906 | ||
| 907 | /* Now see what the actual condition is */ | |
| 908 | ||
| 909 | if (condcode == OP_RREF || condcode == OP_NRREF) /* Recursion test */ | |
| 910 | { | |
| 911 | if (md->recursive == NULL) /* Not recursing => FALSE */ | |
| 912 | { | |
| 913 | condition = FALSE; | |
| 914 | ecode += GET(ecode, 1); | |
| 915 | } | |
| 916 | else | |
| 917 | { | |
| 918 | int recno = GET2(ecode, LINK_SIZE + 2); /* Recursion group number*/ | |
| 919 | condition = (recno == RREF_ANY || recno == md->recursive->group_num); | |
| 920 | ||
| 921 | /* If the test is for recursion into a specific subpattern, and it is | |
| 922 | false, but the test was set up by name, scan the table to see if the | |
| 923 | name refers to any other numbers, and test them. The condition is true | |
| 924 | if any one is set. */ | |
| 925 | ||
| 926 | if (!condition && condcode == OP_NRREF && recno != RREF_ANY) | |
| 927 | { | |
| 928 | uschar *slotA = md->name_table; | |
| 929 | for (i = 0; i < md->name_count; i++) | |
| 930 | { | |
| 931 | if (GET2(slotA, 0) == recno) break; | |
| 932 | slotA += md->name_entry_size; | |
| 933 | } | |
| 934 | ||
| 935 | /* Found a name for the number - there can be only one; duplicate | |
| 936 | names for different numbers are allowed, but not vice versa. First | |
| 937 | scan down for duplicates. */ | |
| 938 | ||
| 939 | if (i < md->name_count) | |
| 940 | { | |
| 941 | uschar *slotB = slotA; | |
| 942 | while (slotB > md->name_table) | |
| 943 | { | |
| 944 | slotB -= md->name_entry_size; | |
| 945 | if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) | |
| 946 | { | |
| 947 | condition = GET2(slotB, 0) == md->recursive->group_num; | |
| 948 | if (condition) break; | |
| 949 | } | |
| 950 | else break; | |
| 951 | } | |
| 952 | ||
| 953 | /* Scan up for duplicates */ | |
| 954 | ||
| 955 | if (!condition) | |
| 956 | { | |
| 957 | slotB = slotA; | |
| 958 | for (i++; i < md->name_count; i++) | |
| 959 | { | |
| 960 | slotB += md->name_entry_size; | |
| 961 | if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) | |
| 962 | { | |
| 963 | condition = GET2(slotB, 0) == md->recursive->group_num; | |
| 964 | if (condition) break; | |
| 965 | } | |
| 966 | else break; | |
| 967 | } | |
| 968 | } | |
| 969 | } | |
| 970 | } | |
| 971 | ||
| 972 | /* Chose branch according to the condition */ | |
| 973 | ||
| 974 | ecode += condition? 3 : GET(ecode, 1); | |
| 975 | } | |
| 976 | } | } |
| 977 | ||
| 978 | else if (ecode[LINK_SIZE+1] == OP_CREF) /* Group used test */ | else if (condcode == OP_CREF || condcode == OP_NCREF) /* Group used test */ |
| 979 | { | { |
| 980 | offset = GET2(ecode, LINK_SIZE+2) << 1; /* Doubled ref number */ | offset = GET2(ecode, LINK_SIZE+2) << 1; /* Doubled ref number */ |
| 981 | condition = offset < offset_top && md->offset_vector[offset] >= 0; | condition = offset < offset_top && md->offset_vector[offset] >= 0; |
| 982 | ||
| 983 | /* If the numbered capture is unset, but the reference was by name, | |
| 984 | scan the table to see if the name refers to any other numbers, and test | |
| 985 | them. The condition is true if any one is set. This is tediously similar | |
| 986 | to the code above, but not close enough to try to amalgamate. */ | |
| 987 | ||
| 988 | if (!condition && condcode == OP_NCREF) | |
| 989 | { | |
| 990 | int refno = offset >> 1; | |
| 991 | uschar *slotA = md->name_table; | |
| 992 | ||
| 993 | for (i = 0; i < md->name_count; i++) | |
| 994 | { | |
| 995 | if (GET2(slotA, 0) == refno) break; | |
| 996 | slotA += md->name_entry_size; | |
| 997 | } | |
| 998 | ||
| 999 | /* Found a name for the number - there can be only one; duplicate names | |
| 1000 | for different numbers are allowed, but not vice versa. First scan down | |
| 1001 | for duplicates. */ | |
| 1002 | ||
| 1003 | if (i < md->name_count) | |
| 1004 | { | |
| 1005 | uschar *slotB = slotA; | |
| 1006 | while (slotB > md->name_table) | |
| 1007 | { | |
| 1008 | slotB -= md->name_entry_size; | |
| 1009 | if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) | |
| 1010 | { | |
| 1011 | offset = GET2(slotB, 0) << 1; | |
| 1012 | condition = offset < offset_top && | |
| 1013 | md->offset_vector[offset] >= 0; | |
| 1014 | if (condition) break; | |
| 1015 | } | |
| 1016 | else break; | |
| 1017 | } | |
| 1018 | ||
| 1019 | /* Scan up for duplicates */ | |
| 1020 | ||
| 1021 | if (!condition) | |
| 1022 | { | |
| 1023 | slotB = slotA; | |
| 1024 | for (i++; i < md->name_count; i++) | |
| 1025 | { | |
| 1026 | slotB += md->name_entry_size; | |
| 1027 | if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) | |
| 1028 | { | |
| 1029 | offset = GET2(slotB, 0) << 1; | |
| 1030 | condition = offset < offset_top && | |
| 1031 | md->offset_vector[offset] >= 0; | |
| 1032 | if (condition) break; | |
| 1033 | } | |
| 1034 | else break; | |
| 1035 | } | |
| 1036 | } | |
| 1037 | } | |
| 1038 | } | |
| 1039 | ||
| 1040 | /* Chose branch according to the condition */ | |
| 1041 | ||
| 1042 | ecode += condition? 3 : GET(ecode, 1); | ecode += condition? 3 : GET(ecode, 1); |
| 1043 | } | } |
| 1044 | ||
| 1045 | else if (ecode[LINK_SIZE+1] == OP_DEF) /* DEFINE - always false */ | else if (condcode == OP_DEF) /* DEFINE - always false */ |
| 1046 | { | { |
| 1047 | condition = FALSE; | condition = FALSE; |
| 1048 | ecode += GET(ecode, 1); | ecode += GET(ecode, 1); |
| # | Line 760 for (;;) | Line 1062 for (;;) |
| 1062 | ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2); | ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2); |
| 1063 | while (*ecode == OP_ALT) ecode += GET(ecode, 1); | while (*ecode == OP_ALT) ecode += GET(ecode, 1); |
| 1064 | } | } |
| 1065 | else if (rrc != MATCH_NOMATCH) | else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) |
| 1066 | { | { |
| 1067 | RRETURN(rrc); /* Need braces because of following else */ | RRETURN(rrc); /* Need braces because of following else */ |
| 1068 | } | } |
| 1069 | else | else |
| 1070 | { | { |
| 1071 | condition = FALSE; | condition = FALSE; |
| 1072 | ecode += GET(ecode, 1); | ecode += codelink; |
| 1073 | } | } |
| 1074 | } | } |
| 1075 | ||
| # | Line 790 for (;;) | Line 1092 for (;;) |
| 1092 | goto TAIL_RECURSE; | goto TAIL_RECURSE; |
| 1093 | } | } |
| 1094 | } | } |
| 1095 | else /* Condition false & no 2nd alternative */ | else /* Condition false & no alternative */ |
| 1096 | { | { |
| 1097 | ecode += 1 + LINK_SIZE; | ecode += 1 + LINK_SIZE; |
| 1098 | } | } |
| 1099 | break; | break; |
| 1100 | ||
| 1101 | ||
| 1102 | /* 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, |
| 1103 | restore the offsets appropriately and continue from after the call. */ | to close any currently open capturing brackets. */ |
| 1104 | ||
| 1105 | case OP_CLOSE: | |
| 1106 | number = GET2(ecode, 1); | |
| 1107 | offset = number << 1; | |
| 1108 | ||
| 1109 | #ifdef PCRE_DEBUG | |
| 1110 | printf("end bracket %d at *ACCEPT", number); | |
| 1111 | printf("\n"); | |
| 1112 | #endif | |
| 1113 | ||
| 1114 | md->capture_last = number; | |
| 1115 | if (offset >= md->offset_max) md->offset_overflow = TRUE; else | |
| 1116 | { | |
| 1117 | md->offset_vector[offset] = | |
| 1118 | md->offset_vector[md->offset_end - number]; | |
| 1119 | md->offset_vector[offset+1] = eptr - md->start_subject; | |
| 1120 | if (offset_top <= offset) offset_top = offset + 2; | |
| 1121 | } | |
| 1122 | ecode += 3; | |
| 1123 | break; | |
| 1124 | ||
| 1125 | ||
| 1126 | /* End of the pattern, either real or forced. If we are in a top-level | |
| 1127 | recursion, we should restore the offsets appropriately and continue from | |
| 1128 | after the call. */ | |
| 1129 | ||
| 1130 | case OP_ACCEPT: | |
| 1131 | case OP_END: | case OP_END: |
| 1132 | if (md->recursive != NULL && md->recursive->group_num == 0) | if (md->recursive != NULL && md->recursive->group_num == 0) |
| 1133 | { | { |
| # | Line 808 for (;;) | Line 1136 for (;;) |
| 1136 | md->recursive = rec->prevrec; | md->recursive = rec->prevrec; |
| 1137 | memmove(md->offset_vector, rec->offset_save, | memmove(md->offset_vector, rec->offset_save, |
| 1138 | rec->saved_max * sizeof(int)); | rec->saved_max * sizeof(int)); |
| 1139 | mstart = rec->save_start; | offset_top = rec->save_offset_top; |
| 1140 | ims = original_ims; | ims = original_ims; |
| 1141 | ecode = rec->after_call; | ecode = rec->after_call; |
| 1142 | break; | break; |
| 1143 | } | } |
| 1144 | ||
| 1145 | /* 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 |
| 1146 | 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 |
| 1147 | the subject. In both cases, backtracking will then try other alternatives, | |
| 1148 | if any. */ | |
| 1149 | ||
| 1150 | if (eptr == mstart && | |
| 1151 | (md->notempty || | |
| 1152 | (md->notempty_atstart && | |
| 1153 | mstart == md->start_subject + md->start_offset))) | |
| 1154 | MRRETURN(MATCH_NOMATCH); | |
| 1155 | ||
| 1156 | /* Otherwise, we have a match. */ | |
| 1157 | ||
| if (md->notempty && eptr == mstart) RRETURN(MATCH_NOMATCH); | ||
| 1158 | md->end_match_ptr = eptr; /* Record where we ended */ | md->end_match_ptr = eptr; /* Record where we ended */ |
| 1159 | md->end_offset_top = offset_top; /* and how many extracts were taken */ | md->end_offset_top = offset_top; /* and how many extracts were taken */ |
| 1160 | md->start_match_ptr = mstart; /* and the start (\K can modify) */ | md->start_match_ptr = mstart; /* and the start (\K can modify) */ |
| 1161 | RRETURN(MATCH_MATCH); | MRRETURN(((op == OP_END)? MATCH_MATCH : MATCH_ACCEPT)); |
| 1162 | ||
| 1163 | /* Change option settings */ | /* Change option settings */ |
| 1164 | ||
| # | Line 843 for (;;) | Line 1180 for (;;) |
| 1180 | { | { |
| 1181 | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0, | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0, |
| 1182 | RM4); | RM4); |
| 1183 | if (rrc == MATCH_MATCH) break; | if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) |
| 1184 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | { |
| 1185 | mstart = md->start_match_ptr; /* In case \K reset it */ | |
| 1186 | break; | |
| 1187 | } | |
| 1188 | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); | |
| 1189 | ecode += GET(ecode, 1); | ecode += GET(ecode, 1); |
| 1190 | } | } |
| 1191 | while (*ecode == OP_ALT); | while (*ecode == OP_ALT); |
| 1192 | if (*ecode == OP_KET) RRETURN(MATCH_NOMATCH); | if (*ecode == OP_KET) MRRETURN(MATCH_NOMATCH); |
| 1193 | ||
| 1194 | /* If checking an assertion for a condition, return MATCH_MATCH. */ | /* If checking an assertion for a condition, return MATCH_MATCH. */ |
| 1195 | ||
| # | Line 862 for (;;) | Line 1203 for (;;) |
| 1203 | offset_top = md->end_offset_top; | offset_top = md->end_offset_top; |
| 1204 | continue; | continue; |
| 1205 | ||
| 1206 | /* Negative assertion: all branches must fail to match */ | /* Negative assertion: all branches must fail to match. Encountering SKIP, |
| 1207 | PRUNE, or COMMIT means we must assume failure without checking subsequent | |
| 1208 | branches. */ | |
| 1209 | ||
| 1210 | case OP_ASSERT_NOT: | case OP_ASSERT_NOT: |
| 1211 | case OP_ASSERTBACK_NOT: | case OP_ASSERTBACK_NOT: |
| # | Line 870 for (;;) | Line 1213 for (;;) |
| 1213 | { | { |
| 1214 | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0, | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0, |
| 1215 | RM5); | RM5); |
| 1216 | if (rrc == MATCH_MATCH) RRETURN(MATCH_NOMATCH); | if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) MRRETURN(MATCH_NOMATCH); |
| 1217 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT) |
| 1218 | { | |
| 1219 | do ecode += GET(ecode,1); while (*ecode == OP_ALT); | |
| 1220 | break; | |
| 1221 | } | |
| 1222 | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); | |
| 1223 | ecode += GET(ecode,1); | ecode += GET(ecode,1); |
| 1224 | } | } |
| 1225 | while (*ecode == OP_ALT); | while (*ecode == OP_ALT); |
| # | Line 894 for (;;) | Line 1242 for (;;) |
| 1242 | while (i-- > 0) | while (i-- > 0) |
| 1243 | { | { |
| 1244 | eptr--; | eptr--; |
| 1245 | if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH); | if (eptr < md->start_subject) MRRETURN(MATCH_NOMATCH); |
| 1246 | BACKCHAR(eptr); | BACKCHAR(eptr); |
| 1247 | } | } |
| 1248 | } | } |
| # | Line 905 for (;;) | Line 1253 for (;;) |
| 1253 | ||
| 1254 | { | { |
| 1255 | eptr -= GET(ecode, 1); | eptr -= GET(ecode, 1); |
| 1256 | if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH); | if (eptr < md->start_subject) MRRETURN(MATCH_NOMATCH); |
| 1257 | } | } |
| 1258 | ||
| 1259 | /* Skip to next op code */ | /* Save the earliest consulted character, then skip to next op code */ |
| 1260 | ||
| 1261 | if (eptr < md->start_used_ptr) md->start_used_ptr = eptr; | |
| 1262 | ecode += 1 + LINK_SIZE; | ecode += 1 + LINK_SIZE; |
| 1263 | break; | break; |
| 1264 | ||
| # | Line 933 for (;;) | Line 1282 for (;;) |
| 1282 | cb.capture_top = offset_top/2; | cb.capture_top = offset_top/2; |
| 1283 | cb.capture_last = md->capture_last; | cb.capture_last = md->capture_last; |
| 1284 | cb.callout_data = md->callout_data; | cb.callout_data = md->callout_data; |
| 1285 | if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH); | if ((rrc = (*pcre_callout)(&cb)) > 0) MRRETURN(MATCH_NOMATCH); |
| 1286 | if (rrc < 0) RRETURN(rrc); | if (rrc < 0) RRETURN(rrc); |
| 1287 | } | } |
| 1288 | ecode += 2 + 2*LINK_SIZE; | ecode += 2 + 2*LINK_SIZE; |
| # | Line 988 for (;;) | Line 1337 for (;;) |
| 1337 | ||
| 1338 | memcpy(new_recursive.offset_save, md->offset_vector, | memcpy(new_recursive.offset_save, md->offset_vector, |
| 1339 | new_recursive.saved_max * sizeof(int)); | new_recursive.saved_max * sizeof(int)); |
| 1340 | new_recursive.save_start = mstart; | new_recursive.save_offset_top = offset_top; |
| mstart = eptr; | ||
| 1341 | ||
| 1342 | /* 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 |
| 1343 | restore the offset and recursion data. */ | restore the offset and recursion data. */ |
| # | Line 1000 for (;;) | Line 1348 for (;;) |
| 1348 | { | { |
| 1349 | RMATCH(eptr, callpat + _pcre_OP_lengths[*callpat], offset_top, | RMATCH(eptr, callpat + _pcre_OP_lengths[*callpat], offset_top, |
| 1350 | md, ims, eptrb, flags, RM6); | md, ims, eptrb, flags, RM6); |
| 1351 | if (rrc == MATCH_MATCH) | if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) |
| 1352 | { | { |
| 1353 | DPRINTF(("Recursion matched\n")); | DPRINTF(("Recursion matched\n")); |
| 1354 | md->recursive = new_recursive.prevrec; | md->recursive = new_recursive.prevrec; |
| 1355 | if (new_recursive.offset_save != stacksave) | if (new_recursive.offset_save != stacksave) |
| 1356 | (pcre_free)(new_recursive.offset_save); | (pcre_free)(new_recursive.offset_save); |
| 1357 | RRETURN(MATCH_MATCH); | MRRETURN(MATCH_MATCH); |
| 1358 | } | } |
| 1359 | else if (rrc != MATCH_NOMATCH) | else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) |
| 1360 | { | { |
| 1361 | DPRINTF(("Recursion gave error %d\n", rrc)); | DPRINTF(("Recursion gave error %d\n", rrc)); |
| 1362 | if (new_recursive.offset_save != stacksave) | |
| 1363 | (pcre_free)(new_recursive.offset_save); | |
| 1364 | RRETURN(rrc); | RRETURN(rrc); |
| 1365 | } | } |
| 1366 | ||
| # | Line 1025 for (;;) | Line 1375 for (;;) |
| 1375 | md->recursive = new_recursive.prevrec; | md->recursive = new_recursive.prevrec; |
| 1376 | if (new_recursive.offset_save != stacksave) | if (new_recursive.offset_save != stacksave) |
| 1377 | (pcre_free)(new_recursive.offset_save); | (pcre_free)(new_recursive.offset_save); |
| 1378 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1379 | } | } |
| 1380 | /* Control never reaches here */ | /* Control never reaches here */ |
| 1381 | ||
| # | Line 1034 for (;;) | Line 1384 for (;;) |
| 1384 | a move back into the brackets. Friedl calls these "atomic" subpatterns. | a move back into the brackets. Friedl calls these "atomic" subpatterns. |
| 1385 | Check the alternative branches in turn - the matching won't pass the KET | Check the alternative branches in turn - the matching won't pass the KET |
| 1386 | for this kind of subpattern. If any one branch matches, we carry on as at | for this kind of subpattern. If any one branch matches, we carry on as at |
| 1387 | the end of a normal bracket, leaving the subject pointer. */ | the end of a normal bracket, leaving the subject pointer, but resetting |
| 1388 | the start-of-match value in case it was changed by \K. */ | |
| 1389 | ||
| 1390 | case OP_ONCE: | case OP_ONCE: |
| 1391 | prev = ecode; | prev = ecode; |
| # | Line 1043 for (;;) | Line 1394 for (;;) |
| 1394 | do | do |
| 1395 | { | { |
| 1396 | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM7); | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM7); |
| 1397 | if (rrc == MATCH_MATCH) break; | if (rrc == MATCH_MATCH) /* Note: _not_ MATCH_ACCEPT */ |
| 1398 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | { |
| 1399 | mstart = md->start_match_ptr; | |
| 1400 | break; | |
| 1401 | } | |
| 1402 | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); | |
| 1403 | ecode += GET(ecode,1); | ecode += GET(ecode,1); |
| 1404 | } | } |
| 1405 | while (*ecode == OP_ALT); | while (*ecode == OP_ALT); |
| # | Line 1110 for (;;) | Line 1465 for (;;) |
| 1465 | do ecode += GET(ecode,1); while (*ecode == OP_ALT); | do ecode += GET(ecode,1); while (*ecode == OP_ALT); |
| 1466 | break; | break; |
| 1467 | ||
| 1468 | /* BRAZERO and BRAMINZERO occur just before a bracket group, indicating | /* BRAZERO, BRAMINZERO and SKIPZERO occur just before a bracket group, |
| 1469 | 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 |
| 1470 | 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 |
| 1471 | 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 |
| 1472 | preceded by BRAZERO or BRAMINZERO. */ | optional ones preceded by BRAZERO or BRAMINZERO. */ |
| 1473 | ||
| 1474 | case OP_BRAZERO: | case OP_BRAZERO: |
| 1475 | { | { |
| # | Line 1136 for (;;) | Line 1491 for (;;) |
| 1491 | } | } |
| 1492 | break; | break; |
| 1493 | ||
| 1494 | case OP_SKIPZERO: | |
| 1495 | { | |
| 1496 | next = ecode+1; | |
| 1497 | do next += GET(next,1); while (*next == OP_ALT); | |
| 1498 | ecode = next + 1 + LINK_SIZE; | |
| 1499 | } | |
| 1500 | break; | |
| 1501 | ||
| 1502 | /* End of a group, repeated or non-repeating. */ | /* End of a group, repeated or non-repeating. */ |
| 1503 | ||
| 1504 | case OP_KET: | case OP_KET: |
| # | Line 1154 for (;;) | Line 1517 for (;;) |
| 1517 | } | } |
| 1518 | else saved_eptr = NULL; | else saved_eptr = NULL; |
| 1519 | ||
| 1520 | /* If we are at the end of an assertion group, stop matching and return | /* If we are at the end of an assertion group or an atomic group, stop |
| 1521 | MATCH_MATCH, but record the current high water mark for use by positive | matching and return MATCH_MATCH, but record the current high water mark for |
| 1522 | assertions. Do this also for the "once" (atomic) groups. */ | use by positive assertions. We also need to record the match start in case |
| 1523 | it was changed by \K. */ | |
| 1524 | ||
| 1525 | if (*prev == OP_ASSERT || *prev == OP_ASSERT_NOT || | if (*prev == OP_ASSERT || *prev == OP_ASSERT_NOT || |
| 1526 | *prev == OP_ASSERTBACK || *prev == OP_ASSERTBACK_NOT || | *prev == OP_ASSERTBACK || *prev == OP_ASSERTBACK_NOT || |
| # | Line 1164 for (;;) | Line 1528 for (;;) |
| 1528 | { | { |
| 1529 | md->end_match_ptr = eptr; /* For ONCE */ | md->end_match_ptr = eptr; /* For ONCE */ |
| 1530 | md->end_offset_top = offset_top; | md->end_offset_top = offset_top; |
| 1531 | RRETURN(MATCH_MATCH); | md->start_match_ptr = mstart; |
| 1532 | MRRETURN(MATCH_MATCH); | |
| 1533 | } | } |
| 1534 | ||
| 1535 | /* For capturing groups we have to check the group number back at the start | /* For capturing groups we have to check the group number back at the start |
| # | Line 1178 for (;;) | Line 1543 for (;;) |
| 1543 | number = GET2(prev, 1+LINK_SIZE); | number = GET2(prev, 1+LINK_SIZE); |
| 1544 | offset = number << 1; | offset = number << 1; |
| 1545 | ||
| 1546 | #ifdef DEBUG | #ifdef PCRE_DEBUG |
| 1547 | printf("end bracket %d", number); | printf("end bracket %d", number); |
| 1548 | printf("\n"); | printf("\n"); |
| 1549 | #endif | #endif |
| # | Line 1200 for (;;) | Line 1565 for (;;) |
| 1565 | recursion_info *rec = md->recursive; | recursion_info *rec = md->recursive; |
| 1566 | DPRINTF(("Recursion (%d) succeeded - continuing\n", number)); | DPRINTF(("Recursion (%d) succeeded - continuing\n", number)); |
| 1567 | md->recursive = rec->prevrec; | md->recursive = rec->prevrec; |
| mstart = rec->save_start; | ||
| 1568 | memcpy(md->offset_vector, rec->offset_save, | memcpy(md->offset_vector, rec->offset_save, |
| 1569 | rec->saved_max * sizeof(int)); | rec->saved_max * sizeof(int)); |
| 1570 | offset_top = rec->save_offset_top; | |
| 1571 | ecode = rec->after_call; | ecode = rec->after_call; |
| 1572 | ims = original_ims; | ims = original_ims; |
| 1573 | break; | break; |
| # | Line 1259 for (;;) | Line 1624 for (;;) |
| 1624 | /* Start of subject unless notbol, or after internal newline if multiline */ | /* Start of subject unless notbol, or after internal newline if multiline */ |
| 1625 | ||
| 1626 | case OP_CIRC: | case OP_CIRC: |
| 1627 | if (md->notbol && eptr == md->start_subject) RRETURN(MATCH_NOMATCH); | if (md->notbol && eptr == md->start_subject) MRRETURN(MATCH_NOMATCH); |
| 1628 | if ((ims & PCRE_MULTILINE) != 0) | if ((ims & PCRE_MULTILINE) != 0) |
| 1629 | { | { |
| 1630 | if (eptr != md->start_subject && | if (eptr != md->start_subject && |
| 1631 | (eptr == md->end_subject || !WAS_NEWLINE(eptr))) | (eptr == md->end_subject || !WAS_NEWLINE(eptr))) |
| 1632 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1633 | ecode++; | ecode++; |
| 1634 | break; | break; |
| 1635 | } | } |
| # | Line 1273 for (;;) | Line 1638 for (;;) |
| 1638 | /* Start of subject assertion */ | /* Start of subject assertion */ |
| 1639 | ||
| 1640 | case OP_SOD: | case OP_SOD: |
| 1641 | if (eptr != md->start_subject) RRETURN(MATCH_NOMATCH); | if (eptr != md->start_subject) MRRETURN(MATCH_NOMATCH); |
| 1642 | ecode++; | ecode++; |
| 1643 | break; | break; |
| 1644 | ||
| 1645 | /* Start of match assertion */ | /* Start of match assertion */ |
| 1646 | ||
| 1647 | case OP_SOM: | case OP_SOM: |
| 1648 | if (eptr != md->start_subject + md->start_offset) RRETURN(MATCH_NOMATCH); | if (eptr != md->start_subject + md->start_offset) MRRETURN(MATCH_NOMATCH); |
| 1649 | ecode++; | ecode++; |
| 1650 | break; | break; |
| 1651 | ||
| # | Line 1298 for (;;) | Line 1663 for (;;) |
| 1663 | if ((ims & PCRE_MULTILINE) != 0) | if ((ims & PCRE_MULTILINE) != 0) |
| 1664 | { | { |
| 1665 | if (eptr < md->end_subject) | if (eptr < md->end_subject) |
| 1666 | { if (!IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); } | { if (!IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH); } |
| 1667 | else | else |
| 1668 | { if (md->noteol) RRETURN(MATCH_NOMATCH); } | { if (md->noteol) MRRETURN(MATCH_NOMATCH); } |
| 1669 | ecode++; | ecode++; |
| 1670 | break; | break; |
| 1671 | } | } |
| 1672 | else | else |
| 1673 | { | { |
| 1674 | if (md->noteol) RRETURN(MATCH_NOMATCH); | if (md->noteol) MRRETURN(MATCH_NOMATCH); |
| 1675 | if (!md->endonly) | if (!md->endonly) |
| 1676 | { | { |
| 1677 | if (eptr != md->end_subject && | if (eptr != md->end_subject && |
| 1678 | (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen)) | (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen)) |
| 1679 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1680 | ecode++; | ecode++; |
| 1681 | break; | break; |
| 1682 | } | } |
| # | Line 1321 for (;;) | Line 1686 for (;;) |
| 1686 | /* End of subject assertion (\z) */ | /* End of subject assertion (\z) */ |
| 1687 | ||
| 1688 | case OP_EOD: | case OP_EOD: |
| 1689 | if (eptr < md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr < md->end_subject) MRRETURN(MATCH_NOMATCH); |
| 1690 | ecode++; | ecode++; |
| 1691 | break; | break; |
| 1692 | ||
| # | Line 1330 for (;;) | Line 1695 for (;;) |
| 1695 | case OP_EODN: | case OP_EODN: |
| 1696 | if (eptr != md->end_subject && | if (eptr != md->end_subject && |
| 1697 | (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen)) | (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen)) |
| 1698 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1699 | ecode++; | ecode++; |
| 1700 | break; | break; |
| 1701 | ||
| # | Line 1342 for (;;) | Line 1707 for (;;) |
| 1707 | ||
| 1708 | /* Find out if the previous and current characters are "word" characters. | /* Find out if the previous and current characters are "word" characters. |
| 1709 | 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 |
| 1710 | be "non-word" characters. */ | be "non-word" characters. Remember the earliest consulted character for |
| 1711 | partial matching. */ | |
| 1712 | ||
| 1713 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| 1714 | if (utf8) | if (utf8) |
| 1715 | { | { |
| 1716 | if (eptr == md->start_subject) prev_is_word = FALSE; else | if (eptr == md->start_subject) prev_is_word = FALSE; else |
| 1717 | { | { |
| 1718 | const uschar *lastptr = eptr - 1; | USPTR lastptr = eptr - 1; |
| 1719 | while((*lastptr & 0xc0) == 0x80) lastptr--; | while((*lastptr & 0xc0) == 0x80) lastptr--; |
| 1720 | if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr; | |
| 1721 | GETCHAR(c, lastptr); | GETCHAR(c, lastptr); |
| 1722 | prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; | prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; |
| 1723 | } | } |
| 1724 | if (eptr >= md->end_subject) cur_is_word = FALSE; else | if (eptr >= md->end_subject) |
| 1725 | { | |
| 1726 | SCHECK_PARTIAL(); | |
| 1727 | cur_is_word = FALSE; | |
| 1728 | } | |
| 1729 | else | |
| 1730 | { | { |
| 1731 | GETCHAR(c, eptr); | GETCHAR(c, eptr); |
| 1732 | cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; | cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; |
| # | Line 1363 for (;;) | Line 1735 for (;;) |
| 1735 | else | else |
| 1736 | #endif | #endif |
| 1737 | ||
| 1738 | /* More streamlined when not in UTF-8 mode */ | /* Not in UTF-8 mode */ |
| 1739 | ||
| 1740 | { | { |
| 1741 | prev_is_word = (eptr != md->start_subject) && | if (eptr == md->start_subject) prev_is_word = FALSE; else |
| 1742 | ((md->ctypes[eptr[-1]] & ctype_word) != 0); | { |
| 1743 | cur_is_word = (eptr < md->end_subject) && | if (eptr <= md->start_used_ptr) md->start_used_ptr = eptr - 1; |
| 1744 | ((md->ctypes[*eptr] & ctype_word) != 0); | prev_is_word = ((md->ctypes[eptr[-1]] & ctype_word) != 0); |
| 1745 | } | |
| 1746 | if (eptr >= md->end_subject) | |
| 1747 | { | |
| 1748 | SCHECK_PARTIAL(); | |
| 1749 | cur_is_word = FALSE; | |
| 1750 | } | |
| 1751 | else cur_is_word = ((md->ctypes[*eptr] & ctype_word) != 0); | |
| 1752 | } | } |
| 1753 | ||
| 1754 | /* Now see if the situation is what we want */ | /* Now see if the situation is what we want */ |
| 1755 | ||
| 1756 | if ((*ecode++ == OP_WORD_BOUNDARY)? | if ((*ecode++ == OP_WORD_BOUNDARY)? |
| 1757 | cur_is_word == prev_is_word : cur_is_word != prev_is_word) | cur_is_word == prev_is_word : cur_is_word != prev_is_word) |
| 1758 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1759 | } | } |
| 1760 | break; | break; |
| 1761 | ||
| 1762 | /* Match a single character type; inline for speed */ | /* Match a single character type; inline for speed */ |
| 1763 | ||
| 1764 | case OP_ANY: | case OP_ANY: |
| 1765 | if ((ims & PCRE_DOTALL) == 0) | if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH); |
| 1766 | /* Fall through */ | |
| 1767 | ||
| 1768 | case OP_ALLANY: | |
| 1769 | if (eptr++ >= md->end_subject) | |
| 1770 | { | { |
| 1771 | if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); | SCHECK_PARTIAL(); |
| 1772 | MRRETURN(MATCH_NOMATCH); | |
| 1773 | } | } |
| 1774 | 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++; | ||
| 1775 | ecode++; | ecode++; |
| 1776 | break; | break; |
| 1777 | ||
| # | Line 1397 for (;;) | Line 1779 for (;;) |
| 1779 | any byte, even newline, independent of the setting of PCRE_DOTALL. */ | any byte, even newline, independent of the setting of PCRE_DOTALL. */ |
| 1780 | ||
| 1781 | case OP_ANYBYTE: | case OP_ANYBYTE: |
| 1782 | if (eptr++ >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr++ >= md->end_subject) |
| 1783 | { | |
| 1784 | SCHECK_PARTIAL(); | |
| 1785 | MRRETURN(MATCH_NOMATCH); | |
| 1786 | } | |
| 1787 | ecode++; | ecode++; |
| 1788 | break; | break; |
| 1789 | ||
| 1790 | case OP_NOT_DIGIT: | case OP_NOT_DIGIT: |
| 1791 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1792 | { | |
| 1793 | SCHECK_PARTIAL(); | |
| 1794 | MRRETURN(MATCH_NOMATCH); | |
| 1795 | } | |
| 1796 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1797 | if ( | if ( |
| 1798 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| # | Line 1410 for (;;) | Line 1800 for (;;) |
| 1800 | #endif | #endif |
| 1801 | (md->ctypes[c] & ctype_digit) != 0 | (md->ctypes[c] & ctype_digit) != 0 |
| 1802 | ) | ) |
| 1803 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1804 | ecode++; | ecode++; |
| 1805 | break; | break; |
| 1806 | ||
| 1807 | case OP_DIGIT: | case OP_DIGIT: |
| 1808 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1809 | { | |
| 1810 | SCHECK_PARTIAL(); | |
| 1811 | MRRETURN(MATCH_NOMATCH); | |
| 1812 | } | |
| 1813 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1814 | if ( | if ( |
| 1815 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| # | Line 1423 for (;;) | Line 1817 for (;;) |
| 1817 | #endif | #endif |
| 1818 | (md->ctypes[c] & ctype_digit) == 0 | (md->ctypes[c] & ctype_digit) == 0 |
| 1819 | ) | ) |
| 1820 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1821 | ecode++; | ecode++; |
| 1822 | break; | break; |
| 1823 | ||
| 1824 | case OP_NOT_WHITESPACE: | case OP_NOT_WHITESPACE: |
| 1825 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1826 | { | |
| 1827 | SCHECK_PARTIAL(); | |
| 1828 | MRRETURN(MATCH_NOMATCH); | |
| 1829 | } | |
| 1830 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1831 | if ( | if ( |
| 1832 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| # | Line 1436 for (;;) | Line 1834 for (;;) |
| 1834 | #endif | #endif |
| 1835 | (md->ctypes[c] & ctype_space) != 0 | (md->ctypes[c] & ctype_space) != 0 |
| 1836 | ) | ) |
| 1837 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1838 | ecode++; | ecode++; |
| 1839 | break; | break; |
| 1840 | ||
| 1841 | case OP_WHITESPACE: | case OP_WHITESPACE: |
| 1842 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1843 | { | |
| 1844 | SCHECK_PARTIAL(); | |
| 1845 | MRRETURN(MATCH_NOMATCH); | |
| 1846 | } | |
| 1847 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1848 | if ( | if ( |
| 1849 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| # | Line 1449 for (;;) | Line 1851 for (;;) |
| 1851 | #endif | #endif |
| 1852 | (md->ctypes[c] & ctype_space) == 0 | (md->ctypes[c] & ctype_space) == 0 |
| 1853 | ) | ) |
| 1854 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1855 | ecode++; | ecode++; |
| 1856 | break; | break; |
| 1857 | ||
| 1858 | case OP_NOT_WORDCHAR: | case OP_NOT_WORDCHAR: |
| 1859 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1860 | { | |
| 1861 | SCHECK_PARTIAL(); | |
| 1862 | MRRETURN(MATCH_NOMATCH); | |
| 1863 | } | |
| 1864 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1865 | if ( | if ( |
| 1866 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| # | Line 1462 for (;;) | Line 1868 for (;;) |
| 1868 | #endif | #endif |
| 1869 | (md->ctypes[c] & ctype_word) != 0 | (md->ctypes[c] & ctype_word) != 0 |
| 1870 | ) | ) |
| 1871 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1872 | ecode++; | ecode++; |
| 1873 | break; | break; |
| 1874 | ||
| 1875 | case OP_WORDCHAR: | case OP_WORDCHAR: |
| 1876 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1877 | { | |
| 1878 | SCHECK_PARTIAL(); | |
| 1879 | MRRETURN(MATCH_NOMATCH); | |
| 1880 | } | |
| 1881 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1882 | if ( | if ( |
| 1883 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| # | Line 1475 for (;;) | Line 1885 for (;;) |
| 1885 | #endif | #endif |
| 1886 | (md->ctypes[c] & ctype_word) == 0 | (md->ctypes[c] & ctype_word) == 0 |
| 1887 | ) | ) |
| 1888 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1889 | ecode++; | ecode++; |
| 1890 | break; | break; |
| 1891 | ||
| 1892 | case OP_ANYNL: | case OP_ANYNL: |
| 1893 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1894 | { | |
| 1895 | SCHECK_PARTIAL(); | |
| 1896 | MRRETURN(MATCH_NOMATCH); | |
| 1897 | } | |
| 1898 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1899 | switch(c) | switch(c) |
| 1900 | { | { |
| 1901 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 1902 | case 0x000d: | case 0x000d: |
| 1903 | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 1904 | break; | break; |
| 1905 | ||
| 1906 | case 0x000a: | case 0x000a: |
| 1907 | break; | |
| 1908 | ||
| 1909 | case 0x000b: | case 0x000b: |
| 1910 | case 0x000c: | case 0x000c: |
| 1911 | case 0x0085: | case 0x0085: |
| 1912 | case 0x2028: | case 0x2028: |
| 1913 | case 0x2029: | case 0x2029: |
| 1914 | if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH); | |
| 1915 | break; | break; |
| 1916 | } | } |
| 1917 | ecode++; | ecode++; |
| 1918 | break; | break; |
| 1919 | ||
| 1920 | case OP_NOT_HSPACE: | case OP_NOT_HSPACE: |
| 1921 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1922 | { | |
| 1923 | SCHECK_PARTIAL(); | |
| 1924 | MRRETURN(MATCH_NOMATCH); | |
| 1925 | } | |
| 1926 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1927 | switch(c) | switch(c) |
| 1928 | { | { |
| # | Line 1524 for (;;) | Line 1946 for (;;) |
| 1946 | case 0x202f: /* NARROW NO-BREAK SPACE */ | case 0x202f: /* NARROW NO-BREAK SPACE */ |
| 1947 | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ |
| 1948 | case 0x3000: /* IDEOGRAPHIC SPACE */ | case 0x3000: /* IDEOGRAPHIC SPACE */ |
| 1949 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1950 | } | } |
| 1951 | ecode++; | ecode++; |
| 1952 | break; | break; |
| 1953 | ||
| 1954 | case OP_HSPACE: | case OP_HSPACE: |
| 1955 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1956 | { | |
| 1957 | SCHECK_PARTIAL(); | |
| 1958 | MRRETURN(MATCH_NOMATCH); | |
| 1959 | } | |
| 1960 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1961 | switch(c) | switch(c) |
| 1962 | { | { |
| 1963 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 1964 | case 0x09: /* HT */ | case 0x09: /* HT */ |
| 1965 | case 0x20: /* SPACE */ | case 0x20: /* SPACE */ |
| 1966 | case 0xa0: /* NBSP */ | case 0xa0: /* NBSP */ |
| # | Line 1560 for (;;) | Line 1986 for (;;) |
| 1986 | break; | break; |
| 1987 | ||
| 1988 | case OP_NOT_VSPACE: | case OP_NOT_VSPACE: |
| 1989 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1990 | { | |
| 1991 | SCHECK_PARTIAL(); | |
| 1992 | MRRETURN(MATCH_NOMATCH); | |
| 1993 | } | |
| 1994 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1995 | switch(c) | switch(c) |
| 1996 | { | { |
| # | Line 1572 for (;;) | Line 2002 for (;;) |
| 2002 | case 0x85: /* NEL */ | case 0x85: /* NEL */ |
| 2003 | case 0x2028: /* LINE SEPARATOR */ | case 0x2028: /* LINE SEPARATOR */ |
| 2004 | case 0x2029: /* PARAGRAPH SEPARATOR */ | case 0x2029: /* PARAGRAPH SEPARATOR */ |
| 2005 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2006 | } | } |
| 2007 | ecode++; | ecode++; |
| 2008 | break; | break; |
| 2009 | ||
| 2010 | case OP_VSPACE: | case OP_VSPACE: |
| 2011 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 2012 | { | |
| 2013 | SCHECK_PARTIAL(); | |
| 2014 | MRRETURN(MATCH_NOMATCH); | |
| 2015 | } | |
| 2016 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2017 | switch(c) | switch(c) |
| 2018 | { | { |
| 2019 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 2020 | case 0x0a: /* LF */ | case 0x0a: /* LF */ |
| 2021 | case 0x0b: /* VT */ | case 0x0b: /* VT */ |
| 2022 | case 0x0c: /* FF */ | case 0x0c: /* FF */ |
| # | Line 1601 for (;;) | Line 2035 for (;;) |
| 2035 | ||
| 2036 | case OP_PROP: | case OP_PROP: |
| 2037 | case OP_NOTPROP: | case OP_NOTPROP: |
| 2038 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 2039 | { | |
| 2040 | SCHECK_PARTIAL(); | |
| 2041 | MRRETURN(MATCH_NOMATCH); | |
| 2042 | } | |
| 2043 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2044 | { | { |
| 2045 | int chartype, script; | const ucd_record *prop = GET_UCD(c); |
| int category = _pcre_ucp_findprop(c, &chartype, &script); | ||
| 2046 | ||
| 2047 | switch(ecode[1]) | switch(ecode[1]) |
| 2048 | { | { |
| 2049 | case PT_ANY: | case PT_ANY: |
| 2050 | if (op == OP_NOTPROP) RRETURN(MATCH_NOMATCH); | if (op == OP_NOTPROP) MRRETURN(MATCH_NOMATCH); |
| 2051 | break; | break; |
| 2052 | ||
| 2053 | case PT_LAMP: | case PT_LAMP: |
| 2054 | if ((chartype == ucp_Lu || | if ((prop->chartype == ucp_Lu || |
| 2055 | chartype == ucp_Ll || | prop->chartype == ucp_Ll || |
| 2056 | chartype == ucp_Lt) == (op == OP_NOTPROP)) | prop->chartype == ucp_Lt) == (op == OP_NOTPROP)) |
| 2057 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2058 | break; | break; |
| 2059 | ||
| 2060 | case PT_GC: | case PT_GC: |
| 2061 | if ((ecode[2] != category) == (op == OP_PROP)) | if ((ecode[2] != _pcre_ucp_gentype[prop->chartype]) == (op == OP_PROP)) |
| 2062 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2063 | break; | break; |
| 2064 | ||
| 2065 | case PT_PC: | case PT_PC: |
| 2066 | if ((ecode[2] != chartype) == (op == OP_PROP)) | if ((ecode[2] != prop->chartype) == (op == OP_PROP)) |
| 2067 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2068 | break; | break; |
| 2069 | ||
| 2070 | case PT_SC: | case PT_SC: |
| 2071 | if ((ecode[2] != script) == (op == OP_PROP)) | if ((ecode[2] != prop->script) == (op == OP_PROP)) |
| 2072 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2073 | break; | break; |
| 2074 | ||
| 2075 | default: | default: |
| # | Line 1647 for (;;) | Line 2084 for (;;) |
| 2084 | is in the binary; otherwise a compile-time error occurs. */ | is in the binary; otherwise a compile-time error occurs. */ |
| 2085 | ||
| 2086 | case OP_EXTUNI: | case OP_EXTUNI: |
| 2087 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 2088 | { | |
| 2089 | SCHECK_PARTIAL(); | |
| 2090 | MRRETURN(MATCH_NOMATCH); | |
| 2091 | } | |
| 2092 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2093 | { | { |
| 2094 | int chartype, script; | int category = UCD_CATEGORY(c); |
| 2095 | int category = _pcre_ucp_findprop(c, &chartype, &script); | if (category == ucp_M) MRRETURN(MATCH_NOMATCH); |
| if (category == ucp_M) RRETURN(MATCH_NOMATCH); | ||
| 2096 | while (eptr < md->end_subject) | while (eptr < md->end_subject) |
| 2097 | { | { |
| 2098 | int len = 1; | int len = 1; |
| # | Line 1660 for (;;) | Line 2100 for (;;) |
| 2100 | { | { |
| 2101 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 2102 | } | } |
| 2103 | category = _pcre_ucp_findprop(c, &chartype, &script); | category = UCD_CATEGORY(c); |
| 2104 | if (category != ucp_M) break; | if (category != ucp_M) break; |
| 2105 | eptr += len; | eptr += len; |
| 2106 | } | } |
| # | Line 1681 for (;;) | Line 2121 for (;;) |
| 2121 | case OP_REF: | case OP_REF: |
| 2122 | { | { |
| 2123 | offset = GET2(ecode, 1) << 1; /* Doubled ref number */ | offset = GET2(ecode, 1) << 1; /* Doubled ref number */ |
| 2124 | ecode += 3; /* Advance past item */ | ecode += 3; |
| 2125 | ||
| 2126 | /* If the reference is unset, there are two possibilities: | |
| 2127 | ||
| 2128 | (a) In the default, Perl-compatible state, set the length to be longer | |
| 2129 | than the amount of subject left; this ensures that every attempt at a | |
| 2130 | match fails. We can't just fail here, because of the possibility of | |
| 2131 | quantifiers with zero minima. | |
| 2132 | ||
| 2133 | /* If the reference is unset, set the length to be longer than the amount | (b) If the JavaScript compatibility flag is set, set the length to zero |
| 2134 | of subject left; this ensures that every attempt at a match fails. We | so that the back reference matches an empty string. |
| 2135 | can't just fail here, because of the possibility of quantifiers with zero | |
| 2136 | minima. */ | Otherwise, set the length to the length of what was matched by the |
| 2137 | referenced subpattern. */ | |
| 2138 | length = (offset >= offset_top || md->offset_vector[offset] < 0)? | |
| 2139 | md->end_subject - eptr + 1 : | if (offset >= offset_top || md->offset_vector[offset] < 0) |
| 2140 | md->offset_vector[offset+1] - md->offset_vector[offset]; | length = (md->jscript_compat)? 0 : md->end_subject - eptr + 1; |
| 2141 | else | |
| 2142 | length = md->offset_vector[offset+1] - md->offset_vector[offset]; | |
| 2143 | ||
| 2144 | /* Set up for repetition, or handle the non-repeated case */ | /* Set up for repetition, or handle the non-repeated case */ |
| 2145 | ||
| # | Line 1719 for (;;) | Line 2168 for (;;) |
| 2168 | break; | break; |
| 2169 | ||
| 2170 | default: /* No repeat follows */ | default: /* No repeat follows */ |
| 2171 | if (!match_ref(offset, eptr, length, md, ims)) RRETURN(MATCH_NOMATCH); | if (!match_ref(offset, eptr, length, md, ims)) |
| 2172 | { | |
| 2173 | CHECK_PARTIAL(); | |
| 2174 | MRRETURN(MATCH_NOMATCH); | |
| 2175 | } | |
| 2176 | eptr += length; | eptr += length; |
| 2177 | continue; /* With the main loop */ | continue; /* With the main loop */ |
| 2178 | } | } |
| # | Line 1735 for (;;) | Line 2188 for (;;) |
| 2188 | ||
| 2189 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 2190 | { | { |
| 2191 | if (!match_ref(offset, eptr, length, md, ims)) RRETURN(MATCH_NOMATCH); | if (!match_ref(offset, eptr, length, md, ims)) |
| 2192 | { | |
| 2193 | CHECK_PARTIAL(); | |
| 2194 | MRRETURN(MATCH_NOMATCH); | |
| 2195 | } | |
| 2196 | eptr += length; | eptr += length; |
| 2197 | } | } |
| 2198 | ||
| # | Line 1752 for (;;) | Line 2209 for (;;) |
| 2209 | { | { |
| 2210 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM14); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM14); |
| 2211 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2212 | if (fi >= max || !match_ref(offset, eptr, length, md, ims)) | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 2213 | RRETURN(MATCH_NOMATCH); | if (!match_ref(offset, eptr, length, md, ims)) |
| 2214 | { | |
| 2215 | CHECK_PARTIAL(); | |
| 2216 | MRRETURN(MATCH_NOMATCH); | |
| 2217 | } | |
| 2218 | eptr += length; | eptr += length; |
| 2219 | } | } |
| 2220 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 1766 for (;;) | Line 2227 for (;;) |
| 2227 | pp = eptr; | pp = eptr; |
| 2228 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 2229 | { | { |
| 2230 | if (!match_ref(offset, eptr, length, md, ims)) break; | if (!match_ref(offset, eptr, length, md, ims)) |
| 2231 | { | |
| 2232 | CHECK_PARTIAL(); | |
| 2233 | break; | |
| 2234 | } | |
| 2235 | eptr += length; | eptr += length; |
| 2236 | } | } |
| 2237 | while (eptr >= pp) | while (eptr >= pp) |
| # | Line 1775 for (;;) | Line 2240 for (;;) |
| 2240 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2241 | eptr -= length; | eptr -= length; |
| 2242 | } | } |
| 2243 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2244 | } | } |
| 2245 | } | } |
| 2246 | /* Control never gets here */ | /* Control never gets here */ |
| 2247 | ||
| 2248 | /* Match a bit-mapped character class, possibly repeatedly. This op code is | /* Match a bit-mapped character class, possibly repeatedly. This op code is |
| 2249 | 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, |
| 2250 | 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 1836 for (;;) | Line 2299 for (;;) |
| 2299 | { | { |
| 2300 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 2301 | { | { |
| 2302 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 2303 | { | |
| 2304 | SCHECK_PARTIAL(); | |
| 2305 | MRRETURN(MATCH_NOMATCH); | |
| 2306 | } | |
| 2307 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 2308 | if (c > 255) | if (c > 255) |
| 2309 | { | { |
| 2310 | if (op == OP_CLASS) RRETURN(MATCH_NOMATCH); | if (op == OP_CLASS) MRRETURN(MATCH_NOMATCH); |
| 2311 | } | } |
| 2312 | else | else |
| 2313 | { | { |
| 2314 | if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH); | if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH); |
| 2315 | } | } |
| 2316 | } | } |
| 2317 | } | } |
| # | Line 1854 for (;;) | Line 2321 for (;;) |
| 2321 | { | { |
| 2322 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 2323 | { | { |
| 2324 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 2325 | { | |
| 2326 | SCHECK_PARTIAL(); | |
| 2327 | MRRETURN(MATCH_NOMATCH); | |
| 2328 | } | |
| 2329 | c = *eptr++; | c = *eptr++; |
| 2330 | if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH); | if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH); |
| 2331 | } | } |
| 2332 | } | } |
| 2333 | ||
| # | Line 1878 for (;;) | Line 2349 for (;;) |
| 2349 | { | { |
| 2350 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM16); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM16); |
| 2351 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2352 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 2353 | if (eptr >= md->end_subject) | |
| 2354 | { | |
| 2355 | SCHECK_PARTIAL(); | |
| 2356 | MRRETURN(MATCH_NOMATCH); | |
| 2357 | } | |
| 2358 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 2359 | if (c > 255) | if (c > 255) |
| 2360 | { | { |
| 2361 | if (op == OP_CLASS) RRETURN(MATCH_NOMATCH); | if (op == OP_CLASS) MRRETURN(MATCH_NOMATCH); |
| 2362 | } | } |
| 2363 | else | else |
| 2364 | { | { |
| 2365 | if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH); | if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH); |
| 2366 | } | } |
| 2367 | } | } |
| 2368 | } | } |
| # | Line 1898 for (;;) | Line 2374 for (;;) |
| 2374 | { | { |
| 2375 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM17); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM17); |
| 2376 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2377 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 2378 | if (eptr >= md->end_subject) | |
| 2379 | { | |
| 2380 | SCHECK_PARTIAL(); | |
| 2381 | MRRETURN(MATCH_NOMATCH); | |
| 2382 | } | |
| 2383 | c = *eptr++; | c = *eptr++; |
| 2384 | if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH); | if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH); |
| 2385 | } | } |
| 2386 | } | } |
| 2387 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 1919 for (;;) | Line 2400 for (;;) |
| 2400 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 2401 | { | { |
| 2402 | int len = 1; | int len = 1; |
| 2403 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 2404 | { | |
| 2405 | SCHECK_PARTIAL(); | |
| 2406 | break; | |
| 2407 | } | |
| 2408 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 2409 | if (c > 255) | if (c > 255) |
| 2410 | { | { |
| # | Line 1945 for (;;) | Line 2430 for (;;) |
| 2430 | { | { |
| 2431 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 2432 | { | { |
| 2433 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 2434 | { | |
| 2435 | SCHECK_PARTIAL(); | |
| 2436 | break; | |
| 2437 | } | |
| 2438 | c = *eptr; | c = *eptr; |
| 2439 | if ((data[c/8] & (1 << (c&7))) == 0) break; | if ((data[c/8] & (1 << (c&7))) == 0) break; |
| 2440 | eptr++; | eptr++; |
| # | Line 1958 for (;;) | Line 2447 for (;;) |
| 2447 | } | } |
| 2448 | } | } |
| 2449 | ||
| 2450 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2451 | } | } |
| 2452 | } | } |
| 2453 | /* Control never gets here */ | /* Control never gets here */ |
| 2454 | ||
| 2455 | ||
| 2456 | /* Match an extended character class. This opcode is encountered only | /* Match an extended character class. This opcode is encountered only |
| 2457 | 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 |
| 2458 | mode, because Unicode properties are supported in non-UTF-8 mode. */ | |
| 2459 | ||
| 2460 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| 2461 | case OP_XCLASS: | case OP_XCLASS: |
| # | Line 2006 for (;;) | Line 2496 for (;;) |
| 2496 | ||
| 2497 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 2498 | { | { |
| 2499 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 2500 | GETCHARINC(c, eptr); | { |
| 2501 | if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH); | SCHECK_PARTIAL(); |
| 2502 | MRRETURN(MATCH_NOMATCH); | |
| 2503 | } | |
| 2504 | GETCHARINCTEST(c, eptr); | |
| 2505 | if (!_pcre_xclass(c, data)) MRRETURN(MATCH_NOMATCH); | |
| 2506 | } | } |
| 2507 | ||
| 2508 | /* If max == min we can continue with the main loop without the | /* If max == min we can continue with the main loop without the |
| # | Line 2025 for (;;) | Line 2519 for (;;) |
| 2519 | { | { |
| 2520 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM20); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM20); |
| 2521 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2522 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 2523 | GETCHARINC(c, eptr); | if (eptr >= md->end_subject) |
| 2524 | if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH); | { |
| 2525 | SCHECK_PARTIAL(); | |
| 2526 | MRRETURN(MATCH_NOMATCH); | |
| 2527 | } | |
| 2528 | GETCHARINCTEST(c, eptr); | |
| 2529 | if (!_pcre_xclass(c, data)) MRRETURN(MATCH_NOMATCH); | |
| 2530 | } | } |
| 2531 | /* Control never gets here */ | /* Control never gets here */ |
| 2532 | } | } |
| # | Line 2040 for (;;) | Line 2539 for (;;) |
| 2539 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 2540 | { | { |
| 2541 | int len = 1; | int len = 1; |
| 2542 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 2543 | GETCHARLEN(c, eptr, len); | { |
| 2544 | SCHECK_PARTIAL(); | |
| 2545 | break; | |
| 2546 | } | |
| 2547 | GETCHARLENTEST(c, eptr, len); | |
| 2548 | if (!_pcre_xclass(c, data)) break; | if (!_pcre_xclass(c, data)) break; |
| 2549 | eptr += len; | eptr += len; |
| 2550 | } | } |
| # | Line 2050 for (;;) | Line 2553 for (;;) |
| 2553 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM21); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM21); |
| 2554 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2555 | if (eptr-- == pp) break; /* Stop if tried at original pos */ | if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 2556 | BACKCHAR(eptr); | if (utf8) BACKCHAR(eptr); |
| 2557 | } | } |
| 2558 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2559 | } | } |
| 2560 | ||
| 2561 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 2068 for (;;) | Line 2571 for (;;) |
| 2571 | length = 1; | length = 1; |
| 2572 | ecode++; | ecode++; |
| 2573 | GETCHARLEN(fc, ecode, length); | GETCHARLEN(fc, ecode, length); |
| 2574 | if (length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH); | if (length > md->end_subject - eptr) |
| 2575 | while (length-- > 0) if (*ecode++ != *eptr++) RRETURN(MATCH_NOMATCH); | { |
| 2576 | CHECK_PARTIAL(); /* Not SCHECK_PARTIAL() */ | |
| 2577 | MRRETURN(MATCH_NOMATCH); | |
| 2578 | } | |
| 2579 | while (length-- > 0) if (*ecode++ != *eptr++) MRRETURN(MATCH_NOMATCH); | |
| 2580 | } | } |
| 2581 | else | else |
| 2582 | #endif | #endif |
| 2583 | ||
| 2584 | /* Non-UTF-8 mode */ | /* Non-UTF-8 mode */ |
| 2585 | { | { |
| 2586 | if (md->end_subject - eptr < 1) RRETURN(MATCH_NOMATCH); | if (md->end_subject - eptr < 1) |
| 2587 | if (ecode[1] != *eptr++) RRETURN(MATCH_NOMATCH); | { |
| 2588 | SCHECK_PARTIAL(); /* This one can use SCHECK_PARTIAL() */ | |
| 2589 | MRRETURN(MATCH_NOMATCH); | |
| 2590 | } | |
| 2591 | if (ecode[1] != *eptr++) MRRETURN(MATCH_NOMATCH); | |
| 2592 | ecode += 2; | ecode += 2; |
| 2593 | } | } |
| 2594 | break; | break; |
| # | Line 2092 for (;;) | Line 2603 for (;;) |
| 2603 | ecode++; | ecode++; |
| 2604 | GETCHARLEN(fc, ecode, length); | GETCHARLEN(fc, ecode, length); |
| 2605 | ||
| 2606 | if (length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH); | if (length > md->end_subject - eptr) |
| 2607 | { | |
| 2608 | CHECK_PARTIAL(); /* Not SCHECK_PARTIAL() */ | |
| 2609 | MRRETURN(MATCH_NOMATCH); | |
| 2610 | } | |
| 2611 | ||
| 2612 | /* 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 |
| 2613 | can use the fast lookup table. */ | can use the fast lookup table. */ |
| 2614 | ||
| 2615 | if (fc < 128) | if (fc < 128) |
| 2616 | { | { |
| 2617 | if (md->lcc[*ecode++] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); | if (md->lcc[*ecode++] != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH); |
| 2618 | } | } |
| 2619 | ||
| 2620 | /* Otherwise we must pick up the subject character */ | /* Otherwise we must pick up the subject character */ |
| # | Line 2116 for (;;) | Line 2631 for (;;) |
| 2631 | if (fc != dc) | if (fc != dc) |
| 2632 | { | { |
| 2633 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 2634 | if (dc != _pcre_ucp_othercase(fc)) | if (dc != UCD_OTHERCASE(fc)) |
| 2635 | #endif | #endif |
| 2636 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2637 | } | } |
| 2638 | } | } |
| 2639 | } | } |
| # | Line 2127 for (;;) | Line 2642 for (;;) |
| 2642 | ||
| 2643 | /* Non-UTF-8 mode */ | /* Non-UTF-8 mode */ |
| 2644 | { | { |
| 2645 | if (md->end_subject - eptr < 1) RRETURN(MATCH_NOMATCH); | if (md->end_subject - eptr < 1) |
| 2646 | if (md->lcc[ecode[1]] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); | { |
| 2647 | SCHECK_PARTIAL(); /* This one can use SCHECK_PARTIAL() */ | |
| 2648 | MRRETURN(MATCH_NOMATCH); | |
| 2649 | } | |
| 2650 | if (md->lcc[ecode[1]] != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH); | |
| 2651 | ecode += 2; | ecode += 2; |
| 2652 | } | } |
| 2653 | break; | break; |
| # | Line 2181 for (;;) | Line 2700 for (;;) |
| 2700 | case OP_MINQUERY: | case OP_MINQUERY: |
| 2701 | c = *ecode++ - OP_STAR; | c = *ecode++ - OP_STAR; |
| 2702 | minimize = (c & 1) != 0; | minimize = (c & 1) != 0; |
| 2703 | ||
| 2704 | min = rep_min[c]; /* Pick up values from tables; */ | min = rep_min[c]; /* Pick up values from tables; */ |
| 2705 | max = rep_max[c]; /* zero for max => infinity */ | max = rep_max[c]; /* zero for max => infinity */ |
| 2706 | if (max == 0) max = INT_MAX; | if (max == 0) max = INT_MAX; |
| 2707 | ||
| 2708 | /* 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. */ | ||
| 2709 | ||
| 2710 | REPEATCHAR: | REPEATCHAR: |
| 2711 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| # | Line 2196 for (;;) | Line 2714 for (;;) |
| 2714 | length = 1; | length = 1; |
| 2715 | charptr = ecode; | charptr = ecode; |
| 2716 | GETCHARLEN(fc, ecode, length); | GETCHARLEN(fc, ecode, length); |
| if (min * length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH); | ||
| 2717 | ecode += length; | ecode += length; |
| 2718 | ||
| 2719 | /* Handle multibyte character matching specially here. There is | /* Handle multibyte character matching specially here. There is |
| # | Line 2207 for (;;) | Line 2724 for (;;) |
| 2724 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 2725 | unsigned int othercase; | unsigned int othercase; |
| 2726 | if ((ims & PCRE_CASELESS) != 0 && | if ((ims & PCRE_CASELESS) != 0 && |
| 2727 | (othercase = _pcre_ucp_othercase(fc)) != NOTACHAR) | (othercase = UCD_OTHERCASE(fc)) != fc) |
| 2728 | oclength = _pcre_ord2utf8(othercase, occhars); | oclength = _pcre_ord2utf8(othercase, occhars); |
| 2729 | else oclength = 0; | else oclength = 0; |
| 2730 | #endif /* SUPPORT_UCP */ | #endif /* SUPPORT_UCP */ |
| 2731 | ||
| 2732 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 2733 | { | { |
| 2734 | if (memcmp(eptr, charptr, length) == 0) eptr += length; | if (eptr <= md->end_subject - length && |
| 2735 | memcmp(eptr, charptr, length) == 0) eptr += length; | |
| 2736 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 2737 | /* Need braces because of following else */ | else if (oclength > 0 && |
| 2738 | else if (oclength == 0) { RRETURN(MATCH_NOMATCH); } | eptr <= md->end_subject - oclength && |
| 2739 | memcmp(eptr, occhars, oclength) == 0) eptr += oclength; | |
| 2740 | #endif /* SUPPORT_UCP */ | |
| 2741 | else | else |
| 2742 | { | { |
| 2743 | if (memcmp(eptr, occhars, oclength) != 0) RRETURN(MATCH_NOMATCH); | CHECK_PARTIAL(); |
| 2744 | eptr += oclength; | MRRETURN(MATCH_NOMATCH); |
| 2745 | } | } |
| #else /* without SUPPORT_UCP */ | ||
| else { RRETURN(MATCH_NOMATCH); } | ||
| #endif /* SUPPORT_UCP */ | ||
| 2746 | } | } |
| 2747 | ||
| 2748 | if (min == max) continue; | if (min == max) continue; |
| # | Line 2236 for (;;) | Line 2753 for (;;) |
| 2753 | { | { |
| 2754 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM22); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM22); |
| 2755 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2756 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 2757 | if (memcmp(eptr, charptr, length) == 0) eptr += length; | if (eptr <= md->end_subject - length && |
| 2758 | memcmp(eptr, charptr, length) == 0) eptr += length; | |
| 2759 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 2760 | /* Need braces because of following else */ | else if (oclength > 0 && |
| 2761 | else if (oclength == 0) { RRETURN(MATCH_NOMATCH); } | eptr <= md->end_subject - oclength && |
| 2762 | memcmp(eptr, occhars, oclength) == 0) eptr += oclength; | |
| 2763 | #endif /* SUPPORT_UCP */ | |
| 2764 | else | else |
| 2765 | { | { |
| 2766 | if (memcmp(eptr, occhars, oclength) != 0) RRETURN(MATCH_NOMATCH); | CHECK_PARTIAL(); |
| 2767 | eptr += oclength; | MRRETURN(MATCH_NOMATCH); |
| 2768 | } | } |
| #else /* without SUPPORT_UCP */ | ||
| else { RRETURN (MATCH_NOMATCH); } | ||
| #endif /* SUPPORT_UCP */ | ||
| 2769 | } | } |
| 2770 | /* Control never gets here */ | /* Control never gets here */ |
| 2771 | } | } |
| # | Line 2258 for (;;) | Line 2775 for (;;) |
| 2775 | pp = eptr; | pp = eptr; |
| 2776 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 2777 | { | { |
| 2778 | if (eptr > md->end_subject - length) break; | if (eptr <= md->end_subject - length && |
| 2779 | if (memcmp(eptr, charptr, length) == 0) eptr += length; | memcmp(eptr, charptr, length) == 0) eptr += length; |
| 2780 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 2781 | else if (oclength == 0) break; | else if (oclength > 0 && |
| 2782 | eptr <= md->end_subject - oclength && | |
| 2783 | memcmp(eptr, occhars, oclength) == 0) eptr += oclength; | |
| 2784 | #endif /* SUPPORT_UCP */ | |
| 2785 | else | else |
| 2786 | { | { |
| 2787 | if (memcmp(eptr, occhars, oclength) != 0) break; | CHECK_PARTIAL(); |
| 2788 | eptr += oclength; | break; |
| 2789 | } | } |
| #else /* without SUPPORT_UCP */ | ||
| else break; | ||
| #endif /* SUPPORT_UCP */ | ||
| 2790 | } | } |
| 2791 | ||
| 2792 | if (possessive) continue; | if (possessive) continue; |
| 2793 | ||
| 2794 | for(;;) | for(;;) |
| 2795 | { | { |
| 2796 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM23); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM23); |
| 2797 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2798 | if (eptr == pp) RRETURN(MATCH_NOMATCH); | if (eptr == pp) { MRRETURN(MATCH_NOMATCH); } |
| 2799 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 2800 | eptr--; | eptr--; |
| 2801 | BACKCHAR(eptr); | BACKCHAR(eptr); |
| 2802 | #else /* without SUPPORT_UCP */ | #else /* without SUPPORT_UCP */ |
| 2803 | eptr -= length; | eptr -= length; |
| 2804 | #endif /* SUPPORT_UCP */ | #endif /* SUPPORT_UCP */ |
| 2805 | } | } |
| 2806 | } | } |
| 2807 | /* Control never gets here */ | /* Control never gets here */ |
| 2808 | } | } |
| # | Line 2297 for (;;) | Line 2815 for (;;) |
| 2815 | #endif /* SUPPORT_UTF8 */ | #endif /* SUPPORT_UTF8 */ |
| 2816 | ||
| 2817 | /* When not in UTF-8 mode, load a single-byte character. */ | /* When not in UTF-8 mode, load a single-byte character. */ |
| 2818 | { | |
| 2819 | if (min > md->end_subject - eptr) RRETURN(MATCH_NOMATCH); | fc = *ecode++; |
| fc = *ecode++; | ||
| } | ||
| 2820 | ||
| 2821 | /* 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 |
| 2822 | 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 2318 for (;;) | Line 2834 for (;;) |
| 2834 | { | { |
| 2835 | fc = md->lcc[fc]; | fc = md->lcc[fc]; |
| 2836 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 2837 | if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); | { |
| 2838 | if (eptr >= md->end_subject) | |
| 2839 | { | |
| 2840 | SCHECK_PARTIAL(); | |
| 2841 | MRRETURN(MATCH_NOMATCH); | |
| 2842 | } | |
| 2843 | if (fc != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH); | |
| 2844 | } | |
| 2845 | if (min == max) continue; | if (min == max) continue; |
| 2846 | if (minimize) | if (minimize) |
| 2847 | { | { |
| # | Line 2326 for (;;) | Line 2849 for (;;) |
| 2849 | { | { |
| 2850 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM24); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM24); |
| 2851 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2852 | if (fi >= max || eptr >= md->end_subject || | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 2853 | fc != md->lcc[*eptr++]) | if (eptr >= md->end_subject) |
| 2854 | RRETURN(MATCH_NOMATCH); | { |
| 2855 | SCHECK_PARTIAL(); | |
| 2856 | MRRETURN(MATCH_NOMATCH); | |
| 2857 | } | |
| 2858 | if (fc != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH); | |
| 2859 | } | } |
| 2860 | /* Control never gets here */ | /* Control never gets here */ |
| 2861 | } | } |
| # | Line 2337 for (;;) | Line 2864 for (;;) |
| 2864 | pp = eptr; | pp = eptr; |
| 2865 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 2866 | { | { |
| 2867 | if (eptr >= md->end_subject || fc != md->lcc[*eptr]) break; | if (eptr >= md->end_subject) |
| 2868 | { | |
| 2869 | SCHECK_PARTIAL(); | |
| 2870 | break; | |
| 2871 | } | |
| 2872 | if (fc != md->lcc[*eptr]) break; | |
| 2873 | eptr++; | eptr++; |
| 2874 | } | } |
| 2875 | ||
| 2876 | if (possessive) continue; | if (possessive) continue; |
| 2877 | ||
| 2878 | while (eptr >= pp) | while (eptr >= pp) |
| 2879 | { | { |
| 2880 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM25); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM25); |
| 2881 | eptr--; | eptr--; |
| 2882 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2883 | } | } |
| 2884 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2885 | } | } |
| 2886 | /* Control never gets here */ | /* Control never gets here */ |
| 2887 | } | } |
| # | Line 2356 for (;;) | Line 2890 for (;;) |
| 2890 | ||
| 2891 | else | else |
| 2892 | { | { |
| 2893 | for (i = 1; i <= min; i++) if (fc != *eptr++) RRETURN(MATCH_NOMATCH); | for (i = 1; i <= min; i++) |
| 2894 | { | |
| 2895 | if (eptr >= md->end_subject) | |
| 2896 | { | |
| 2897 | SCHECK_PARTIAL(); | |
| 2898 | MRRETURN(MATCH_NOMATCH); | |
| 2899 | } | |
| 2900 | if (fc != *eptr++) MRRETURN(MATCH_NOMATCH); | |
| 2901 | } | |
| 2902 | ||
| 2903 | if (min == max) continue; | if (min == max) continue; |
| 2904 | ||
| 2905 | if (minimize) | if (minimize) |
| 2906 | { | { |
| 2907 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 2908 | { | { |
| 2909 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM26); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM26); |
| 2910 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2911 | if (fi >= max || eptr >= md->end_subject || fc != *eptr++) | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 2912 | RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 2913 | { | |
| 2914 | SCHECK_PARTIAL(); | |
| 2915 | MRRETURN(MATCH_NOMATCH); | |
| 2916 | } | |
| 2917 | if (fc != *eptr++) MRRETURN(MATCH_NOMATCH); | |
| 2918 | } | } |
| 2919 | /* Control never gets here */ | /* Control never gets here */ |
| 2920 | } | } |
| # | Line 2374 for (;;) | Line 2923 for (;;) |
| 2923 | pp = eptr; | pp = eptr; |
| 2924 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 2925 | { | { |
| 2926 | if (eptr >= md->end_subject || fc != *eptr) break; | if (eptr >= md->end_subject) |
| 2927 | { | |
| 2928 | SCHECK_PARTIAL(); | |
| 2929 | break; | |
| 2930 | } | |
| 2931 | if (fc != *eptr) break; | |
| 2932 | eptr++; | eptr++; |
| 2933 | } | } |
| 2934 | if (possessive) continue; | if (possessive) continue; |
| 2935 | ||
| 2936 | while (eptr >= pp) | while (eptr >= pp) |
| 2937 | { | { |
| 2938 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM27); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM27); |
| 2939 | eptr--; | eptr--; |
| 2940 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2941 | } | } |
| 2942 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2943 | } | } |
| 2944 | } | } |
| 2945 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 2393 for (;;) | Line 2948 for (;;) |
| 2948 | checking can be multibyte. */ | checking can be multibyte. */ |
| 2949 | ||
| 2950 | case OP_NOT: | case OP_NOT: |
| 2951 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 2952 | { | |
| 2953 | SCHECK_PARTIAL(); | |
| 2954 | MRRETURN(MATCH_NOMATCH); | |
| 2955 | } | |
| 2956 | ecode++; | ecode++; |
| 2957 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2958 | if ((ims & PCRE_CASELESS) != 0) | if ((ims & PCRE_CASELESS) != 0) |
| # | Line 2402 for (;;) | Line 2961 for (;;) |
| 2961 | if (c < 256) | if (c < 256) |
| 2962 | #endif | #endif |
| 2963 | c = md->lcc[c]; | c = md->lcc[c]; |
| 2964 | if (md->lcc[*ecode++] == c) RRETURN(MATCH_NOMATCH); | if (md->lcc[*ecode++] == c) MRRETURN(MATCH_NOMATCH); |
| 2965 | } | } |
| 2966 | else | else |
| 2967 | { | { |
| 2968 | if (*ecode++ == c) RRETURN(MATCH_NOMATCH); | if (*ecode++ == c) MRRETURN(MATCH_NOMATCH); |
| 2969 | } | } |
| 2970 | break; | break; |
| 2971 | ||
| # | Line 2470 for (;;) | Line 3029 for (;;) |
| 3029 | max = rep_max[c]; /* zero for max => infinity */ | max = rep_max[c]; /* zero for max => infinity */ |
| 3030 | if (max == 0) max = INT_MAX; | if (max == 0) max = INT_MAX; |
| 3031 | ||
| 3032 | /* 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. */ | ||
| 3033 | ||
| 3034 | REPEATNOTCHAR: | REPEATNOTCHAR: |
| if (min > md->end_subject - eptr) RRETURN(MATCH_NOMATCH); | ||
| 3035 | fc = *ecode++; | fc = *ecode++; |
| 3036 | ||
| 3037 | /* 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 2500 for (;;) | Line 3056 for (;;) |
| 3056 | register unsigned int d; | register unsigned int d; |
| 3057 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3058 | { | { |
| 3059 | if (eptr >= md->end_subject) | |
| 3060 | { | |
| 3061 | SCHECK_PARTIAL(); | |
| 3062 | MRRETURN(MATCH_NOMATCH); | |
| 3063 | } | |
| 3064 | GETCHARINC(d, eptr); | GETCHARINC(d, eptr); |
| 3065 | if (d < 256) d = md->lcc[d]; | if (d < 256) d = md->lcc[d]; |
| 3066 | if (fc == d) RRETURN(MATCH_NOMATCH); | if (fc == d) MRRETURN(MATCH_NOMATCH); |
| 3067 | } | } |
| 3068 | } | } |
| 3069 | else | else |
| # | Line 2511 for (;;) | Line 3072 for (;;) |
| 3072 | /* Not UTF-8 mode */ | /* Not UTF-8 mode */ |
| 3073 | { | { |
| 3074 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3075 | if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); | { |
| 3076 | if (eptr >= md->end_subject) | |
| 3077 | { | |
| 3078 | SCHECK_PARTIAL(); | |
| 3079 | MRRETURN(MATCH_NOMATCH); | |
| 3080 | } | |
| 3081 | if (fc == md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH); | |
| 3082 | } | |
| 3083 | } | } |
| 3084 | ||
| 3085 | if (min == max) continue; | if (min == max) continue; |
| # | Line 2527 for (;;) | Line 3095 for (;;) |
| 3095 | { | { |
| 3096 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM28); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM28); |
| 3097 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3098 | if (fi >= max) MRRETURN(MATCH_NOMATCH); | |
| 3099 | if (eptr >= md->end_subject) | |
| 3100 | { | |
| 3101 | SCHECK_PARTIAL(); | |
| 3102 | MRRETURN(MATCH_NOMATCH); | |
| 3103 | } | |
| 3104 | GETCHARINC(d, eptr); | GETCHARINC(d, eptr); |
| 3105 | if (d < 256) d = md->lcc[d]; | if (d < 256) d = md->lcc[d]; |
| 3106 | if (fi >= max || eptr >= md->end_subject || fc == d) | if (fc == d) MRRETURN(MATCH_NOMATCH); |
| RRETURN(MATCH_NOMATCH); | ||
| 3107 | } | } |
| 3108 | } | } |
| 3109 | else | else |
| # | Line 2541 for (;;) | Line 3114 for (;;) |
| 3114 | { | { |
| 3115 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM29); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM29); |
| 3116 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3117 | if (fi >= max || eptr >= md->end_subject || fc == md->lcc[*eptr++]) | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 3118 | RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3119 | { | |
| 3120 | SCHECK_PARTIAL(); | |
| 3121 | MRRETURN(MATCH_NOMATCH); | |
| 3122 | } | |
| 3123 | if (fc == md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH); | |
| 3124 | } | } |
| 3125 | } | } |
| 3126 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 2562 for (;;) | Line 3140 for (;;) |
| 3140 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 3141 | { | { |
| 3142 | int len = 1; | int len = 1; |
| 3143 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 3144 | { | |
| 3145 | SCHECK_PARTIAL(); | |
| 3146 | break; | |
| 3147 | } | |
| 3148 | GETCHARLEN(d, eptr, len); | GETCHARLEN(d, eptr, len); |
| 3149 | if (d < 256) d = md->lcc[d]; | if (d < 256) d = md->lcc[d]; |
| 3150 | if (fc == d) break; | if (fc == d) break; |
| # | Line 2583 for (;;) | Line 3165 for (;;) |
| 3165 | { | { |
| 3166 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 3167 | { | { |
| 3168 | if (eptr >= md->end_subject || fc == md->lcc[*eptr]) break; | if (eptr >= md->end_subject) |
| 3169 | { | |
| 3170 | SCHECK_PARTIAL(); | |
| 3171 | break; | |
| 3172 | } | |
| 3173 | if (fc == md->lcc[*eptr]) break; | |
| 3174 | eptr++; | eptr++; |
| 3175 | } | } |
| 3176 | if (possessive) continue; | if (possessive) continue; |
| # | Line 2595 for (;;) | Line 3182 for (;;) |
| 3182 | } | } |
| 3183 | } | } |
| 3184 | ||
| 3185 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3186 | } | } |
| 3187 | /* Control never gets here */ | /* Control never gets here */ |
| 3188 | } | } |
| # | Line 2611 for (;;) | Line 3198 for (;;) |
| 3198 | register unsigned int d; | register unsigned int d; |
| 3199 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3200 | { | { |
| 3201 | if (eptr >= md->end_subject) | |
| 3202 | { | |
| 3203 | SCHECK_PARTIAL(); | |
| 3204 | MRRETURN(MATCH_NOMATCH); | |
| 3205 | } | |
| 3206 | GETCHARINC(d, eptr); | GETCHARINC(d, eptr); |
| 3207 | if (fc == d) RRETURN(MATCH_NOMATCH); | if (fc == d) MRRETURN(MATCH_NOMATCH); |
| 3208 | } | } |
| 3209 | } | } |
| 3210 | else | else |
| # | Line 2620 for (;;) | Line 3212 for (;;) |
| 3212 | /* Not UTF-8 mode */ | /* Not UTF-8 mode */ |
| 3213 | { | { |
| 3214 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3215 | if (fc == *eptr++) RRETURN(MATCH_NOMATCH); | { |
| 3216 | if (eptr >= md->end_subject) | |
| 3217 | { | |
| 3218 | SCHECK_PARTIAL(); | |
| 3219 | MRRETURN(MATCH_NOMATCH); | |
| 3220 | } | |
| 3221 | if (fc == *eptr++) MRRETURN(MATCH_NOMATCH); | |
| 3222 | } | |
| 3223 | } | } |
| 3224 | ||
| 3225 | if (min == max) continue; | if (min == max) continue; |
| # | Line 2636 for (;;) | Line 3235 for (;;) |
| 3235 | { | { |
| 3236 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM32); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM32); |
| 3237 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3238 | if (fi >= max) MRRETURN(MATCH_NOMATCH); | |
| 3239 | if (eptr >= md->end_subject) | |
| 3240 | { | |
| 3241 | SCHECK_PARTIAL(); | |
| 3242 | MRRETURN(MATCH_NOMATCH); | |
| 3243 | } | |
| 3244 | GETCHARINC(d, eptr); | GETCHARINC(d, eptr); |
| 3245 | if (fi >= max || eptr >= md->end_subject || fc == d) | if (fc == d) MRRETURN(MATCH_NOMATCH); |
| RRETURN(MATCH_NOMATCH); | ||
| 3246 | } | } |
| 3247 | } | } |
| 3248 | else | else |
| # | Line 2649 for (;;) | Line 3253 for (;;) |
| 3253 | { | { |
| 3254 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM33); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM33); |
| 3255 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3256 | if (fi >= max || eptr >= md->end_subject || fc == *eptr++) | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 3257 | RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3258 | { | |
| 3259 | SCHECK_PARTIAL(); | |
| 3260 | MRRETURN(MATCH_NOMATCH); | |
| 3261 | } | |
| 3262 | if (fc == *eptr++) MRRETURN(MATCH_NOMATCH); | |
| 3263 | } | } |
| 3264 | } | } |
| 3265 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 2670 for (;;) | Line 3279 for (;;) |
| 3279 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 3280 | { | { |
| 3281 | int len = 1; | int len = 1; |
| 3282 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 3283 | { | |
| 3284 | SCHECK_PARTIAL(); | |
| 3285 | break; | |
| 3286 | } | |
| 3287 | GETCHARLEN(d, eptr, len); | GETCHARLEN(d, eptr, len); |
| 3288 | if (fc == d) break; | if (fc == d) break; |
| 3289 | eptr += len; | eptr += len; |
| # | Line 2690 for (;;) | Line 3303 for (;;) |
| 3303 | { | { |
| 3304 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 3305 | { | { |
| 3306 | if (eptr >= md->end_subject || fc == *eptr) break; | if (eptr >= md->end_subject) |
| 3307 | { | |
| 3308 | SCHECK_PARTIAL(); | |
| 3309 | break; | |
| 3310 | } | |
| 3311 | if (fc == *eptr) break; | |
| 3312 | eptr++; | eptr++; |
| 3313 | } | } |
| 3314 | if (possessive) continue; | if (possessive) continue; |
| # | Line 2702 for (;;) | Line 3320 for (;;) |
| 3320 | } | } |
| 3321 | } | } |
| 3322 | ||
| 3323 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3324 | } | } |
| 3325 | } | } |
| 3326 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 2784 for (;;) | Line 3402 for (;;) |
| 3402 | ||
| 3403 | /* First, ensure the minimum number of matches are present. Use inline | /* First, ensure the minimum number of matches are present. Use inline |
| 3404 | 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 |
| 3405 | (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 | ||
| 3406 | 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 |
| 3407 | and single-bytes. */ | and single-bytes. */ |
| 3408 | ||
| if (min > md->end_subject - eptr) RRETURN(MATCH_NOMATCH); | ||
| 3409 | if (min > 0) | if (min > 0) |
| 3410 | { | { |
| 3411 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| # | Line 2799 for (;;) | Line 3414 for (;;) |
| 3414 | switch(prop_type) | switch(prop_type) |
| 3415 | { | { |
| 3416 | case PT_ANY: | case PT_ANY: |
| 3417 | if (prop_fail_result) RRETURN(MATCH_NOMATCH); | if (prop_fail_result) MRRETURN(MATCH_NOMATCH); |
| 3418 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3419 | { | { |
| 3420 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3421 | { | |
| 3422 | SCHECK_PARTIAL(); | |
| 3423 | MRRETURN(MATCH_NOMATCH); | |
| 3424 | } | |
| 3425 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3426 | } | } |
| 3427 | break; | break; |
| # | Line 2810 for (;;) | Line 3429 for (;;) |
| 3429 | case PT_LAMP: | case PT_LAMP: |
| 3430 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3431 | { | { |
| 3432 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3433 | { | |
| 3434 | SCHECK_PARTIAL(); | |
| 3435 | MRRETURN(MATCH_NOMATCH); | |
| 3436 | } | |
| 3437 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3438 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_chartype = UCD_CHARTYPE(c); |
| 3439 | if ((prop_chartype == ucp_Lu || | if ((prop_chartype == ucp_Lu || |
| 3440 | prop_chartype == ucp_Ll || | prop_chartype == ucp_Ll || |
| 3441 | prop_chartype == ucp_Lt) == prop_fail_result) | prop_chartype == ucp_Lt) == prop_fail_result) |
| 3442 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3443 | } | } |
| 3444 | break; | break; |
| 3445 | ||
| 3446 | case PT_GC: | case PT_GC: |
| 3447 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3448 | { | { |
| 3449 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3450 | { | |
| 3451 | SCHECK_PARTIAL(); | |
| 3452 | MRRETURN(MATCH_NOMATCH); | |
| 3453 | } | |
| 3454 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3455 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_category = UCD_CATEGORY(c); |
| 3456 | if ((prop_category == prop_value) == prop_fail_result) | if ((prop_category == prop_value) == prop_fail_result) |
| 3457 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3458 | } | } |
| 3459 | break; | break; |
| 3460 | ||
| 3461 | case PT_PC: | case PT_PC: |
| 3462 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3463 | { | { |
| 3464 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3465 | { | |
| 3466 | SCHECK_PARTIAL(); | |
| 3467 | MRRETURN(MATCH_NOMATCH); | |
| 3468 | } | |
| 3469 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3470 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_chartype = UCD_CHARTYPE(c); |
| 3471 | if ((prop_chartype == prop_value) == prop_fail_result) | if ((prop_chartype == prop_value) == prop_fail_result) |
| 3472 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3473 | } | } |
| 3474 | break; | break; |
| 3475 | ||
| 3476 | case PT_SC: | case PT_SC: |
| 3477 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3478 | { | { |
| 3479 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3480 | { | |
| 3481 | SCHECK_PARTIAL(); | |
| 3482 | MRRETURN(MATCH_NOMATCH); | |
| 3483 | } | |
| 3484 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3485 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_script = UCD_SCRIPT(c); |
| 3486 | if ((prop_script == prop_value) == prop_fail_result) | if ((prop_script == prop_value) == prop_fail_result) |
| 3487 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3488 | } | } |
| 3489 | break; | break; |
| 3490 | ||
| # | Line 2865 for (;;) | Line 3500 for (;;) |
| 3500 | { | { |
| 3501 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3502 | { | { |
| 3503 | if (eptr >= md->end_subject) | |
| 3504 | { | |
| 3505 | SCHECK_PARTIAL(); | |
| 3506 | MRRETURN(MATCH_NOMATCH); | |
| 3507 | } | |
| 3508 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3509 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_category = UCD_CATEGORY(c); |
| 3510 | if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH); | if (prop_category == ucp_M) MRRETURN(MATCH_NOMATCH); |
| 3511 | while (eptr < md->end_subject) | while (eptr < md->end_subject) |
| 3512 | { | { |
| 3513 | int len = 1; | int len = 1; |
| 3514 | if (!utf8) c = *eptr; else | if (!utf8) c = *eptr; |
| 3515 | { | else { GETCHARLEN(c, eptr, len); } |
| 3516 | GETCHARLEN(c, eptr, len); | prop_category = UCD_CATEGORY(c); |
| } | ||
| prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | ||
| 3517 | if (prop_category != ucp_M) break; | if (prop_category != ucp_M) break; |
| 3518 | eptr += len; | eptr += len; |
| 3519 | } | } |
| # | Line 2893 for (;;) | Line 3531 for (;;) |
| 3531 | case OP_ANY: | case OP_ANY: |
| 3532 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3533 | { | { |
| 3534 | if (eptr >= md->end_subject || | if (eptr >= md->end_subject) |
| 3535 | ((ims & PCRE_DOTALL) == 0 && IS_NEWLINE(eptr))) | { |
| 3536 | RRETURN(MATCH_NOMATCH); | SCHECK_PARTIAL(); |
| 3537 | MRRETURN(MATCH_NOMATCH); | |
| 3538 | } | |
| 3539 | if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH); | |
| 3540 | eptr++; | |
| 3541 | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | |
| 3542 | } | |
| 3543 | break; | |
| 3544 | ||
| 3545 | case OP_ALLANY: | |
| 3546 | for (i = 1; i <= min; i++) | |
| 3547 | { | |
| 3548 | if (eptr >= md->end_subject) | |
| 3549 | { | |
| 3550 | SCHECK_PARTIAL(); | |
| 3551 | MRRETURN(MATCH_NOMATCH); | |
| 3552 | } | |
| 3553 | eptr++; | eptr++; |
| 3554 | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| 3555 | } | } |
| 3556 | break; | break; |
| 3557 | ||
| 3558 | case OP_ANYBYTE: | case OP_ANYBYTE: |
| 3559 | if (eptr > md->end_subject - min) MRRETURN(MATCH_NOMATCH); | |
| 3560 | eptr += min; | eptr += min; |
| 3561 | break; | break; |
| 3562 | ||
| 3563 | case OP_ANYNL: | case OP_ANYNL: |
| 3564 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3565 | { | { |
| 3566 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3567 | { | |
| 3568 | SCHECK_PARTIAL(); | |
| 3569 | MRRETURN(MATCH_NOMATCH); | |
| 3570 | } | |
| 3571 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 3572 | switch(c) | switch(c) |
| 3573 | { | { |
| 3574 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 3575 | case 0x000d: | case 0x000d: |
| 3576 | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 3577 | break; | break; |
| 3578 | ||
| 3579 | case 0x000a: | case 0x000a: |
| 3580 | break; | |
| 3581 | ||
| 3582 | case 0x000b: | case 0x000b: |
| 3583 | case 0x000c: | case 0x000c: |
| 3584 | case 0x0085: | case 0x0085: |
| 3585 | case 0x2028: | case 0x2028: |
| 3586 | case 0x2029: | case 0x2029: |
| 3587 | if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH); | |
| 3588 | break; | break; |
| 3589 | } | } |
| 3590 | } | } |
| # | Line 2930 for (;;) | Line 3593 for (;;) |
| 3593 | case OP_NOT_HSPACE: | case OP_NOT_HSPACE: |
| 3594 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3595 | { | { |
| 3596 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3597 | { | |
| 3598 | SCHECK_PARTIAL(); | |
| 3599 | MRRETURN(MATCH_NOMATCH); | |
| 3600 | } | |
| 3601 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 3602 | switch(c) | switch(c) |
| 3603 | { | { |
| # | Line 2954 for (;;) | Line 3621 for (;;) |
| 3621 | case 0x202f: /* NARROW NO-BREAK SPACE */ | case 0x202f: /* NARROW NO-BREAK SPACE */ |
| 3622 | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ |
| 3623 | case 0x3000: /* IDEOGRAPHIC SPACE */ | case 0x3000: /* IDEOGRAPHIC SPACE */ |
| 3624 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3625 | } | } |
| 3626 | } | } |
| 3627 | break; | break; |
| # | Line 2962 for (;;) | Line 3629 for (;;) |
| 3629 | case OP_HSPACE: | case OP_HSPACE: |
| 3630 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3631 | { | { |
| 3632 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3633 | { | |
| 3634 | SCHECK_PARTIAL(); | |
| 3635 | MRRETURN(MATCH_NOMATCH); | |
| 3636 | } | |
| 3637 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 3638 | switch(c) | switch(c) |
| 3639 | { | { |
| 3640 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 3641 | case 0x09: /* HT */ | case 0x09: /* HT */ |
| 3642 | case 0x20: /* SPACE */ | case 0x20: /* SPACE */ |
| 3643 | case 0xa0: /* NBSP */ | case 0xa0: /* NBSP */ |
| # | Line 2994 for (;;) | Line 3665 for (;;) |
| 3665 | case OP_NOT_VSPACE: | case OP_NOT_VSPACE: |
| 3666 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3667 | { | { |
| 3668 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3669 | { | |
| 3670 | SCHECK_PARTIAL(); | |
| 3671 | MRRETURN(MATCH_NOMATCH); | |
| 3672 | } | |
| 3673 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 3674 | switch(c) | switch(c) |
| 3675 | { | { |
| # | Line 3006 for (;;) | Line 3681 for (;;) |
| 3681 | case 0x85: /* NEL */ | case 0x85: /* NEL */ |
| 3682 | case 0x2028: /* LINE SEPARATOR */ | case 0x2028: /* LINE SEPARATOR */ |
| 3683 | case 0x2029: /* PARAGRAPH SEPARATOR */ | case 0x2029: /* PARAGRAPH SEPARATOR */ |
| 3684 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3685 | } | } |
| 3686 | } | } |
| 3687 | break; | break; |
| # | Line 3014 for (;;) | Line 3689 for (;;) |
| 3689 | case OP_VSPACE: | case OP_VSPACE: |
| 3690 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3691 | { | { |
| 3692 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3693 | { | |
| 3694 | SCHECK_PARTIAL(); | |
| 3695 | MRRETURN(MATCH_NOMATCH); | |
| 3696 | } | |
| 3697 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 3698 | switch(c) | switch(c) |
| 3699 | { | { |
| 3700 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 3701 | case 0x0a: /* LF */ | case 0x0a: /* LF */ |
| 3702 | case 0x0b: /* VT */ | case 0x0b: /* VT */ |
| 3703 | case 0x0c: /* FF */ | case 0x0c: /* FF */ |
| # | Line 3034 for (;;) | Line 3713 for (;;) |
| 3713 | case OP_NOT_DIGIT: | case OP_NOT_DIGIT: |
| 3714 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3715 | { | { |
| 3716 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3717 | { | |
| 3718 | SCHECK_PARTIAL(); | |
| 3719 | MRRETURN(MATCH_NOMATCH); | |
| 3720 | } | |
| 3721 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 3722 | if (c < 128 && (md->ctypes[c] & ctype_digit) != 0) | if (c < 128 && (md->ctypes[c] & ctype_digit) != 0) |
| 3723 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3724 | } | } |
| 3725 | break; | break; |
| 3726 | ||
| 3727 | case OP_DIGIT: | case OP_DIGIT: |
| 3728 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3729 | { | { |
| 3730 | if (eptr >= md->end_subject || | if (eptr >= md->end_subject) |
| 3731 | *eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0) | { |
| 3732 | RRETURN(MATCH_NOMATCH); | SCHECK_PARTIAL(); |
| 3733 | MRRETURN(MATCH_NOMATCH); | |
| 3734 | } | |
| 3735 | if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0) | |
| 3736 | MRRETURN(MATCH_NOMATCH); | |
| 3737 | /* 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 */ |
| 3738 | } | } |
| 3739 | break; | break; |
| # | Line 3054 for (;;) | Line 3741 for (;;) |
| 3741 | case OP_NOT_WHITESPACE: | case OP_NOT_WHITESPACE: |
| 3742 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3743 | { | { |
| 3744 | if (eptr >= md->end_subject || | if (eptr >= md->end_subject) |
| 3745 | (*eptr < 128 && (md->ctypes[*eptr++] & ctype_space) != 0)) | { |
| 3746 | RRETURN(MATCH_NOMATCH); | SCHECK_PARTIAL(); |
| 3747 | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | MRRETURN(MATCH_NOMATCH); |
| 3748 | } | |
| 3749 | if (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0) | |
| 3750 | MRRETURN(MATCH_NOMATCH); | |
| 3751 | while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80); | |
| 3752 | } | } |
| 3753 | break; | break; |
| 3754 | ||
| 3755 | case OP_WHITESPACE: | case OP_WHITESPACE: |
| 3756 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3757 | { | { |
| 3758 | if (eptr >= md->end_subject || | if (eptr >= md->end_subject) |
| 3759 | *eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0) | { |
| 3760 | RRETURN(MATCH_NOMATCH); | SCHECK_PARTIAL(); |
| 3761 | MRRETURN(MATCH_NOMATCH); | |
| 3762 | } | |
| 3763 | if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0) | |
| 3764 | MRRETURN(MATCH_NOMATCH); | |
| 3765 | /* 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 */ |
| 3766 | } | } |
| 3767 | break; | break; |
| # | Line 3074 for (;;) | Line 3769 for (;;) |
| 3769 | case OP_NOT_WORDCHAR: | case OP_NOT_WORDCHAR: |
| 3770 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3771 | { | { |
| 3772 | if (eptr >= md->end_subject || | if (eptr >= md->end_subject) |
| 3773 | (*eptr < 128 && (md->ctypes[*eptr++] & ctype_word) != 0)) | { |
| 3774 | RRETURN(MATCH_NOMATCH); | SCHECK_PARTIAL(); |
| 3775 | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | MRRETURN(MATCH_NOMATCH); |
| 3776 | } | |
| 3777 | if (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0) | |
| 3778 | MRRETURN(MATCH_NOMATCH); | |
| 3779 | while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80); | |
| 3780 | } | } |
| 3781 | break; | break; |
| 3782 | ||
| 3783 | case OP_WORDCHAR: | case OP_WORDCHAR: |
| 3784 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3785 | { | { |
| 3786 | if (eptr >= md->end_subject || | if (eptr >= md->end_subject) |
| 3787 | *eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0) | { |
| 3788 | RRETURN(MATCH_NOMATCH); | SCHECK_PARTIAL(); |
| 3789 | MRRETURN(MATCH_NOMATCH); | |
| 3790 | } | |
| 3791 | if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0) | |
| 3792 | MRRETURN(MATCH_NOMATCH); | |
| 3793 | /* 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 */ |
| 3794 | } | } |
| 3795 | break; | break; |
| # | Line 3099 for (;;) | Line 3802 for (;;) |
| 3802 | #endif /* SUPPORT_UTF8 */ | #endif /* SUPPORT_UTF8 */ |
| 3803 | ||
| 3804 | /* 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 |
| 3805 | 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. */ | ||
| 3806 | ||
| 3807 | switch(ctype) | switch(ctype) |
| 3808 | { | { |
| 3809 | case OP_ANY: | case OP_ANY: |
| 3810 | if ((ims & PCRE_DOTALL) == 0) | for (i = 1; i <= min; i++) |
| 3811 | { | { |
| 3812 | for (i = 1; i <= min; i++) | if (eptr >= md->end_subject) |
| 3813 | { | { |
| 3814 | if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); | SCHECK_PARTIAL(); |
| 3815 | eptr++; | MRRETURN(MATCH_NOMATCH); |
| 3816 | } | } |
| 3817 | if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH); | |
| 3818 | eptr++; | |
| 3819 | } | } |
| else eptr += min; | ||
| 3820 | break; | break; |
| 3821 | ||
| 3822 | case OP_ANYBYTE: | case OP_ALLANY: |
| 3823 | if (eptr > md->end_subject - min) | |
| 3824 | { | |
| 3825 | SCHECK_PARTIAL(); | |
| 3826 | MRRETURN(MATCH_NOMATCH); | |
| 3827 | } | |
| 3828 | eptr += min; | eptr += min; |
| 3829 | break; | break; |
| 3830 | ||
| 3831 | /* Because of the CRLF case, we can't assume the minimum number of | case OP_ANYBYTE: |
| 3832 | bytes are present in this case. */ | if (eptr > md->end_subject - min) |
| 3833 | { | |
| 3834 | SCHECK_PARTIAL(); | |
| 3835 | MRRETURN(MATCH_NOMATCH); | |
| 3836 | } | |
| 3837 | eptr += min; | |
| 3838 | break; | |
| 3839 | ||
| 3840 | case OP_ANYNL: | case OP_ANYNL: |
| 3841 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3842 | { | { |
| 3843 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3844 | { | |
| 3845 | SCHECK_PARTIAL(); | |
| 3846 | MRRETURN(MATCH_NOMATCH); | |
| 3847 | } | |
| 3848 | switch(*eptr++) | switch(*eptr++) |
| 3849 | { | { |
| 3850 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 3851 | case 0x000d: | case 0x000d: |
| 3852 | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 3853 | break; | break; |
| 3854 | case 0x000a: | case 0x000a: |
| 3855 | break; | |
| 3856 | ||
| 3857 | case 0x000b: | case 0x000b: |
| 3858 | case 0x000c: | case 0x000c: |
| 3859 | case 0x0085: | case 0x0085: |
| 3860 | if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH); | |
| 3861 | break; | break; |
| 3862 | } | } |
| 3863 | } | } |
| # | Line 3145 for (;;) | Line 3866 for (;;) |
| 3866 | case OP_NOT_HSPACE: | case OP_NOT_HSPACE: |
| 3867 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3868 | { | { |
| 3869 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3870 | { | |
| 3871 | SCHECK_PARTIAL(); | |
| 3872 | MRRETURN(MATCH_NOMATCH); | |
| 3873 | } | |
| 3874 | switch(*eptr++) | switch(*eptr++) |
| 3875 | { | { |
| 3876 | default: break; | default: break; |
| 3877 | case 0x09: /* HT */ | case 0x09: /* HT */ |
| 3878 | case 0x20: /* SPACE */ | case 0x20: /* SPACE */ |
| 3879 | case 0xa0: /* NBSP */ | case 0xa0: /* NBSP */ |
| 3880 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3881 | } | } |
| 3882 | } | } |
| 3883 | break; | break; |
| # | Line 3160 for (;;) | Line 3885 for (;;) |
| 3885 | case OP_HSPACE: | case OP_HSPACE: |
| 3886 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3887 | { | { |
| 3888 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3889 | { | |
| 3890 | SCHECK_PARTIAL(); | |
| 3891 | MRRETURN(MATCH_NOMATCH); | |
| 3892 | } | |
| 3893 | switch(*eptr++) | switch(*eptr++) |
| 3894 | { | { |
| 3895 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 3896 | case 0x09: /* HT */ | case 0x09: /* HT */ |
| 3897 | case 0x20: /* SPACE */ | case 0x20: /* SPACE */ |
| 3898 | case 0xa0: /* NBSP */ | case 0xa0: /* NBSP */ |
| # | Line 3175 for (;;) | Line 3904 for (;;) |
| 3904 | case OP_NOT_VSPACE: | case OP_NOT_VSPACE: |
| 3905 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3906 | { | { |
| 3907 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3908 | { | |
| 3909 | SCHECK_PARTIAL(); | |
| 3910 | MRRETURN(MATCH_NOMATCH); | |
| 3911 | } | |
| 3912 | switch(*eptr++) | switch(*eptr++) |
| 3913 | { | { |
| 3914 | default: break; | default: break; |
| # | Line 3184 for (;;) | Line 3917 for (;;) |
| 3917 | case 0x0c: /* FF */ | case 0x0c: /* FF */ |
| 3918 | case 0x0d: /* CR */ | case 0x0d: /* CR */ |
| 3919 | case 0x85: /* NEL */ | case 0x85: /* NEL */ |
| 3920 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3921 | } | } |
| 3922 | } | } |
| 3923 | break; | break; |
| # | Line 3192 for (;;) | Line 3925 for (;;) |
| 3925 | case OP_VSPACE: | case OP_VSPACE: |
| 3926 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3927 | { | { |
| 3928 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3929 | { | |
| 3930 | SCHECK_PARTIAL(); | |
| 3931 | MRRETURN(MATCH_NOMATCH); | |
| 3932 | } | |
| 3933 | switch(*eptr++) | switch(*eptr++) |
| 3934 | { | { |
| 3935 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 3936 | case 0x0a: /* LF */ | case 0x0a: /* LF */ |
| 3937 | case 0x0b: /* VT */ | case 0x0b: /* VT */ |
| 3938 | case 0x0c: /* FF */ | case 0x0c: /* FF */ |
| # | Line 3208 for (;;) | Line 3945 for (;;) |
| 3945 | ||
| 3946 | case OP_NOT_DIGIT: | case OP_NOT_DIGIT: |
| 3947 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3948 | if ((md->ctypes[*eptr++] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH); | { |
| 3949 | if (eptr >= md->end_subject) | |
| 3950 | { | |
| 3951 | SCHECK_PARTIAL(); | |
| 3952 | MRRETURN(MATCH_NOMATCH); | |
| 3953 | } | |
| 3954 | if ((md->ctypes[*eptr++] & ctype_digit) != 0) MRRETURN(MATCH_NOMATCH); | |
| 3955 | } | |
| 3956 | break; | break; |
| 3957 | ||
| 3958 | case OP_DIGIT: | case OP_DIGIT: |
| 3959 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3960 | if ((md->ctypes[*eptr++] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH); | { |
| 3961 | if (eptr >= md->end_subject) | |
| 3962 | { | |
| 3963 | SCHECK_PARTIAL(); | |
| 3964 | MRRETURN(MATCH_NOMATCH); | |
| 3965 | } | |
| 3966 | if ((md->ctypes[*eptr++] & ctype_digit) == 0) MRRETURN(MATCH_NOMATCH); | |
| 3967 | } | |
| 3968 | break; | break; |
| 3969 | ||
| 3970 | case OP_NOT_WHITESPACE: | case OP_NOT_WHITESPACE: |
| 3971 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3972 | if ((md->ctypes[*eptr++] & ctype_space) != 0) RRETURN(MATCH_NOMATCH); | { |
| 3973 | if (eptr >= md->end_subject) | |
| 3974 | { | |
| 3975 | SCHECK_PARTIAL(); | |
| 3976 | MRRETURN(MATCH_NOMATCH); | |
| 3977 | } | |
| 3978 | if ((md->ctypes[*eptr++] & ctype_space) != 0) MRRETURN(MATCH_NOMATCH); | |
| 3979 | } | |
| 3980 | break; | break; |
| 3981 | ||
| 3982 | case OP_WHITESPACE: | case OP_WHITESPACE: |
| 3983 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3984 | if ((md->ctypes[*eptr++] & ctype_space) == 0) RRETURN(MATCH_NOMATCH); | { |
| 3985 | if (eptr >= md->end_subject) | |
| 3986 | { | |
| 3987 | SCHECK_PARTIAL(); | |
| 3988 | MRRETURN(MATCH_NOMATCH); | |
| 3989 | } | |
| 3990 | if ((md->ctypes[*eptr++] & ctype_space) == 0) MRRETURN(MATCH_NOMATCH); | |
| 3991 | } | |
| 3992 | break; | break; |
| 3993 | ||
| 3994 | case OP_NOT_WORDCHAR: | case OP_NOT_WORDCHAR: |
| 3995 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3996 | { | |
| 3997 | if (eptr >= md->end_subject) | |
| 3998 | { | |
| 3999 | SCHECK_PARTIAL(); | |
| 4000 | MRRETURN(MATCH_NOMATCH); | |
| 4001 | } | |
| 4002 | if ((md->ctypes[*eptr++] & ctype_word) != 0) | if ((md->ctypes[*eptr++] & ctype_word) != 0) |
| 4003 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4004 | } | |
| 4005 | break; | break; |
| 4006 | ||
| 4007 | case OP_WORDCHAR: | case OP_WORDCHAR: |
| 4008 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 4009 | { | |
| 4010 | if (eptr >= md->end_subject) | |
| 4011 | { | |
| 4012 | SCHECK_PARTIAL(); | |
| 4013 | MRRETURN(MATCH_NOMATCH); | |
| 4014 | } | |
| 4015 | if ((md->ctypes[*eptr++] & ctype_word) == 0) | if ((md->ctypes[*eptr++] & ctype_word) == 0) |
| 4016 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4017 | } | |
| 4018 | break; | break; |
| 4019 | ||
| 4020 | default: | default: |
| # | Line 3263 for (;;) | Line 4042 for (;;) |
| 4042 | { | { |
| 4043 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM36); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM36); |
| 4044 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4045 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4046 | if (eptr >= md->end_subject) | |
| 4047 | { | |
| 4048 | SCHECK_PARTIAL(); | |
| 4049 | MRRETURN(MATCH_NOMATCH); | |
| 4050 | } | |
| 4051 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 4052 | if (prop_fail_result) RRETURN(MATCH_NOMATCH); | if (prop_fail_result) MRRETURN(MATCH_NOMATCH); |
| 4053 | } | } |
| 4054 | /* Control never gets here */ | /* Control never gets here */ |
| 4055 | ||
| # | Line 3274 for (;;) | Line 4058 for (;;) |
| 4058 | { | { |
| 4059 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM37); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM37); |
| 4060 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4061 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4062 | if (eptr >= md->end_subject) | |
| 4063 | { | |
| 4064 | SCHECK_PARTIAL(); | |
| 4065 | MRRETURN(MATCH_NOMATCH); | |
| 4066 | } | |
| 4067 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 4068 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_chartype = UCD_CHARTYPE(c); |
| 4069 | if ((prop_chartype == ucp_Lu || | if ((prop_chartype == ucp_Lu || |
| 4070 | prop_chartype == ucp_Ll || | prop_chartype == ucp_Ll || |
| 4071 | prop_chartype == ucp_Lt) == prop_fail_result) | prop_chartype == ucp_Lt) == prop_fail_result) |
| 4072 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4073 | } | } |
| 4074 | /* Control never gets here */ | /* Control never gets here */ |
| 4075 | ||
| # | Line 3289 for (;;) | Line 4078 for (;;) |
| 4078 | { | { |
| 4079 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM38); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM38); |
| 4080 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4081 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4082 | if (eptr >= md->end_subject) | |
| 4083 | { | |
| 4084 | SCHECK_PARTIAL(); | |
| 4085 | MRRETURN(MATCH_NOMATCH); | |
| 4086 | } | |
| 4087 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 4088 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_category = UCD_CATEGORY(c); |
| 4089 | if ((prop_category == prop_value) == prop_fail_result) | if ((prop_category == prop_value) == prop_fail_result) |
| 4090 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4091 | } | } |
| 4092 | /* Control never gets here */ | /* Control never gets here */ |
| 4093 | ||
| # | Line 3302 for (;;) | Line 4096 for (;;) |
| 4096 | { | { |
| 4097 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM39); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM39); |
| 4098 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4099 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4100 | if (eptr >= md->end_subject) | |
| 4101 | { | |
| 4102 | SCHECK_PARTIAL(); | |
| 4103 | MRRETURN(MATCH_NOMATCH); | |
| 4104 | } | |
| 4105 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 4106 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_chartype = UCD_CHARTYPE(c); |
| 4107 | if ((prop_chartype == prop_value) == prop_fail_result) | if ((prop_chartype == prop_value) == prop_fail_result) |
| 4108 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4109 | } | } |
| 4110 | /* Control never gets here */ | /* Control never gets here */ |
| 4111 | ||
| # | Line 3315 for (;;) | Line 4114 for (;;) |
| 4114 | { | { |
| 4115 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM40); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM40); |
| 4116 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4117 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4118 | if (eptr >= md->end_subject) | |
| 4119 | { | |
| 4120 | SCHECK_PARTIAL(); | |
| 4121 | MRRETURN(MATCH_NOMATCH); | |
| 4122 | } | |
| 4123 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 4124 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_script = UCD_SCRIPT(c); |
| 4125 | if ((prop_script == prop_value) == prop_fail_result) | if ((prop_script == prop_value) == prop_fail_result) |
| 4126 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4127 | } | } |
| 4128 | /* Control never gets here */ | /* Control never gets here */ |
| 4129 | ||
| # | Line 3337 for (;;) | Line 4141 for (;;) |
| 4141 | { | { |
| 4142 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM41); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM41); |
| 4143 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4144 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4145 | if (eptr >= md->end_subject) | |
| 4146 | { | |
| 4147 | SCHECK_PARTIAL(); | |
| 4148 | MRRETURN(MATCH_NOMATCH); | |
| 4149 | } | |
| 4150 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 4151 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_category = UCD_CATEGORY(c); |
| 4152 | if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH); | if (prop_category == ucp_M) MRRETURN(MATCH_NOMATCH); |
| 4153 | while (eptr < md->end_subject) | while (eptr < md->end_subject) |
| 4154 | { | { |
| 4155 | int len = 1; | int len = 1; |
| 4156 | if (!utf8) c = *eptr; else | if (!utf8) c = *eptr; |
| 4157 | { | else { GETCHARLEN(c, eptr, len); } |
| 4158 | GETCHARLEN(c, eptr, len); | prop_category = UCD_CATEGORY(c); |
| } | ||
| prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | ||
| 4159 | if (prop_category != ucp_M) break; | if (prop_category != ucp_M) break; |
| 4160 | eptr += len; | eptr += len; |
| 4161 | } | } |
| # | Line 3366 for (;;) | Line 4173 for (;;) |
| 4173 | { | { |
| 4174 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM42); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM42); |
| 4175 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4176 | if (fi >= max || eptr >= md->end_subject || | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4177 | (ctype == OP_ANY && (ims & PCRE_DOTALL) == 0 && | if (eptr >= md->end_subject) |
| 4178 | IS_NEWLINE(eptr))) | { |
| 4179 | RRETURN(MATCH_NOMATCH); | SCHECK_PARTIAL(); |
| 4180 | MRRETURN(MATCH_NOMATCH); | |
| 4181 | } | |
| 4182 | if (ctype == OP_ANY && IS_NEWLINE(eptr)) | |
| 4183 | MRRETURN(MATCH_NOMATCH); | |
| 4184 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 4185 | switch(ctype) | switch(ctype) |
| 4186 | { | { |
| 4187 | case OP_ANY: /* This is the DOTALL case */ | case OP_ANY: /* This is the non-NL case */ |
| 4188 | break; | case OP_ALLANY: |
| 4189 | case OP_ANYBYTE: | case OP_ANYBYTE: |
| 4190 | break; | break; |
| 4191 | ||
| 4192 | case OP_ANYNL: | case OP_ANYNL: |
| 4193 | switch(c) | switch(c) |
| 4194 | { | { |
| 4195 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4196 | case 0x000d: | case 0x000d: |
| 4197 | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 4198 | break; | break; |
| 4199 | case 0x000a: | case 0x000a: |
| 4200 | break; | |
| 4201 | ||
| 4202 | case 0x000b: | case 0x000b: |
| 4203 | case 0x000c: | case 0x000c: |
| 4204 | case 0x0085: | case 0x0085: |
| 4205 | case 0x2028: | case 0x2028: |
| 4206 | case 0x2029: | case 0x2029: |
| 4207 | if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH); | |
| 4208 | break; | break; |
| 4209 | } | } |
| 4210 | break; | break; |
| # | Line 3420 for (;;) | Line 4232 for (;;) |
| 4232 | case 0x202f: /* NARROW NO-BREAK SPACE */ | case 0x202f: /* NARROW NO-BREAK SPACE */ |
| 4233 | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ |
| 4234 | case 0x3000: /* IDEOGRAPHIC SPACE */ | case 0x3000: /* IDEOGRAPHIC SPACE */ |
| 4235 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4236 | } | } |
| 4237 | break; | break; |
| 4238 | ||
| 4239 | case OP_HSPACE: | case OP_HSPACE: |
| 4240 | switch(c) | switch(c) |
| 4241 | { | { |
| 4242 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4243 | case 0x09: /* HT */ | case 0x09: /* HT */ |
| 4244 | case 0x20: /* SPACE */ | case 0x20: /* SPACE */ |
| 4245 | case 0xa0: /* NBSP */ | case 0xa0: /* NBSP */ |
| # | Line 3462 for (;;) | Line 4274 for (;;) |
| 4274 | case 0x85: /* NEL */ | case 0x85: /* NEL */ |
| 4275 | case 0x2028: /* LINE SEPARATOR */ | case 0x2028: /* LINE SEPARATOR */ |
| 4276 | case 0x2029: /* PARAGRAPH SEPARATOR */ | case 0x2029: /* PARAGRAPH SEPARATOR */ |
| 4277 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4278 | } | } |
| 4279 | break; | break; |
| 4280 | ||
| 4281 | case OP_VSPACE: | case OP_VSPACE: |
| 4282 | switch(c) | switch(c) |
| 4283 | { | { |
| 4284 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4285 | case 0x0a: /* LF */ | case 0x0a: /* LF */ |
| 4286 | case 0x0b: /* VT */ | case 0x0b: /* VT */ |
| 4287 | case 0x0c: /* FF */ | case 0x0c: /* FF */ |
| # | Line 3483 for (;;) | Line 4295 for (;;) |
| 4295 | ||
| 4296 | case OP_NOT_DIGIT: | case OP_NOT_DIGIT: |
| 4297 | if (c < 256 && (md->ctypes[c] & ctype_digit) != 0) | if (c < 256 && (md->ctypes[c] & ctype_digit) != 0) |
| 4298 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4299 | break; | break; |
| 4300 | ||
| 4301 | case OP_DIGIT: | case OP_DIGIT: |
| 4302 | if (c >= 256 || (md->ctypes[c] & ctype_digit) == 0) | if (c >= 256 || (md->ctypes[c] & ctype_digit) == 0) |
| 4303 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4304 | break; | break; |
| 4305 | ||
| 4306 | case OP_NOT_WHITESPACE: | case OP_NOT_WHITESPACE: |
| 4307 | if (c < 256 && (md->ctypes[c] & ctype_space) != 0) | if (c < 256 && (md->ctypes[c] & ctype_space) != 0) |
| 4308 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4309 | break; | break; |
| 4310 | ||
| 4311 | case OP_WHITESPACE: | case OP_WHITESPACE: |
| 4312 | if (c >= 256 || (md->ctypes[c] & ctype_space) == 0) | if (c >= 256 || (md->ctypes[c] & ctype_space) == 0) |
| 4313 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4314 | break; | break; |
| 4315 | ||
| 4316 | case OP_NOT_WORDCHAR: | case OP_NOT_WORDCHAR: |
| 4317 | if (c < 256 && (md->ctypes[c] & ctype_word) != 0) | if (c < 256 && (md->ctypes[c] & ctype_word) != 0) |
| 4318 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4319 | break; | break; |
| 4320 | ||
| 4321 | case OP_WORDCHAR: | case OP_WORDCHAR: |
| 4322 | if (c >= 256 || (md->ctypes[c] & ctype_word) == 0) | if (c >= 256 || (md->ctypes[c] & ctype_word) == 0) |
| 4323 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4324 | break; | break; |
| 4325 | ||
| 4326 | default: | default: |
| # | Line 3524 for (;;) | Line 4336 for (;;) |
| 4336 | { | { |
| 4337 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM43); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM43); |
| 4338 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4339 | if (fi >= max || eptr >= md->end_subject || | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4340 | ((ims & PCRE_DOTALL) == 0 && IS_NEWLINE(eptr))) | if (eptr >= md->end_subject) |
| 4341 | RRETURN(MATCH_NOMATCH); | { |
| 4342 | SCHECK_PARTIAL(); | |
| 4343 | MRRETURN(MATCH_NOMATCH); | |
| 4344 | } | |
| 4345 | if (ctype == OP_ANY && IS_NEWLINE(eptr)) | |
| 4346 | MRRETURN(MATCH_NOMATCH); | |
| 4347 | c = *eptr++; | c = *eptr++; |
| 4348 | switch(ctype) | switch(ctype) |
| 4349 | { | { |
| 4350 | case OP_ANY: /* This is the DOTALL case */ | case OP_ANY: /* This is the non-NL case */ |
| 4351 | break; | case OP_ALLANY: |
| 4352 | case OP_ANYBYTE: | case OP_ANYBYTE: |
| 4353 | break; | break; |
| 4354 | ||
| 4355 | case OP_ANYNL: | case OP_ANYNL: |
| 4356 | switch(c) | switch(c) |
| 4357 | { | { |
| 4358 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4359 | case 0x000d: | case 0x000d: |
| 4360 | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 4361 | break; | break; |
| 4362 | ||
| 4363 | case 0x000a: | case 0x000a: |
| 4364 | break; | |
| 4365 | ||
| 4366 | case 0x000b: | case 0x000b: |
| 4367 | case 0x000c: | case 0x000c: |
| 4368 | case 0x0085: | case 0x0085: |
| 4369 | if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH); | |
| 4370 | break; | break; |
| 4371 | } | } |
| 4372 | break; | break; |
| # | Line 3559 for (;;) | Line 4378 for (;;) |
| 4378 | case 0x09: /* HT */ | case 0x09: /* HT */ |
| 4379 | case 0x20: /* SPACE */ | case 0x20: /* SPACE */ |
| 4380 | case 0xa0: /* NBSP */ | case 0xa0: /* NBSP */ |
| 4381 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4382 | } | } |
| 4383 | break; | break; |
| 4384 | ||
| 4385 | case OP_HSPACE: | case OP_HSPACE: |
| 4386 | switch(c) | switch(c) |
| 4387 | { | { |
| 4388 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4389 | case 0x09: /* HT */ | case 0x09: /* HT */ |
| 4390 | case 0x20: /* SPACE */ | case 0x20: /* SPACE */ |
| 4391 | case 0xa0: /* NBSP */ | case 0xa0: /* NBSP */ |
| # | Line 3583 for (;;) | Line 4402 for (;;) |
| 4402 | case 0x0c: /* FF */ | case 0x0c: /* FF */ |
| 4403 | case 0x0d: /* CR */ | case 0x0d: /* CR */ |
| 4404 | case 0x85: /* NEL */ | case 0x85: /* NEL */ |
| 4405 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4406 | } | } |
| 4407 | break; | break; |
| 4408 | ||
| 4409 | case OP_VSPACE: | case OP_VSPACE: |
| 4410 | switch(c) | switch(c) |
| 4411 | { | { |
| 4412 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4413 | case 0x0a: /* LF */ | case 0x0a: /* LF */ |
| 4414 | case 0x0b: /* VT */ | case 0x0b: /* VT */ |
| 4415 | case 0x0c: /* FF */ | case 0x0c: /* FF */ |
| # | Line 3601 for (;;) | Line 4420 for (;;) |
| 4420 | break; | break; |
| 4421 | ||
| 4422 | case OP_NOT_DIGIT: | case OP_NOT_DIGIT: |
| 4423 | if ((md->ctypes[c] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[c] & ctype_digit) != 0) MRRETURN(MATCH_NOMATCH); |
| 4424 | break; | break; |
| 4425 | ||
| 4426 | case OP_DIGIT: | case OP_DIGIT: |
| 4427 | if ((md->ctypes[c] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[c] & ctype_digit) == 0) MRRETURN(MATCH_NOMATCH); |
| 4428 | break; | break; |
| 4429 | ||
| 4430 | case OP_NOT_WHITESPACE: | case OP_NOT_WHITESPACE: |
| 4431 | if ((md->ctypes[c] & ctype_space) != 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[c] & ctype_space) != 0) MRRETURN(MATCH_NOMATCH); |
| 4432 | break; | break; |
| 4433 | ||
| 4434 | case OP_WHITESPACE: | case OP_WHITESPACE: |
| 4435 | if ((md->ctypes[c] & ctype_space) == 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[c] & ctype_space) == 0) MRRETURN(MATCH_NOMATCH); |
| 4436 | break; | break; |
| 4437 | ||
| 4438 | case OP_NOT_WORDCHAR: | case OP_NOT_WORDCHAR: |
| 4439 | if ((md->ctypes[c] & ctype_word) != 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[c] & ctype_word) != 0) MRRETURN(MATCH_NOMATCH); |
| 4440 | break; | break; |
| 4441 | ||
| 4442 | case OP_WORDCHAR: | case OP_WORDCHAR: |
| 4443 | if ((md->ctypes[c] & ctype_word) == 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[c] & ctype_word) == 0) MRRETURN(MATCH_NOMATCH); |
| 4444 | break; | break; |
| 4445 | ||
| 4446 | default: | default: |
| # | Line 3649 for (;;) | Line 4468 for (;;) |
| 4468 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4469 | { | { |
| 4470 | int len = 1; | int len = 1; |
| 4471 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4472 | { | |
| 4473 | SCHECK_PARTIAL(); | |
| 4474 | break; | |
| 4475 | } | |
| 4476 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4477 | if (prop_fail_result) break; | if (prop_fail_result) break; |
| 4478 | eptr+= len; | eptr+= len; |
| # | Line 3660 for (;;) | Line 4483 for (;;) |
| 4483 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4484 | { | { |
| 4485 | int len = 1; | int len = 1; |
| 4486 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4487 | { | |
| 4488 | SCHECK_PARTIAL(); | |
| 4489 | break; | |
| 4490 | } | |
| 4491 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4492 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_chartype = UCD_CHARTYPE(c); |
| 4493 | if ((prop_chartype == ucp_Lu || | if ((prop_chartype == ucp_Lu || |
| 4494 | prop_chartype == ucp_Ll || | prop_chartype == ucp_Ll || |
| 4495 | prop_chartype == ucp_Lt) == prop_fail_result) | prop_chartype == ucp_Lt) == prop_fail_result) |
| # | Line 3675 for (;;) | Line 4502 for (;;) |
| 4502 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4503 | { | { |
| 4504 | int len = 1; | int len = 1; |
| 4505 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4506 | { | |
| 4507 | SCHECK_PARTIAL(); | |
| 4508 | break; | |
| 4509 | } | |
| 4510 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4511 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_category = UCD_CATEGORY(c); |
| 4512 | if ((prop_category == prop_value) == prop_fail_result) | if ((prop_category == prop_value) == prop_fail_result) |
| 4513 | break; | break; |
| 4514 | eptr+= len; | eptr+= len; |
| # | Line 3688 for (;;) | Line 4519 for (;;) |
| 4519 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4520 | { | { |
| 4521 | int len = 1; | int len = 1; |
| 4522 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4523 | { | |
| 4524 | SCHECK_PARTIAL(); | |
| 4525 | break; | |
| 4526 | } | |
| 4527 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4528 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_chartype = UCD_CHARTYPE(c); |
| 4529 | if ((prop_chartype == prop_value) == prop_fail_result) | if ((prop_chartype == prop_value) == prop_fail_result) |
| 4530 | break; | break; |
| 4531 | eptr+= len; | eptr+= len; |
| # | Line 3701 for (;;) | Line 4536 for (;;) |
| 4536 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4537 | { | { |
| 4538 | int len = 1; | int len = 1; |
| 4539 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4540 | { | |
| 4541 | SCHECK_PARTIAL(); | |
| 4542 | break; | |
| 4543 | } | |
| 4544 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4545 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_script = UCD_SCRIPT(c); |
| 4546 | if ((prop_script == prop_value) == prop_fail_result) | if ((prop_script == prop_value) == prop_fail_result) |
| 4547 | break; | break; |
| 4548 | eptr+= len; | eptr+= len; |
| # | Line 3730 for (;;) | Line 4569 for (;;) |
| 4569 | { | { |
| 4570 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4571 | { | { |
| 4572 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4573 | { | |
| 4574 | SCHECK_PARTIAL(); | |
| 4575 | break; | |
| 4576 | } | |
| 4577 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 4578 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_category = UCD_CATEGORY(c); |
| 4579 | if (prop_category == ucp_M) break; | if (prop_category == ucp_M) break; |
| 4580 | while (eptr < md->end_subject) | while (eptr < md->end_subject) |
| 4581 | { | { |
| # | Line 3741 for (;;) | Line 4584 for (;;) |
| 4584 | { | { |
| 4585 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4586 | } | } |
| 4587 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_category = UCD_CATEGORY(c); |
| 4588 | if (prop_category != ucp_M) break; | if (prop_category != ucp_M) break; |
| 4589 | eptr += len; | eptr += len; |
| 4590 | } | } |
| # | Line 3750 for (;;) | Line 4593 for (;;) |
| 4593 | /* eptr is now past the end of the maximum run */ | /* eptr is now past the end of the maximum run */ |
| 4594 | ||
| 4595 | if (possessive) continue; | if (possessive) continue; |
| 4596 | ||
| 4597 | for(;;) | for(;;) |
| 4598 | { | { |
| 4599 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM45); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM45); |
| # | Line 3763 for (;;) | Line 4607 for (;;) |
| 4607 | BACKCHAR(eptr); | BACKCHAR(eptr); |
| 4608 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4609 | } | } |
| 4610 | prop_category = _pcre_ucp_findprop(c, &prop_chartype, &prop_script); | prop_category = UCD_CATEGORY(c); |
| 4611 | if (prop_category != ucp_M) break; | if (prop_category != ucp_M) break; |
| 4612 | eptr--; | eptr--; |
| 4613 | } | } |
| # | Line 3783 for (;;) | Line 4627 for (;;) |
| 4627 | case OP_ANY: | case OP_ANY: |
| 4628 | if (max < INT_MAX) | if (max < INT_MAX) |
| 4629 | { | { |
| 4630 | 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 | ||
| 4631 | { | { |
| 4632 | for (i = min; i < max; i++) | if (eptr >= md->end_subject) |
| 4633 | { | { |
| 4634 | if (eptr >= md->end_subject) break; | SCHECK_PARTIAL(); |
| 4635 | eptr++; | break; |
| while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | ||
| 4636 | } | } |
| 4637 | if (IS_NEWLINE(eptr)) break; | |
| 4638 | eptr++; | |
| 4639 | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | |
| 4640 | } | } |
| 4641 | } | } |
| 4642 | ||
| # | Line 3807 for (;;) | Line 4644 for (;;) |
| 4644 | ||
| 4645 | else | else |
| 4646 | { | { |
| 4647 | if ((ims & PCRE_DOTALL) == 0) | for (i = min; i < max; i++) |
| 4648 | { | { |
| 4649 | for (i = min; i < max; i++) | if (eptr >= md->end_subject) |
| 4650 | { | { |
| 4651 | if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break; | SCHECK_PARTIAL(); |
| 4652 | eptr++; | break; |
| while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | ||
| 4653 | } | } |
| 4654 | if (IS_NEWLINE(eptr)) break; | |
| 4655 | eptr++; | |
| 4656 | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | |
| 4657 | } | } |
| 4658 | else | } |
| 4659 | break; | |