Parent Directory
|
Revision Log
|
Patch
| revision 371 by ph10, Mon Aug 25 18:28:05 2008 UTC | revision 512 by ph10, Tue Mar 30 11:11:52 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-2008 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 71 defined PCRE_ERROR_xxx codes, which are | Line 71 defined PCRE_ERROR_xxx codes, which are |
| 71 | /* Special internal returns from the match() function. Make them sufficiently | /* Special internal returns from the match() function. Make them sufficiently |
| 72 | negative to avoid the external error codes. */ | negative to avoid the external error codes. */ |
| 73 | ||
| 74 | #define MATCH_COMMIT (-999) | #define MATCH_ACCEPT (-999) |
| 75 | #define MATCH_PRUNE (-998) | #define MATCH_COMMIT (-998) |
| 76 | #define MATCH_SKIP (-997) | #define MATCH_PRUNE (-997) |
| 77 | #define MATCH_THEN (-996) | #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, |
| # | Line 89 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 141 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 245 enum { RM1=1, RM2, RM3, RM4, RM5, RM | Line 255 enum { RM1=1, RM2, RM3, RM4, RM5, RM |
| 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 }; | RM51, RM52, RM53, RM54, RM55, RM56, RM57, RM58 }; |
| 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 268 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 288 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 322 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 333 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 360 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 395 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 | #define CHECK_PARTIAL()\ | |
| 423 | 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 the | /* Performance note: It might be tempting to extract commonly used fields from |
| 438 | md structure (e.g. utf8, end_subject) into individual variables to improve | 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 407 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 420 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 439 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 454 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 469 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 481 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 561 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 594 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 636 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, RM55); | |
| 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: | case OP_FAIL: |
| 708 | RRETURN(MATCH_NOMATCH); | 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: | case OP_PRUNE: |
| 717 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
| 718 | ims, eptrb, flags, RM51); | ims, eptrb, flags, RM51); |
| 719 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 720 | RRETURN(MATCH_PRUNE); | MRRETURN(MATCH_PRUNE); |
| 721 | ||
| 722 | case OP_COMMIT: | case OP_PRUNE_ARG: |
| 723 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md, |
| 724 | ims, eptrb, flags, RM52); | ims, eptrb, flags, RM56); |
| 725 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 726 | RRETURN(MATCH_COMMIT); | md->mark = ecode + 2; |
| 727 | RRETURN(MATCH_PRUNE); | |
| 728 | ||
| 729 | case OP_SKIP: | case OP_SKIP: |
| 730 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
| 731 | ims, eptrb, flags, RM53); | ims, eptrb, flags, RM53); |
| 732 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 733 | md->start_match_ptr = eptr; /* Pass back current position */ | md->start_match_ptr = eptr; /* Pass back current position */ |
| 734 | RRETURN(MATCH_SKIP); | 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, RM57); | |
| 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: | case OP_THEN: |
| 750 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
| 751 | ims, eptrb, flags, RM54); | ims, eptrb, flags, RM54); |
| 752 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | 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, RM58); | |
| 758 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | |
| 759 | md->mark = ecode + 2; | |
| 760 | RRETURN(MATCH_THEN); | 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 |
| # | Line 693 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 727 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 766 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 | if (rrc == MATCH_NOMATCH) md->mark = markptr; | |
| 856 | RRETURN(rrc); | RRETURN(rrc); |
| 857 | } | } |
| 858 | ||
| # | Line 787 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 829 for (;;) | Line 1069 for (;;) |
| 1069 | else | else |
| 1070 | { | { |
| 1071 | condition = FALSE; | condition = FALSE; |
| 1072 | ecode += GET(ecode, 1); | ecode += codelink; |
| 1073 | } | } |
| 1074 | } | } |
| 1075 | ||
| # | Line 852 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 | /* Before OP_ACCEPT there may be any number of OP_CLOSE opcodes, | |
| 1103 | 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 | /* 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 | recursion, we should restore the offsets appropriately and continue from |
| 1128 | after the call. */ | after the call. */ |
| # | Line 872 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); | |
| 1162 | /* For some reason, the macros don't work properly if an expression is | |
| 1163 | given as the argument to MRRETURN when the heap is in use. */ | |
| 1164 | ||
| 1165 | rrc = (op == OP_END)? MATCH_MATCH : MATCH_ACCEPT; | |
| 1166 | MRRETURN(rrc); | |
| 1167 | ||
| 1168 | /* Change option settings */ | /* Change option settings */ |
| 1169 | ||
| # | Line 907 for (;;) | Line 1185 for (;;) |
| 1185 | { | { |
| 1186 | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0, | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0, |
| 1187 | RM4); | RM4); |
| 1188 | if (rrc == MATCH_MATCH) break; | if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) |
| 1189 | { | |
| 1190 | mstart = md->start_match_ptr; /* In case \K reset it */ | |
| 1191 | break; | |
| 1192 | } | |
| 1193 | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); |
| 1194 | ecode += GET(ecode, 1); | ecode += GET(ecode, 1); |
| 1195 | } | } |
| 1196 | while (*ecode == OP_ALT); | while (*ecode == OP_ALT); |
| 1197 | if (*ecode == OP_KET) RRETURN(MATCH_NOMATCH); | if (*ecode == OP_KET) MRRETURN(MATCH_NOMATCH); |
| 1198 | ||
| 1199 | /* If checking an assertion for a condition, return MATCH_MATCH. */ | /* If checking an assertion for a condition, return MATCH_MATCH. */ |
| 1200 | ||
| # | Line 926 for (;;) | Line 1208 for (;;) |
| 1208 | offset_top = md->end_offset_top; | offset_top = md->end_offset_top; |
| 1209 | continue; | continue; |
| 1210 | ||
| 1211 | /* Negative assertion: all branches must fail to match */ | /* Negative assertion: all branches must fail to match. Encountering SKIP, |
| 1212 | PRUNE, or COMMIT means we must assume failure without checking subsequent | |
| 1213 | branches. */ | |
| 1214 | ||
| 1215 | case OP_ASSERT_NOT: | case OP_ASSERT_NOT: |
| 1216 | case OP_ASSERTBACK_NOT: | case OP_ASSERTBACK_NOT: |
| # | Line 934 for (;;) | Line 1218 for (;;) |
| 1218 | { | { |
| 1219 | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0, | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0, |
| 1220 | RM5); | RM5); |
| 1221 | if (rrc == MATCH_MATCH) RRETURN(MATCH_NOMATCH); | if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) MRRETURN(MATCH_NOMATCH); |
| 1222 | if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT) | |
| 1223 | { | |
| 1224 | do ecode += GET(ecode,1); while (*ecode == OP_ALT); | |
| 1225 | break; | |
| 1226 | } | |
| 1227 | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); |
| 1228 | ecode += GET(ecode,1); | ecode += GET(ecode,1); |
| 1229 | } | } |
| # | Line 958 for (;;) | Line 1247 for (;;) |
| 1247 | while (i-- > 0) | while (i-- > 0) |
| 1248 | { | { |
| 1249 | eptr--; | eptr--; |
| 1250 | if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH); | if (eptr < md->start_subject) MRRETURN(MATCH_NOMATCH); |
| 1251 | BACKCHAR(eptr); | BACKCHAR(eptr); |
| 1252 | } | } |
| 1253 | } | } |
| # | Line 969 for (;;) | Line 1258 for (;;) |
| 1258 | ||
| 1259 | { | { |
| 1260 | eptr -= GET(ecode, 1); | eptr -= GET(ecode, 1); |
| 1261 | if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH); | if (eptr < md->start_subject) MRRETURN(MATCH_NOMATCH); |
| 1262 | } | } |
| 1263 | ||
| 1264 | /* Skip to next op code */ | /* Save the earliest consulted character, then skip to next op code */ |
| 1265 | ||
| 1266 | if (eptr < md->start_used_ptr) md->start_used_ptr = eptr; | |
| 1267 | ecode += 1 + LINK_SIZE; | ecode += 1 + LINK_SIZE; |
| 1268 | break; | break; |
| 1269 | ||
| # | Line 997 for (;;) | Line 1287 for (;;) |
| 1287 | cb.capture_top = offset_top/2; | cb.capture_top = offset_top/2; |
| 1288 | cb.capture_last = md->capture_last; | cb.capture_last = md->capture_last; |
| 1289 | cb.callout_data = md->callout_data; | cb.callout_data = md->callout_data; |
| 1290 | if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH); | if ((rrc = (*pcre_callout)(&cb)) > 0) MRRETURN(MATCH_NOMATCH); |
| 1291 | if (rrc < 0) RRETURN(rrc); | if (rrc < 0) RRETURN(rrc); |
| 1292 | } | } |
| 1293 | ecode += 2 + 2*LINK_SIZE; | ecode += 2 + 2*LINK_SIZE; |
| # | Line 1052 for (;;) | Line 1342 for (;;) |
| 1342 | ||
| 1343 | memcpy(new_recursive.offset_save, md->offset_vector, | memcpy(new_recursive.offset_save, md->offset_vector, |
| 1344 | new_recursive.saved_max * sizeof(int)); | new_recursive.saved_max * sizeof(int)); |
| 1345 | new_recursive.save_start = mstart; | new_recursive.save_offset_top = offset_top; |
| mstart = eptr; | ||
| 1346 | ||
| 1347 | /* 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 |
| 1348 | restore the offset and recursion data. */ | restore the offset and recursion data. */ |
| # | Line 1064 for (;;) | Line 1353 for (;;) |
| 1353 | { | { |
| 1354 | RMATCH(eptr, callpat + _pcre_OP_lengths[*callpat], offset_top, | RMATCH(eptr, callpat + _pcre_OP_lengths[*callpat], offset_top, |
| 1355 | md, ims, eptrb, flags, RM6); | md, ims, eptrb, flags, RM6); |
| 1356 | if (rrc == MATCH_MATCH) | if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) |
| 1357 | { | { |
| 1358 | DPRINTF(("Recursion matched\n")); | DPRINTF(("Recursion matched\n")); |
| 1359 | md->recursive = new_recursive.prevrec; | md->recursive = new_recursive.prevrec; |
| 1360 | if (new_recursive.offset_save != stacksave) | if (new_recursive.offset_save != stacksave) |
| 1361 | (pcre_free)(new_recursive.offset_save); | (pcre_free)(new_recursive.offset_save); |
| 1362 | RRETURN(MATCH_MATCH); | MRRETURN(MATCH_MATCH); |
| 1363 | } | } |
| 1364 | else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) | else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) |
| 1365 | { | { |
| 1366 | DPRINTF(("Recursion gave error %d\n", rrc)); | DPRINTF(("Recursion gave error %d\n", rrc)); |
| 1367 | if (new_recursive.offset_save != stacksave) | |
| 1368 | (pcre_free)(new_recursive.offset_save); | |
| 1369 | RRETURN(rrc); | RRETURN(rrc); |
| 1370 | } | } |
| 1371 | ||
| # | Line 1089 for (;;) | Line 1380 for (;;) |
| 1380 | md->recursive = new_recursive.prevrec; | md->recursive = new_recursive.prevrec; |
| 1381 | if (new_recursive.offset_save != stacksave) | if (new_recursive.offset_save != stacksave) |
| 1382 | (pcre_free)(new_recursive.offset_save); | (pcre_free)(new_recursive.offset_save); |
| 1383 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1384 | } | } |
| 1385 | /* Control never reaches here */ | /* Control never reaches here */ |
| 1386 | ||
| # | Line 1098 for (;;) | Line 1389 for (;;) |
| 1389 | a move back into the brackets. Friedl calls these "atomic" subpatterns. | a move back into the brackets. Friedl calls these "atomic" subpatterns. |
| 1390 | 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 |
| 1391 | 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 |
| 1392 | the end of a normal bracket, leaving the subject pointer. */ | the end of a normal bracket, leaving the subject pointer, but resetting |
| 1393 | the start-of-match value in case it was changed by \K. */ | |
| 1394 | ||
| 1395 | case OP_ONCE: | case OP_ONCE: |
| 1396 | prev = ecode; | prev = ecode; |
| # | Line 1107 for (;;) | Line 1399 for (;;) |
| 1399 | do | do |
| 1400 | { | { |
| 1401 | 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); |
| 1402 | if (rrc == MATCH_MATCH) break; | if (rrc == MATCH_MATCH) /* Note: _not_ MATCH_ACCEPT */ |
| 1403 | { | |
| 1404 | mstart = md->start_match_ptr; | |
| 1405 | break; | |
| 1406 | } | |
| 1407 | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); |
| 1408 | ecode += GET(ecode,1); | ecode += GET(ecode,1); |
| 1409 | } | } |
| # | Line 1226 for (;;) | Line 1522 for (;;) |
| 1522 | } | } |
| 1523 | else saved_eptr = NULL; | else saved_eptr = NULL; |
| 1524 | ||
| 1525 | /* 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 |
| 1526 | 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 |
| 1527 | assertions. Do this also for the "once" (atomic) groups. */ | use by positive assertions. We also need to record the match start in case |
| 1528 | it was changed by \K. */ | |
| 1529 | ||
| 1530 | if (*prev == OP_ASSERT || *prev == OP_ASSERT_NOT || | if (*prev == OP_ASSERT || *prev == OP_ASSERT_NOT || |
| 1531 | *prev == OP_ASSERTBACK || *prev == OP_ASSERTBACK_NOT || | *prev == OP_ASSERTBACK || *prev == OP_ASSERTBACK_NOT || |
| # | Line 1236 for (;;) | Line 1533 for (;;) |
| 1533 | { | { |
| 1534 | md->end_match_ptr = eptr; /* For ONCE */ | md->end_match_ptr = eptr; /* For ONCE */ |
| 1535 | md->end_offset_top = offset_top; | md->end_offset_top = offset_top; |
| 1536 | RRETURN(MATCH_MATCH); | md->start_match_ptr = mstart; |
| 1537 | MRRETURN(MATCH_MATCH); | |
| 1538 | } | } |
| 1539 | ||
| 1540 | /* 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 1250 for (;;) | Line 1548 for (;;) |
| 1548 | number = GET2(prev, 1+LINK_SIZE); | number = GET2(prev, 1+LINK_SIZE); |
| 1549 | offset = number << 1; | offset = number << 1; |
| 1550 | ||
| 1551 | #ifdef DEBUG | #ifdef PCRE_DEBUG |
| 1552 | printf("end bracket %d", number); | printf("end bracket %d", number); |
| 1553 | printf("\n"); | printf("\n"); |
| 1554 | #endif | #endif |
| # | Line 1272 for (;;) | Line 1570 for (;;) |
| 1570 | recursion_info *rec = md->recursive; | recursion_info *rec = md->recursive; |
| 1571 | DPRINTF(("Recursion (%d) succeeded - continuing\n", number)); | DPRINTF(("Recursion (%d) succeeded - continuing\n", number)); |
| 1572 | md->recursive = rec->prevrec; | md->recursive = rec->prevrec; |
| mstart = rec->save_start; | ||
| 1573 | memcpy(md->offset_vector, rec->offset_save, | memcpy(md->offset_vector, rec->offset_save, |
| 1574 | rec->saved_max * sizeof(int)); | rec->saved_max * sizeof(int)); |
| 1575 | offset_top = rec->save_offset_top; | |
| 1576 | ecode = rec->after_call; | ecode = rec->after_call; |
| 1577 | ims = original_ims; | ims = original_ims; |
| 1578 | break; | break; |
| # | Line 1331 for (;;) | Line 1629 for (;;) |
| 1629 | /* Start of subject unless notbol, or after internal newline if multiline */ | /* Start of subject unless notbol, or after internal newline if multiline */ |
| 1630 | ||
| 1631 | case OP_CIRC: | case OP_CIRC: |
| 1632 | if (md->notbol && eptr == md->start_subject) RRETURN(MATCH_NOMATCH); | if (md->notbol && eptr == md->start_subject) MRRETURN(MATCH_NOMATCH); |
| 1633 | if ((ims & PCRE_MULTILINE) != 0) | if ((ims & PCRE_MULTILINE) != 0) |
| 1634 | { | { |
| 1635 | if (eptr != md->start_subject && | if (eptr != md->start_subject && |
| 1636 | (eptr == md->end_subject || !WAS_NEWLINE(eptr))) | (eptr == md->end_subject || !WAS_NEWLINE(eptr))) |
| 1637 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1638 | ecode++; | ecode++; |
| 1639 | break; | break; |
| 1640 | } | } |
| # | Line 1345 for (;;) | Line 1643 for (;;) |
| 1643 | /* Start of subject assertion */ | /* Start of subject assertion */ |
| 1644 | ||
| 1645 | case OP_SOD: | case OP_SOD: |
| 1646 | if (eptr != md->start_subject) RRETURN(MATCH_NOMATCH); | if (eptr != md->start_subject) MRRETURN(MATCH_NOMATCH); |
| 1647 | ecode++; | ecode++; |
| 1648 | break; | break; |
| 1649 | ||
| 1650 | /* Start of match assertion */ | /* Start of match assertion */ |
| 1651 | ||
| 1652 | case OP_SOM: | case OP_SOM: |
| 1653 | if (eptr != md->start_subject + md->start_offset) RRETURN(MATCH_NOMATCH); | if (eptr != md->start_subject + md->start_offset) MRRETURN(MATCH_NOMATCH); |
| 1654 | ecode++; | ecode++; |
| 1655 | break; | break; |
| 1656 | ||
| # | Line 1370 for (;;) | Line 1668 for (;;) |
| 1668 | if ((ims & PCRE_MULTILINE) != 0) | if ((ims & PCRE_MULTILINE) != 0) |
| 1669 | { | { |
| 1670 | if (eptr < md->end_subject) | if (eptr < md->end_subject) |
| 1671 | { if (!IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); } | { if (!IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH); } |
| 1672 | else | else |
| 1673 | { if (md->noteol) RRETURN(MATCH_NOMATCH); } | { if (md->noteol) MRRETURN(MATCH_NOMATCH); } |
| 1674 | ecode++; | ecode++; |
| 1675 | break; | break; |
| 1676 | } | } |
| 1677 | else | else |
| 1678 | { | { |
| 1679 | if (md->noteol) RRETURN(MATCH_NOMATCH); | if (md->noteol) MRRETURN(MATCH_NOMATCH); |
| 1680 | if (!md->endonly) | if (!md->endonly) |
| 1681 | { | { |
| 1682 | if (eptr != md->end_subject && | if (eptr != md->end_subject && |
| 1683 | (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen)) | (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen)) |
| 1684 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1685 | ecode++; | ecode++; |
| 1686 | break; | break; |
| 1687 | } | } |
| # | Line 1393 for (;;) | Line 1691 for (;;) |
| 1691 | /* End of subject assertion (\z) */ | /* End of subject assertion (\z) */ |
| 1692 | ||
| 1693 | case OP_EOD: | case OP_EOD: |
| 1694 | if (eptr < md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr < md->end_subject) MRRETURN(MATCH_NOMATCH); |
| 1695 | ecode++; | ecode++; |
| 1696 | break; | break; |
| 1697 | ||
| # | Line 1402 for (;;) | Line 1700 for (;;) |
| 1700 | case OP_EODN: | case OP_EODN: |
| 1701 | if (eptr != md->end_subject && | if (eptr != md->end_subject && |
| 1702 | (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen)) | (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen)) |
| 1703 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1704 | ecode++; | ecode++; |
| 1705 | break; | break; |
| 1706 | ||
| # | Line 1414 for (;;) | Line 1712 for (;;) |
| 1712 | ||
| 1713 | /* Find out if the previous and current characters are "word" characters. | /* Find out if the previous and current characters are "word" characters. |
| 1714 | 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 |
| 1715 | be "non-word" characters. */ | be "non-word" characters. Remember the earliest consulted character for |
| 1716 | partial matching. */ | |
| 1717 | ||
| 1718 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| 1719 | if (utf8) | if (utf8) |
| 1720 | { | { |
| 1721 | if (eptr == md->start_subject) prev_is_word = FALSE; else | if (eptr == md->start_subject) prev_is_word = FALSE; else |
| 1722 | { | { |
| 1723 | const uschar *lastptr = eptr - 1; | USPTR lastptr = eptr - 1; |
| 1724 | while((*lastptr & 0xc0) == 0x80) lastptr--; | while((*lastptr & 0xc0) == 0x80) lastptr--; |
| 1725 | if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr; | |
| 1726 | GETCHAR(c, lastptr); | GETCHAR(c, lastptr); |
| 1727 | prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; | prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; |
| 1728 | } | } |
| 1729 | if (eptr >= md->end_subject) cur_is_word = FALSE; else | if (eptr >= md->end_subject) |
| 1730 | { | |
| 1731 | SCHECK_PARTIAL(); | |
| 1732 | cur_is_word = FALSE; | |
| 1733 | } | |
| 1734 | else | |
| 1735 | { | { |
| 1736 | GETCHAR(c, eptr); | GETCHAR(c, eptr); |
| 1737 | cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; | cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; |
| # | Line 1435 for (;;) | Line 1740 for (;;) |
| 1740 | else | else |
| 1741 | #endif | #endif |
| 1742 | ||
| 1743 | /* More streamlined when not in UTF-8 mode */ | /* Not in UTF-8 mode */ |
| 1744 | ||
| 1745 | { | { |
| 1746 | prev_is_word = (eptr != md->start_subject) && | if (eptr == md->start_subject) prev_is_word = FALSE; else |
| 1747 | ((md->ctypes[eptr[-1]] & ctype_word) != 0); | { |
| 1748 | cur_is_word = (eptr < md->end_subject) && | if (eptr <= md->start_used_ptr) md->start_used_ptr = eptr - 1; |
| 1749 | ((md->ctypes[*eptr] & ctype_word) != 0); | prev_is_word = ((md->ctypes[eptr[-1]] & ctype_word) != 0); |
| 1750 | } | |
| 1751 | if (eptr >= md->end_subject) | |
| 1752 | { | |
| 1753 | SCHECK_PARTIAL(); | |
| 1754 | cur_is_word = FALSE; | |
| 1755 | } | |
| 1756 | else cur_is_word = ((md->ctypes[*eptr] & ctype_word) != 0); | |
| 1757 | } | } |
| 1758 | ||
| 1759 | /* Now see if the situation is what we want */ | /* Now see if the situation is what we want */ |
| 1760 | ||
| 1761 | if ((*ecode++ == OP_WORD_BOUNDARY)? | if ((*ecode++ == OP_WORD_BOUNDARY)? |
| 1762 | cur_is_word == prev_is_word : cur_is_word != prev_is_word) | cur_is_word == prev_is_word : cur_is_word != prev_is_word) |
| 1763 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1764 | } | } |
| 1765 | break; | break; |
| 1766 | ||
| 1767 | /* Match a single character type; inline for speed */ | /* Match a single character type; inline for speed */ |
| 1768 | ||
| 1769 | case OP_ANY: | case OP_ANY: |
| 1770 | if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); | if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH); |
| 1771 | /* Fall through */ | /* Fall through */ |
| 1772 | ||
| 1773 | case OP_ALLANY: | case OP_ALLANY: |
| 1774 | if (eptr++ >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr++ >= md->end_subject) |
| 1775 | { | |
| 1776 | SCHECK_PARTIAL(); | |
| 1777 | MRRETURN(MATCH_NOMATCH); | |
| 1778 | } | |
| 1779 | if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| 1780 | ecode++; | ecode++; |
| 1781 | break; | break; |
| # | Line 1468 for (;;) | Line 1784 for (;;) |
| 1784 | any byte, even newline, independent of the setting of PCRE_DOTALL. */ | any byte, even newline, independent of the setting of PCRE_DOTALL. */ |
| 1785 | ||
| 1786 | case OP_ANYBYTE: | case OP_ANYBYTE: |
| 1787 | if (eptr++ >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr++ >= md->end_subject) |
| 1788 | { | |
| 1789 | SCHECK_PARTIAL(); | |
| 1790 | MRRETURN(MATCH_NOMATCH); | |
| 1791 | } | |
| 1792 | ecode++; | ecode++; |
| 1793 | break; | break; |
| 1794 | ||
| 1795 | case OP_NOT_DIGIT: | case OP_NOT_DIGIT: |
| 1796 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1797 | { | |
| 1798 | SCHECK_PARTIAL(); | |
| 1799 | MRRETURN(MATCH_NOMATCH); | |
| 1800 | } | |
| 1801 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1802 | if ( | if ( |
| 1803 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| # | Line 1481 for (;;) | Line 1805 for (;;) |
| 1805 | #endif | #endif |
| 1806 | (md->ctypes[c] & ctype_digit) != 0 | (md->ctypes[c] & ctype_digit) != 0 |
| 1807 | ) | ) |
| 1808 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1809 | ecode++; | ecode++; |
| 1810 | break; | break; |
| 1811 | ||
| 1812 | case OP_DIGIT: | case OP_DIGIT: |
| 1813 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1814 | { | |
| 1815 | SCHECK_PARTIAL(); | |
| 1816 | MRRETURN(MATCH_NOMATCH); | |
| 1817 | } | |
| 1818 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1819 | if ( | if ( |
| 1820 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| # | Line 1494 for (;;) | Line 1822 for (;;) |
| 1822 | #endif | #endif |
| 1823 | (md->ctypes[c] & ctype_digit) == 0 | (md->ctypes[c] & ctype_digit) == 0 |
| 1824 | ) | ) |
| 1825 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1826 | ecode++; | ecode++; |
| 1827 | break; | break; |
| 1828 | ||
| 1829 | case OP_NOT_WHITESPACE: | case OP_NOT_WHITESPACE: |
| 1830 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1831 | { | |
| 1832 | SCHECK_PARTIAL(); | |
| 1833 | MRRETURN(MATCH_NOMATCH); | |
| 1834 | } | |
| 1835 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1836 | if ( | if ( |
| 1837 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| # | Line 1507 for (;;) | Line 1839 for (;;) |
| 1839 | #endif | #endif |
| 1840 | (md->ctypes[c] & ctype_space) != 0 | (md->ctypes[c] & ctype_space) != 0 |
| 1841 | ) | ) |
| 1842 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1843 | ecode++; | ecode++; |
| 1844 | break; | break; |
| 1845 | ||
| 1846 | case OP_WHITESPACE: | case OP_WHITESPACE: |
| 1847 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1848 | { | |
| 1849 | SCHECK_PARTIAL(); | |
| 1850 | MRRETURN(MATCH_NOMATCH); | |
| 1851 | } | |
| 1852 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1853 | if ( | if ( |
| 1854 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| # | Line 1520 for (;;) | Line 1856 for (;;) |
| 1856 | #endif | #endif |
| 1857 | (md->ctypes[c] & ctype_space) == 0 | (md->ctypes[c] & ctype_space) == 0 |
| 1858 | ) | ) |
| 1859 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1860 | ecode++; | ecode++; |
| 1861 | break; | break; |
| 1862 | ||
| 1863 | case OP_NOT_WORDCHAR: | case OP_NOT_WORDCHAR: |
| 1864 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1865 | { | |
| 1866 | SCHECK_PARTIAL(); | |
| 1867 | MRRETURN(MATCH_NOMATCH); | |
| 1868 | } | |
| 1869 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1870 | if ( | if ( |
| 1871 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| # | Line 1533 for (;;) | Line 1873 for (;;) |
| 1873 | #endif | #endif |
| 1874 | (md->ctypes[c] & ctype_word) != 0 | (md->ctypes[c] & ctype_word) != 0 |
| 1875 | ) | ) |
| 1876 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1877 | ecode++; | ecode++; |
| 1878 | break; | break; |
| 1879 | ||
| 1880 | case OP_WORDCHAR: | case OP_WORDCHAR: |
| 1881 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1882 | { | |
| 1883 | SCHECK_PARTIAL(); | |
| 1884 | MRRETURN(MATCH_NOMATCH); | |
| 1885 | } | |
| 1886 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1887 | if ( | if ( |
| 1888 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| # | Line 1546 for (;;) | Line 1890 for (;;) |
| 1890 | #endif | #endif |
| 1891 | (md->ctypes[c] & ctype_word) == 0 | (md->ctypes[c] & ctype_word) == 0 |
| 1892 | ) | ) |
| 1893 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1894 | ecode++; | ecode++; |
| 1895 | break; | break; |
| 1896 | ||
| 1897 | case OP_ANYNL: | case OP_ANYNL: |
| 1898 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1899 | { | |
| 1900 | SCHECK_PARTIAL(); | |
| 1901 | MRRETURN(MATCH_NOMATCH); | |
| 1902 | } | |
| 1903 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1904 | switch(c) | switch(c) |
| 1905 | { | { |
| 1906 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 1907 | case 0x000d: | case 0x000d: |
| 1908 | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 1909 | break; | break; |
| # | Line 1568 for (;;) | Line 1916 for (;;) |
| 1916 | case 0x0085: | case 0x0085: |
| 1917 | case 0x2028: | case 0x2028: |
| 1918 | case 0x2029: | case 0x2029: |
| 1919 | if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); | if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH); |
| 1920 | break; | break; |
| 1921 | } | } |
| 1922 | ecode++; | ecode++; |
| 1923 | break; | break; |
| 1924 | ||
| 1925 | case OP_NOT_HSPACE: | case OP_NOT_HSPACE: |
| 1926 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1927 | { | |
| 1928 | SCHECK_PARTIAL(); | |
| 1929 | MRRETURN(MATCH_NOMATCH); | |
| 1930 | } | |
| 1931 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1932 | switch(c) | switch(c) |
| 1933 | { | { |
| # | Line 1599 for (;;) | Line 1951 for (;;) |
| 1951 | case 0x202f: /* NARROW NO-BREAK SPACE */ | case 0x202f: /* NARROW NO-BREAK SPACE */ |
| 1952 | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ |
| 1953 | case 0x3000: /* IDEOGRAPHIC SPACE */ | case 0x3000: /* IDEOGRAPHIC SPACE */ |
| 1954 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1955 | } | } |
| 1956 | ecode++; | ecode++; |
| 1957 | break; | break; |
| 1958 | ||
| 1959 | case OP_HSPACE: | case OP_HSPACE: |
| 1960 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1961 | { | |
| 1962 | SCHECK_PARTIAL(); | |
| 1963 | MRRETURN(MATCH_NOMATCH); | |
| 1964 | } | |
| 1965 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1966 | switch(c) | switch(c) |
| 1967 | { | { |
| 1968 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 1969 | case 0x09: /* HT */ | case 0x09: /* HT */ |
| 1970 | case 0x20: /* SPACE */ | case 0x20: /* SPACE */ |
| 1971 | case 0xa0: /* NBSP */ | case 0xa0: /* NBSP */ |
| # | Line 1635 for (;;) | Line 1991 for (;;) |
| 1991 | break; | break; |
| 1992 | ||
| 1993 | case OP_NOT_VSPACE: | case OP_NOT_VSPACE: |
| 1994 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 1995 | { | |
| 1996 | SCHECK_PARTIAL(); | |
| 1997 | MRRETURN(MATCH_NOMATCH); | |
| 1998 | } | |
| 1999 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2000 | switch(c) | switch(c) |
| 2001 | { | { |
| # | Line 1647 for (;;) | Line 2007 for (;;) |
| 2007 | case 0x85: /* NEL */ | case 0x85: /* NEL */ |
| 2008 | case 0x2028: /* LINE SEPARATOR */ | case 0x2028: /* LINE SEPARATOR */ |
| 2009 | case 0x2029: /* PARAGRAPH SEPARATOR */ | case 0x2029: /* PARAGRAPH SEPARATOR */ |
| 2010 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2011 | } | } |
| 2012 | ecode++; | ecode++; |
| 2013 | break; | break; |
| 2014 | ||
| 2015 | case OP_VSPACE: | case OP_VSPACE: |
| 2016 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 2017 | { | |
| 2018 | SCHECK_PARTIAL(); | |
| 2019 | MRRETURN(MATCH_NOMATCH); | |
| 2020 | } | |
| 2021 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2022 | switch(c) | switch(c) |
| 2023 | { | { |
| 2024 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 2025 | case 0x0a: /* LF */ | case 0x0a: /* LF */ |
| 2026 | case 0x0b: /* VT */ | case 0x0b: /* VT */ |
| 2027 | case 0x0c: /* FF */ | case 0x0c: /* FF */ |
| # | Line 1676 for (;;) | Line 2040 for (;;) |
| 2040 | ||
| 2041 | case OP_PROP: | case OP_PROP: |
| 2042 | case OP_NOTPROP: | case OP_NOTPROP: |
| 2043 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 2044 | { | |
| 2045 | SCHECK_PARTIAL(); | |
| 2046 | MRRETURN(MATCH_NOMATCH); | |
| 2047 | } | |
| 2048 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2049 | { | { |
| 2050 | const ucd_record * prop = GET_UCD(c); | const ucd_record *prop = GET_UCD(c); |
| 2051 | ||
| 2052 | switch(ecode[1]) | switch(ecode[1]) |
| 2053 | { | { |
| 2054 | case PT_ANY: | case PT_ANY: |
| 2055 | if (op == OP_NOTPROP) RRETURN(MATCH_NOMATCH); | if (op == OP_NOTPROP) MRRETURN(MATCH_NOMATCH); |
| 2056 | break; | break; |
| 2057 | ||
| 2058 | case PT_LAMP: | case PT_LAMP: |
| 2059 | if ((prop->chartype == ucp_Lu || | if ((prop->chartype == ucp_Lu || |
| 2060 | prop->chartype == ucp_Ll || | prop->chartype == ucp_Ll || |
| 2061 | prop->chartype == ucp_Lt) == (op == OP_NOTPROP)) | prop->chartype == ucp_Lt) == (op == OP_NOTPROP)) |
| 2062 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2063 | break; | break; |
| 2064 | ||
| 2065 | case PT_GC: | case PT_GC: |
| 2066 | if ((ecode[2] != _pcre_ucp_gentype[prop->chartype]) == (op == OP_PROP)) | if ((ecode[2] != _pcre_ucp_gentype[prop->chartype]) == (op == OP_PROP)) |
| 2067 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2068 | break; | break; |
| 2069 | ||
| 2070 | case PT_PC: | case PT_PC: |
| 2071 | if ((ecode[2] != prop->chartype) == (op == OP_PROP)) | if ((ecode[2] != prop->chartype) == (op == OP_PROP)) |
| 2072 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2073 | break; | break; |
| 2074 | ||
| 2075 | case PT_SC: | case PT_SC: |
| 2076 | if ((ecode[2] != prop->script) == (op == OP_PROP)) | if ((ecode[2] != prop->script) == (op == OP_PROP)) |
| 2077 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2078 | break; | break; |
| 2079 | ||
| 2080 | default: | default: |
| # | Line 1721 for (;;) | Line 2089 for (;;) |
| 2089 | is in the binary; otherwise a compile-time error occurs. */ | is in the binary; otherwise a compile-time error occurs. */ |
| 2090 | ||
| 2091 | case OP_EXTUNI: | case OP_EXTUNI: |
| 2092 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 2093 | { | |
| 2094 | SCHECK_PARTIAL(); | |
| 2095 | MRRETURN(MATCH_NOMATCH); | |
| 2096 | } | |
| 2097 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2098 | { | { |
| 2099 | int category = UCD_CATEGORY(c); | int category = UCD_CATEGORY(c); |
| 2100 | if (category == ucp_M) RRETURN(MATCH_NOMATCH); | if (category == ucp_M) MRRETURN(MATCH_NOMATCH); |
| 2101 | while (eptr < md->end_subject) | while (eptr < md->end_subject) |
| 2102 | { | { |
| 2103 | int len = 1; | int len = 1; |
| # | Line 1801 for (;;) | Line 2173 for (;;) |
| 2173 | break; | break; |
| 2174 | ||
| 2175 | default: /* No repeat follows */ | default: /* No repeat follows */ |
| 2176 | if (!match_ref(offset, eptr, length, md, ims)) RRETURN(MATCH_NOMATCH); | if (!match_ref(offset, eptr, length, md, ims)) |
| 2177 | { | |
| 2178 | CHECK_PARTIAL(); | |
| 2179 | MRRETURN(MATCH_NOMATCH); | |
| 2180 | } | |
| 2181 | eptr += length; | eptr += length; |
| 2182 | continue; /* With the main loop */ | continue; /* With the main loop */ |
| 2183 | } | } |
| # | Line 1817 for (;;) | Line 2193 for (;;) |
| 2193 | ||
| 2194 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 2195 | { | { |
| 2196 | if (!match_ref(offset, eptr, length, md, ims)) RRETURN(MATCH_NOMATCH); | if (!match_ref(offset, eptr, length, md, ims)) |
| 2197 | { | |
| 2198 | CHECK_PARTIAL(); | |
| 2199 | MRRETURN(MATCH_NOMATCH); | |
| 2200 | } | |
| 2201 | eptr += length; | eptr += length; |
| 2202 | } | } |
| 2203 | ||
| # | Line 1834 for (;;) | Line 2214 for (;;) |
| 2214 | { | { |
| 2215 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM14); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM14); |
| 2216 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2217 | if (fi >= max || !match_ref(offset, eptr, length, md, ims)) | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 2218 | RRETURN(MATCH_NOMATCH); | if (!match_ref(offset, eptr, length, md, ims)) |
| 2219 | { | |
| 2220 | CHECK_PARTIAL(); | |
| 2221 | MRRETURN(MATCH_NOMATCH); | |
| 2222 | } | |
| 2223 | eptr += length; | eptr += length; |
| 2224 | } | } |
| 2225 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 1848 for (;;) | Line 2232 for (;;) |
| 2232 | pp = eptr; | pp = eptr; |
| 2233 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 2234 | { | { |
| 2235 | if (!match_ref(offset, eptr, length, md, ims)) break; | if (!match_ref(offset, eptr, length, md, ims)) |
| 2236 | { | |
| 2237 | CHECK_PARTIAL(); | |
| 2238 | break; | |
| 2239 | } | |
| 2240 | eptr += length; | eptr += length; |
| 2241 | } | } |
| 2242 | while (eptr >= pp) | while (eptr >= pp) |
| # | Line 1857 for (;;) | Line 2245 for (;;) |
| 2245 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2246 | eptr -= length; | eptr -= length; |
| 2247 | } | } |
| 2248 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2249 | } | } |
| 2250 | } | } |
| 2251 | /* Control never gets here */ | /* Control never gets here */ |
| 2252 | ||
| 2253 | /* Match a bit-mapped character class, possibly repeatedly. This op code is | /* Match a bit-mapped character class, possibly repeatedly. This op code is |
| 2254 | 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, |
| 2255 | 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 1918 for (;;) | Line 2304 for (;;) |
| 2304 | { | { |
| 2305 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 2306 | { | { |
| 2307 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 2308 | { | |
| 2309 | SCHECK_PARTIAL(); | |
| 2310 | MRRETURN(MATCH_NOMATCH); | |
| 2311 | } | |
| 2312 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 2313 | if (c > 255) | if (c > 255) |
| 2314 | { | { |
| 2315 | if (op == OP_CLASS) RRETURN(MATCH_NOMATCH); | if (op == OP_CLASS) MRRETURN(MATCH_NOMATCH); |
| 2316 | } | } |
| 2317 | else | else |
| 2318 | { | { |
| 2319 | if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH); | if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH); |
| 2320 | } | } |
| 2321 | } | } |
| 2322 | } | } |
| # | Line 1936 for (;;) | Line 2326 for (;;) |
| 2326 | { | { |
| 2327 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 2328 | { | { |
| 2329 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 2330 | { | |
| 2331 | SCHECK_PARTIAL(); | |
| 2332 | MRRETURN(MATCH_NOMATCH); | |
| 2333 | } | |
| 2334 | c = *eptr++; | c = *eptr++; |
| 2335 | if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH); | if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH); |
| 2336 | } | } |
| 2337 | } | } |
| 2338 | ||
| # | Line 1960 for (;;) | Line 2354 for (;;) |
| 2354 | { | { |
| 2355 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM16); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM16); |
| 2356 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2357 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 2358 | if (eptr >= md->end_subject) | |
| 2359 | { | |
| 2360 | SCHECK_PARTIAL(); | |
| 2361 | MRRETURN(MATCH_NOMATCH); | |
| 2362 | } | |
| 2363 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 2364 | if (c > 255) | if (c > 255) |
| 2365 | { | { |
| 2366 | if (op == OP_CLASS) RRETURN(MATCH_NOMATCH); | if (op == OP_CLASS) MRRETURN(MATCH_NOMATCH); |
| 2367 | } | } |
| 2368 | else | else |
| 2369 | { | { |
| 2370 | if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH); | if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH); |
| 2371 | } | } |
| 2372 | } | } |
| 2373 | } | } |
| # | Line 1980 for (;;) | Line 2379 for (;;) |
| 2379 | { | { |
| 2380 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM17); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM17); |
| 2381 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2382 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 2383 | if (eptr >= md->end_subject) | |
| 2384 | { | |
| 2385 | SCHECK_PARTIAL(); | |
| 2386 | MRRETURN(MATCH_NOMATCH); | |
| 2387 | } | |
| 2388 | c = *eptr++; | c = *eptr++; |
| 2389 | if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH); | if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH); |
| 2390 | } | } |
| 2391 | } | } |
| 2392 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 2001 for (;;) | Line 2405 for (;;) |
| 2405 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 2406 | { | { |
| 2407 | int len = 1; | int len = 1; |
| 2408 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 2409 | { | |
| 2410 | SCHECK_PARTIAL(); | |
| 2411 | break; | |
| 2412 | } | |
| 2413 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 2414 | if (c > 255) | if (c > 255) |
| 2415 | { | { |
| # | Line 2027 for (;;) | Line 2435 for (;;) |
| 2435 | { | { |
| 2436 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 2437 | { | { |
| 2438 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 2439 | { | |
| 2440 | SCHECK_PARTIAL(); | |
| 2441 | break; | |
| 2442 | } | |
| 2443 | c = *eptr; | c = *eptr; |
| 2444 | if ((data[c/8] & (1 << (c&7))) == 0) break; | if ((data[c/8] & (1 << (c&7))) == 0) break; |
| 2445 | eptr++; | eptr++; |
| # | Line 2040 for (;;) | Line 2452 for (;;) |
| 2452 | } | } |
| 2453 | } | } |
| 2454 | ||
| 2455 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2456 | } | } |
| 2457 | } | } |
| 2458 | /* Control never gets here */ | /* Control never gets here */ |
| 2459 | ||
| 2460 | ||
| 2461 | /* Match an extended character class. This opcode is encountered only | /* Match an extended character class. This opcode is encountered only |
| 2462 | 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 |
| 2463 | mode, because Unicode properties are supported in non-UTF-8 mode. */ | |
| 2464 | ||
| 2465 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| 2466 | case OP_XCLASS: | case OP_XCLASS: |
| # | Line 2088 for (;;) | Line 2501 for (;;) |
| 2501 | ||
| 2502 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 2503 | { | { |
| 2504 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 2505 | GETCHARINC(c, eptr); | { |
| 2506 | if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH); | SCHECK_PARTIAL(); |
| 2507 | MRRETURN(MATCH_NOMATCH); | |
| 2508 | } | |
| 2509 | GETCHARINCTEST(c, eptr); | |
| 2510 | if (!_pcre_xclass(c, data)) MRRETURN(MATCH_NOMATCH); | |
| 2511 | } | } |
| 2512 | ||
| 2513 | /* 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 2107 for (;;) | Line 2524 for (;;) |
| 2524 | { | { |
| 2525 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM20); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM20); |
| 2526 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2527 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 2528 | GETCHARINC(c, eptr); | if (eptr >= md->end_subject) |
| 2529 | if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH); | { |
| 2530 | SCHECK_PARTIAL(); | |
| 2531 | MRRETURN(MATCH_NOMATCH); | |
| 2532 | } | |
| 2533 | GETCHARINCTEST(c, eptr); | |
| 2534 | if (!_pcre_xclass(c, data)) MRRETURN(MATCH_NOMATCH); | |
| 2535 | } | } |
| 2536 | /* Control never gets here */ | /* Control never gets here */ |
| 2537 | } | } |
| # | Line 2122 for (;;) | Line 2544 for (;;) |
| 2544 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 2545 | { | { |
| 2546 | int len = 1; | int len = 1; |
| 2547 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 2548 | GETCHARLEN(c, eptr, len); | { |
| 2549 | SCHECK_PARTIAL(); | |
| 2550 | break; | |
| 2551 | } | |
| 2552 | GETCHARLENTEST(c, eptr, len); | |
| 2553 | if (!_pcre_xclass(c, data)) break; | if (!_pcre_xclass(c, data)) break; |
| 2554 | eptr += len; | eptr += len; |
| 2555 | } | } |
| # | Line 2134 for (;;) | Line 2560 for (;;) |
| 2560 | if (eptr-- == pp) break; /* Stop if tried at original pos */ | if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 2561 | if (utf8) BACKCHAR(eptr); | if (utf8) BACKCHAR(eptr); |
| 2562 | } | } |
| 2563 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2564 | } | } |
| 2565 | ||
| 2566 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 2150 for (;;) | Line 2576 for (;;) |
| 2576 | length = 1; | length = 1; |
| 2577 | ecode++; | ecode++; |
| 2578 | GETCHARLEN(fc, ecode, length); | GETCHARLEN(fc, ecode, length); |
| 2579 | if (length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH); | if (length > md->end_subject - eptr) |
| 2580 | while (length-- > 0) if (*ecode++ != *eptr++) RRETURN(MATCH_NOMATCH); | { |
| 2581 | CHECK_PARTIAL(); /* Not SCHECK_PARTIAL() */ | |
| 2582 | MRRETURN(MATCH_NOMATCH); | |
| 2583 | } | |
| 2584 | while (length-- > 0) if (*ecode++ != *eptr++) MRRETURN(MATCH_NOMATCH); | |
| 2585 | } | } |
| 2586 | else | else |
| 2587 | #endif | #endif |
| 2588 | ||
| 2589 | /* Non-UTF-8 mode */ | /* Non-UTF-8 mode */ |
| 2590 | { | { |
| 2591 | if (md->end_subject - eptr < 1) RRETURN(MATCH_NOMATCH); | if (md->end_subject - eptr < 1) |
| 2592 | if (ecode[1] != *eptr++) RRETURN(MATCH_NOMATCH); | { |
| 2593 | SCHECK_PARTIAL(); /* This one can use SCHECK_PARTIAL() */ | |
| 2594 | MRRETURN(MATCH_NOMATCH); | |
| 2595 | } | |
| 2596 | if (ecode[1] != *eptr++) MRRETURN(MATCH_NOMATCH); | |
| 2597 | ecode += 2; | ecode += 2; |
| 2598 | } | } |
| 2599 | break; | break; |
| # | Line 2174 for (;;) | Line 2608 for (;;) |
| 2608 | ecode++; | ecode++; |
| 2609 | GETCHARLEN(fc, ecode, length); | GETCHARLEN(fc, ecode, length); |
| 2610 | ||
| 2611 | if (length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH); | if (length > md->end_subject - eptr) |
| 2612 | { | |
| 2613 | CHECK_PARTIAL(); /* Not SCHECK_PARTIAL() */ | |
| 2614 | MRRETURN(MATCH_NOMATCH); | |
| 2615 | } | |
| 2616 | ||
| 2617 | /* 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 |
| 2618 | can use the fast lookup table. */ | can use the fast lookup table. */ |
| 2619 | ||
| 2620 | if (fc < 128) | if (fc < 128) |
| 2621 | { | { |
| 2622 | if (md->lcc[*ecode++] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); | if (md->lcc[*ecode++] != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH); |
| 2623 | } | } |
| 2624 | ||
| 2625 | /* Otherwise we must pick up the subject character */ | /* Otherwise we must pick up the subject character */ |
| # | Line 2200 for (;;) | Line 2638 for (;;) |
| 2638 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 2639 | if (dc != UCD_OTHERCASE(fc)) | if (dc != UCD_OTHERCASE(fc)) |
| 2640 | #endif | #endif |
| 2641 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2642 | } | } |
| 2643 | } | } |
| 2644 | } | } |
| # | Line 2209 for (;;) | Line 2647 for (;;) |
| 2647 | ||
| 2648 | /* Non-UTF-8 mode */ | /* Non-UTF-8 mode */ |
| 2649 | { | { |
| 2650 | if (md->end_subject - eptr < 1) RRETURN(MATCH_NOMATCH); | if (md->end_subject - eptr < 1) |
| 2651 | if (md->lcc[ecode[1]] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); | { |
| 2652 | SCHECK_PARTIAL(); /* This one can use SCHECK_PARTIAL() */ | |
| 2653 | MRRETURN(MATCH_NOMATCH); | |
| 2654 | } | |
| 2655 | if (md->lcc[ecode[1]] != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH); | |
| 2656 | ecode += 2; | ecode += 2; |
| 2657 | } | } |
| 2658 | break; | break; |
| # | Line 2263 for (;;) | Line 2705 for (;;) |
| 2705 | case OP_MINQUERY: | case OP_MINQUERY: |
| 2706 | c = *ecode++ - OP_STAR; | c = *ecode++ - OP_STAR; |
| 2707 | minimize = (c & 1) != 0; | minimize = (c & 1) != 0; |
| 2708 | ||
| 2709 | min = rep_min[c]; /* Pick up values from tables; */ | min = rep_min[c]; /* Pick up values from tables; */ |
| 2710 | max = rep_max[c]; /* zero for max => infinity */ | max = rep_max[c]; /* zero for max => infinity */ |
| 2711 | if (max == 0) max = INT_MAX; | if (max == 0) max = INT_MAX; |
| 2712 | ||
| 2713 | /* 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. */ | ||
| 2714 | ||
| 2715 | REPEATCHAR: | REPEATCHAR: |
| 2716 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| # | Line 2278 for (;;) | Line 2719 for (;;) |
| 2719 | length = 1; | length = 1; |
| 2720 | charptr = ecode; | charptr = ecode; |
| 2721 | GETCHARLEN(fc, ecode, length); | GETCHARLEN(fc, ecode, length); |
| if (min * length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH); | ||
| 2722 | ecode += length; | ecode += length; |
| 2723 | ||
| 2724 | /* Handle multibyte character matching specially here. There is | /* Handle multibyte character matching specially here. There is |
| # | Line 2296 for (;;) | Line 2736 for (;;) |
| 2736 | ||
| 2737 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 2738 | { | { |
| 2739 | if (memcmp(eptr, charptr, length) == 0) eptr += length; | if (eptr <= md->end_subject - length && |
| 2740 | memcmp(eptr, charptr, length) == 0) eptr += length; | |
| 2741 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 2742 | /* Need braces because of following else */ | else if (oclength > 0 && |
| 2743 | else if (oclength == 0) { RRETURN(MATCH_NOMATCH); } | eptr <= md->end_subject - oclength && |
| 2744 | memcmp(eptr, occhars, oclength) == 0) eptr += oclength; | |
| 2745 | #endif /* SUPPORT_UCP */ | |
| 2746 | else | else |
| 2747 | { | { |
| 2748 | if (memcmp(eptr, occhars, oclength) != 0) RRETURN(MATCH_NOMATCH); | CHECK_PARTIAL(); |
| 2749 | eptr += oclength; | MRRETURN(MATCH_NOMATCH); |
| 2750 | } | } |
| #else /* without SUPPORT_UCP */ | ||
| else { RRETURN(MATCH_NOMATCH); } | ||
| #endif /* SUPPORT_UCP */ | ||
| 2751 | } | } |
| 2752 | ||
| 2753 | if (min == max) continue; | if (min == max) continue; |
| # | Line 2318 for (;;) | Line 2758 for (;;) |
| 2758 | { | { |
| 2759 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM22); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM22); |
| 2760 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2761 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 2762 | if (memcmp(eptr, charptr, length) == 0) eptr += length; | if (eptr <= md->end_subject - length && |
| 2763 | memcmp(eptr, charptr, length) == 0) eptr += length; | |
| 2764 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 2765 | /* Need braces because of following else */ | else if (oclength > 0 && |
| 2766 | else if (oclength == 0) { RRETURN(MATCH_NOMATCH); } | eptr <= md->end_subject - oclength && |
| 2767 | memcmp(eptr, occhars, oclength) == 0) eptr += oclength; | |
| 2768 | #endif /* SUPPORT_UCP */ | |
| 2769 | else | else |
| 2770 | { | { |
| 2771 | if (memcmp(eptr, occhars, oclength) != 0) RRETURN(MATCH_NOMATCH); | CHECK_PARTIAL(); |
| 2772 | eptr += oclength; | MRRETURN(MATCH_NOMATCH); |
| 2773 | } | } |
| #else /* without SUPPORT_UCP */ | ||
| else { RRETURN (MATCH_NOMATCH); } | ||
| #endif /* SUPPORT_UCP */ | ||
| 2774 | } | } |
| 2775 | /* Control never gets here */ | /* Control never gets here */ |
| 2776 | } | } |
| # | Line 2340 for (;;) | Line 2780 for (;;) |
| 2780 | pp = eptr; | pp = eptr; |
| 2781 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 2782 | { | { |
| 2783 | if (eptr > md->end_subject - length) break; | if (eptr <= md->end_subject - length && |
| 2784 | if (memcmp(eptr, charptr, length) == 0) eptr += length; | memcmp(eptr, charptr, length) == 0) eptr += length; |
| 2785 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 2786 | else if (oclength == 0) break; | else if (oclength > 0 && |
| 2787 | eptr <= md->end_subject - oclength && | |
| 2788 | memcmp(eptr, occhars, oclength) == 0) eptr += oclength; | |
| 2789 | #endif /* SUPPORT_UCP */ | |
| 2790 | else | else |
| 2791 | { | { |
| 2792 | if (memcmp(eptr, occhars, oclength) != 0) break; | CHECK_PARTIAL(); |
| 2793 | eptr += oclength; | break; |
| 2794 | } | } |
| #else /* without SUPPORT_UCP */ | ||
| else break; | ||
| #endif /* SUPPORT_UCP */ | ||
| 2795 | } | } |
| 2796 | ||
| 2797 | if (possessive) continue; | if (possessive) continue; |
| 2798 | ||
| 2799 | for(;;) | for(;;) |
| 2800 | { | { |
| 2801 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM23); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM23); |
| 2802 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2803 | if (eptr == pp) RRETURN(MATCH_NOMATCH); | if (eptr == pp) { MRRETURN(MATCH_NOMATCH); } |
| 2804 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 2805 | eptr--; | eptr--; |
| 2806 | BACKCHAR(eptr); | BACKCHAR(eptr); |
| 2807 | #else /* without SUPPORT_UCP */ | #else /* without SUPPORT_UCP */ |
| 2808 | eptr -= length; | eptr -= length; |
| 2809 | #endif /* SUPPORT_UCP */ | #endif /* SUPPORT_UCP */ |
| 2810 | } | } |
| 2811 | } | } |
| 2812 | /* Control never gets here */ | /* Control never gets here */ |
| 2813 | } | } |
| # | Line 2379 for (;;) | Line 2820 for (;;) |
| 2820 | #endif /* SUPPORT_UTF8 */ | #endif /* SUPPORT_UTF8 */ |
| 2821 | ||
| 2822 | /* When not in UTF-8 mode, load a single-byte character. */ | /* When not in UTF-8 mode, load a single-byte character. */ |
| 2823 | { | |
| 2824 | if (min > md->end_subject - eptr) RRETURN(MATCH_NOMATCH); | fc = *ecode++; |
| fc = *ecode++; | ||
| } | ||
| 2825 | ||
| 2826 | /* 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 |
| 2827 | 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 2400 for (;;) | Line 2839 for (;;) |
| 2839 | { | { |
| 2840 | fc = md->lcc[fc]; | fc = md->lcc[fc]; |
| 2841 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 2842 | if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); | { |
| 2843 | if (eptr >= md->end_subject) | |
| 2844 | { | |
| 2845 | SCHECK_PARTIAL(); | |
| 2846 | MRRETURN(MATCH_NOMATCH); | |
| 2847 | } | |
| 2848 | if (fc != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH); | |
| 2849 | } | |
| 2850 | if (min == max) continue; | if (min == max) continue; |
| 2851 | if (minimize) | if (minimize) |
| 2852 | { | { |
| # | Line 2408 for (;;) | Line 2854 for (;;) |
| 2854 | { | { |
| 2855 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM24); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM24); |
| 2856 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2857 | if (fi >= max || eptr >= md->end_subject || | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 2858 | fc != md->lcc[*eptr++]) | if (eptr >= md->end_subject) |
| 2859 | RRETURN(MATCH_NOMATCH); | { |
| 2860 | SCHECK_PARTIAL(); | |
| 2861 | MRRETURN(MATCH_NOMATCH); | |
| 2862 | } | |
| 2863 | if (fc != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH); | |
| 2864 | } | } |
| 2865 | /* Control never gets here */ | /* Control never gets here */ |
| 2866 | } | } |
| # | Line 2419 for (;;) | Line 2869 for (;;) |
| 2869 | pp = eptr; | pp = eptr; |
| 2870 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 2871 | { | { |
| 2872 | if (eptr >= md->end_subject || fc != md->lcc[*eptr]) break; | if (eptr >= md->end_subject) |
| 2873 | { | |
| 2874 | SCHECK_PARTIAL(); | |
| 2875 | break; | |
| 2876 | } | |
| 2877 | if (fc != md->lcc[*eptr]) break; | |
| 2878 | eptr++; | eptr++; |
| 2879 | } | } |
| 2880 | ||
| 2881 | if (possessive) continue; | if (possessive) continue; |
| 2882 | ||
| 2883 | while (eptr >= pp) | while (eptr >= pp) |
| 2884 | { | { |
| 2885 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM25); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM25); |
| 2886 | eptr--; | eptr--; |
| 2887 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2888 | } | } |
| 2889 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2890 | } | } |
| 2891 | /* Control never gets here */ | /* Control never gets here */ |
| 2892 | } | } |
| # | Line 2438 for (;;) | Line 2895 for (;;) |
| 2895 | ||
| 2896 | else | else |
| 2897 | { | { |
| 2898 | for (i = 1; i <= min; i++) if (fc != *eptr++) RRETURN(MATCH_NOMATCH); | for (i = 1; i <= min; i++) |
| 2899 | { | |
| 2900 | if (eptr >= md->end_subject) | |
| 2901 | { | |
| 2902 | SCHECK_PARTIAL(); | |
| 2903 | MRRETURN(MATCH_NOMATCH); | |
| 2904 | } | |
| 2905 | if (fc != *eptr++) MRRETURN(MATCH_NOMATCH); | |
| 2906 | } | |
| 2907 | ||
| 2908 | if (min == max) continue; | if (min == max) continue; |
| 2909 | ||
| 2910 | if (minimize) | if (minimize) |
| 2911 | { | { |
| 2912 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 2913 | { | { |
| 2914 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM26); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM26); |
| 2915 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2916 | if (fi >= max || eptr >= md->end_subject || fc != *eptr++) | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 2917 | RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 2918 | { | |
| 2919 | SCHECK_PARTIAL(); | |
| 2920 | MRRETURN(MATCH_NOMATCH); | |
| 2921 | } | |
| 2922 | if (fc != *eptr++) MRRETURN(MATCH_NOMATCH); | |
| 2923 | } | } |
| 2924 | /* Control never gets here */ | /* Control never gets here */ |
| 2925 | } | } |
| # | Line 2456 for (;;) | Line 2928 for (;;) |
| 2928 | pp = eptr; | pp = eptr; |
| 2929 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 2930 | { | { |
| 2931 | if (eptr >= md->end_subject || fc != *eptr) break; | if (eptr >= md->end_subject) |
| 2932 | eptr++; | { |
| 2933 | SCHECK_PARTIAL(); | |
| 2934 | break; | |
| 2935 | } | |
| 2936 | if (fc != *eptr) break; | |
| 2937 | eptr++; | |
| 2938 | } | } |
| 2939 | if (possessive) continue; | if (possessive) continue; |
| 2940 | ||
| 2941 | while (eptr >= pp) | while (eptr >= pp) |
| 2942 | { | { |
| 2943 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM27); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM27); |
| 2944 | eptr--; | eptr--; |
| 2945 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2946 | } | } |
| 2947 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2948 | } | } |
| 2949 | } | } |
| 2950 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 2475 for (;;) | Line 2953 for (;;) |
| 2953 | checking can be multibyte. */ | checking can be multibyte. */ |
| 2954 | ||
| 2955 | case OP_NOT: | case OP_NOT: |
| 2956 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 2957 | { | |
| 2958 | SCHECK_PARTIAL(); | |
| 2959 | MRRETURN(MATCH_NOMATCH); | |
| 2960 | } | |
| 2961 | ecode++; | ecode++; |
| 2962 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2963 | if ((ims & PCRE_CASELESS) != 0) | if ((ims & PCRE_CASELESS) != 0) |
| # | Line 2484 for (;;) | Line 2966 for (;;) |
| 2966 | if (c < 256) | if (c < 256) |
| 2967 | #endif | #endif |
| 2968 | c = md->lcc[c]; | c = md->lcc[c]; |
| 2969 | if (md->lcc[*ecode++] == c) RRETURN(MATCH_NOMATCH); | if (md->lcc[*ecode++] == c) MRRETURN(MATCH_NOMATCH); |
| 2970 | } | } |
| 2971 | else | else |
| 2972 | { | { |
| 2973 | if (*ecode++ == c) RRETURN(MATCH_NOMATCH); | if (*ecode++ == c) MRRETURN(MATCH_NOMATCH); |
| 2974 | } | } |
| 2975 | break; | break; |
| 2976 | ||
| # | Line 2552 for (;;) | Line 3034 for (;;) |
| 3034 | max = rep_max[c]; /* zero for max => infinity */ | max = rep_max[c]; /* zero for max => infinity */ |
| 3035 | if (max == 0) max = INT_MAX; | if (max == 0) max = INT_MAX; |
| 3036 | ||
| 3037 | /* 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. */ | ||
| 3038 | ||
| 3039 | REPEATNOTCHAR: | REPEATNOTCHAR: |
| if (min > md->end_subject - eptr) RRETURN(MATCH_NOMATCH); | ||
| 3040 | fc = *ecode++; | fc = *ecode++; |
| 3041 | ||
| 3042 | /* 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 2582 for (;;) | Line 3061 for (;;) |
| 3061 | register unsigned int d; | register unsigned int d; |
| 3062 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3063 | { | { |
| 3064 | if (eptr >= md->end_subject) | |
| 3065 | { | |
| 3066 | SCHECK_PARTIAL(); | |
| 3067 | MRRETURN(MATCH_NOMATCH); | |
| 3068 | } | |
| 3069 | GETCHARINC(d, eptr); | GETCHARINC(d, eptr); |
| 3070 | if (d < 256) d = md->lcc[d]; | if (d < 256) d = md->lcc[d]; |
| 3071 | if (fc == d) RRETURN(MATCH_NOMATCH); | if (fc == d) MRRETURN(MATCH_NOMATCH); |
| 3072 | } | } |
| 3073 | } | } |
| 3074 | else | else |
| # | Line 2593 for (;;) | Line 3077 for (;;) |
| 3077 | /* Not UTF-8 mode */ | /* Not UTF-8 mode */ |
| 3078 | { | { |
| 3079 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3080 | if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); | { |
| 3081 | if (eptr >= md->end_subject) | |
| 3082 | { | |
| 3083 | SCHECK_PARTIAL(); | |
| 3084 | MRRETURN(MATCH_NOMATCH); | |
| 3085 | } | |
| 3086 | if (fc == md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH); | |
| 3087 | } | |
| 3088 | } | } |
| 3089 | ||
| 3090 | if (min == max) continue; | if (min == max) continue; |
| # | Line 2609 for (;;) | Line 3100 for (;;) |
| 3100 | { | { |
| 3101 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM28); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM28); |
| 3102 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3103 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 3104 | if (eptr >= md->end_subject) | |
| 3105 | { | |
| 3106 | SCHECK_PARTIAL(); | |
| 3107 | MRRETURN(MATCH_NOMATCH); | |
| 3108 | } | |
| 3109 | GETCHARINC(d, eptr); | GETCHARINC(d, eptr); |
| 3110 | if (d < 256) d = md->lcc[d]; | if (d < 256) d = md->lcc[d]; |
| 3111 | if (fc == d) RRETURN(MATCH_NOMATCH); | if (fc == d) MRRETURN(MATCH_NOMATCH); |
| 3112 | } | } |
| 3113 | } | } |
| 3114 | else | else |
| # | Line 2624 for (;;) | Line 3119 for (;;) |
| 3119 | { | { |
| 3120 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM29); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM29); |
| 3121 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3122 | if (fi >= max || eptr >= md->end_subject || fc == md->lcc[*eptr++]) | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 3123 | RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3124 | { | |
| 3125 | SCHECK_PARTIAL(); | |
| 3126 | MRRETURN(MATCH_NOMATCH); | |
| 3127 | } | |
| 3128 | if (fc == md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH); | |
| 3129 | } | } |
| 3130 | } | } |
| 3131 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 2645 for (;;) | Line 3145 for (;;) |
| 3145 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 3146 | { | { |
| 3147 | int len = 1; | int len = 1; |
| 3148 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 3149 | { | |
| 3150 | SCHECK_PARTIAL(); | |
| 3151 | break; | |
| 3152 | } | |
| 3153 | GETCHARLEN(d, eptr, len); | GETCHARLEN(d, eptr, len); |
| 3154 | if (d < 256) d = md->lcc[d]; | if (d < 256) d = md->lcc[d]; |
| 3155 | if (fc == d) break; | if (fc == d) break; |
| # | Line 2666 for (;;) | Line 3170 for (;;) |
| 3170 | { | { |
| 3171 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 3172 | { | { |
| 3173 | if (eptr >= md->end_subject || fc == md->lcc[*eptr]) break; | if (eptr >= md->end_subject) |
| 3174 | { | |
| 3175 | SCHECK_PARTIAL(); | |
| 3176 | break; | |
| 3177 | } | |
| 3178 | if (fc == md->lcc[*eptr]) break; | |
| 3179 | eptr++; | eptr++; |
| 3180 | } | } |
| 3181 | if (possessive) continue; | if (possessive) continue; |
| # | Line 2678 for (;;) | Line 3187 for (;;) |
| 3187 | } | } |
| 3188 | } | } |
| 3189 | ||
| 3190 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3191 | } | } |
| 3192 | /* Control never gets here */ | /* Control never gets here */ |
| 3193 | } | } |
| # | Line 2694 for (;;) | Line 3203 for (;;) |
| 3203 | register unsigned int d; | register unsigned int d; |
| 3204 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3205 | { | { |
| 3206 | if (eptr >= md->end_subject) | |
| 3207 | { | |
| 3208 | SCHECK_PARTIAL(); | |
| 3209 | MRRETURN(MATCH_NOMATCH); | |
| 3210 | } | |
| 3211 | GETCHARINC(d, eptr); | GETCHARINC(d, eptr); |
| 3212 | if (fc == d) RRETURN(MATCH_NOMATCH); | if (fc == d) MRRETURN(MATCH_NOMATCH); |
| 3213 | } | } |
| 3214 | } | } |
| 3215 | else | else |
| # | Line 2703 for (;;) | Line 3217 for (;;) |
| 3217 | /* Not UTF-8 mode */ | /* Not UTF-8 mode */ |
| 3218 | { | { |
| 3219 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3220 | if (fc == *eptr++) RRETURN(MATCH_NOMATCH); | { |
| 3221 | if (eptr >= md->end_subject) | |
| 3222 | { | |
| 3223 | SCHECK_PARTIAL(); | |
| 3224 | MRRETURN(MATCH_NOMATCH); | |
| 3225 | } | |
| 3226 | if (fc == *eptr++) MRRETURN(MATCH_NOMATCH); | |
| 3227 | } | |
| 3228 | } | } |
| 3229 | ||
| 3230 | if (min == max) continue; | if (min == max) continue; |
| # | Line 2719 for (;;) | Line 3240 for (;;) |
| 3240 | { | { |
| 3241 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM32); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM32); |
| 3242 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3243 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 3244 | if (eptr >= md->end_subject) | |
| 3245 | { | |
| 3246 | SCHECK_PARTIAL(); | |
| 3247 | MRRETURN(MATCH_NOMATCH); | |
| 3248 | } | |
| 3249 | GETCHARINC(d, eptr); | GETCHARINC(d, eptr); |
| 3250 | if (fc == d) RRETURN(MATCH_NOMATCH); | if (fc == d) MRRETURN(MATCH_NOMATCH); |
| 3251 | } | } |
| 3252 | } | } |
| 3253 | else | else |
| # | Line 2732 for (;;) | Line 3258 for (;;) |
| 3258 | { | { |
| 3259 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM33); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM33); |
| 3260 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3261 | if (fi >= max || eptr >= md->end_subject || fc == *eptr++) | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 3262 | RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3263 | { | |
| 3264 | SCHECK_PARTIAL(); | |
| 3265 | MRRETURN(MATCH_NOMATCH); | |
| 3266 | } | |
| 3267 | if (fc == *eptr++) MRRETURN(MATCH_NOMATCH); | |
| 3268 | } | } |
| 3269 | } | } |
| 3270 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 2753 for (;;) | Line 3284 for (;;) |
| 3284 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 3285 | { | { |
| 3286 | int len = 1; | int len = 1; |
| 3287 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 3288 | { | |
| 3289 | SCHECK_PARTIAL(); | |
| 3290 | break; | |
| 3291 | } | |
| 3292 | GETCHARLEN(d, eptr, len); | GETCHARLEN(d, eptr, len); |
| 3293 | if (fc == d) break; | if (fc == d) break; |
| 3294 | eptr += len; | eptr += len; |
| # | Line 2773 for (;;) | Line 3308 for (;;) |
| 3308 | { | { |
| 3309 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 3310 | { | { |
| 3311 | if (eptr >= md->end_subject || fc == *eptr) break; | if (eptr >= md->end_subject) |
| 3312 | { | |
| 3313 | SCHECK_PARTIAL(); | |
| 3314 | break; | |
| 3315 | } | |
| 3316 | if (fc == *eptr) break; | |
| 3317 | eptr++; | eptr++; |
| 3318 | } | } |
| 3319 | if (possessive) continue; | if (possessive) continue; |
| # | Line 2785 for (;;) | Line 3325 for (;;) |
| 3325 | } | } |
| 3326 | } | } |
| 3327 | ||
| 3328 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3329 | } | } |
| 3330 | } | } |
| 3331 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 2867 for (;;) | Line 3407 for (;;) |
| 3407 | ||
| 3408 | /* First, ensure the minimum number of matches are present. Use inline | /* First, ensure the minimum number of matches are present. Use inline |
| 3409 | 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 |
| 3410 | (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 | ||
| 3411 | 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 |
| 3412 | and single-bytes. */ | and single-bytes. */ |
| 3413 | ||
| if (min > md->end_subject - eptr) RRETURN(MATCH_NOMATCH); | ||
| 3414 | if (min > 0) | if (min > 0) |
| 3415 | { | { |
| 3416 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| # | Line 2882 for (;;) | Line 3419 for (;;) |
| 3419 | switch(prop_type) | switch(prop_type) |
| 3420 | { | { |
| 3421 | case PT_ANY: | case PT_ANY: |
| 3422 | if (prop_fail_result) RRETURN(MATCH_NOMATCH); | if (prop_fail_result) MRRETURN(MATCH_NOMATCH); |
| 3423 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3424 | { | { |
| 3425 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3426 | { | |
| 3427 | SCHECK_PARTIAL(); | |
| 3428 | MRRETURN(MATCH_NOMATCH); | |
| 3429 | } | |
| 3430 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3431 | } | } |
| 3432 | break; | break; |
| # | Line 2893 for (;;) | Line 3434 for (;;) |
| 3434 | case PT_LAMP: | case PT_LAMP: |
| 3435 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3436 | { | { |
| 3437 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3438 | { | |
| 3439 | SCHECK_PARTIAL(); | |
| 3440 | MRRETURN(MATCH_NOMATCH); | |
| 3441 | } | |
| 3442 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3443 | prop_chartype = UCD_CHARTYPE(c); | prop_chartype = UCD_CHARTYPE(c); |
| 3444 | if ((prop_chartype == ucp_Lu || | if ((prop_chartype == ucp_Lu || |
| 3445 | prop_chartype == ucp_Ll || | prop_chartype == ucp_Ll || |
| 3446 | prop_chartype == ucp_Lt) == prop_fail_result) | prop_chartype == ucp_Lt) == prop_fail_result) |
| 3447 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3448 | } | } |
| 3449 | break; | break; |
| 3450 | ||
| 3451 | case PT_GC: | case PT_GC: |
| 3452 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3453 | { | { |
| 3454 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3455 | { | |
| 3456 | SCHECK_PARTIAL(); | |
| 3457 | MRRETURN(MATCH_NOMATCH); | |
| 3458 | } | |
| 3459 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3460 | prop_category = UCD_CATEGORY(c); | prop_category = UCD_CATEGORY(c); |
| 3461 | if ((prop_category == prop_value) == prop_fail_result) | if ((prop_category == prop_value) == prop_fail_result) |
| 3462 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3463 | } | } |
| 3464 | break; | break; |
| 3465 | ||
| 3466 | case PT_PC: | case PT_PC: |
| 3467 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3468 | { | { |
| 3469 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3470 | { | |
| 3471 | SCHECK_PARTIAL(); | |
| 3472 | MRRETURN(MATCH_NOMATCH); | |
| 3473 | } | |
| 3474 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3475 | prop_chartype = UCD_CHARTYPE(c); | prop_chartype = UCD_CHARTYPE(c); |
| 3476 | if ((prop_chartype == prop_value) == prop_fail_result) | if ((prop_chartype == prop_value) == prop_fail_result) |
| 3477 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3478 | } | } |
| 3479 | break; | break; |
| 3480 | ||
| 3481 | case PT_SC: | case PT_SC: |
| 3482 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3483 | { | { |
| 3484 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3485 | { | |
| 3486 | SCHECK_PARTIAL(); | |
| 3487 | MRRETURN(MATCH_NOMATCH); | |
| 3488 | } | |
| 3489 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3490 | prop_script = UCD_SCRIPT(c); | prop_script = UCD_SCRIPT(c); |
| 3491 | if ((prop_script == prop_value) == prop_fail_result) | if ((prop_script == prop_value) == prop_fail_result) |
| 3492 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3493 | } | } |
| 3494 | break; | break; |
| 3495 | ||
| # | Line 2948 for (;;) | Line 3505 for (;;) |
| 3505 | { | { |
| 3506 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3507 | { | { |
| 3508 | if (eptr >= md->end_subject) | |
| 3509 | { | |
| 3510 | SCHECK_PARTIAL(); | |
| 3511 | MRRETURN(MATCH_NOMATCH); | |
| 3512 | } | |
| 3513 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3514 | prop_category = UCD_CATEGORY(c); | prop_category = UCD_CATEGORY(c); |
| 3515 | if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH); | if (prop_category == ucp_M) MRRETURN(MATCH_NOMATCH); |
| 3516 | while (eptr < md->end_subject) | while (eptr < md->end_subject) |
| 3517 | { | { |
| 3518 | int len = 1; | int len = 1; |
| 3519 | if (!utf8) c = *eptr; else | if (!utf8) c = *eptr; |
| 3520 | { | else { GETCHARLEN(c, eptr, len); } |
| GETCHARLEN(c, eptr, len); | ||
| } | ||
| 3521 | prop_category = UCD_CATEGORY(c); | prop_category = UCD_CATEGORY(c); |
| 3522 | if (prop_category != ucp_M) break; | if (prop_category != ucp_M) break; |
| 3523 | eptr += len; | eptr += len; |
| # | Line 2976 for (;;) | Line 3536 for (;;) |
| 3536 | case OP_ANY: | case OP_ANY: |
| 3537 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3538 | { | { |
| 3539 | if (eptr >= md->end_subject || IS_NEWLINE(eptr)) | if (eptr >= md->end_subject) |
| 3540 | RRETURN(MATCH_NOMATCH); | { |
| 3541 | SCHECK_PARTIAL(); | |
| 3542 | MRRETURN(MATCH_NOMATCH); | |
| 3543 | } | |
| 3544 | if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH); | |
| 3545 | eptr++; | eptr++; |
| 3546 | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| 3547 | } | } |
| # | Line 2986 for (;;) | Line 3550 for (;;) |
| 3550 | case OP_ALLANY: | case OP_ALLANY: |
| 3551 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3552 | { | { |
| 3553 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3554 | { | |
| 3555 | SCHECK_PARTIAL(); | |
| 3556 | MRRETURN(MATCH_NOMATCH); | |
| 3557 | } | |
| 3558 | eptr++; | eptr++; |
| 3559 | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| 3560 | } | } |
| 3561 | break; | break; |
| 3562 | ||
| 3563 | case OP_ANYBYTE: | case OP_ANYBYTE: |
| 3564 | if (eptr > md->end_subject - min) MRRETURN(MATCH_NOMATCH); | |
| 3565 | eptr += min; | eptr += min; |
| 3566 | break; | break; |
| 3567 | ||
| 3568 | case OP_ANYNL: | case OP_ANYNL: |
| 3569 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3570 | { | { |
| 3571 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3572 | { | |
| 3573 | SCHECK_PARTIAL(); | |
| 3574 | MRRETURN(MATCH_NOMATCH); | |
| 3575 | } | |
| 3576 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 3577 | switch(c) | switch(c) |
| 3578 | { | { |
| 3579 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 3580 | case 0x000d: | case 0x000d: |
| 3581 | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 3582 | break; | break; |
| # | Line 3016 for (;;) | Line 3589 for (;;) |
| 3589 | case 0x0085: | case 0x0085: |
| 3590 | case 0x2028: | case 0x2028: |
| 3591 | case 0x2029: | case 0x2029: |
| 3592 | if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); | if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH); |
| 3593 | break; | break; |
| 3594 | } | } |
| 3595 | } | } |
| # | Line 3025 for (;;) | Line 3598 for (;;) |
| 3598 | case OP_NOT_HSPACE: | case OP_NOT_HSPACE: |
| 3599 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3600 | { | { |
| 3601 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3602 | { | |
| 3603 | SCHECK_PARTIAL(); | |
| 3604 | MRRETURN(MATCH_NOMATCH); | |
| 3605 | } | |
| 3606 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 3607 | switch(c) | switch(c) |
| 3608 | { | { |
| # | Line 3049 for (;;) | Line 3626 for (;;) |
| 3626 | case 0x202f: /* NARROW NO-BREAK SPACE */ | case 0x202f: /* NARROW NO-BREAK SPACE */ |
| 3627 | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ |
| 3628 | case 0x3000: /* IDEOGRAPHIC SPACE */ | case 0x3000: /* IDEOGRAPHIC SPACE */ |
| 3629 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3630 | } | } |
| 3631 | } | } |
| 3632 | break; | break; |
| # | Line 3057 for (;;) | Line 3634 for (;;) |
| 3634 | case OP_HSPACE: | case OP_HSPACE: |
| 3635 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3636 | { | { |
| 3637 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3638 | { | |
| 3639 | SCHECK_PARTIAL(); | |
| 3640 | MRRETURN(MATCH_NOMATCH); | |
| 3641 | } | |
| 3642 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 3643 | switch(c) | switch(c) |
| 3644 | { | { |
| 3645 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 3646 | case 0x09: /* HT */ | case 0x09: /* HT */ |
| 3647 | case 0x20: /* SPACE */ | case 0x20: /* SPACE */ |
| 3648 | case 0xa0: /* NBSP */ | case 0xa0: /* NBSP */ |
| # | Line 3089 for (;;) | Line 3670 for (;;) |
| 3670 | case OP_NOT_VSPACE: | case OP_NOT_VSPACE: |
| 3671 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3672 | { | { |
| 3673 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3674 | { | |
| 3675 | SCHECK_PARTIAL(); | |
| 3676 | MRRETURN(MATCH_NOMATCH); | |
| 3677 | } | |
| 3678 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 3679 | switch(c) | switch(c) |
| 3680 | { | { |
| # | Line 3101 for (;;) | Line 3686 for (;;) |
| 3686 | case 0x85: /* NEL */ | case 0x85: /* NEL */ |
| 3687 | case 0x2028: /* LINE SEPARATOR */ | case 0x2028: /* LINE SEPARATOR */ |
| 3688 | case 0x2029: /* PARAGRAPH SEPARATOR */ | case 0x2029: /* PARAGRAPH SEPARATOR */ |
| 3689 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3690 | } | } |
| 3691 | } | } |
| 3692 | break; | break; |
| # | Line 3109 for (;;) | Line 3694 for (;;) |
| 3694 | case OP_VSPACE: | case OP_VSPACE: |
| 3695 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3696 | { | { |
| 3697 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3698 | { | |
| 3699 | SCHECK_PARTIAL(); | |
| 3700 | MRRETURN(MATCH_NOMATCH); | |
| 3701 | } | |
| 3702 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 3703 | switch(c) | switch(c) |
| 3704 | { | { |
| 3705 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 3706 | case 0x0a: /* LF */ | case 0x0a: /* LF */ |
| 3707 | case 0x0b: /* VT */ | case 0x0b: /* VT */ |
| 3708 | case 0x0c: /* FF */ | case 0x0c: /* FF */ |
| # | Line 3129 for (;;) | Line 3718 for (;;) |
| 3718 | case OP_NOT_DIGIT: | case OP_NOT_DIGIT: |
| 3719 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3720 | { | { |
| 3721 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3722 | { | |
| 3723 | SCHECK_PARTIAL(); | |
| 3724 | MRRETURN(MATCH_NOMATCH); | |
| 3725 | } | |
| 3726 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 3727 | if (c < 128 && (md->ctypes[c] & ctype_digit) != 0) | if (c < 128 && (md->ctypes[c] & ctype_digit) != 0) |
| 3728 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3729 | } | } |
| 3730 | break; | break; |
| 3731 | ||
| 3732 | case OP_DIGIT: | case OP_DIGIT: |
| 3733 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3734 | { | { |
| 3735 | if (eptr >= md->end_subject || | if (eptr >= md->end_subject) |
| 3736 | *eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0) | { |
| 3737 | RRETURN(MATCH_NOMATCH); | SCHECK_PARTIAL(); |
| 3738 | MRRETURN(MATCH_NOMATCH); | |
| 3739 | } | |
| 3740 | if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0) | |
| 3741 | MRRETURN(MATCH_NOMATCH); | |
| 3742 | /* 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 */ |
| 3743 | } | } |
| 3744 | break; | break; |
| # | Line 3149 for (;;) | Line 3746 for (;;) |
| 3746 | case OP_NOT_WHITESPACE: | case OP_NOT_WHITESPACE: |
| 3747 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3748 | { | { |
| 3749 | if (eptr >= md->end_subject || | if (eptr >= md->end_subject) |
| 3750 | (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0)) | { |
| 3751 | RRETURN(MATCH_NOMATCH); | SCHECK_PARTIAL(); |
| 3752 | MRRETURN(MATCH_NOMATCH); | |
| 3753 | } | |
| 3754 | if (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0) | |
| 3755 | MRRETURN(MATCH_NOMATCH); | |
| 3756 | while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80); | while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80); |
| 3757 | } | } |
| 3758 | break; | break; |
| # | Line 3159 for (;;) | Line 3760 for (;;) |
| 3760 | case OP_WHITESPACE: | case OP_WHITESPACE: |
| 3761 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3762 | { | { |
| 3763 | if (eptr >= md->end_subject || | if (eptr >= md->end_subject) |
| 3764 | *eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0) | { |
| 3765 | RRETURN(MATCH_NOMATCH); | SCHECK_PARTIAL(); |
| 3766 | MRRETURN(MATCH_NOMATCH); | |
| 3767 | } | |
| 3768 | if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0) | |
| 3769 | MRRETURN(MATCH_NOMATCH); | |
| 3770 | /* 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 */ |
| 3771 | } | } |
| 3772 | break; | break; |
| # | Line 3169 for (;;) | Line 3774 for (;;) |
| 3774 | case OP_NOT_WORDCHAR: | case OP_NOT_WORDCHAR: |
| 3775 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3776 | { | { |
| 3777 | if (eptr >= md->end_subject || | if (eptr >= md->end_subject) |
| 3778 | (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0)) | { |
| 3779 | RRETURN(MATCH_NOMATCH); | SCHECK_PARTIAL(); |
| 3780 | MRRETURN(MATCH_NOMATCH); | |
| 3781 | } | |
| 3782 | if (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0) | |
| 3783 | MRRETURN(MATCH_NOMATCH); | |
| 3784 | while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80); | while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80); |
| 3785 | } | } |
| 3786 | break; | break; |
| # | Line 3179 for (;;) | Line 3788 for (;;) |
| 3788 | case OP_WORDCHAR: | case OP_WORDCHAR: |
| 3789 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3790 | { | { |
| 3791 | if (eptr >= md->end_subject || | if (eptr >= md->end_subject) |
| 3792 | *eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0) | { |
| 3793 | RRETURN(MATCH_NOMATCH); | SCHECK_PARTIAL(); |
| 3794 | MRRETURN(MATCH_NOMATCH); | |
| 3795 | } | |
| 3796 | if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0) | |
| 3797 | MRRETURN(MATCH_NOMATCH); | |
| 3798 | /* 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 */ |
| 3799 | } | } |
| 3800 | break; | break; |
| # | Line 3194 for (;;) | Line 3807 for (;;) |
| 3807 | #endif /* SUPPORT_UTF8 */ | #endif /* SUPPORT_UTF8 */ |
| 3808 | ||
| 3809 | /* 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 |
| 3810 | 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. */ | ||
| 3811 | ||
| 3812 | switch(ctype) | switch(ctype) |
| 3813 | { | { |
| 3814 | case OP_ANY: | case OP_ANY: |
| 3815 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3816 | { | { |
| 3817 | if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3818 | { | |
| 3819 | SCHECK_PARTIAL(); | |
| 3820 | MRRETURN(MATCH_NOMATCH); | |
| 3821 | } | |
| 3822 | if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH); | |
| 3823 | eptr++; | eptr++; |
| 3824 | } | } |
| 3825 | break; | break; |
| 3826 | ||
| 3827 | case OP_ALLANY: | case OP_ALLANY: |
| 3828 | if (eptr > md->end_subject - min) | |
| 3829 | { | |
| 3830 | SCHECK_PARTIAL(); | |
| 3831 | MRRETURN(MATCH_NOMATCH); | |
| 3832 | } | |
| 3833 | eptr += min; | eptr += min; |
| 3834 | break; | break; |
| 3835 | ||
| 3836 | case OP_ANYBYTE: | case OP_ANYBYTE: |
| 3837 | if (eptr > md->end_subject - min) | |
| 3838 | { | |
| 3839 | SCHECK_PARTIAL(); | |
| 3840 | MRRETURN(MATCH_NOMATCH); | |
| 3841 | } | |
| 3842 | eptr += min; | eptr += min; |
| 3843 | break; | break; |
| 3844 | ||
| /* Because of the CRLF case, we can't assume the minimum number of | ||
| bytes are present in this case. */ | ||
| 3845 | case OP_ANYNL: | case OP_ANYNL: |
| 3846 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3847 | { | { |
| 3848 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3849 | { | |
| 3850 | SCHECK_PARTIAL(); | |
| 3851 | MRRETURN(MATCH_NOMATCH); | |
| 3852 | } | |
| 3853 | switch(*eptr++) | switch(*eptr++) |
| 3854 | { | { |
| 3855 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 3856 | case 0x000d: | case 0x000d: |
| 3857 | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 3858 | break; | break; |
| # | Line 3234 for (;;) | Line 3862 for (;;) |
| 3862 | case 0x000b: | case 0x000b: |
| 3863 | case 0x000c: | case 0x000c: |
| 3864 | case 0x0085: | case 0x0085: |
| 3865 | if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); | if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH); |
| 3866 | break; | break; |
| 3867 | } | } |
| 3868 | } | } |
| # | Line 3243 for (;;) | Line 3871 for (;;) |
| 3871 | case OP_NOT_HSPACE: | case OP_NOT_HSPACE: |
| 3872 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3873 | { | { |
| 3874 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3875 | { | |
| 3876 | SCHECK_PARTIAL(); | |
| 3877 | MRRETURN(MATCH_NOMATCH); | |
| 3878 | } | |
| 3879 | switch(*eptr++) | switch(*eptr++) |
| 3880 | { | { |
| 3881 | default: break; | default: break; |
| 3882 | case 0x09: /* HT */ | case 0x09: /* HT */ |
| 3883 | case 0x20: /* SPACE */ | case 0x20: /* SPACE */ |
| 3884 | case 0xa0: /* NBSP */ | case 0xa0: /* NBSP */ |
| 3885 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3886 | } | } |
| 3887 | } | } |
| 3888 | break; | break; |
| # | Line 3258 for (;;) | Line 3890 for (;;) |
| 3890 | case OP_HSPACE: | case OP_HSPACE: |
| 3891 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3892 | { | { |
| 3893 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3894 | { | |
| 3895 | SCHECK_PARTIAL(); | |
| 3896 | MRRETURN(MATCH_NOMATCH); | |
| 3897 | } | |
| 3898 | switch(*eptr++) | switch(*eptr++) |
| 3899 | { | { |
| 3900 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 3901 | case 0x09: /* HT */ | case 0x09: /* HT */ |
| 3902 | case 0x20: /* SPACE */ | case 0x20: /* SPACE */ |
| 3903 | case 0xa0: /* NBSP */ | case 0xa0: /* NBSP */ |
| # | Line 3273 for (;;) | Line 3909 for (;;) |
| 3909 | case OP_NOT_VSPACE: | case OP_NOT_VSPACE: |
| 3910 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3911 | { | { |
| 3912 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3913 | { | |
| 3914 | SCHECK_PARTIAL(); | |
| 3915 | MRRETURN(MATCH_NOMATCH); | |
| 3916 | } | |
| 3917 | switch(*eptr++) | switch(*eptr++) |
| 3918 | { | { |
| 3919 | default: break; | default: break; |
| # | Line 3282 for (;;) | Line 3922 for (;;) |
| 3922 | case 0x0c: /* FF */ | case 0x0c: /* FF */ |
| 3923 | case 0x0d: /* CR */ | case 0x0d: /* CR */ |
| 3924 | case 0x85: /* NEL */ | case 0x85: /* NEL */ |
| 3925 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3926 | } | } |
| 3927 | } | } |
| 3928 | break; | break; |
| # | Line 3290 for (;;) | Line 3930 for (;;) |
| 3930 | case OP_VSPACE: | case OP_VSPACE: |
| 3931 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3932 | { | { |
| 3933 | if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr >= md->end_subject) |
| 3934 | { | |
| 3935 | SCHECK_PARTIAL(); | |
| 3936 | MRRETURN(MATCH_NOMATCH); | |
| 3937 | } | |
| 3938 | switch(*eptr++) | switch(*eptr++) |
| 3939 | { | { |
| 3940 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 3941 | case 0x0a: /* LF */ | case 0x0a: /* LF */ |
| 3942 | case 0x0b: /* VT */ | case 0x0b: /* VT */ |
| 3943 | case 0x0c: /* FF */ | case 0x0c: /* FF */ |
| # | Line 3306 for (;;) | Line 3950 for (;;) |
| 3950 | ||
| 3951 | case OP_NOT_DIGIT: | case OP_NOT_DIGIT: |
| 3952 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3953 | if ((md->ctypes[*eptr++] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH); | { |
| 3954 | if (eptr >= md->end_subject) | |
| 3955 | { | |
| 3956 | SCHECK_PARTIAL(); | |
| 3957 | MRRETURN(MATCH_NOMATCH); | |
| 3958 | } | |
| 3959 | if ((md->ctypes[*eptr++] & ctype_digit) != 0) MRRETURN(MATCH_NOMATCH); | |
| 3960 | } | |
| 3961 | break; | break; |
| 3962 | ||
| 3963 | case OP_DIGIT: | case OP_DIGIT: |
| 3964 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3965 | if ((md->ctypes[*eptr++] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH); | { |
| 3966 | if (eptr >= md->end_subject) | |
| 3967 | { | |
| 3968 | SCHECK_PARTIAL(); | |
| 3969 | MRRETURN(MATCH_NOMATCH); | |
| 3970 | } | |
| 3971 | if ((md->ctypes[*eptr++] & ctype_digit) == 0) MRRETURN(MATCH_NOMATCH); | |
| 3972 | } | |
| 3973 | break; | break; |
| 3974 | ||
| 3975 | case OP_NOT_WHITESPACE: | case OP_NOT_WHITESPACE: |
| 3976 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3977 | if ((md->ctypes[*eptr++] & ctype_space) != 0) RRETURN(MATCH_NOMATCH); | { |
| 3978 | if (eptr >= md->end_subject) | |
| 3979 | { | |
| 3980 | SCHECK_PARTIAL(); | |
| 3981 | MRRETURN(MATCH_NOMATCH); | |
| 3982 | } | |
| 3983 | if ((md->ctypes[*eptr++] & ctype_space) != 0) MRRETURN(MATCH_NOMATCH); | |
| 3984 | } | |
| 3985 | break; | break; |
| 3986 | ||
| 3987 | case OP_WHITESPACE: | case OP_WHITESPACE: |
| 3988 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3989 | if ((md->ctypes[*eptr++] & ctype_space) == 0) RRETURN(MATCH_NOMATCH); | { |
| 3990 | if (eptr >= md->end_subject) | |
| 3991 | { | |
| 3992 | SCHECK_PARTIAL(); | |
| 3993 | MRRETURN(MATCH_NOMATCH); | |
| 3994 | } | |
| 3995 | if ((md->ctypes[*eptr++] & ctype_space) == 0) MRRETURN(MATCH_NOMATCH); | |
| 3996 | } | |
| 3997 | break; | break; |
| 3998 | ||
| 3999 | case OP_NOT_WORDCHAR: | case OP_NOT_WORDCHAR: |
| 4000 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 4001 | { | |
| 4002 | if (eptr >= md->end_subject) | |
| 4003 | { | |
| 4004 | SCHECK_PARTIAL(); | |
| 4005 | MRRETURN(MATCH_NOMATCH); | |
| 4006 | } | |
| 4007 | if ((md->ctypes[*eptr++] & ctype_word) != 0) | if ((md->ctypes[*eptr++] & ctype_word) != 0) |
| 4008 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4009 | } | |
| 4010 | break; | break; |
| 4011 | ||
| 4012 | case OP_WORDCHAR: | case OP_WORDCHAR: |
| 4013 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 4014 | { | |
| 4015 | if (eptr >= md->end_subject) | |
| 4016 | { | |
| 4017 | SCHECK_PARTIAL(); | |
| 4018 | MRRETURN(MATCH_NOMATCH); | |
| 4019 | } | |
| 4020 | if ((md->ctypes[*eptr++] & ctype_word) == 0) | if ((md->ctypes[*eptr++] & ctype_word) == 0) |
| 4021 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4022 | } | |
| 4023 | break; | break; |
| 4024 | ||
| 4025 | default: | default: |
| # | Line 3361 for (;;) | Line 4047 for (;;) |
| 4047 | { | { |
| 4048 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM36); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM36); |
| 4049 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4050 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4051 | if (eptr >= md->end_subject) | |
| 4052 | { | |
| 4053 | SCHECK_PARTIAL(); | |
| 4054 | MRRETURN(MATCH_NOMATCH); | |
| 4055 | } | |
| 4056 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 4057 | if (prop_fail_result) RRETURN(MATCH_NOMATCH); | if (prop_fail_result) MRRETURN(MATCH_NOMATCH); |
| 4058 | } | } |
| 4059 | /* Control never gets here */ | /* Control never gets here */ |
| 4060 | ||
| # | Line 3372 for (;;) | Line 4063 for (;;) |
| 4063 | { | { |
| 4064 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM37); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM37); |
| 4065 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4066 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4067 | if (eptr >= md->end_subject) | |
| 4068 | { | |
| 4069 | SCHECK_PARTIAL(); | |
| 4070 | MRRETURN(MATCH_NOMATCH); | |
| 4071 | } | |
| 4072 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 4073 | prop_chartype = UCD_CHARTYPE(c); | prop_chartype = UCD_CHARTYPE(c); |
| 4074 | if ((prop_chartype == ucp_Lu || | if ((prop_chartype == ucp_Lu || |
| 4075 | prop_chartype == ucp_Ll || | prop_chartype == ucp_Ll || |
| 4076 | prop_chartype == ucp_Lt) == prop_fail_result) | prop_chartype == ucp_Lt) == prop_fail_result) |
| 4077 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4078 | } | } |
| 4079 | /* Control never gets here */ | /* Control never gets here */ |
| 4080 | ||
| # | Line 3387 for (;;) | Line 4083 for (;;) |
| 4083 | { | { |
| 4084 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM38); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM38); |
| 4085 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4086 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4087 | if (eptr >= md->end_subject) | |
| 4088 | { | |
| 4089 | SCHECK_PARTIAL(); | |
| 4090 | MRRETURN(MATCH_NOMATCH); | |
| 4091 | } | |
| 4092 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 4093 | prop_category = UCD_CATEGORY(c); | prop_category = UCD_CATEGORY(c); |
| 4094 | if ((prop_category == prop_value) == prop_fail_result) | if ((prop_category == prop_value) == prop_fail_result) |
| 4095 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4096 | } | } |
| 4097 | /* Control never gets here */ | /* Control never gets here */ |
| 4098 | ||
| # | Line 3400 for (;;) | Line 4101 for (;;) |
| 4101 | { | { |
| 4102 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM39); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM39); |
| 4103 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4104 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4105 | if (eptr >= md->end_subject) | |
| 4106 | { | |
| 4107 | SCHECK_PARTIAL(); | |
| 4108 | MRRETURN(MATCH_NOMATCH); | |
| 4109 | } | |
| 4110 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 4111 | prop_chartype = UCD_CHARTYPE(c); | prop_chartype = UCD_CHARTYPE(c); |
| 4112 | if ((prop_chartype == prop_value) == prop_fail_result) | if ((prop_chartype == prop_value) == prop_fail_result) |
| 4113 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4114 | } | } |
| 4115 | /* Control never gets here */ | /* Control never gets here */ |
| 4116 | ||
| # | Line 3413 for (;;) | Line 4119 for (;;) |
| 4119 | { | { |
| 4120 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM40); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM40); |
| 4121 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4122 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4123 | if (eptr >= md->end_subject) | |
| 4124 | { | |
| 4125 | SCHECK_PARTIAL(); | |
| 4126 | MRRETURN(MATCH_NOMATCH); | |
| 4127 | } | |
| 4128 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 4129 | prop_script = UCD_SCRIPT(c); | prop_script = UCD_SCRIPT(c); |
| 4130 | if ((prop_script == prop_value) == prop_fail_result) | if ((prop_script == prop_value) == prop_fail_result) |
| 4131 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4132 | } | } |
| 4133 | /* Control never gets here */ | /* Control never gets here */ |
| 4134 | ||
| # | Line 3435 for (;;) | Line 4146 for (;;) |
| 4146 | { | { |
| 4147 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM41); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM41); |
| 4148 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4149 | if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4150 | if (eptr >= md->end_subject) | |
| 4151 | { | |
| 4152 | SCHECK_PARTIAL(); | |
| 4153 | MRRETURN(MATCH_NOMATCH); | |
| 4154 | } | |
| 4155 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 4156 | prop_category = UCD_CATEGORY(c); | prop_category = UCD_CATEGORY(c); |
| 4157 | if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH); | if (prop_category == ucp_M) MRRETURN(MATCH_NOMATCH); |
| 4158 | while (eptr < md->end_subject) | while (eptr < md->end_subject) |
| 4159 | { | { |
| 4160 | int len = 1; | int len = 1; |
| 4161 | if (!utf8) c = *eptr; else | if (!utf8) c = *eptr; |
| 4162 | { | else { GETCHARLEN(c, eptr, len); } |
| GETCHARLEN(c, eptr, len); | ||
| } | ||
| 4163 | prop_category = UCD_CATEGORY(c); | prop_category = UCD_CATEGORY(c); |
| 4164 | if (prop_category != ucp_M) break; | if (prop_category != ucp_M) break; |
| 4165 | eptr += len; | eptr += len; |
| # | Line 3464 for (;;) | Line 4178 for (;;) |
| 4178 | { | { |
| 4179 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM42); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM42); |
| 4180 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4181 | if (fi >= max || eptr >= md->end_subject || | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4182 | (ctype == OP_ANY && IS_NEWLINE(eptr))) | if (eptr >= md->end_subject) |
| 4183 | RRETURN(MATCH_NOMATCH); | { |
| 4184 | SCHECK_PARTIAL(); | |
| 4185 | MRRETURN(MATCH_NOMATCH); | |
| 4186 | } | |
| 4187 | if (ctype == OP_ANY && IS_NEWLINE(eptr)) | |
| 4188 | MRRETURN(MATCH_NOMATCH); | |
| 4189 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 4190 | switch(ctype) | switch(ctype) |
| 4191 | { | { |
| # | Line 3479 for (;;) | Line 4197 for (;;) |
| 4197 | case OP_ANYNL: | case OP_ANYNL: |
| 4198 | switch(c) | switch(c) |
| 4199 | { | { |
| 4200 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4201 | case 0x000d: | case 0x000d: |
| 4202 | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 4203 | break; | break; |
| # | Line 3491 for (;;) | Line 4209 for (;;) |
| 4209 | case 0x0085: | case 0x0085: |
| 4210 | case 0x2028: | case 0x2028: |
| 4211 | case 0x2029: | case 0x2029: |
| 4212 | if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); | if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH); |
| 4213 | break; | break; |
| 4214 | } | } |
| 4215 | break; | break; |
| # | Line 3519 for (;;) | Line 4237 for (;;) |
| 4237 | case 0x202f: /* NARROW NO-BREAK SPACE */ | case 0x202f: /* NARROW NO-BREAK SPACE */ |
| 4238 | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ |
| 4239 | case 0x3000: /* IDEOGRAPHIC SPACE */ | case 0x3000: /* IDEOGRAPHIC SPACE */ |
| 4240 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4241 | } | } |
| 4242 | break; | break; |
| 4243 | ||
| 4244 | case OP_HSPACE: | case OP_HSPACE: |
| 4245 | switch(c) | switch(c) |
| 4246 | { | { |
| 4247 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4248 | case 0x09: /* HT */ | case 0x09: /* HT */ |
| 4249 | case 0x20: /* SPACE */ | case 0x20: /* SPACE */ |
| 4250 | case 0xa0: /* NBSP */ | case 0xa0: /* NBSP */ |
| # | Line 3561 for (;;) | Line 4279 for (;;) |
| 4279 | case 0x85: /* NEL */ | case 0x85: /* NEL */ |
| 4280 | case 0x2028: /* LINE SEPARATOR */ | case 0x2028: /* LINE SEPARATOR */ |
| 4281 | case 0x2029: /* PARAGRAPH SEPARATOR */ | case 0x2029: /* PARAGRAPH SEPARATOR */ |
| 4282 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4283 | } | } |
| 4284 | break; | break; |
| 4285 | ||
| 4286 | case OP_VSPACE: | case OP_VSPACE: |
| 4287 | switch(c) | switch(c) |
| 4288 | { | { |
| 4289 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4290 | case 0x0a: /* LF */ | case 0x0a: /* LF */ |
| 4291 | case 0x0b: /* VT */ | case 0x0b: /* VT */ |
| 4292 | case 0x0c: /* FF */ | case 0x0c: /* FF */ |
| # | Line 3582 for (;;) | Line 4300 for (;;) |
| 4300 | ||
| 4301 | case OP_NOT_DIGIT: | case OP_NOT_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_DIGIT: | case OP_DIGIT: |
| 4307 | if (c >= 256 || (md->ctypes[c] & ctype_digit) == 0) | if (c >= 256 || (md->ctypes[c] & ctype_digit) == 0) |
| 4308 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4309 | break; | break; |
| 4310 | ||
| 4311 | case OP_NOT_WHITESPACE: | case OP_NOT_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_WHITESPACE: | case OP_WHITESPACE: |
| 4317 | if (c >= 256 || (md->ctypes[c] & ctype_space) == 0) | if (c >= 256 || (md->ctypes[c] & ctype_space) == 0) |
| 4318 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4319 | break; | break; |
| 4320 | ||
| 4321 | case OP_NOT_WORDCHAR: | case OP_NOT_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 | case OP_WORDCHAR: | case OP_WORDCHAR: |
| 4327 | if (c >= 256 || (md->ctypes[c] & ctype_word) == 0) | if (c >= 256 || (md->ctypes[c] & ctype_word) == 0) |
| 4328 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4329 | break; | break; |
| 4330 | ||
| 4331 | default: | default: |
| # | Line 3623 for (;;) | Line 4341 for (;;) |
| 4341 | { | { |
| 4342 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM43); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM43); |
| 4343 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4344 | if (fi >= max || eptr >= md->end_subject || | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4345 | (ctype == OP_ANY && IS_NEWLINE(eptr))) | if (eptr >= md->end_subject) |
| 4346 | RRETURN(MATCH_NOMATCH); | { |
| 4347 | SCHECK_PARTIAL(); | |
| 4348 | MRRETURN(MATCH_NOMATCH); | |
| 4349 | } | |
| 4350 | if (ctype == OP_ANY && IS_NEWLINE(eptr)) | |
| 4351 | MRRETURN(MATCH_NOMATCH); | |
| 4352 | c = *eptr++; | c = *eptr++; |
| 4353 | switch(ctype) | switch(ctype) |
| 4354 | { | { |
| # | Line 3638 for (;;) | Line 4360 for (;;) |
| 4360 | case OP_ANYNL: | case OP_ANYNL: |
| 4361 | switch(c) | switch(c) |
| 4362 | { | { |
| 4363 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4364 | case 0x000d: | case 0x000d: |
| 4365 | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 4366 | break; | break; |
| # | Line 3649 for (;;) | Line 4371 for (;;) |
| 4371 | case 0x000b: | case 0x000b: |
| 4372 | case 0x000c: | case 0x000c: |
| 4373 | case 0x0085: | case 0x0085: |
| 4374 | if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); | if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH); |
| 4375 | break; | break; |
| 4376 | } | } |
| 4377 | break; | break; |
| # | Line 3661 for (;;) | Line 4383 for (;;) |
| 4383 | case 0x09: /* HT */ | case 0x09: /* HT */ |
| 4384 | case 0x20: /* SPACE */ | case 0x20: /* SPACE */ |
| 4385 | case 0xa0: /* NBSP */ | case 0xa0: /* NBSP */ |
| 4386 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4387 | } | } |
| 4388 | break; | break; |
| 4389 | ||
| 4390 | case OP_HSPACE: | case OP_HSPACE: |
| 4391 | switch(c) | switch(c) |
| 4392 | { | { |
| 4393 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4394 | case 0x09: /* HT */ | case 0x09: /* HT */ |
| 4395 | case 0x20: /* SPACE */ | case 0x20: /* SPACE */ |
| 4396 | case 0xa0: /* NBSP */ | case 0xa0: /* NBSP */ |
| # | Line 3685 for (;;) | Line 4407 for (;;) |
| 4407 | case 0x0c: /* FF */ | case 0x0c: /* FF */ |
| 4408 | case 0x0d: /* CR */ | case 0x0d: /* CR */ |
| 4409 | case 0x85: /* NEL */ | case 0x85: /* NEL */ |
| 4410 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4411 | } | } |
| 4412 | break; | break; |
| 4413 | ||
| 4414 | case OP_VSPACE: | case OP_VSPACE: |
| 4415 | switch(c) | switch(c) |
| 4416 | { | { |
| 4417 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4418 | case 0x0a: /* LF */ | case 0x0a: /* LF */ |
| 4419 | case 0x0b: /* VT */ | case 0x0b: /* VT */ |
| 4420 | case 0x0c: /* FF */ | case 0x0c: /* FF */ |
| # | Line 3703 for (;;) | Line 4425 for (;;) |
| 4425 | break; | break; |
| 4426 | ||
| 4427 | case OP_NOT_DIGIT: | case OP_NOT_DIGIT: |
| 4428 | if ((md->ctypes[c] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[c] & ctype_digit) != 0) MRRETURN(MATCH_NOMATCH); |
| 4429 | break; | break; |
| 4430 | ||
| 4431 | case OP_DIGIT: | case OP_DIGIT: |
| 4432 | if ((md->ctypes[c] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[c] & ctype_digit) == 0) MRRETURN(MATCH_NOMATCH); |
| 4433 | break; | break; |
| 4434 | ||
| 4435 | case OP_NOT_WHITESPACE: | case OP_NOT_WHITESPACE: |
| 4436 | if ((md->ctypes[c] & ctype_space) != 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[c] & ctype_space) != 0) MRRETURN(MATCH_NOMATCH); |
| 4437 | break; | break; |
| 4438 | ||
| 4439 | case OP_WHITESPACE: | case OP_WHITESPACE: |
| 4440 | if ((md->ctypes[c] & ctype_space) == 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[c] & ctype_space) == 0) MRRETURN(MATCH_NOMATCH); |
| 4441 | break; | break; |
| 4442 | ||
| 4443 | case OP_NOT_WORDCHAR: | case OP_NOT_WORDCHAR: |
| 4444 | if ((md->ctypes[c] & ctype_word) != 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[c] & ctype_word) != 0) MRRETURN(MATCH_NOMATCH); |
| 4445 | break; | break; |
| 4446 | ||
| 4447 | case OP_WORDCHAR: | case OP_WORDCHAR: |
| 4448 | if ((md->ctypes[c] & ctype_word) == 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[c] & ctype_word) == 0) MRRETURN(MATCH_NOMATCH); |
| 4449 | break; | break; |
| 4450 | ||
| 4451 | default: | default: |
| # | Line 3751 for (;;) | Line 4473 for (;;) |
| 4473 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4474 | { | { |
| 4475 | int len = 1; | int len = 1; |
| 4476 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4477 | { | |
| 4478 | SCHECK_PARTIAL(); | |
| 4479 | break; | |
| 4480 | } | |
| 4481 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4482 | if (prop_fail_result) break; | if (prop_fail_result) break; |
| 4483 | eptr+= len; | eptr+= len; |
| # | Line 3762 for (;;) | Line 4488 for (;;) |
| 4488 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4489 | { | { |
| 4490 | int len = 1; | int len = 1; |
| 4491 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4492 | { | |
| 4493 | SCHECK_PARTIAL(); | |
| 4494 | break; | |
| 4495 | } | |
| 4496 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4497 | prop_chartype = UCD_CHARTYPE(c); | prop_chartype = UCD_CHARTYPE(c); |
| 4498 | if ((prop_chartype == ucp_Lu || | if ((prop_chartype == ucp_Lu || |
| # | Line 3777 for (;;) | Line 4507 for (;;) |
| 4507 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4508 | { | { |
| 4509 | int len = 1; | int len = 1; |
| 4510 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4511 | { | |
| 4512 | SCHECK_PARTIAL(); | |
| 4513 | break; | |
| 4514 | } | |
| 4515 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4516 | prop_category = UCD_CATEGORY(c); | prop_category = UCD_CATEGORY(c); |
| 4517 | if ((prop_category == prop_value) == prop_fail_result) | if ((prop_category == prop_value) == prop_fail_result) |
| # | Line 3790 for (;;) | Line 4524 for (;;) |
| 4524 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4525 | { | { |
| 4526 | int len = 1; | int len = 1; |
| 4527 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4528 | { | |
| 4529 | SCHECK_PARTIAL(); | |
| 4530 | break; | |
| 4531 | } | |
| 4532 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4533 | prop_chartype = UCD_CHARTYPE(c); | prop_chartype = UCD_CHARTYPE(c); |
| 4534 | if ((prop_chartype == prop_value) == prop_fail_result) | if ((prop_chartype == prop_value) == prop_fail_result) |
| # | Line 3803 for (;;) | Line 4541 for (;;) |
| 4541 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4542 | { | { |
| 4543 | int len = 1; | int len = 1; |
| 4544 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4545 | { | |
| 4546 | SCHECK_PARTIAL(); | |
| 4547 | break; | |
| 4548 | } | |
| 4549 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4550 | prop_script = UCD_SCRIPT(c); | prop_script = UCD_SCRIPT(c); |
| 4551 | if ((prop_script == prop_value) == prop_fail_result) | if ((prop_script == prop_value) == prop_fail_result) |
| # | Line 3832 for (;;) | Line 4574 for (;;) |
| 4574 | { | { |
| 4575 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4576 | { | { |
| 4577 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4578 | { | |
| 4579 | SCHECK_PARTIAL(); | |
| 4580 | break; | |
| 4581 | } | |
| 4582 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 4583 | prop_category = UCD_CATEGORY(c); | prop_category = UCD_CATEGORY(c); |
| 4584 | if (prop_category == ucp_M) break; | if (prop_category == ucp_M) break; |
| # | Line 3852 for (;;) | Line 4598 for (;;) |
| 4598 | /* eptr is now past the end of the maximum run */ | /* eptr is now past the end of the maximum run */ |
| 4599 | ||
| 4600 | if (possessive) continue; | if (possessive) continue; |
| 4601 | ||
| 4602 | for(;;) | for(;;) |
| 4603 | { | { |
| 4604 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM45); | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM45); |
| # | Line 3887 for (;;) | Line 4634 for (;;) |
| 4634 | { | { |
| 4635 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4636 | { | { |
| 4637 | if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break; | if (eptr >= md->end_subject) |
| 4638 | { | |
| 4639 | SCHECK_PARTIAL(); | |
| 4640 | break; | |
| 4641 | } | |
| 4642 | if (IS_NEWLINE(eptr)) break; | |
| 4643 | eptr++; | eptr++; |
| 4644 | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| 4645 | } | } |
| # | Line 3899 for (;;) | Line 4651 for (;;) |
| 4651 | { | { |
| 4652 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4653 | { | { |
| 4654 | if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break; | if (eptr >= md->end_subject) |
| 4655 | { | |
| 4656 | SCHECK_PARTIAL(); | |
| 4657 | break; | |
| 4658 | } | |
| 4659 | if (IS_NEWLINE(eptr)) break; | |
| 4660 | eptr++; | eptr++; |
| 4661 | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| 4662 | } | } |
| # | Line 3911 for (;;) | Line 4668 for (;;) |
| 4668 | { | { |
| 4669 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4670 | { | { |
| 4671 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4672 | { | |
| 4673 | SCHECK_PARTIAL(); | |
| 4674 | break; | |
| 4675 | } | |
| 4676 | eptr++; | eptr++; |
| 4677 | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| 4678 | } | } |
| # | Line 3924 for (;;) | Line 4685 for (;;) |
| 4685 | case OP_ANYBYTE: | case OP_ANYBYTE: |
| 4686 | c = max - min; | c = max - min; |
| 4687 | if (c > (unsigned int)(md->end_subject - eptr)) | if (c > (unsigned int)(md->end_subject - eptr)) |
| 4688 | c = md->end_subject - eptr; | { |
| 4689 | eptr += c; | eptr = md->end_subject; |
| 4690 | SCHECK_PARTIAL(); | |
| 4691 | } | |
| 4692 | else eptr += c; | |
| 4693 | break; | break; |
| 4694 | ||
| 4695 | case OP_ANYNL: | case OP_ANYNL: |
| 4696 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4697 | { | { |
| 4698 | int len = 1; | int len = 1; |
| 4699 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4700 | { | |
| 4701 | SCHECK_PARTIAL(); | |
| 4702 | break; | |
| 4703 | } | |
| 4704 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4705 | if (c == 0x000d) | if (c == 0x000d) |
| 4706 | { | { |
| # | Line 3957 for (;;) | Line 4725 for (;;) |
| 4725 | { | { |
| 4726 | BOOL gotspace; | BOOL gotspace; |
| 4727 | int len = 1; | int len = 1; |
| 4728 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4729 | { | |
| 4730 | SCHECK_PARTIAL(); | |
| 4731 | break; | |
| 4732 | } | |
| 4733 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4734 | switch(c) | switch(c) |
| 4735 | { | { |
| # | Line 3995 for (;;) | Line 4767 for (;;) |
| 4767 | { | { |
| 4768 | BOOL gotspace; | BOOL gotspace; |
| 4769 | int len = 1; | int len = 1; |
| 4770 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4771 | { | |
| 4772 | SCHECK_PARTIAL(); | |
| 4773 | break; | |
| 4774 | } | |
| 4775 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4776 | switch(c) | switch(c) |
| 4777 | { | { |
| # | Line 4019 for (;;) | Line 4795 for (;;) |
| 4795 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4796 | { | { |
| 4797 | int len = 1; | int len = 1; |
| 4798 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4799 | { | |
| 4800 | SCHECK_PARTIAL(); | |
| 4801 | break; | |
| 4802 | } | |
| 4803 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4804 | if (c < 256 && (md->ctypes[c] & ctype_digit) != 0) break; | if (c < 256 && (md->ctypes[c] & ctype_digit) != 0) break; |
| 4805 | eptr+= len; | eptr+= len; |
| # | Line 4030 for (;;) | Line 4810 for (;;) |
| 4810 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4811 | { | { |
| 4812 | int len = 1; | int len = 1; |
| 4813 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4814 | { | |
| 4815 | SCHECK_PARTIAL(); | |
| 4816 | break; | |
| 4817 | } | |
| 4818 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4819 | if (c >= 256 ||(md->ctypes[c] & ctype_digit) == 0) break; | if (c >= 256 ||(md->ctypes[c] & ctype_digit) == 0) break; |
| 4820 | eptr+= len; | eptr+= len; |
| # | Line 4041 for (;;) | Line 4825 for (;;) |
| 4825 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4826 | { | { |
| 4827 | int len = 1; | int len = 1; |
| 4828 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4829 | { | |
| 4830 | SCHECK_PARTIAL(); | |
| 4831 | break; | |
| 4832 | } | |
| 4833 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4834 | if (c < 256 && (md->ctypes[c] & ctype_space) != 0) break; | if (c < 256 && (md->ctypes[c] & ctype_space) != 0) break; |
| 4835 | eptr+= len; | eptr+= len; |
| # | Line 4052 for (;;) | Line 4840 for (;;) |
| 4840 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4841 | { | { |
| 4842 | int len = 1; | int len = 1; |
| 4843 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4844 | { | |
| 4845 | SCHECK_PARTIAL(); | |
| 4846 | break; | |
| 4847 | } | |
| 4848 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4849 | if (c >= 256 ||(md->ctypes[c] & ctype_space) == 0) break; | if (c >= 256 ||(md->ctypes[c] & ctype_space) == 0) break; |
| 4850 | eptr+= len; | eptr+= len; |
| # | Line 4063 for (;;) | Line 4855 for (;;) |
| 4855 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4856 | { | { |
| 4857 | int len = 1; | int len = 1; |
| 4858 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4859 | { | |
| 4860 | SCHECK_PARTIAL(); | |
| 4861 | break; | |
| 4862 | } | |
| 4863 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4864 | if (c < 256 && (md->ctypes[c] & ctype_word) != 0) break; | if (c < 256 && (md->ctypes[c] & ctype_word) != 0) break; |
| 4865 | eptr+= len; | eptr+= len; |
| # | Line 4074 for (;;) | Line 4870 for (;;) |
| 4870 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4871 | { | { |
| 4872 | int len = 1; | int len = 1; |
| 4873 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4874 | { | |
| 4875 | SCHECK_PARTIAL(); | |
| 4876 | break; | |
| 4877 | } | |
| 4878 | GETCHARLEN(c, eptr, len); | GETCHARLEN(c, eptr, len); |
| 4879 | if (c >= 256 || (md->ctypes[c] & ctype_word) == 0) break; | if (c >= 256 || (md->ctypes[c] & ctype_word) == 0) break; |
| 4880 | eptr+= len; | eptr+= len; |
| # | Line 4106 for (;;) | Line 4906 for (;;) |
| 4906 | case OP_ANY: | case OP_ANY: |
| 4907 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4908 | { | { |
| 4909 | if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break; | if (eptr >= md->end_subject) |
| 4910 | { | |
| 4911 | SCHECK_PARTIAL(); | |
| 4912 | break; | |
| 4913 | } | |
| 4914 | if (IS_NEWLINE(eptr)) break; | |
| 4915 | eptr++; | eptr++; |
| 4916 | } | } |
| 4917 | break; | break; |
| # | Line 4115 for (;;) | Line 4920 for (;;) |
| 4920 | case OP_ANYBYTE: | case OP_ANYBYTE: |
| 4921 | c = max - min; | c = max - min; |
| 4922 | if (c > (unsigned int)(md->end_subject - eptr)) | if (c > (unsigned int)(md->end_subject - eptr)) |
| 4923 | c = md->end_subject - eptr; | { |
| 4924 | eptr += c; | eptr = md->end_subject; |
| 4925 | SCHECK_PARTIAL(); | |
| 4926 | } | |
| 4927 | else eptr += c; | |
| 4928 | break; | break; |
| 4929 | ||
| 4930 | case OP_ANYNL: | case OP_ANYNL: |
| 4931 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4932 | { | { |
| 4933 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4934 | { | |
| 4935 | SCHECK_PARTIAL(); | |
| 4936 | break; | |
| 4937 | } | |
| 4938 | c = *eptr; | c = *eptr; |
| 4939 | if (c == 0x000d) | if (c == 0x000d) |
| 4940 | { | { |
| # | Line 4143 for (;;) | Line 4955 for (;;) |
| 4955 | case OP_NOT_HSPACE: | case OP_NOT_HSPACE: |
| 4956 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4957 | { | { |
| 4958 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4959 | { | |
| 4960 | SCHECK_PARTIAL(); | |
| 4961 | break; | |
| 4962 | } | |
| 4963 | c = *eptr; | c = *eptr; |
| 4964 | if (c == 0x09 || c == 0x20 || c == 0xa0) break; | if (c == 0x09 || c == 0x20 || c == 0xa0) break; |
| 4965 | eptr++; | eptr++; |
| # | Line 4153 for (;;) | Line 4969 for (;;) |
| 4969 | case OP_HSPACE: | case OP_HSPACE: |
| 4970 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4971 | { | { |
| 4972 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4973 | { | |
| 4974 | SCHECK_PARTIAL(); | |
| 4975 | break; | |
| 4976 | } | |
| 4977 | c = *eptr; | c = *eptr; |
| 4978 | if (c != 0x09 && c != 0x20 && c != 0xa0) break; | if (c != 0x09 && c != 0x20 && c != 0xa0) break; |
| 4979 | eptr++; | eptr++; |
| # | Line 4163 for (;;) | Line 4983 for (;;) |
| 4983 | case OP_NOT_VSPACE: | case OP_NOT_VSPACE: |
| 4984 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 4985 | { | { |
| 4986 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 4987 | { | |
| 4988 | SCHECK_PARTIAL(); | |
| 4989 | break; | |
| 4990 | } | |
| 4991 | c = *eptr; | c = *eptr; |
| 4992 | if (c == 0x0a || c == 0x0b || c == 0x0c || c == 0x0d || c == 0x85) | if (c == 0x0a || c == 0x0b || c == 0x0c || c == 0x0d || c == 0x85) |
| 4993 | break; | break; |
| # | Line 4174 for (;;) | Line 4998 for (;;) |
| 4998 | case OP_VSPACE: | case OP_VSPACE: |
| 4999 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 5000 | { | { |
| 5001 | if (eptr >= md->end_subject) break; | if (eptr >= md->end_subject) |
| 5002 | { | |
| 5003 | SCHECK_PARTIAL(); | |
| 5004 | break; | |
| 5005 | } | |
| 5006 | c = *eptr; | c = *eptr; |
| 5007 | if (c != 0x0a && c != 0x0b && c != 0x0c && c != 0x0d && c != 0x85) | if (c != 0x0a && c != 0x0b && c != 0x0c && c != 0x0d && c != 0x85) |
| 5008 | break; | break; |
| # | Line 4185 for (;;) | Line 5013 for (;;) |
| 5013 | case OP_NOT_DIGIT: | case OP_NOT_DIGIT: |
| 5014 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 5015 | { | { |
| 5016 | if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) != 0) | if (eptr >= md->end_subject) |
| 5017 | { | |
| 5018 | SCHECK_PARTIAL(); | |
| 5019 | break; | break; |
| 5020 | } | |
| 5021 | if ((md->ctypes[*eptr] & ctype_digit) != 0) break; | |
| 5022 | eptr++; | eptr++; |
| 5023 | } | } |
| 5024 | break; | break; |
| # | Line 4194 for (;;) | Line 5026 for (;;) |
| 5026 | case OP_DIGIT: | case OP_DIGIT: |
| 5027 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 5028 | { | { |
| 5029 | if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) == 0) | if (eptr >= md->end_subject) |
| 5030 | { | |
| 5031 | SCHECK_PARTIAL(); | |
| 5032 | break; | break; |
| 5033 | } | |
| 5034 | if ((md->ctypes[*eptr] & ctype_digit) == 0) break; | |
| 5035 | eptr++; | eptr++; |
| 5036 | } | } |
| 5037 | break; | break; |
| # | Line 4203 for (;;) | Line 5039 for (;;) |
| 5039 | case OP_NOT_WHITESPACE: | case OP_NOT_WHITESPACE: |
| 5040 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 5041 | { | { |
| 5042 | if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) != 0) | if (eptr >= md->end_subject) |
| 5043 | { | |
| 5044 | SCHECK_PARTIAL(); | |
| 5045 | break; | break; |
| 5046 | } | |
| 5047 | if ((md->ctypes[*eptr] & ctype_space) != 0) break; | |
| 5048 | eptr++; | eptr++; |
| 5049 | } | } |
| 5050 | break; | break; |
| # | Line 4212 for (;;) | Line 5052 for (;;) |
| 5052 | case OP_WHITESPACE: | case OP_WHITESPACE: |
| 5053 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 5054 | { | { |
| 5055 | if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) == 0) | if (eptr >= md->end_subject) |
| 5056 | { | |
| 5057 | SCHECK_PARTIAL(); | |
| 5058 | break; | break; |
| 5059 | } | |
| 5060 | if ((md->ctypes[*eptr] & ctype_space) == 0) break; | |
| 5061 | eptr++; | eptr++; |
| 5062 | } | } |
| 5063 | break; | break; |
| # | Line 4221 for (;;) | Line 5065 for (;;) |
| 5065 | case OP_NOT_WORDCHAR: | case OP_NOT_WORDCHAR: |
| 5066 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 5067 | { | { |
| 5068 | if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) != 0) | if (eptr >= md->end_subject) |
| 5069 | { | |
| 5070 | SCHECK_PARTIAL(); | |
| 5071 | break; | break; |
| 5072 | } | |
| 5073 | if ((md->ctypes[*eptr] & ctype_word) != 0) break; | |
| 5074 | eptr++; | eptr++; |
| 5075 | } | } |
| 5076 | break; | break; |
| # | Line 4230 for (;;) | Line 5078 for (;;) |
| 5078 | case OP_WORDCHAR: | case OP_WORDCHAR: |
| 5079 | for (i = min; i < max; i++) | for (i = min; i < max; i++) |
| 5080 | { | { |
| 5081 | if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) == 0) | if (eptr >= md->end_subject) |
| 5082 | { | |
| 5083 | SCHECK_PARTIAL(); | |
| 5084 | break; | break; |
| 5085 | } | |
| 5086 | if ((md->ctypes[*eptr] & ctype_word) == 0) break; | |
| 5087 | eptr++; | eptr++; |
| 5088 | } | } |
| 5089 | break; | break; |
| # | Line 4253 for (;;) | Line 5105 for (;;) |
| 5105 | ||
| 5106 | /* Get here if we can't make it match with any permitted repetitions */ | /* Get here if we can't make it match with any permitted repetitions */ |
| 5107 | ||
| 5108 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 5109 | } | } |
| 5110 | /* Control never gets here */ | /* Control never gets here */ |
| 5111 | ||
| # | Line 4286 switch (frame->Xwhere) | Line 5138 switch (frame->Xwhere) |
| 5138 | LBL( 9) LBL(10) LBL(11) LBL(12) LBL(13) LBL(14) LBL(15) LBL(17) | LBL( 9) LBL(10) LBL(11) LBL(12) LBL(13) LBL(14) LBL(15) LBL(17) |
| 5139 | LBL(19) LBL(24) LBL(25) LBL(26) LBL(27) LBL(29) LBL(31) LBL(33) | LBL(19) LBL(24) LBL(25) LBL(26) LBL(27) LBL(29) LBL(31) LBL(33) |
| 5140 | LBL(35) LBL(43) LBL(47) LBL(48) LBL(49) LBL(50) LBL(51) LBL(52) | LBL(35) LBL(43) LBL(47) LBL(48) LBL(49) LBL(50) LBL(51) LBL(52) |
| 5141 | LBL(53) LBL(54) | LBL(53) LBL(54) LBL(55) LBL(56) LBL(57) LBL(58) |
| 5142 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| 5143 | LBL(16) LBL(18) LBL(20) LBL(21) LBL(22) LBL(23) LBL(28) LBL(30) | LBL(16) LBL(18) LBL(20) LBL(21) LBL(22) LBL(23) LBL(28) LBL(30) |
| 5144 | LBL(32) LBL(34) LBL(42) LBL(46) | LBL(32) LBL(34) LBL(42) LBL(46) |
| # | Line 4409 const uschar *tables; | Line 5261 const uschar *tables; |
| 5261 | const uschar *start_bits = NULL; | const uschar *start_bits = NULL; |
| 5262 | USPTR start_match = (USPTR)subject + start_offset; | USPTR start_match = (USPTR)subject + start_offset; |
| 5263 | USPTR end_subject; | USPTR end_subject; |
| 5264 | USPTR start_partial = NULL; | |
| 5265 | USPTR req_byte_ptr = start_match - 1; | USPTR req_byte_ptr = start_match - 1; |
| 5266 | ||
| 5267 | pcre_study_data internal_study; | pcre_study_data internal_study; |
| # | Line 4425 if (re == NULL || subject == NULL || | Line 5278 if (re == NULL || subject == NULL || |
| 5278 | (offsets == NULL && offsetcount > 0)) return PCRE_ERROR_NULL; | (offsets == NULL && offsetcount > 0)) return PCRE_ERROR_NULL; |
| 5279 | if (offsetcount < 0) return PCRE_ERROR_BADCOUNT; | if (offsetcount < 0) return PCRE_ERROR_BADCOUNT; |
| 5280 | ||
| 5281 | /* This information is for finding all the numbers associated with a given | |
| 5282 | name, for condition testing. */ | |
| 5283 | ||
| 5284 | md->name_table = (uschar *)re + re->name_table_offset; | |
| 5285 | md->name_count = re->name_count; | |
| 5286 | md->name_entry_size = re->name_entry_size; | |
| 5287 | ||
| 5288 | /* Fish out the optional data from the extra_data structure, first setting | /* Fish out the optional data from the extra_data structure, first setting |
| 5289 | the default values. */ | the default values. */ |
| 5290 | ||
| # | Line 4492 md->jscript_compat = (re->options & PCRE | Line 5352 md->jscript_compat = (re->options & PCRE |
| 5352 | md->notbol = (options & PCRE_NOTBOL) != 0; | md->notbol = (options & PCRE_NOTBOL) != 0; |
| 5353 | md->noteol = (options & PCRE_NOTEOL) != 0; | md->noteol = (options & PCRE_NOTEOL) != 0; |
| 5354 | md->notempty = (options & PCRE_NOTEMPTY) != 0; | md->notempty = (options & PCRE_NOTEMPTY) != 0; |
| 5355 | md->partial = (options & PCRE_PARTIAL) != 0; | md->notempty_atstart = (options & PCRE_NOTEMPTY_ATSTART) != 0; |
| 5356 | md->partial = ((options & PCRE_PARTIAL_HARD) != 0)? 2 : | |
| 5357 | ((options & PCRE_PARTIAL_SOFT) != 0)? 1 : 0; | |
| 5358 | md->hitend = FALSE; | md->hitend = FALSE; |
| 5359 | md->mark = NULL; /* In case never set */ | |
| 5360 | ||
| 5361 | md->recursive = NULL; /* No recursion at top level */ | md->recursive = NULL; /* No recursion at top level */ |
| 5362 | ||
| # | Line 4533 switch ((((options & PCRE_NEWLINE_BITS) | Line 5396 switch ((((options & PCRE_NEWLINE_BITS) |
| 5396 | (pcre_uint32)options) & PCRE_NEWLINE_BITS) | (pcre_uint32)options) & PCRE_NEWLINE_BITS) |
| 5397 | { | { |
| 5398 | case 0: newline = NEWLINE; break; /* Compile-time default */ | case 0: newline = NEWLINE; break; /* Compile-time default */ |
| 5399 | case PCRE_NEWLINE_CR: newline = '\r'; break; | case PCRE_NEWLINE_CR: newline = CHAR_CR; break; |
| 5400 | case PCRE_NEWLINE_LF: newline = '\n'; break; | case PCRE_NEWLINE_LF: newline = CHAR_NL; break; |
| 5401 | case PCRE_NEWLINE_CR+ | case PCRE_NEWLINE_CR+ |
| 5402 | PCRE_NEWLINE_LF: newline = ('\r' << 8) | '\n'; break; | PCRE_NEWLINE_LF: newline = (CHAR_CR << 8) | CHAR_NL; break; |
| 5403 | case PCRE_NEWLINE_ANY: newline = -1; break; | case PCRE_NEWLINE_ANY: newline = -1; break; |
| 5404 | case PCRE_NEWLINE_ANYCRLF: newline = -2; break; | case PCRE_NEWLINE_ANYCRLF: newline = -2; break; |
| 5405 | default: return PCRE_ERROR_BADNEWLINE; | default: return PCRE_ERROR_BADNEWLINE; |
| # | Line 4566 else | Line 5429 else |
| 5429 | } | } |
| 5430 | } | } |
| 5431 | ||
| 5432 | /* Partial matching is supported only for a restricted set of regexes at the | /* Partial matching was originally supported only for a restricted set of |
| 5433 | moment. */ | regexes; from release 8.00 there are no restrictions, but the bits are still |
| 5434 | defined (though never set). So there's no harm in leaving this code. */ | |
| 5435 | ||
| 5436 | if (md->partial && (re->flags & PCRE_NOPARTIAL) != 0) | if (md->partial && (re->flags & PCRE_NOPARTIAL) != 0) |