Parent Directory
|
Revision Log
|
Patch
| revision 501 by ph10, Sun Mar 7 11:49:54 2010 UTC | revision 602 by ph10, Wed May 25 08:29:03 2011 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-2010 University of Cambridge | Copyright (c) 1997-2011 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 122 while (length-- > 0) | Line 132 while (length-- > 0) |
| 132 | * Match a back-reference * | * Match a back-reference * |
| 133 | *************************************************/ | *************************************************/ |
| 134 | ||
| 135 | /* If a back reference hasn't been set, the length that is passed is greater | /* Normally, if a back reference hasn't been set, the length that is passed is |
| 136 | than the number of characters left in the string, so the match fails. | negative, so the match always fails. However, in JavaScript compatibility mode, |
| 137 | the length passed is zero. Note that in caseless UTF-8 mode, the number of | |
| 138 | subject bytes matched may be different to the number of reference bytes. | |
| 139 | ||
| 140 | Arguments: | Arguments: |
| 141 | offset index into the offset vector | offset index into the offset vector |
| 142 | eptr points into the subject | eptr pointer into the subject |
| 143 | length length to be matched | length length of reference to be matched (number of bytes) |
| 144 | md points to match data block | md points to match data block |
| 145 | ims the ims flags | caseless TRUE if caseless |
| 146 | ||
| 147 | Returns: TRUE if matched | Returns: < 0 if not matched, otherwise the number of subject bytes matched |
| 148 | */ | */ |
| 149 | ||
| 150 | static BOOL | static int |
| 151 | match_ref(int offset, register USPTR eptr, int length, match_data *md, | match_ref(int offset, register USPTR eptr, int length, match_data *md, |
| 152 | unsigned long int ims) | BOOL caseless) |
| 153 | { | { |
| 154 | USPTR p = md->start_subject + md->offset_vector[offset]; | USPTR eptr_start = eptr; |
| 155 | register USPTR p = md->start_subject + md->offset_vector[offset]; | |
| 156 | ||
| 157 | #ifdef PCRE_DEBUG | #ifdef PCRE_DEBUG |
| 158 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| # | Line 154 pchars(p, length, FALSE, md); | Line 167 pchars(p, length, FALSE, md); |
| 167 | printf("\n"); | printf("\n"); |
| 168 | #endif | #endif |
| 169 | ||
| 170 | /* Always fail if not enough characters left */ | /* Always fail if reference not set (and not JavaScript compatible). */ |
| 171 | ||
| 172 | if (length > md->end_subject - eptr) return FALSE; | if (length < 0) return -1; |
| 173 | ||
| 174 | /* Separate the caseless case for speed. In UTF-8 mode we can only do this | /* Separate the caseless case for speed. In UTF-8 mode we can only do this |
| 175 | properly if Unicode properties are supported. Otherwise, we can check only | properly if Unicode properties are supported. Otherwise, we can check only |
| 176 | ASCII characters. */ | ASCII characters. */ |
| 177 | ||
| 178 | if ((ims & PCRE_CASELESS) != 0) | if (caseless) |
| 179 | { | { |
| 180 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| 181 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 182 | if (md->utf8) | if (md->utf8) |
| 183 | { | { |
| 184 | USPTR endptr = eptr + length; | /* Match characters up to the end of the reference. NOTE: the number of |
| 185 | while (eptr < endptr) | bytes matched may differ, because there are some characters whose upper and |
| 186 | lower case versions code as different numbers of bytes. For example, U+023A | |
| 187 | (2 bytes in UTF-8) is the upper case version of U+2C65 (3 bytes in UTF-8); | |
| 188 | a sequence of 3 of the former uses 6 bytes, as does a sequence of two of | |
| 189 | the latter. It is important, therefore, to check the length along the | |
| 190 | reference, not along the subject (earlier code did this wrong). */ | |
| 191 | ||
| 192 | USPTR endptr = p + length; | |
| 193 | while (p < endptr) | |
| 194 | { | { |
| 195 | int c, d; | int c, d; |
| 196 | if (eptr >= md->end_subject) return -1; | |
| 197 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 198 | GETCHARINC(d, p); | GETCHARINC(d, p); |
| 199 | if (c != d && c != UCD_OTHERCASE(d)) return FALSE; | if (c != d && c != UCD_OTHERCASE(d)) return -1; |
| 200 | } | } |
| 201 | } | } |
| 202 | else | else |
| # | Line 183 if ((ims & PCRE_CASELESS) != 0) | Line 205 if ((ims & PCRE_CASELESS) != 0) |
| 205 | ||
| 206 | /* The same code works when not in UTF-8 mode and in UTF-8 mode when there | /* The same code works when not in UTF-8 mode and in UTF-8 mode when there |
| 207 | is no UCP support. */ | is no UCP support. */ |
| 208 | { | |
| 209 | while (length-- > 0) | if (eptr + length > md->end_subject) return -1; |
| 210 | { if (md->lcc[*p++] != md->lcc[*eptr++]) return FALSE; } | while (length-- > 0) |
| 211 | { if (md->lcc[*p++] != md->lcc[*eptr++]) return -1; } | |
| 212 | } | |
| 213 | } | } |
| 214 | ||
| 215 | /* In the caseful case, we can just compare the bytes, whether or not we | /* In the caseful case, we can just compare the bytes, whether or not we |
| 216 | are in UTF-8 mode. */ | are in UTF-8 mode. */ |
| 217 | ||
| 218 | else | else |
| 219 | { while (length-- > 0) if (*p++ != *eptr++) return FALSE; } | { |
| 220 | if (eptr + length > md->end_subject) return -1; | |
| 221 | while (length-- > 0) if (*p++ != *eptr++) return -1; | |
| 222 | } | |
| 223 | ||
| 224 | return TRUE; | return eptr - eptr_start; |
| 225 | } | } |
| 226 | ||
| 227 | ||
| # | Line 245 enum { RM1=1, RM2, RM3, RM4, RM5, RM | Line 272 enum { RM1=1, RM2, RM3, RM4, RM5, RM |
| 272 | RM21, RM22, RM23, RM24, RM25, RM26, RM27, RM28, RM29, RM30, | RM21, RM22, RM23, RM24, RM25, RM26, RM27, RM28, RM29, RM30, |
| 273 | RM31, RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40, | RM31, RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40, |
| 274 | RM41, RM42, RM43, RM44, RM45, RM46, RM47, RM48, RM49, RM50, | RM41, RM42, RM43, RM44, RM45, RM46, RM47, RM48, RM49, RM50, |
| 275 | RM51, RM52, RM53, RM54 }; | RM51, RM52, RM53, RM54, RM55, RM56, RM57, RM58, RM59, RM60, |
| 276 | RM61, RM62 }; | |
| 277 | ||
| 278 | /* 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 |
| 279 | 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 |
| # | Line 255 actually used in this definition. */ | Line 283 actually used in this definition. */ |
| 283 | #define REGISTER register | #define REGISTER register |
| 284 | ||
| 285 | #ifdef PCRE_DEBUG | #ifdef PCRE_DEBUG |
| 286 | #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \ | #define RMATCH(ra,rb,rc,rd,re,rf,rw) \ |
| 287 | { \ | { \ |
| 288 | printf("match() called in line %d\n", __LINE__); \ | printf("match() called in line %d\n", __LINE__); \ |
| 289 | rrc = match(ra,rb,mstart,markptr,rc,rd,re,rf,rg,rdepth+1); \ | rrc = match(ra,rb,mstart,markptr,rc,rd,re,rf,rdepth+1); \ |
| 290 | printf("to line %d\n", __LINE__); \ | printf("to line %d\n", __LINE__); \ |
| 291 | } | } |
| 292 | #define RRETURN(ra) \ | #define RRETURN(ra) \ |
| # | Line 267 actually used in this definition. */ | Line 295 actually used in this definition. */ |
| 295 | return ra; \ | return ra; \ |
| 296 | } | } |
| 297 | #else | #else |
| 298 | #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \ | #define RMATCH(ra,rb,rc,rd,re,rf,rw) \ |
| 299 | rrc = match(ra,rb,mstart,markptr,rc,rd,re,rf,rg,rdepth+1) | rrc = match(ra,rb,mstart,markptr,rc,rd,re,rf,rdepth+1) |
| 300 | #define RRETURN(ra) return ra | #define RRETURN(ra) return ra |
| 301 | #endif | #endif |
| 302 | ||
| # | Line 281 argument of match(), which never changes | Line 309 argument of match(), which never changes |
| 309 | ||
| 310 | #define REGISTER | #define REGISTER |
| 311 | ||
| 312 | #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw)\ | #define RMATCH(ra,rb,rc,rd,re,rf,rw)\ |
| 313 | {\ | {\ |
| 314 | heapframe *newframe = (pcre_stack_malloc)(sizeof(heapframe));\ | heapframe *newframe = (heapframe *)(pcre_stack_malloc)(sizeof(heapframe));\ |
| 315 | if (newframe == NULL) RRETURN(PCRE_ERROR_NOMEMORY);\ | |
| 316 | frame->Xwhere = rw; \ | frame->Xwhere = rw; \ |
| 317 | newframe->Xeptr = ra;\ | newframe->Xeptr = ra;\ |
| 318 | newframe->Xecode = rb;\ | newframe->Xecode = rb;\ |
| 319 | newframe->Xmstart = mstart;\ | newframe->Xmstart = mstart;\ |
| 320 | newframe->Xmarkptr = markptr;\ | newframe->Xmarkptr = markptr;\ |
| 321 | newframe->Xoffset_top = rc;\ | newframe->Xoffset_top = rc;\ |
| 322 | newframe->Xims = re;\ | newframe->Xeptrb = re;\ |
| 323 | newframe->Xeptrb = rf;\ | newframe->Xflags = rf;\ |
| newframe->Xflags = rg;\ | ||
| 324 | newframe->Xrdepth = frame->Xrdepth + 1;\ | newframe->Xrdepth = frame->Xrdepth + 1;\ |
| 325 | newframe->Xprevframe = frame;\ | newframe->Xprevframe = frame;\ |
| 326 | frame = newframe;\ | frame = newframe;\ |
| # | Line 304 argument of match(), which never changes | Line 332 argument of match(), which never changes |
| 332 | ||
| 333 | #define RRETURN(ra)\ | #define RRETURN(ra)\ |
| 334 | {\ | {\ |
| 335 | heapframe *newframe = frame;\ | heapframe *oldframe = frame;\ |
| 336 | frame = newframe->Xprevframe;\ | frame = oldframe->Xprevframe;\ |
| 337 | (pcre_stack_free)(newframe);\ | (pcre_stack_free)(oldframe);\ |
| 338 | if (frame != NULL)\ | if (frame != NULL)\ |
| 339 | {\ | {\ |
| 340 | rrc = ra;\ | rrc = ra;\ |
| # | Line 328 typedef struct heapframe { | Line 356 typedef struct heapframe { |
| 356 | USPTR Xmstart; | USPTR Xmstart; |
| 357 | USPTR Xmarkptr; | USPTR Xmarkptr; |
| 358 | int Xoffset_top; | int Xoffset_top; |
| long int Xims; | ||
| 359 | eptrblock *Xeptrb; | eptrblock *Xeptrb; |
| 360 | int Xflags; | int Xflags; |
| 361 | unsigned int Xrdepth; | unsigned int Xrdepth; |
| # | Line 351 typedef struct heapframe { | Line 378 typedef struct heapframe { |
| 378 | BOOL Xcondition; | BOOL Xcondition; |
| 379 | BOOL Xprev_is_word; | BOOL Xprev_is_word; |
| 380 | ||
| unsigned long int Xoriginal_ims; | ||
| 381 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 382 | int Xprop_type; | int Xprop_type; |
| 383 | int Xprop_value; | int Xprop_value; |
| # | Line 410 immediately. The second one is used when | Line 435 immediately. The second one is used when |
| 435 | the subject. */ | the subject. */ |
| 436 | ||
| 437 | #define CHECK_PARTIAL()\ | #define CHECK_PARTIAL()\ |
| 438 | if (md->partial != 0 && eptr >= md->end_subject && eptr > mstart)\ | if (md->partial != 0 && eptr >= md->end_subject && \ |
| 439 | {\ | eptr > md->start_used_ptr) \ |
| 440 | md->hitend = TRUE;\ | { \ |
| 441 | if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);\ | md->hitend = TRUE; \ |
| 442 | if (md->partial > 1) MRRETURN(PCRE_ERROR_PARTIAL); \ | |
| 443 | } | } |
| 444 | ||
| 445 | #define SCHECK_PARTIAL()\ | #define SCHECK_PARTIAL()\ |
| 446 | if (md->partial != 0 && eptr > mstart)\ | if (md->partial != 0 && eptr > md->start_used_ptr) \ |
| 447 | {\ | { \ |
| 448 | md->hitend = TRUE;\ | md->hitend = TRUE; \ |
| 449 | if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);\ | if (md->partial > 1) MRRETURN(PCRE_ERROR_PARTIAL); \ |
| 450 | } | } |
| 451 | ||
| 452 | ||
| # | Line 437 Arguments: | Line 463 Arguments: |
| 463 | markptr pointer to the most recent MARK name, or NULL | markptr pointer to the most recent MARK name, or NULL |
| 464 | offset_top current top pointer | offset_top current top pointer |
| 465 | md pointer to "static" info for the match | md pointer to "static" info for the match |
| ims current /i, /m, and /s options | ||
| 466 | eptrb pointer to chain of blocks containing eptr at start of | eptrb pointer to chain of blocks containing eptr at start of |
| 467 | brackets - for testing for empty matches | brackets - for testing for empty matches |
| 468 | flags can contain | flags can contain |
| # | Line 448 Arguments: | Line 473 Arguments: |
| 473 | ||
| 474 | Returns: MATCH_MATCH if matched ) these values are >= 0 | Returns: MATCH_MATCH if matched ) these values are >= 0 |
| 475 | MATCH_NOMATCH if failed to match ) | MATCH_NOMATCH if failed to match ) |
| 476 | a negative MATCH_xxx value for PRUNE, SKIP, etc | |
| 477 | a negative PCRE_ERROR_xxx value if aborted by an error condition | a negative PCRE_ERROR_xxx value if aborted by an error condition |
| 478 | (e.g. stopped by repeated call or recursion limit) | (e.g. stopped by repeated call or recursion limit) |
| 479 | */ | */ |
| 480 | ||
| 481 | static int | static int |
| 482 | match(REGISTER USPTR eptr, REGISTER const uschar *ecode, USPTR mstart, USPTR | match(REGISTER USPTR eptr, REGISTER const uschar *ecode, USPTR mstart, |
| 483 | markptr, int offset_top, match_data *md, unsigned long int ims, | const uschar *markptr, int offset_top, match_data *md, eptrblock *eptrb, |
| 484 | eptrblock *eptrb, int flags, unsigned int rdepth) | int flags, unsigned int rdepth) |
| 485 | { | { |
| 486 | /* 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, |
| 487 | 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 467 register unsigned int c; /* Character | Line 493 register unsigned int c; /* Character |
| 493 | register BOOL utf8; /* Local copy of UTF-8 flag for speed */ | register BOOL utf8; /* Local copy of UTF-8 flag for speed */ |
| 494 | ||
| 495 | BOOL minimize, possessive; /* Quantifier options */ | BOOL minimize, possessive; /* Quantifier options */ |
| 496 | BOOL caseless; | |
| 497 | int condcode; | int condcode; |
| 498 | ||
| 499 | /* 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 |
| # | Line 475 heap storage. Set up the top-level frame | Line 502 heap storage. Set up the top-level frame |
| 502 | heap whenever RMATCH() does a "recursion". See the macro definitions above. */ | heap whenever RMATCH() does a "recursion". See the macro definitions above. */ |
| 503 | ||
| 504 | #ifdef NO_RECURSE | #ifdef NO_RECURSE |
| 505 | heapframe *frame = (pcre_stack_malloc)(sizeof(heapframe)); | heapframe *frame = (heapframe *)(pcre_stack_malloc)(sizeof(heapframe)); |
| 506 | if (frame == NULL) RRETURN(PCRE_ERROR_NOMEMORY); | |
| 507 | frame->Xprevframe = NULL; /* Marks the top level */ | frame->Xprevframe = NULL; /* Marks the top level */ |
| 508 | ||
| 509 | /* Copy in the original argument variables */ | /* Copy in the original argument variables */ |
| # | Line 485 frame->Xecode = ecode; | Line 513 frame->Xecode = ecode; |
| 513 | frame->Xmstart = mstart; | frame->Xmstart = mstart; |
| 514 | frame->Xmarkptr = markptr; | frame->Xmarkptr = markptr; |
| 515 | frame->Xoffset_top = offset_top; | frame->Xoffset_top = offset_top; |
| frame->Xims = ims; | ||
| 516 | frame->Xeptrb = eptrb; | frame->Xeptrb = eptrb; |
| 517 | frame->Xflags = flags; | frame->Xflags = flags; |
| 518 | frame->Xrdepth = rdepth; | frame->Xrdepth = rdepth; |
| # | Line 501 HEAP_RECURSE: | Line 528 HEAP_RECURSE: |
| 528 | #define mstart frame->Xmstart | #define mstart frame->Xmstart |
| 529 | #define markptr frame->Xmarkptr | #define markptr frame->Xmarkptr |
| 530 | #define offset_top frame->Xoffset_top | #define offset_top frame->Xoffset_top |
| #define ims frame->Xims | ||
| 531 | #define eptrb frame->Xeptrb | #define eptrb frame->Xeptrb |
| 532 | #define flags frame->Xflags | #define flags frame->Xflags |
| 533 | #define rdepth frame->Xrdepth | #define rdepth frame->Xrdepth |
| # | Line 525 HEAP_RECURSE: | Line 551 HEAP_RECURSE: |
| 551 | #define condition frame->Xcondition | #define condition frame->Xcondition |
| 552 | #define prev_is_word frame->Xprev_is_word | #define prev_is_word frame->Xprev_is_word |
| 553 | ||
| #define original_ims frame->Xoriginal_ims | ||
| 554 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 555 | #define prop_type frame->Xprop_type | #define prop_type frame->Xprop_type |
| 556 | #define prop_value frame->Xprop_value | #define prop_value frame->Xprop_value |
| # | Line 580 BOOL cur_is_word; /* a | Line 604 BOOL cur_is_word; /* a |
| 604 | BOOL condition; | BOOL condition; |
| 605 | BOOL prev_is_word; | BOOL prev_is_word; |
| 606 | ||
| unsigned long int original_ims; | ||
| 607 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 608 | int prop_type; | int prop_type; |
| 609 | int prop_value; | int prop_value; |
| # | Line 644 haven't exceeded the recursive call limi | Line 666 haven't exceeded the recursive call limi |
| 666 | if (md->match_call_count++ >= md->match_limit) RRETURN(PCRE_ERROR_MATCHLIMIT); | if (md->match_call_count++ >= md->match_limit) RRETURN(PCRE_ERROR_MATCHLIMIT); |
| 667 | if (rdepth >= md->match_limit_recursion) RRETURN(PCRE_ERROR_RECURSIONLIMIT); | if (rdepth >= md->match_limit_recursion) RRETURN(PCRE_ERROR_RECURSIONLIMIT); |
| 668 | ||
| original_ims = ims; /* Save for resetting on ')' */ | ||
| 669 | /* At the start of a group with an unlimited repeat that may match an empty | /* At the start of a group with an unlimited repeat that may match an empty |
| 670 | string, the match_cbegroup flag is set. When this is the case, add the current | string, the match_cbegroup flag is set. When this is the case, add the current |
| 671 | subject pointer to the chain of such remembered pointers, to be checked when we | subject pointer to the chain of such remembered pointers, to be checked when we |
| # | Line 671 for (;;) | Line 691 for (;;) |
| 691 | ||
| 692 | switch(op) | switch(op) |
| 693 | { | { |
| 694 | case OP_MARK: | |
| 695 | markptr = ecode + 2; | |
| 696 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md, | |
| 697 | eptrb, flags, RM55); | |
| 698 | ||
| 699 | /* A return of MATCH_SKIP_ARG means that matching failed at SKIP with an | |
| 700 | argument, and we must check whether that argument matches this MARK's | |
| 701 | argument. It is passed back in md->start_match_ptr (an overloading of that | |
| 702 | variable). If it does match, we reset that variable to the current subject | |
| 703 | position and return MATCH_SKIP. Otherwise, pass back the return code | |
| 704 | unaltered. */ | |
| 705 | ||
| 706 | if (rrc == MATCH_SKIP_ARG && | |
| 707 | strcmp((char *)markptr, (char *)(md->start_match_ptr)) == 0) | |
| 708 | { | |
| 709 | md->start_match_ptr = eptr; | |
| 710 | RRETURN(MATCH_SKIP); | |
| 711 | } | |
| 712 | ||
| 713 | if (md->mark == NULL) md->mark = markptr; | |
| 714 | RRETURN(rrc); | |
| 715 | ||
| 716 | case OP_FAIL: | case OP_FAIL: |
| 717 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 718 | ||
| 719 | /* COMMIT overrides PRUNE, SKIP, and THEN */ | |
| 720 | ||
| 721 | case OP_COMMIT: | |
| 722 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | |
| 723 | eptrb, flags, RM52); | |
| 724 | if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && | |
| 725 | rrc != MATCH_SKIP && rrc != MATCH_SKIP_ARG && | |
| 726 | rrc != MATCH_THEN) | |
| 727 | RRETURN(rrc); | |
| 728 | MRRETURN(MATCH_COMMIT); | |
| 729 | ||
| 730 | /* PRUNE overrides THEN */ | |
| 731 | ||
| 732 | case OP_PRUNE: | case OP_PRUNE: |
| 733 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
| 734 | ims, eptrb, flags, RM51); | eptrb, flags, RM51); |
| 735 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); |
| 736 | MRRETURN(MATCH_PRUNE); | |
| 737 | ||
| 738 | case OP_PRUNE_ARG: | |
| 739 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md, | |
| 740 | eptrb, flags, RM56); | |
| 741 | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); | |
| 742 | md->mark = ecode + 2; | |
| 743 | RRETURN(MATCH_PRUNE); | RRETURN(MATCH_PRUNE); |
| 744 | ||
| 745 | case OP_COMMIT: | /* SKIP overrides PRUNE and THEN */ |
| RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | ||
| ims, eptrb, flags, RM52); | ||
| if (rrc != MATCH_NOMATCH) RRETURN(rrc); | ||
| RRETURN(MATCH_COMMIT); | ||
| 746 | ||
| 747 | case OP_SKIP: | case OP_SKIP: |
| 748 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
| 749 | ims, eptrb, flags, RM53); | eptrb, flags, RM53); |
| 750 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN) |
| 751 | RRETURN(rrc); | |
| 752 | md->start_match_ptr = eptr; /* Pass back current position */ | md->start_match_ptr = eptr; /* Pass back current position */ |
| 753 | RRETURN(MATCH_SKIP); | MRRETURN(MATCH_SKIP); |
| 754 | ||
| 755 | case OP_SKIP_ARG: | |
| 756 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md, | |
| 757 | eptrb, flags, RM57); | |
| 758 | if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN) | |
| 759 | RRETURN(rrc); | |
| 760 | ||
| 761 | /* Pass back the current skip name by overloading md->start_match_ptr and | |
| 762 | returning the special MATCH_SKIP_ARG return code. This will either be | |
| 763 | caught by a matching MARK, or get to the top, where it is treated the same | |
| 764 | as PRUNE. */ | |
| 765 | ||
| 766 | md->start_match_ptr = ecode + 2; | |
| 767 | RRETURN(MATCH_SKIP_ARG); | |
| 768 | ||
| 769 | /* For THEN (and THEN_ARG) we pass back the address of the bracket or | |
| 770 | the alt that is at the start of the current branch. This makes it possible | |
| 771 | to skip back past alternatives that precede the THEN within the current | |
| 772 | branch. */ | |
| 773 | ||
| 774 | case OP_THEN: | case OP_THEN: |
| 775 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
| 776 | ims, eptrb, flags, RM54); | eptrb, flags, RM54); |
| 777 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | |
| 778 | md->start_match_ptr = ecode - GET(ecode, 1); | |
| 779 | MRRETURN(MATCH_THEN); | |
| 780 | ||
| 781 | case OP_THEN_ARG: | |
| 782 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1+LINK_SIZE], | |
| 783 | offset_top, md, eptrb, flags, RM58); | |
| 784 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 785 | md->start_match_ptr = ecode - GET(ecode, 1); | |
| 786 | md->mark = ecode + LINK_SIZE + 2; | |
| 787 | RRETURN(MATCH_THEN); | RRETURN(MATCH_THEN); |
| 788 | ||
| 789 | /* 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 733 for (;;) | Line 820 for (;;) |
| 820 | save_capture_last = md->capture_last; | save_capture_last = md->capture_last; |
| 821 | ||
| 822 | DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3)); | DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3)); |
| 823 | md->offset_vector[md->offset_end - number] = eptr - md->start_subject; | md->offset_vector[md->offset_end - number] = |
| 824 | (int)(eptr - md->start_subject); | |
| 825 | ||
| 826 | flags = (op == OP_SCBRA)? match_cbegroup : 0; | flags = (op == OP_SCBRA)? match_cbegroup : 0; |
| 827 | do | do |
| 828 | { | { |
| 829 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
| 830 | ims, eptrb, flags, RM1); | eptrb, flags, RM1); |
| 831 | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); | if (rrc != MATCH_NOMATCH && |
| 832 | (rrc != MATCH_THEN || md->start_match_ptr != ecode)) | |
| 833 | RRETURN(rrc); | |
| 834 | md->capture_last = save_capture_last; | md->capture_last = save_capture_last; |
| 835 | ecode += GET(ecode, 1); | ecode += GET(ecode, 1); |
| 836 | } | } |
| # | Line 752 for (;;) | Line 842 for (;;) |
| 842 | md->offset_vector[offset+1] = save_offset2; | md->offset_vector[offset+1] = save_offset2; |
| 843 | md->offset_vector[md->offset_end - number] = save_offset3; | md->offset_vector[md->offset_end - number] = save_offset3; |
| 844 | ||
| 845 | if (rrc != MATCH_THEN) md->mark = markptr; | |
| 846 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 847 | } | } |
| 848 | ||
| # | Line 789 for (;;) | Line 880 for (;;) |
| 880 | ||
| 881 | /* Possibly empty group; can't use tail recursion. */ | /* Possibly empty group; can't use tail recursion. */ |
| 882 | ||
| 883 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims, | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, eptrb, |
| 884 | eptrb, flags, RM48); | flags, RM48); |
| 885 | if (rrc == MATCH_NOMATCH) md->mark = markptr; | |
| 886 | RRETURN(rrc); | RRETURN(rrc); |
| 887 | } | } |
| 888 | ||
| 889 | /* For non-final alternatives, continue the loop for a NOMATCH result; | /* For non-final alternatives, continue the loop for a NOMATCH result; |
| 890 | otherwise return. */ | otherwise return. */ |
| 891 | ||
| 892 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims, | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, eptrb, |
| 893 | eptrb, flags, RM2); | flags, RM2); |
| 894 | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); | if (rrc != MATCH_NOMATCH && |
| 895 | (rrc != MATCH_THEN || md->start_match_ptr != ecode)) | |
| 896 | RRETURN(rrc); | |
| 897 | ecode += GET(ecode, 1); | ecode += GET(ecode, 1); |
| 898 | } | } |
| 899 | /* Control never reaches here. */ | /* Control never reaches here. */ |
| # | Line 826 for (;;) | Line 920 for (;;) |
| 920 | cb.callout_number = ecode[LINK_SIZE+2]; | cb.callout_number = ecode[LINK_SIZE+2]; |
| 921 | cb.offset_vector = md->offset_vector; | cb.offset_vector = md->offset_vector; |
| 922 | cb.subject = (PCRE_SPTR)md->start_subject; | cb.subject = (PCRE_SPTR)md->start_subject; |
| 923 | cb.subject_length = md->end_subject - md->start_subject; | cb.subject_length = (int)(md->end_subject - md->start_subject); |
| 924 | cb.start_match = mstart - md->start_subject; | cb.start_match = (int)(mstart - md->start_subject); |
| 925 | cb.current_position = eptr - md->start_subject; | cb.current_position = (int)(eptr - md->start_subject); |
| 926 | cb.pattern_position = GET(ecode, LINK_SIZE + 3); | cb.pattern_position = GET(ecode, LINK_SIZE + 3); |
| 927 | cb.next_item_length = GET(ecode, 3 + 2*LINK_SIZE); | cb.next_item_length = GET(ecode, 3 + 2*LINK_SIZE); |
| 928 | cb.capture_top = offset_top/2; | cb.capture_top = offset_top/2; |
| 929 | cb.capture_last = md->capture_last; | cb.capture_last = md->capture_last; |
| 930 | cb.callout_data = md->callout_data; | cb.callout_data = md->callout_data; |
| 931 | if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH); | if ((rrc = (*pcre_callout)(&cb)) > 0) MRRETURN(MATCH_NOMATCH); |
| 932 | if (rrc < 0) RRETURN(rrc); | if (rrc < 0) RRETURN(rrc); |
| 933 | } | } |
| 934 | ecode += _pcre_OP_lengths[OP_CALLOUT]; | ecode += _pcre_OP_lengths[OP_CALLOUT]; |
| # | Line 992 for (;;) | Line 1086 for (;;) |
| 1086 | ||
| 1087 | else | else |
| 1088 | { | { |
| 1089 | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, |
| 1090 | match_condassert, RM3); | match_condassert, RM3); |
| 1091 | if (rrc == MATCH_MATCH) | if (rrc == MATCH_MATCH) |
| 1092 | { | { |
| # | Line 1000 for (;;) | Line 1094 for (;;) |
| 1094 | ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2); | ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2); |
| 1095 | while (*ecode == OP_ALT) ecode += GET(ecode, 1); | while (*ecode == OP_ALT) ecode += GET(ecode, 1); |
| 1096 | } | } |
| 1097 | else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) | else if (rrc != MATCH_NOMATCH && |
| 1098 | (rrc != MATCH_THEN || md->start_match_ptr != ecode)) | |
| 1099 | { | { |
| 1100 | RRETURN(rrc); /* Need braces because of following else */ | RRETURN(rrc); /* Need braces because of following else */ |
| 1101 | } | } |
| # | Line 1021 for (;;) | Line 1116 for (;;) |
| 1116 | ecode += 1 + LINK_SIZE; | ecode += 1 + LINK_SIZE; |
| 1117 | if (op == OP_SCOND) /* Possibly empty group */ | if (op == OP_SCOND) /* Possibly empty group */ |
| 1118 | { | { |
| 1119 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, match_cbegroup, RM49); | RMATCH(eptr, ecode, offset_top, md, eptrb, match_cbegroup, RM49); |
| 1120 | RRETURN(rrc); | RRETURN(rrc); |
| 1121 | } | } |
| 1122 | else /* Group must match something */ | else /* Group must match something */ |
| # | Line 1054 for (;;) | Line 1149 for (;;) |
| 1149 | { | { |
| 1150 | md->offset_vector[offset] = | md->offset_vector[offset] = |
| 1151 | md->offset_vector[md->offset_end - number]; | md->offset_vector[md->offset_end - number]; |
| 1152 | md->offset_vector[offset+1] = eptr - md->start_subject; | md->offset_vector[offset+1] = (int)(eptr - md->start_subject); |
| 1153 | if (offset_top <= offset) offset_top = offset + 2; | if (offset_top <= offset) offset_top = offset + 2; |
| 1154 | } | } |
| 1155 | ecode += 3; | ecode += 3; |
| # | Line 1075 for (;;) | Line 1170 for (;;) |
| 1170 | memmove(md->offset_vector, rec->offset_save, | memmove(md->offset_vector, rec->offset_save, |
| 1171 | rec->saved_max * sizeof(int)); | rec->saved_max * sizeof(int)); |
| 1172 | offset_top = rec->save_offset_top; | offset_top = rec->save_offset_top; |
| ims = original_ims; | ||
| 1173 | ecode = rec->after_call; | ecode = rec->after_call; |
| 1174 | break; | break; |
| 1175 | } | } |
| # | Line 1089 for (;;) | Line 1183 for (;;) |
| 1183 | (md->notempty || | (md->notempty || |
| 1184 | (md->notempty_atstart && | (md->notempty_atstart && |
| 1185 | mstart == md->start_subject + md->start_offset))) | mstart == md->start_subject + md->start_offset))) |
| 1186 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1187 | ||
| 1188 | /* Otherwise, we have a match. */ | /* Otherwise, we have a match. */ |
| 1189 | ||
| 1190 | md->end_match_ptr = eptr; /* Record where we ended */ | md->end_match_ptr = eptr; /* Record where we ended */ |
| 1191 | md->end_offset_top = offset_top; /* and how many extracts were taken */ | md->end_offset_top = offset_top; /* and how many extracts were taken */ |
| 1192 | md->start_match_ptr = mstart; /* and the start (\K can modify) */ | md->start_match_ptr = mstart; /* and the start (\K can modify) */ |
| RRETURN(MATCH_MATCH); | ||
| 1193 | ||
| 1194 | /* Change option settings */ | /* For some reason, the macros don't work properly if an expression is |
| 1195 | given as the argument to MRRETURN when the heap is in use. */ | |
| 1196 | ||
| 1197 | case OP_OPT: | rrc = (op == OP_END)? MATCH_MATCH : MATCH_ACCEPT; |
| 1198 | ims = ecode[1]; | MRRETURN(rrc); |
| ecode += 2; | ||
| DPRINTF(("ims set to %02lx\n", ims)); | ||
| break; | ||
| 1199 | ||
| 1200 | /* Assertion brackets. Check the alternative branches in turn - the | /* Assertion brackets. Check the alternative branches in turn - the |
| 1201 | matching won't pass the KET for an assertion. If any one branch matches, | matching won't pass the KET for an assertion. If any one branch matches, |
| # | Line 1116 for (;;) | Line 1207 for (;;) |
| 1207 | case OP_ASSERTBACK: | case OP_ASSERTBACK: |
| 1208 | do | do |
| 1209 | { | { |
| 1210 | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0, | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, 0, |
| 1211 | RM4); | RM4); |
| 1212 | if (rrc == MATCH_MATCH) | if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) |
| 1213 | { | { |
| 1214 | mstart = md->start_match_ptr; /* In case \K reset it */ | mstart = md->start_match_ptr; /* In case \K reset it */ |
| 1215 | break; | break; |
| 1216 | } | } |
| 1217 | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); | if (rrc != MATCH_NOMATCH && |
| 1218 | (rrc != MATCH_THEN || md->start_match_ptr != ecode)) | |
| 1219 | RRETURN(rrc); | |
| 1220 | ecode += GET(ecode, 1); | ecode += GET(ecode, 1); |
| 1221 | } | } |
| 1222 | while (*ecode == OP_ALT); | while (*ecode == OP_ALT); |
| 1223 | if (*ecode == OP_KET) RRETURN(MATCH_NOMATCH); | if (*ecode == OP_KET) MRRETURN(MATCH_NOMATCH); |
| 1224 | ||
| 1225 | /* If checking an assertion for a condition, return MATCH_MATCH. */ | /* If checking an assertion for a condition, return MATCH_MATCH. */ |
| 1226 | ||
| # | Line 1149 for (;;) | Line 1242 for (;;) |
| 1242 | case OP_ASSERTBACK_NOT: | case OP_ASSERTBACK_NOT: |
| 1243 | do | do |
| 1244 | { | { |
| 1245 | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0, | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, 0, |
| 1246 | RM5); | RM5); |
| 1247 | if (rrc == MATCH_MATCH) RRETURN(MATCH_NOMATCH); | if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) MRRETURN(MATCH_NOMATCH); |
| 1248 | if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT) | if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT) |
| 1249 | { | { |
| 1250 | do ecode += GET(ecode,1); while (*ecode == OP_ALT); | do ecode += GET(ecode,1); while (*ecode == OP_ALT); |
| 1251 | break; | break; |
| 1252 | } | } |
| 1253 | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); | if (rrc != MATCH_NOMATCH && |
| 1254 | (rrc != MATCH_THEN || md->start_match_ptr != ecode)) | |
| 1255 | RRETURN(rrc); | |
| 1256 | ecode += GET(ecode,1); | ecode += GET(ecode,1); |
| 1257 | } | } |
| 1258 | while (*ecode == OP_ALT); | while (*ecode == OP_ALT); |
| # | Line 1180 for (;;) | Line 1275 for (;;) |
| 1275 | while (i-- > 0) | while (i-- > 0) |
| 1276 | { | { |
| 1277 | eptr--; | eptr--; |
| 1278 | if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH); | if (eptr < md->start_subject) MRRETURN(MATCH_NOMATCH); |
| 1279 | BACKCHAR(eptr); | BACKCHAR(eptr); |
| 1280 | } | } |
| 1281 | } | } |
| # | Line 1191 for (;;) | Line 1286 for (;;) |
| 1286 | ||
| 1287 | { | { |
| 1288 | eptr -= GET(ecode, 1); | eptr -= GET(ecode, 1); |
| 1289 | if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH); | if (eptr < md->start_subject) MRRETURN(MATCH_NOMATCH); |
| 1290 | } | } |
| 1291 | ||
| 1292 | /* Save the earliest consulted character, then skip to next op code */ | /* Save the earliest consulted character, then skip to next op code */ |
| # | Line 1212 for (;;) | Line 1307 for (;;) |
| 1307 | cb.callout_number = ecode[1]; | cb.callout_number = ecode[1]; |
| 1308 | cb.offset_vector = md->offset_vector; | cb.offset_vector = md->offset_vector; |
| 1309 | cb.subject = (PCRE_SPTR)md->start_subject; | cb.subject = (PCRE_SPTR)md->start_subject; |
| 1310 | cb.subject_length = md->end_subject - md->start_subject; | cb.subject_length = (int)(md->end_subject - md->start_subject); |
| 1311 | cb.start_match = mstart - md->start_subject; | cb.start_match = (int)(mstart - md->start_subject); |
| 1312 | cb.current_position = eptr - md->start_subject; | cb.current_position = (int)(eptr - md->start_subject); |
| 1313 | cb.pattern_position = GET(ecode, 2); | cb.pattern_position = GET(ecode, 2); |
| 1314 | cb.next_item_length = GET(ecode, 2 + LINK_SIZE); | cb.next_item_length = GET(ecode, 2 + LINK_SIZE); |
| 1315 | cb.capture_top = offset_top/2; | cb.capture_top = offset_top/2; |
| 1316 | cb.capture_last = md->capture_last; | cb.capture_last = md->capture_last; |
| 1317 | cb.callout_data = md->callout_data; | cb.callout_data = md->callout_data; |
| 1318 | if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH); | if ((rrc = (*pcre_callout)(&cb)) > 0) MRRETURN(MATCH_NOMATCH); |
| 1319 | if (rrc < 0) RRETURN(rrc); | if (rrc < 0) RRETURN(rrc); |
| 1320 | } | } |
| 1321 | ecode += 2 + 2*LINK_SIZE; | ecode += 2 + 2*LINK_SIZE; |
| # | Line 1285 for (;;) | Line 1380 for (;;) |
| 1380 | do | do |
| 1381 | { | { |
| 1382 | RMATCH(eptr, callpat + _pcre_OP_lengths[*callpat], offset_top, | RMATCH(eptr, callpat + _pcre_OP_lengths[*callpat], offset_top, |
| 1383 | md, ims, eptrb, flags, RM6); | md, eptrb, flags, RM6); |
| 1384 | if (rrc == MATCH_MATCH) | if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) |
| 1385 | { | { |
| 1386 | DPRINTF(("Recursion matched\n")); | DPRINTF(("Recursion matched\n")); |
| 1387 | md->recursive = new_recursive.prevrec; | md->recursive = new_recursive.prevrec; |
| 1388 | if (new_recursive.offset_save != stacksave) | if (new_recursive.offset_save != stacksave) |
| 1389 | (pcre_free)(new_recursive.offset_save); | (pcre_free)(new_recursive.offset_save); |
| 1390 | RRETURN(MATCH_MATCH); | MRRETURN(MATCH_MATCH); |
| 1391 | } | } |
| 1392 | else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) | else if (rrc != MATCH_NOMATCH && |
| 1393 | (rrc != MATCH_THEN || md->start_match_ptr != ecode)) | |
| 1394 | { | { |
| 1395 | DPRINTF(("Recursion gave error %d\n", rrc)); | DPRINTF(("Recursion gave error %d\n", rrc)); |
| 1396 | if (new_recursive.offset_save != stacksave) | if (new_recursive.offset_save != stacksave) |
| # | Line 1313 for (;;) | Line 1409 for (;;) |
| 1409 | md->recursive = new_recursive.prevrec; | md->recursive = new_recursive.prevrec; |
| 1410 | if (new_recursive.offset_save != stacksave) | if (new_recursive.offset_save != stacksave) |
| 1411 | (pcre_free)(new_recursive.offset_save); | (pcre_free)(new_recursive.offset_save); |
| 1412 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1413 | } | } |
| 1414 | /* Control never reaches here */ | /* Control never reaches here */ |
| 1415 | ||
| # | Line 1331 for (;;) | Line 1427 for (;;) |
| 1427 | ||
| 1428 | do | do |
| 1429 | { | { |
| 1430 | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM7); | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, 0, RM7); |
| 1431 | if (rrc == MATCH_MATCH) | if (rrc == MATCH_MATCH) /* Note: _not_ MATCH_ACCEPT */ |
| 1432 | { | { |
| 1433 | mstart = md->start_match_ptr; | mstart = md->start_match_ptr; |
| 1434 | break; | break; |
| 1435 | } | } |
| 1436 | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); | if (rrc != MATCH_NOMATCH && |
| 1437 | (rrc != MATCH_THEN || md->start_match_ptr != ecode)) | |
| 1438 | RRETURN(rrc); | |
| 1439 | ecode += GET(ecode,1); | ecode += GET(ecode,1); |
| 1440 | } | } |
| 1441 | while (*ecode == OP_ALT); | while (*ecode == OP_ALT); |
| # | Line 1368 for (;;) | Line 1466 for (;;) |
| 1466 | ||
| 1467 | /* The repeating kets try the rest of the pattern or restart from the | /* The repeating kets try the rest of the pattern or restart from the |
| 1468 | preceding bracket, in the appropriate order. The second "call" of match() | preceding bracket, in the appropriate order. The second "call" of match() |
| 1469 | uses tail recursion, to avoid using another stack frame. We need to reset | uses tail recursion, to avoid using another stack frame. */ |
| any options that changed within the bracket before re-running it, so | ||
| check the next opcode. */ | ||
| if (ecode[1+LINK_SIZE] == OP_OPT) | ||
| { | ||
| ims = (ims & ~PCRE_IMS) | ecode[4]; | ||
| DPRINTF(("ims set to %02lx at group repeat\n", ims)); | ||
| } | ||
| 1470 | ||
| 1471 | if (*ecode == OP_KETRMIN) | if (*ecode == OP_KETRMIN) |
| 1472 | { | { |
| 1473 | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM8); | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, 0, RM8); |
| 1474 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1475 | ecode = prev; | ecode = prev; |
| 1476 | flags = 0; | flags = 0; |
| # | Line 1388 for (;;) | Line 1478 for (;;) |
| 1478 | } | } |
| 1479 | else /* OP_KETRMAX */ | else /* OP_KETRMAX */ |
| 1480 | { | { |
| 1481 | RMATCH(eptr, prev, offset_top, md, ims, eptrb, match_cbegroup, RM9); | RMATCH(eptr, prev, offset_top, md, eptrb, match_cbegroup, RM9); |
| 1482 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1483 | ecode += 1 + LINK_SIZE; | ecode += 1 + LINK_SIZE; |
| 1484 | flags = 0; | flags = 0; |
| # | Line 1412 for (;;) | Line 1502 for (;;) |
| 1502 | case OP_BRAZERO: | case OP_BRAZERO: |
| 1503 | { | { |
| 1504 | next = ecode+1; | next = ecode+1; |
| 1505 | RMATCH(eptr, next, offset_top, md, ims, eptrb, 0, RM10); | RMATCH(eptr, next, offset_top, md, eptrb, 0, RM10); |
| 1506 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1507 | do next += GET(next,1); while (*next == OP_ALT); | do next += GET(next,1); while (*next == OP_ALT); |
| 1508 | ecode = next + 1 + LINK_SIZE; | ecode = next + 1 + LINK_SIZE; |
| # | Line 1423 for (;;) | Line 1513 for (;;) |
| 1513 | { | { |
| 1514 | next = ecode+1; | next = ecode+1; |
| 1515 | do next += GET(next, 1); while (*next == OP_ALT); | do next += GET(next, 1); while (*next == OP_ALT); |
| 1516 | RMATCH(eptr, next + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0, RM11); | RMATCH(eptr, next + 1+LINK_SIZE, offset_top, md, eptrb, 0, RM11); |
| 1517 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1518 | ecode++; | ecode++; |
| 1519 | } | } |
| # | Line 1467 for (;;) | Line 1557 for (;;) |
| 1557 | md->end_match_ptr = eptr; /* For ONCE */ | md->end_match_ptr = eptr; /* For ONCE */ |
| 1558 | md->end_offset_top = offset_top; | md->end_offset_top = offset_top; |
| 1559 | md->start_match_ptr = mstart; | md->start_match_ptr = mstart; |
| 1560 | RRETURN(MATCH_MATCH); | MRRETURN(MATCH_MATCH); |
| 1561 | } | } |
| 1562 | ||
| 1563 | /* 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 1491 for (;;) | Line 1581 for (;;) |
| 1581 | { | { |
| 1582 | md->offset_vector[offset] = | md->offset_vector[offset] = |
| 1583 | md->offset_vector[md->offset_end - number]; | md->offset_vector[md->offset_end - number]; |
| 1584 | md->offset_vector[offset+1] = eptr - md->start_subject; | md->offset_vector[offset+1] = (int)(eptr - md->start_subject); |
| 1585 | if (offset_top <= offset) offset_top = offset + 2; | if (offset_top <= offset) offset_top = offset + 2; |
| 1586 | } | } |
| 1587 | ||
| # | Line 1507 for (;;) | Line 1597 for (;;) |
| 1597 | rec->saved_max * sizeof(int)); | rec->saved_max * sizeof(int)); |
| 1598 | offset_top = rec->save_offset_top; | offset_top = rec->save_offset_top; |
| 1599 | ecode = rec->after_call; | ecode = rec->after_call; |
| ims = original_ims; | ||
| 1600 | break; | break; |
| 1601 | } | } |
| 1602 | } | } |
| 1603 | ||
| /* For both capturing and non-capturing groups, reset the value of the ims | ||
| flags, in case they got changed during the group. */ | ||
| ims = original_ims; | ||
| DPRINTF(("ims reset to %02lx\n", ims)); | ||
| 1604 | /* For a non-repeating ket, just continue at this level. This also | /* For a non-repeating ket, just continue at this level. This also |
| 1605 | happens for a repeating ket if no characters were matched in the group. | happens for a repeating ket if no characters were matched in the group. |
| 1606 | This is the forcible breaking of infinite loops as implemented in Perl | This is the forcible breaking of infinite loops as implemented in Perl |
| # | Line 1539 for (;;) | Line 1622 for (;;) |
| 1622 | ||
| 1623 | if (*ecode == OP_KETRMIN) | if (*ecode == OP_KETRMIN) |
| 1624 | { | { |
| 1625 | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM12); | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, 0, RM12); |
| 1626 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1627 | if (flags != 0) /* Could match an empty string */ | if (flags != 0) /* Could match an empty string */ |
| 1628 | { | { |
| 1629 | RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM50); | RMATCH(eptr, prev, offset_top, md, eptrb, flags, RM50); |
| 1630 | RRETURN(rrc); | RRETURN(rrc); |
| 1631 | } | } |
| 1632 | ecode = prev; | ecode = prev; |
| # | Line 1551 for (;;) | Line 1634 for (;;) |
| 1634 | } | } |
| 1635 | else /* OP_KETRMAX */ | else /* OP_KETRMAX */ |
| 1636 | { | { |
| 1637 | RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM13); | RMATCH(eptr, prev, offset_top, md, eptrb, flags, RM13); |
| 1638 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1639 | ecode += 1 + LINK_SIZE; | ecode += 1 + LINK_SIZE; |
| 1640 | flags = 0; | flags = 0; |
| # | Line 1559 for (;;) | Line 1642 for (;;) |
| 1642 | } | } |
| 1643 | /* Control never gets here */ | /* Control never gets here */ |
| 1644 | ||
| 1645 | /* Start of subject unless notbol, or after internal newline if multiline */ | /* Not multiline mode: start of subject assertion, unless notbol. */ |
| 1646 | ||
| 1647 | case OP_CIRC: | case OP_CIRC: |
| 1648 | if (md->notbol && eptr == md->start_subject) RRETURN(MATCH_NOMATCH); | if (md->notbol && eptr == md->start_subject) MRRETURN(MATCH_NOMATCH); |
| 1649 | if ((ims & PCRE_MULTILINE) != 0) | |
| { | ||
| if (eptr != md->start_subject && | ||
| (eptr == md->end_subject || !WAS_NEWLINE(eptr))) | ||
| RRETURN(MATCH_NOMATCH); | ||
| ecode++; | ||
| break; | ||
| } | ||
| /* ... else fall through */ | ||
| 1650 | /* Start of subject assertion */ | /* Start of subject assertion */ |
| 1651 | ||
| 1652 | case OP_SOD: | case OP_SOD: |
| 1653 | if (eptr != md->start_subject) RRETURN(MATCH_NOMATCH); | if (eptr != md->start_subject) MRRETURN(MATCH_NOMATCH); |
| 1654 | ecode++; | |
| 1655 | break; | |
| 1656 | ||
| 1657 | /* Multiline mode: start of subject unless notbol, or after any newline. */ | |
| 1658 | ||
| 1659 | case OP_CIRCM: | |
| 1660 | if (md->notbol && eptr == md->start_subject) MRRETURN(MATCH_NOMATCH); | |
| 1661 | if (eptr != md->start_subject && | |
| 1662 | (eptr == md->end_subject || !WAS_NEWLINE(eptr))) | |
| 1663 | MRRETURN(MATCH_NOMATCH); | |
| 1664 | ecode++; | ecode++; |
| 1665 | break; | break; |
| 1666 | ||
| 1667 | /* Start of match assertion */ | /* Start of match assertion */ |
| 1668 | ||
| 1669 | case OP_SOM: | case OP_SOM: |
| 1670 | if (eptr != md->start_subject + md->start_offset) RRETURN(MATCH_NOMATCH); | if (eptr != md->start_subject + md->start_offset) MRRETURN(MATCH_NOMATCH); |
| 1671 | ecode++; | ecode++; |
| 1672 | break; | break; |
| 1673 | ||
| # | Line 1594 for (;;) | Line 1678 for (;;) |
| 1678 | ecode++; | ecode++; |
| 1679 | break; | break; |
| 1680 | ||
| 1681 | /* Assert before internal newline if multiline, or before a terminating | /* Multiline mode: assert before any newline, or before end of subject |
| 1682 | newline unless endonly is set, else end of subject unless noteol is set. */ | unless noteol is set. */ |
| 1683 | ||
| 1684 | case OP_DOLL: | case OP_DOLLM: |
| 1685 | if ((ims & PCRE_MULTILINE) != 0) | if (eptr < md->end_subject) |
| 1686 | { | { if (!IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH); } |
| if (eptr < md->end_subject) | ||
| { if (!IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); } | ||
| else | ||
| { if (md->noteol) RRETURN(MATCH_NOMATCH); } | ||
| ecode++; | ||
| break; | ||
| } | ||
| 1687 | else | else |
| 1688 | { | { |
| 1689 | if (md->noteol) RRETURN(MATCH_NOMATCH); | if (md->noteol) MRRETURN(MATCH_NOMATCH); |
| 1690 | if (!md->endonly) | SCHECK_PARTIAL(); |
| { | ||
| if (eptr != md->end_subject && | ||
| (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen)) | ||
| RRETURN(MATCH_NOMATCH); | ||
| ecode++; | ||
| break; | ||
| } | ||
| 1691 | } | } |
| 1692 | ecode++; | |
| 1693 | break; | |
| 1694 | ||
| 1695 | /* Not multiline mode: assert before a terminating newline or before end of | |
| 1696 | subject unless noteol is set. */ | |
| 1697 | ||
| 1698 | case OP_DOLL: | |
| 1699 | if (md->noteol) MRRETURN(MATCH_NOMATCH); | |
| 1700 | if (!md->endonly) goto ASSERT_NL_OR_EOS; | |
| 1701 | ||
| 1702 | /* ... else fall through for endonly */ | /* ... else fall through for endonly */ |
| 1703 | ||
| 1704 | /* End of subject assertion (\z) */ | /* End of subject assertion (\z) */ |
| 1705 | ||
| 1706 | case OP_EOD: | case OP_EOD: |
| 1707 | if (eptr < md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr < md->end_subject) MRRETURN(MATCH_NOMATCH); |
| 1708 | SCHECK_PARTIAL(); | |
| 1709 | ecode++; | ecode++; |
| 1710 | break; | break; |
| 1711 | ||
| 1712 | /* End of subject or ending \n assertion (\Z) */ | /* End of subject or ending \n assertion (\Z) */ |
| 1713 | ||
| 1714 | case OP_EODN: | case OP_EODN: |
| 1715 | if (eptr != md->end_subject && | ASSERT_NL_OR_EOS: |
| 1716 | if (eptr < md->end_subject && | |
| 1717 | (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen)) | (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen)) |
| 1718 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1719 | ||
| 1720 | /* Either at end of string or \n before end. */ | |
| 1721 | ||
| 1722 | SCHECK_PARTIAL(); | |
| 1723 | ecode++; | ecode++; |
| 1724 | break; | break; |
| 1725 | ||
| # | Line 1651 for (;;) | Line 1737 for (;;) |
| 1737 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| 1738 | if (utf8) | if (utf8) |
| 1739 | { | { |
| 1740 | /* Get status of previous character */ | |
| 1741 | ||
| 1742 | if (eptr == md->start_subject) prev_is_word = FALSE; else | if (eptr == md->start_subject) prev_is_word = FALSE; else |
| 1743 | { | { |
| 1744 | USPTR lastptr = eptr - 1; | USPTR lastptr = eptr - 1; |
| 1745 | while((*lastptr & 0xc0) == 0x80) lastptr--; | while((*lastptr & 0xc0) == 0x80) lastptr--; |
| 1746 | if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr; | if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr; |
| 1747 | GETCHAR(c, lastptr); | GETCHAR(c, lastptr); |
| 1748 | #ifdef SUPPORT_UCP | |
| 1749 | if (md->use_ucp) | |
| 1750 | { | |
| 1751 | if (c == '_') prev_is_word = TRUE; else | |
| 1752 | { | |
| 1753 | int cat = UCD_CATEGORY(c); | |
| 1754 | prev_is_word = (cat == ucp_L || cat == ucp_N); | |
| 1755 | } | |
| 1756 | } | |
| 1757 | else | |
| 1758 | #endif | |
| 1759 | prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; | prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; |
| 1760 | } | } |
| 1761 | ||
| 1762 | /* Get status of next character */ | |
| 1763 | ||
| 1764 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 1765 | { | { |
| 1766 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| # | Line 1667 for (;;) | Line 1769 for (;;) |
| 1769 | else | else |
| 1770 | { | { |
| 1771 | GETCHAR(c, eptr); | GETCHAR(c, eptr); |
| 1772 | #ifdef SUPPORT_UCP | |
| 1773 | if (md->use_ucp) | |
| 1774 | { | |
| 1775 | if (c == '_') cur_is_word = TRUE; else | |
| 1776 | { | |
| 1777 | int cat = UCD_CATEGORY(c); | |
| 1778 | cur_is_word = (cat == ucp_L || cat == ucp_N); | |
| 1779 | } | |
| 1780 | } | |
| 1781 | else | |
| 1782 | #endif | |
| 1783 | cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; | cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; |
| 1784 | } | } |
| 1785 | } | } |
| 1786 | else | else |
| 1787 | #endif | #endif |
| 1788 | ||
| 1789 | /* Not in UTF-8 mode */ | /* Not in UTF-8 mode, but we may still have PCRE_UCP set, and for |
| 1790 | consistency with the behaviour of \w we do use it in this case. */ | |
| 1791 | ||
| 1792 | { | { |
| 1793 | /* Get status of previous character */ | |
| 1794 | ||
| 1795 | if (eptr == md->start_subject) prev_is_word = FALSE; else | if (eptr == md->start_subject) prev_is_word = FALSE; else |
| 1796 | { | { |
| 1797 | if (eptr <= md->start_used_ptr) md->start_used_ptr = eptr - 1; | if (eptr <= md->start_used_ptr) md->start_used_ptr = eptr - 1; |
| 1798 | #ifdef SUPPORT_UCP | |
| 1799 | if (md->use_ucp) | |
| 1800 | { | |
| 1801 | c = eptr[-1]; | |
| 1802 | if (c == '_') prev_is_word = TRUE; else | |
| 1803 | { | |
| 1804 | int cat = UCD_CATEGORY(c); | |
| 1805 | prev_is_word = (cat == ucp_L || cat == ucp_N); | |
| 1806 | } | |
| 1807 | } | |
| 1808 | else | |
| 1809 | #endif | |
| 1810 | prev_is_word = ((md->ctypes[eptr[-1]] & ctype_word) != 0); | prev_is_word = ((md->ctypes[eptr[-1]] & ctype_word) != 0); |
| 1811 | } | } |
| 1812 | ||
| 1813 | /* Get status of next character */ | |
| 1814 | ||
| 1815 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 1816 | { | { |
| 1817 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 1818 | cur_is_word = FALSE; | cur_is_word = FALSE; |
| 1819 | } | } |
| 1820 | else cur_is_word = ((md->ctypes[*eptr] & ctype_word) != 0); | else |
| 1821 | #ifdef SUPPORT_UCP | |
| 1822 | if (md->use_ucp) | |
| 1823 | { | |
| 1824 | c = *eptr; | |
| 1825 | if (c == '_') cur_is_word = TRUE; else | |
| 1826 | { | |
| 1827 | int cat = UCD_CATEGORY(c); | |
| 1828 | cur_is_word = (cat == ucp_L || cat == ucp_N); | |
| 1829 | } | |
| 1830 | } | |
| 1831 | else | |
| 1832 | #endif | |
| 1833 | cur_is_word = ((md->ctypes[*eptr] & ctype_word) != 0); | |
| 1834 | } | } |
| 1835 | ||
| 1836 | /* Now see if the situation is what we want */ | /* Now see if the situation is what we want */ |
| 1837 | ||
| 1838 | if ((*ecode++ == OP_WORD_BOUNDARY)? | if ((*ecode++ == OP_WORD_BOUNDARY)? |
| 1839 | cur_is_word == prev_is_word : cur_is_word != prev_is_word) | cur_is_word == prev_is_word : cur_is_word != prev_is_word) |
| 1840 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1841 | } | } |
| 1842 | break; | break; |
| 1843 | ||
| 1844 | /* Match a single character type; inline for speed */ | /* Match a single character type; inline for speed */ |
| 1845 | ||
| 1846 | case OP_ANY: | case OP_ANY: |
| 1847 | if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); | if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH); |
| 1848 | /* Fall through */ | /* Fall through */ |
| 1849 | ||
| 1850 | case OP_ALLANY: | case OP_ALLANY: |
| 1851 | if (eptr++ >= md->end_subject) | if (eptr++ >= md->end_subject) |
| 1852 | { | { |
| 1853 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 1854 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1855 | } | } |
| 1856 | if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| 1857 | ecode++; | ecode++; |
| # | Line 1720 for (;;) | Line 1864 for (;;) |
| 1864 | if (eptr++ >= md->end_subject) | if (eptr++ >= md->end_subject) |
| 1865 | { | { |
| 1866 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 1867 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1868 | } | } |
| 1869 | ecode++; | ecode++; |
| 1870 | break; | break; |
| # | Line 1729 for (;;) | Line 1873 for (;;) |
| 1873 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 1874 | { | { |
| 1875 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 1876 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1877 | } | } |
| 1878 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1879 | if ( | if ( |
| # | Line 1738 for (;;) | Line 1882 for (;;) |
| 1882 | #endif | #endif |
| 1883 | (md->ctypes[c] & ctype_digit) != 0 | (md->ctypes[c] & ctype_digit) != 0 |
| 1884 | ) | ) |
| 1885 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1886 | ecode++; | ecode++; |
| 1887 | break; | break; |
| 1888 | ||
| # | Line 1746 for (;;) | Line 1890 for (;;) |
| 1890 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 1891 | { | { |
| 1892 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 1893 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1894 | } | } |
| 1895 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1896 | if ( | if ( |
| # | Line 1755 for (;;) | Line 1899 for (;;) |
| 1899 | #endif | #endif |
| 1900 | (md->ctypes[c] & ctype_digit) == 0 | (md->ctypes[c] & ctype_digit) == 0 |
| 1901 | ) | ) |
| 1902 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1903 | ecode++; | ecode++; |
| 1904 | break; | break; |
| 1905 | ||
| # | Line 1763 for (;;) | Line 1907 for (;;) |
| 1907 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 1908 | { | { |
| 1909 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 1910 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1911 | } | } |
| 1912 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1913 | if ( | if ( |
| # | Line 1772 for (;;) | Line 1916 for (;;) |
| 1916 | #endif | #endif |
| 1917 | (md->ctypes[c] & ctype_space) != 0 | (md->ctypes[c] & ctype_space) != 0 |
| 1918 | ) | ) |
| 1919 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1920 | ecode++; | ecode++; |
| 1921 | break; | break; |
| 1922 | ||
| # | Line 1780 for (;;) | Line 1924 for (;;) |
| 1924 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 1925 | { | { |
| 1926 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 1927 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1928 | } | } |
| 1929 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1930 | if ( | if ( |
| # | Line 1789 for (;;) | Line 1933 for (;;) |
| 1933 | #endif | #endif |
| 1934 | (md->ctypes[c] & ctype_space) == 0 | (md->ctypes[c] & ctype_space) == 0 |
| 1935 | ) | ) |
| 1936 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1937 | ecode++; | ecode++; |
| 1938 | break; | break; |
| 1939 | ||
| # | Line 1797 for (;;) | Line 1941 for (;;) |
| 1941 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 1942 | { | { |
| 1943 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 1944 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1945 | } | } |
| 1946 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1947 | if ( | if ( |
| # | Line 1806 for (;;) | Line 1950 for (;;) |
| 1950 | #endif | #endif |
| 1951 | (md->ctypes[c] & ctype_word) != 0 | (md->ctypes[c] & ctype_word) != 0 |
| 1952 | ) | ) |
| 1953 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1954 | ecode++; | ecode++; |
| 1955 | break; | break; |
| 1956 | ||
| # | Line 1814 for (;;) | Line 1958 for (;;) |
| 1958 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 1959 | { | { |
| 1960 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 1961 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1962 | } | } |
| 1963 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1964 | if ( | if ( |
| # | Line 1823 for (;;) | Line 1967 for (;;) |
| 1967 | #endif | #endif |
| 1968 | (md->ctypes[c] & ctype_word) == 0 | (md->ctypes[c] & ctype_word) == 0 |
| 1969 | ) | ) |
| 1970 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1971 | ecode++; | ecode++; |
| 1972 | break; | break; |
| 1973 | ||
| # | Line 1831 for (;;) | Line 1975 for (;;) |
| 1975 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 1976 | { | { |
| 1977 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 1978 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1979 | } | } |
| 1980 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 1981 | switch(c) | switch(c) |
| 1982 | { | { |
| 1983 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 1984 | ||
| 1985 | case 0x000d: | case 0x000d: |
| 1986 | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 1987 | break; | break; |
| # | Line 1849 for (;;) | Line 1994 for (;;) |
| 1994 | case 0x0085: | case 0x0085: |
| 1995 | case 0x2028: | case 0x2028: |
| 1996 | case 0x2029: | case 0x2029: |
| 1997 | if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); | if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH); |
| 1998 | break; | break; |
| 1999 | } | } |
| 2000 | ecode++; | ecode++; |
| # | Line 1859 for (;;) | Line 2004 for (;;) |
| 2004 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2005 | { | { |
| 2006 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2007 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2008 | } | } |
| 2009 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2010 | switch(c) | switch(c) |
| # | Line 1884 for (;;) | Line 2029 for (;;) |
| 2029 | case 0x202f: /* NARROW NO-BREAK SPACE */ | case 0x202f: /* NARROW NO-BREAK SPACE */ |
| 2030 | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ |
| 2031 | case 0x3000: /* IDEOGRAPHIC SPACE */ | case 0x3000: /* IDEOGRAPHIC SPACE */ |
| 2032 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2033 | } | } |
| 2034 | ecode++; | ecode++; |
| 2035 | break; | break; |
| # | Line 1893 for (;;) | Line 2038 for (;;) |
| 2038 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2039 | { | { |
| 2040 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2041 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2042 | } | } |
| 2043 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2044 | switch(c) | switch(c) |
| 2045 | { | { |
| 2046 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 2047 | case 0x09: /* HT */ | case 0x09: /* HT */ |
| 2048 | case 0x20: /* SPACE */ | case 0x20: /* SPACE */ |
| 2049 | case 0xa0: /* NBSP */ | case 0xa0: /* NBSP */ |
| # | Line 1927 for (;;) | Line 2072 for (;;) |
| 2072 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2073 | { | { |
| 2074 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2075 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2076 | } | } |
| 2077 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2078 | switch(c) | switch(c) |
| # | Line 1940 for (;;) | Line 2085 for (;;) |
| 2085 | case 0x85: /* NEL */ | case 0x85: /* NEL */ |
| 2086 | case 0x2028: /* LINE SEPARATOR */ | case 0x2028: /* LINE SEPARATOR */ |
| 2087 | case 0x2029: /* PARAGRAPH SEPARATOR */ | case 0x2029: /* PARAGRAPH SEPARATOR */ |
| 2088 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2089 | } | } |
| 2090 | ecode++; | ecode++; |
| 2091 | break; | break; |
| # | Line 1949 for (;;) | Line 2094 for (;;) |
| 2094 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2095 | { | { |
| 2096 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2097 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2098 | } | } |
| 2099 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2100 | switch(c) | switch(c) |
| 2101 | { | { |
| 2102 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 2103 | case 0x0a: /* LF */ | case 0x0a: /* LF */ |
| 2104 | case 0x0b: /* VT */ | case 0x0b: /* VT */ |
| 2105 | case 0x0c: /* FF */ | case 0x0c: /* FF */ |
| # | Line 1976 for (;;) | Line 2121 for (;;) |
| 2121 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2122 | { | { |
| 2123 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2124 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2125 | } | } |
| 2126 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2127 | { | { |
| # | Line 1985 for (;;) | Line 2130 for (;;) |
| 2130 | switch(ecode[1]) | switch(ecode[1]) |
| 2131 | { | { |
| 2132 | case PT_ANY: | case PT_ANY: |
| 2133 | if (op == OP_NOTPROP) RRETURN(MATCH_NOMATCH); | if (op == OP_NOTPROP) MRRETURN(MATCH_NOMATCH); |
| 2134 | break; | break; |
| 2135 | ||
| 2136 | case PT_LAMP: | case PT_LAMP: |
| 2137 | if ((prop->chartype == ucp_Lu || | if ((prop->chartype == ucp_Lu || |
| 2138 | prop->chartype == ucp_Ll || | prop->chartype == ucp_Ll || |
| 2139 | prop->chartype == ucp_Lt) == (op == OP_NOTPROP)) | prop->chartype == ucp_Lt) == (op == OP_NOTPROP)) |
| 2140 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2141 | break; | break; |
| 2142 | ||
| 2143 | case PT_GC: | case PT_GC: |
| 2144 | if ((ecode[2] != _pcre_ucp_gentype[prop->chartype]) == (op == OP_PROP)) | if ((ecode[2] != _pcre_ucp_gentype[prop->chartype]) == (op == OP_PROP)) |
| 2145 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2146 | break; | break; |
| 2147 | ||
| 2148 | case PT_PC: | case PT_PC: |
| 2149 | if ((ecode[2] != prop->chartype) == (op == OP_PROP)) | if ((ecode[2] != prop->chartype) == (op == OP_PROP)) |
| 2150 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2151 | break; | break; |
| 2152 | ||
| 2153 | case PT_SC: | case PT_SC: |
| 2154 | if ((ecode[2] != prop->script) == (op == OP_PROP)) | if ((ecode[2] != prop->script) == (op == OP_PROP)) |
| 2155 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2156 | break; | |
| 2157 | ||
| 2158 | /* These are specials */ | |
| 2159 | ||
| 2160 | case PT_ALNUM: | |
| 2161 | if ((_pcre_ucp_gentype[prop->chartype] == ucp_L || | |
| 2162 | _pcre_ucp_gentype[prop->chartype] == ucp_N) == (op == OP_NOTPROP)) | |
| 2163 | MRRETURN(MATCH_NOMATCH); | |
| 2164 | break; | break; |
| 2165 | ||
| 2166 | case PT_SPACE: /* Perl space */ | |
| 2167 | if ((_pcre_ucp_gentype[prop->chartype] == ucp_Z || | |
| 2168 | c == CHAR_HT || c == CHAR_NL || c == CHAR_FF || c == CHAR_CR) | |
| 2169 | == (op == OP_NOTPROP)) | |
| 2170 | MRRETURN(MATCH_NOMATCH); | |
| 2171 | break; | |
| 2172 | ||
| 2173 | case PT_PXSPACE: /* POSIX space */ | |
| 2174 | if ((_pcre_ucp_gentype[prop->chartype] == ucp_Z || | |
| 2175 | c == CHAR_HT || c == CHAR_NL || c == CHAR_VT || | |
| 2176 | c == CHAR_FF || c == CHAR_CR) | |
| 2177 | == (op == OP_NOTPROP)) | |
| 2178 | MRRETURN(MATCH_NOMATCH); | |
| 2179 | break; | |
| 2180 | ||
| 2181 | case PT_WORD: | |
| 2182 | if ((_pcre_ucp_gentype[prop->chartype] == ucp_L || | |
| 2183 | _pcre_ucp_gentype[prop->chartype] == ucp_N || | |
| 2184 | c == CHAR_UNDERSCORE) == (op == OP_NOTPROP)) | |
| 2185 | MRRETURN(MATCH_NOMATCH); | |
| 2186 | break; | |
| 2187 | ||
| 2188 | /* This should never occur */ | |
| 2189 | ||
| 2190 | default: | default: |
| 2191 | RRETURN(PCRE_ERROR_INTERNAL); | RRETURN(PCRE_ERROR_INTERNAL); |
| 2192 | } | } |
| # | Line 2025 for (;;) | Line 2202 for (;;) |
| 2202 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2203 | { | { |
| 2204 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2205 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2206 | } | } |
| 2207 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2208 | { | { |
| 2209 | int category = UCD_CATEGORY(c); | int category = UCD_CATEGORY(c); |
| 2210 | if (category == ucp_M) RRETURN(MATCH_NOMATCH); | if (category == ucp_M) MRRETURN(MATCH_NOMATCH); |
| 2211 | while (eptr < md->end_subject) | while (eptr < md->end_subject) |
| 2212 | { | { |
| 2213 | int len = 1; | int len = 1; |
| # | Line 2057 for (;;) | Line 2234 for (;;) |
| 2234 | loops). */ | loops). */ |
| 2235 | ||
| 2236 | case OP_REF: | case OP_REF: |
| 2237 | { | case OP_REFI: |
| 2238 | offset = GET2(ecode, 1) << 1; /* Doubled ref number */ | caseless = op == OP_REFI; |
| 2239 | ecode += 3; | offset = GET2(ecode, 1) << 1; /* Doubled ref number */ |
| 2240 | ecode += 3; | |
| 2241 | ||
| 2242 | /* If the reference is unset, there are two possibilities: | /* If the reference is unset, there are two possibilities: |
| 2243 | ||
| 2244 | (a) In the default, Perl-compatible state, set the length to be longer | (a) In the default, Perl-compatible state, set the length negative; |
| 2245 | than the amount of subject left; this ensures that every attempt at a | this ensures that every attempt at a match fails. We can't just fail |
| 2246 | match fails. We can't just fail here, because of the possibility of | here, because of the possibility of quantifiers with zero minima. |
| quantifiers with zero minima. | ||
| 2247 | ||
| 2248 | (b) If the JavaScript compatibility flag is set, set the length to zero | (b) If the JavaScript compatibility flag is set, set the length to zero |
| 2249 | so that the back reference matches an empty string. | so that the back reference matches an empty string. |
| 2250 | ||
| 2251 | Otherwise, set the length to the length of what was matched by the | Otherwise, set the length to the length of what was matched by the |
| 2252 | referenced subpattern. */ | referenced subpattern. */ |
| 2253 | ||
| 2254 | if (offset >= offset_top || md->offset_vector[offset] < 0) | if (offset >= offset_top || md->offset_vector[offset] < 0) |
| 2255 | length = (md->jscript_compat)? 0 : md->end_subject - eptr + 1; | length = (md->jscript_compat)? 0 : -1; |
| 2256 | else | else |
| 2257 | length = md->offset_vector[offset+1] - md->offset_vector[offset]; | length = md->offset_vector[offset+1] - md->offset_vector[offset]; |
| 2258 | ||
| 2259 | /* Set up for repetition, or handle the non-repeated case */ | /* Set up for repetition, or handle the non-repeated case */ |
| 2260 | ||
| 2261 | switch (*ecode) | switch (*ecode) |
| 2262 | { | { |
| 2263 | case OP_CRSTAR: | case OP_CRSTAR: |
| 2264 | case OP_CRMINSTAR: | case OP_CRMINSTAR: |
| 2265 | case OP_CRPLUS: | case OP_CRPLUS: |
| 2266 | case OP_CRMINPLUS: | case OP_CRMINPLUS: |
| 2267 | case OP_CRQUERY: | case OP_CRQUERY: |
| 2268 | case OP_CRMINQUERY: | case OP_CRMINQUERY: |
| 2269 | c = *ecode++ - OP_CRSTAR; | c = *ecode++ - OP_CRSTAR; |
| 2270 | minimize = (c & 1) != 0; | minimize = (c & 1) != 0; |
| 2271 | min = rep_min[c]; /* Pick up values from tables; */ | min = rep_min[c]; /* Pick up values from tables; */ |
| 2272 | max = rep_max[c]; /* zero for max => infinity */ | max = rep_max[c]; /* zero for max => infinity */ |
| 2273 | if (max == 0) max = INT_MAX; | if (max == 0) max = INT_MAX; |
| 2274 | break; | break; |
| 2275 | ||
| 2276 | case OP_CRRANGE: | case OP_CRRANGE: |
| 2277 | case OP_CRMINRANGE: | case OP_CRMINRANGE: |
| 2278 | minimize = (*ecode == OP_CRMINRANGE); | minimize = (*ecode == OP_CRMINRANGE); |
| 2279 | min = GET2(ecode, 1); | min = GET2(ecode, 1); |
| 2280 | max = GET2(ecode, 3); | max = GET2(ecode, 3); |
| 2281 | if (max == 0) max = INT_MAX; | if (max == 0) max = INT_MAX; |
| 2282 | ecode += 5; | ecode += 5; |
| 2283 | break; | break; |
| 2284 | ||
| 2285 | default: /* No repeat follows */ | default: /* No repeat follows */ |
| 2286 | if (!match_ref(offset, eptr, length, md, ims)) | if ((length = match_ref(offset, eptr, length, md, caseless)) < 0) |
| 2287 | { | { |
| 2288 | CHECK_PARTIAL(); | CHECK_PARTIAL(); |
| 2289 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| } | ||
| eptr += length; | ||
| continue; /* With the main loop */ | ||
| 2290 | } | } |
| 2291 | eptr += length; | |
| 2292 | continue; /* With the main loop */ | |
| 2293 | } | |
| 2294 | ||
| 2295 | /* If the length of the reference is zero, just continue with the | /* Handle repeated back references. If the length of the reference is |
| 2296 | main loop. */ | zero, just continue with the main loop. */ |
| 2297 | ||
| 2298 | if (length == 0) continue; | if (length == 0) continue; |
| 2299 | ||
| 2300 | /* First, ensure the minimum number of matches are present. We get back | /* First, ensure the minimum number of matches are present. We get back |
| 2301 | the length of the reference string explicitly rather than passing the | the length of the reference string explicitly rather than passing the |
| 2302 | address of eptr, so that eptr can be a register variable. */ | address of eptr, so that eptr can be a register variable. */ |
| 2303 | ||
| 2304 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 2305 | { | |
| 2306 | int slength; | |
| 2307 | if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0) | |
| 2308 | { | { |
| 2309 | if (!match_ref(offset, eptr, length, md, ims)) | CHECK_PARTIAL(); |
| 2310 | { | MRRETURN(MATCH_NOMATCH); |
| CHECK_PARTIAL(); | ||
| RRETURN(MATCH_NOMATCH); | ||
| } | ||
| eptr += length; | ||
| 2311 | } | } |
| 2312 | eptr += slength; | |
| 2313 | } | |
| 2314 | ||
| 2315 | /* If min = max, continue at the same level without recursion. | /* If min = max, continue at the same level without recursion. |
| 2316 | They are not both allowed to be zero. */ | They are not both allowed to be zero. */ |
| 2317 | ||
| 2318 | if (min == max) continue; | if (min == max) continue; |
| 2319 | ||
| 2320 | /* If minimizing, keep trying and advancing the pointer */ | /* If minimizing, keep trying and advancing the pointer */ |
| 2321 | ||
| 2322 | if (minimize) | if (minimize) |
| 2323 | { | |
| 2324 | for (fi = min;; fi++) | |
| 2325 | { | { |
| 2326 | for (fi = min;; fi++) | int slength; |
| 2327 | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM14); | |
| 2328 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | |
| 2329 | if (fi >= max) MRRETURN(MATCH_NOMATCH); | |
| 2330 | if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0) | |
| 2331 | { | { |
| 2332 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM14); | CHECK_PARTIAL(); |
| 2333 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | MRRETURN(MATCH_NOMATCH); |
| if (fi >= max) RRETURN(MATCH_NOMATCH); | ||
| if (!match_ref(offset, eptr, length, md, ims)) | ||
| { | ||
| CHECK_PARTIAL(); | ||
| RRETURN(MATCH_NOMATCH); | ||
| } | ||
| eptr += length; | ||
| 2334 | } | } |
| 2335 | /* Control never gets here */ | eptr += slength; |
| 2336 | } | } |
| 2337 | /* Control never gets here */ | |
| 2338 | } | |
| 2339 | ||
| 2340 | /* If maximizing, find the longest string and work backwards */ | /* If maximizing, find the longest string and work backwards */ |
| 2341 | ||
| 2342 | else | else |
| 2343 | { | |
| 2344 | pp = eptr; | |
| 2345 | for (i = min; i < max; i++) | |
| 2346 | { | { |
| 2347 | pp = eptr; | int slength; |
| 2348 | for (i = min; i < max; i++) | if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0) |
| 2349 | { | { |
| 2350 | if (!match_ref(offset, eptr, length, md, ims)) | CHECK_PARTIAL(); |
| 2351 | { | break; |
| CHECK_PARTIAL(); | ||
| break; | ||
| } | ||
| eptr += length; | ||
| } | ||
| while (eptr >= pp) | ||
| { | ||
| RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM15); | ||
| if (rrc != MATCH_NOMATCH) RRETURN(rrc); | ||
| eptr -= length; | ||
| 2352 | } | } |
| 2353 | RRETURN(MATCH_NOMATCH); | eptr += slength; |
| 2354 | } | |
| 2355 | while (eptr >= pp) | |
| 2356 | { | |
| 2357 | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM15); | |
| 2358 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | |
| 2359 | eptr -= length; | |
| 2360 | } | } |
| 2361 | MRRETURN(MATCH_NOMATCH); | |
| 2362 | } | } |
| 2363 | /* Control never gets here */ | /* Control never gets here */ |
| 2364 | ||
| # | Line 2240 for (;;) | Line 2419 for (;;) |
| 2419 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2420 | { | { |
| 2421 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2422 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2423 | } | } |
| 2424 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 2425 | if (c > 255) | if (c > 255) |
| 2426 | { | { |
| 2427 | if (op == OP_CLASS) RRETURN(MATCH_NOMATCH); | if (op == OP_CLASS) MRRETURN(MATCH_NOMATCH); |
| 2428 | } | } |
| 2429 | else | else |
| 2430 | { | { |
| 2431 | if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH); | if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH); |
| 2432 | } | } |
| 2433 | } | } |
| 2434 | } | } |
| # | Line 2262 for (;;) | Line 2441 for (;;) |
| 2441 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2442 | { | { |
| 2443 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2444 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2445 | } | } |
| 2446 | c = *eptr++; | c = *eptr++; |
| 2447 | if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH); | if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH); |
| 2448 | } | } |
| 2449 | } | } |
| 2450 | ||
| # | Line 2285 for (;;) | Line 2464 for (;;) |
| 2464 | { | { |
| 2465 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 2466 | { | { |
| 2467 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM16); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM16); |
| 2468 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2469 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 2470 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2471 | { | { |
| 2472 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2473 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2474 | } | } |
| 2475 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 2476 | if (c > 255) | if (c > 255) |
| 2477 | { | { |
| 2478 | if (op == OP_CLASS) RRETURN(MATCH_NOMATCH); | if (op == OP_CLASS) MRRETURN(MATCH_NOMATCH); |
| 2479 | } | } |
| 2480 | else | else |
| 2481 | { | { |
| 2482 | if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH); | if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH); |
| 2483 | } | } |
| 2484 | } | } |
| 2485 | } | } |
| # | Line 2310 for (;;) | Line 2489 for (;;) |
| 2489 | { | { |
| 2490 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 2491 | { | { |
| 2492 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM17); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM17); |
| 2493 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2494 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 2495 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2496 | { | { |
| 2497 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2498 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2499 | } | } |
| 2500 | c = *eptr++; | c = *eptr++; |
| 2501 | if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH); | if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH); |
| 2502 | } | } |
| 2503 | } | } |
| 2504 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 2356 for (;;) | Line 2535 for (;;) |
| 2535 | } | } |
| 2536 | for (;;) | for (;;) |
| 2537 | { | { |
| 2538 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM18); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM18); |
| 2539 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2540 | if (eptr-- == pp) break; /* Stop if tried at original pos */ | if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 2541 | BACKCHAR(eptr); | BACKCHAR(eptr); |
| # | Line 2379 for (;;) | Line 2558 for (;;) |
| 2558 | } | } |
| 2559 | while (eptr >= pp) | while (eptr >= pp) |
| 2560 | { | { |
| 2561 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM19); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM19); |
| 2562 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2563 | eptr--; | eptr--; |
| 2564 | } | } |
| 2565 | } | } |
| 2566 | ||
| 2567 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2568 | } | } |
| 2569 | } | } |
| 2570 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 2437 for (;;) | Line 2616 for (;;) |
| 2616 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2617 | { | { |
| 2618 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2619 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2620 | } | } |
| 2621 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2622 | if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH); | if (!_pcre_xclass(c, data)) MRRETURN(MATCH_NOMATCH); |
| 2623 | } | } |
| 2624 | ||
| 2625 | /* 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 2455 for (;;) | Line 2634 for (;;) |
| 2634 | { | { |
| 2635 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 2636 | { | { |
| 2637 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM20); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM20); |
| 2638 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2639 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 2640 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2641 | { | { |
| 2642 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2643 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2644 | } | } |
| 2645 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2646 | if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH); | if (!_pcre_xclass(c, data)) MRRETURN(MATCH_NOMATCH); |
| 2647 | } | } |
| 2648 | /* Control never gets here */ | /* Control never gets here */ |
| 2649 | } | } |
| # | Line 2488 for (;;) | Line 2667 for (;;) |
| 2667 | } | } |
| 2668 | for(;;) | for(;;) |
| 2669 | { | { |
| 2670 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM21); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM21); |
| 2671 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2672 | if (eptr-- == pp) break; /* Stop if tried at original pos */ | if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 2673 | if (utf8) BACKCHAR(eptr); | if (utf8) BACKCHAR(eptr); |
| 2674 | } | } |
| 2675 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2676 | } | } |
| 2677 | ||
| 2678 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 2512 for (;;) | Line 2691 for (;;) |
| 2691 | if (length > md->end_subject - eptr) | if (length > md->end_subject - eptr) |
| 2692 | { | { |
| 2693 | CHECK_PARTIAL(); /* Not SCHECK_PARTIAL() */ | CHECK_PARTIAL(); /* Not SCHECK_PARTIAL() */ |
| 2694 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2695 | } | } |
| 2696 | while (length-- > 0) if (*ecode++ != *eptr++) RRETURN(MATCH_NOMATCH); | while (length-- > 0) if (*ecode++ != *eptr++) MRRETURN(MATCH_NOMATCH); |
| 2697 | } | } |
| 2698 | else | else |
| 2699 | #endif | #endif |
| # | Line 2524 for (;;) | Line 2703 for (;;) |
| 2703 | if (md->end_subject - eptr < 1) | if (md->end_subject - eptr < 1) |
| 2704 | { | { |
| 2705 | SCHECK_PARTIAL(); /* This one can use SCHECK_PARTIAL() */ | SCHECK_PARTIAL(); /* This one can use SCHECK_PARTIAL() */ |
| 2706 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2707 | } | } |
| 2708 | if (ecode[1] != *eptr++) RRETURN(MATCH_NOMATCH); | if (ecode[1] != *eptr++) MRRETURN(MATCH_NOMATCH); |
| 2709 | ecode += 2; | ecode += 2; |
| 2710 | } | } |
| 2711 | break; | break; |
| 2712 | ||
| 2713 | /* Match a single character, caselessly */ | /* Match a single character, caselessly */ |
| 2714 | ||
| 2715 | case OP_CHARNC: | case OP_CHARI: |
| 2716 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| 2717 | if (utf8) | if (utf8) |
| 2718 | { | { |
| # | Line 2544 for (;;) | Line 2723 for (;;) |
| 2723 | if (length > md->end_subject - eptr) | if (length > md->end_subject - eptr) |
| 2724 | { | { |
| 2725 | CHECK_PARTIAL(); /* Not SCHECK_PARTIAL() */ | CHECK_PARTIAL(); /* Not SCHECK_PARTIAL() */ |
| 2726 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2727 | } | } |
| 2728 | ||
| 2729 | /* 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 |
| # | Line 2552 for (;;) | Line 2731 for (;;) |
| 2731 | ||
| 2732 | if (fc < 128) | if (fc < 128) |
| 2733 | { | { |
| 2734 | if (md->lcc[*ecode++] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); | if (md->lcc[*ecode++] != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH); |
| 2735 | } | } |
| 2736 | ||
| 2737 | /* Otherwise we must pick up the subject character */ | /* Otherwise we must pick up the subject character */ |
| # | Line 2571 for (;;) | Line 2750 for (;;) |
| 2750 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 2751 | if (dc != UCD_OTHERCASE(fc)) | if (dc != UCD_OTHERCASE(fc)) |
| 2752 | #endif | #endif |
| 2753 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2754 | } | } |
| 2755 | } | } |
| 2756 | } | } |
| # | Line 2583 for (;;) | Line 2762 for (;;) |
| 2762 | if (md->end_subject - eptr < 1) | if (md->end_subject - eptr < 1) |
| 2763 | { | { |
| 2764 | SCHECK_PARTIAL(); /* This one can use SCHECK_PARTIAL() */ | SCHECK_PARTIAL(); /* This one can use SCHECK_PARTIAL() */ |
| 2765 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2766 | } | } |
| 2767 | if (md->lcc[ecode[1]] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); | if (md->lcc[ecode[1]] != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH); |
| 2768 | ecode += 2; | ecode += 2; |
| 2769 | } | } |
| 2770 | break; | break; |
| # | Line 2593 for (;;) | Line 2772 for (;;) |
| 2772 | /* Match a single character repeatedly. */ | /* Match a single character repeatedly. */ |
| 2773 | ||
| 2774 | case OP_EXACT: | case OP_EXACT: |
| 2775 | case OP_EXACTI: | |
| 2776 | min = max = GET2(ecode, 1); | min = max = GET2(ecode, 1); |
| 2777 | ecode += 3; | ecode += 3; |
| 2778 | goto REPEATCHAR; | goto REPEATCHAR; |
| 2779 | ||
| 2780 | case OP_POSUPTO: | case OP_POSUPTO: |
| 2781 | case OP_POSUPTOI: | |
| 2782 | possessive = TRUE; | possessive = TRUE; |
| 2783 | /* Fall through */ | /* Fall through */ |
| 2784 | ||
| 2785 | case OP_UPTO: | case OP_UPTO: |
| 2786 | case OP_UPTOI: | |
| 2787 | case OP_MINUPTO: | case OP_MINUPTO: |
| 2788 | case OP_MINUPTOI: | |
| 2789 | min = 0; | min = 0; |
| 2790 | max = GET2(ecode, 1); | max = GET2(ecode, 1); |
| 2791 | minimize = *ecode == OP_MINUPTO; | minimize = *ecode == OP_MINUPTO || *ecode == OP_MINUPTOI; |
| 2792 | ecode += 3; | ecode += 3; |
| 2793 | goto REPEATCHAR; | goto REPEATCHAR; |
| 2794 | ||
| 2795 | case OP_POSSTAR: | case OP_POSSTAR: |
| 2796 | case OP_POSSTARI: | |
| 2797 | possessive = TRUE; | possessive = TRUE; |
| 2798 | min = 0; | min = 0; |
| 2799 | max = INT_MAX; | max = INT_MAX; |
| # | Line 2617 for (;;) | Line 2801 for (;;) |
| 2801 | goto REPEATCHAR; | goto REPEATCHAR; |
| 2802 | ||
| 2803 | case OP_POSPLUS: | case OP_POSPLUS: |
| 2804 | case OP_POSPLUSI: | |
| 2805 | possessive = TRUE; | possessive = TRUE; |
| 2806 | min = 1; | min = 1; |
| 2807 | max = INT_MAX; | max = INT_MAX; |
| # | Line 2624 for (;;) | Line 2809 for (;;) |
| 2809 | goto REPEATCHAR; | goto REPEATCHAR; |
| 2810 | ||
| 2811 | case OP_POSQUERY: | case OP_POSQUERY: |
| 2812 | case OP_POSQUERYI: | |
| 2813 | possessive = TRUE; | possessive = TRUE; |
| 2814 | min = 0; | min = 0; |
| 2815 | max = 1; | max = 1; |
| # | Line 2631 for (;;) | Line 2817 for (;;) |
| 2817 | goto REPEATCHAR; | goto REPEATCHAR; |
| 2818 | ||
| 2819 | case OP_STAR: | case OP_STAR: |
| 2820 | case OP_STARI: | |
| 2821 | case OP_MINSTAR: | case OP_MINSTAR: |
| 2822 | case OP_MINSTARI: | |
| 2823 | case OP_PLUS: | case OP_PLUS: |
| 2824 | case OP_PLUSI: | |
| 2825 | case OP_MINPLUS: | case OP_MINPLUS: |
| 2826 | case OP_MINPLUSI: | |
| 2827 | case OP_QUERY: | case OP_QUERY: |
| 2828 | case OP_QUERYI: | |
| 2829 | case OP_MINQUERY: | case OP_MINQUERY: |
| 2830 | c = *ecode++ - OP_STAR; | case OP_MINQUERYI: |
| 2831 | c = *ecode++ - ((op < OP_STARI)? OP_STAR : OP_STARI); | |
| 2832 | minimize = (c & 1) != 0; | minimize = (c & 1) != 0; |
| 2833 | min = rep_min[c]; /* Pick up values from tables; */ | min = rep_min[c]; /* Pick up values from tables; */ |
| 2834 | max = rep_max[c]; /* zero for max => infinity */ | max = rep_max[c]; /* zero for max => infinity */ |
| 2835 | if (max == 0) max = INT_MAX; | if (max == 0) max = INT_MAX; |
| # | Line 2661 for (;;) | Line 2852 for (;;) |
| 2852 | { | { |
| 2853 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 2854 | unsigned int othercase; | unsigned int othercase; |
| 2855 | if ((ims & PCRE_CASELESS) != 0 && | if (op >= OP_STARI && /* Caseless */ |
| 2856 | (othercase = UCD_OTHERCASE(fc)) != fc) | (othercase = UCD_OTHERCASE(fc)) != fc) |
| 2857 | oclength = _pcre_ord2utf8(othercase, occhars); | oclength = _pcre_ord2utf8(othercase, occhars); |
| 2858 | else oclength = 0; | else oclength = 0; |
| # | Line 2679 for (;;) | Line 2870 for (;;) |
| 2870 | else | else |
| 2871 | { | { |
| 2872 | CHECK_PARTIAL(); | CHECK_PARTIAL(); |
| 2873 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2874 | } | } |
| 2875 | } | } |
| 2876 | ||
| # | Line 2689 for (;;) | Line 2880 for (;;) |
| 2880 | { | { |
| 2881 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 2882 | { | { |
| 2883 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM22); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM22); |
| 2884 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2885 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 2886 | if (eptr <= md->end_subject - length && | if (eptr <= md->end_subject - length && |
| 2887 | memcmp(eptr, charptr, length) == 0) eptr += length; | memcmp(eptr, charptr, length) == 0) eptr += length; |
| 2888 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| # | Line 2702 for (;;) | Line 2893 for (;;) |
| 2893 | else | else |
| 2894 | { | { |
| 2895 | CHECK_PARTIAL(); | CHECK_PARTIAL(); |
| 2896 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2897 | } | } |
| 2898 | } | } |
| 2899 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 2731 for (;;) | Line 2922 for (;;) |
| 2922 | ||
| 2923 | for(;;) | for(;;) |
| 2924 | { | { |
| 2925 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM23); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM23); |
| 2926 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2927 | if (eptr == pp) { RRETURN(MATCH_NOMATCH); } | if (eptr == pp) { MRRETURN(MATCH_NOMATCH); } |
| 2928 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 2929 | eptr--; | eptr--; |
| 2930 | BACKCHAR(eptr); | BACKCHAR(eptr); |
| # | Line 2768 for (;;) | Line 2959 for (;;) |
| 2959 | DPRINTF(("matching %c{%d,%d} against subject %.*s\n", fc, min, max, | DPRINTF(("matching %c{%d,%d} against subject %.*s\n", fc, min, max, |
| 2960 | max, eptr)); | max, eptr)); |
| 2961 | ||
| 2962 | if ((ims & PCRE_CASELESS) != 0) | if (op >= OP_STARI) /* Caseless */ |
| 2963 | { | { |
| 2964 | fc = md->lcc[fc]; | fc = md->lcc[fc]; |
| 2965 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| # | Line 2776 for (;;) | Line 2967 for (;;) |
| 2967 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2968 | { | { |
| 2969 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2970 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2971 | } | } |
| 2972 | if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); | if (fc != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH); |
| 2973 | } | } |
| 2974 | if (min == max) continue; | if (min == max) continue; |
| 2975 | if (minimize) | if (minimize) |
| 2976 | { | { |
| 2977 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 2978 | { | { |
| 2979 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM24); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM24); |
| 2980 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2981 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 2982 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2983 | { | { |
| 2984 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2985 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2986 | } | } |
| 2987 | if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); | if (fc != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH); |
| 2988 | } | } |
| 2989 | /* Control never gets here */ | /* Control never gets here */ |
| 2990 | } | } |
| # | Line 2815 for (;;) | Line 3006 for (;;) |
| 3006 | ||
| 3007 | while (eptr >= pp) | while (eptr >= pp) |
| 3008 | { | { |
| 3009 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM25); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM25); |
| 3010 | eptr--; | eptr--; |
| 3011 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3012 | } | } |
| 3013 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3014 | } | } |
| 3015 | /* Control never gets here */ | /* Control never gets here */ |
| 3016 | } | } |
| # | Line 2833 for (;;) | Line 3024 for (;;) |
| 3024 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3025 | { | { |
| 3026 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3027 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3028 | } | } |
| 3029 | if (fc != *eptr++) RRETURN(MATCH_NOMATCH); | if (fc != *eptr++) MRRETURN(MATCH_NOMATCH); |
| 3030 | } | } |
| 3031 | ||
| 3032 | if (min == max) continue; | if (min == max) continue; |
| # | Line 2844 for (;;) | Line 3035 for (;;) |
| 3035 | { | { |
| 3036 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 3037 | { | { |
| 3038 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM26); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM26); |
| 3039 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3040 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 3041 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3042 | { | { |
| 3043 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3044 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3045 | } | } |
| 3046 | if (fc != *eptr++) RRETURN(MATCH_NOMATCH); | if (fc != *eptr++) MRRETURN(MATCH_NOMATCH); |
| 3047 | } | } |
| 3048 | /* Control never gets here */ | /* Control never gets here */ |
| 3049 | } | } |
| # | Line 2873 for (;;) | Line 3064 for (;;) |
| 3064 | ||
| 3065 | while (eptr >= pp) | while (eptr >= pp) |
| 3066 | { | { |
| 3067 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM27); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM27); |
| 3068 | eptr--; | eptr--; |
| 3069 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3070 | } | } |
| 3071 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3072 | } | } |
| 3073 | } | } |
| 3074 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 2886 for (;;) | Line 3077 for (;;) |
| 3077 | checking can be multibyte. */ | checking can be multibyte. */ |
| 3078 | ||
| 3079 | case OP_NOT: | case OP_NOT: |
| 3080 | case OP_NOTI: | |
| 3081 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3082 | { | { |
| 3083 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3084 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3085 | } | } |
| 3086 | ecode++; | ecode++; |
| 3087 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3088 | if ((ims & PCRE_CASELESS) != 0) | if (op == OP_NOTI) /* The caseless case */ |
| 3089 | { | { |
| 3090 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| 3091 | if (c < 256) | if (c < 256) |
| 3092 | #endif | #endif |
| 3093 | c = md->lcc[c]; | c = md->lcc[c]; |
| 3094 | if (md->lcc[*ecode++] == c) RRETURN(MATCH_NOMATCH); | if (md->lcc[*ecode++] == c) MRRETURN(MATCH_NOMATCH); |
| 3095 | } | } |
| 3096 | else | else /* Caseful */ |
| 3097 | { | { |
| 3098 | if (*ecode++ == c) RRETURN(MATCH_NOMATCH); | if (*ecode++ == c) MRRETURN(MATCH_NOMATCH); |
| 3099 | } | } |
| 3100 | break; | break; |
| 3101 | ||
| # | Line 2915 for (;;) | Line 3107 for (;;) |
| 3107 | about... */ | about... */ |
| 3108 | ||
| 3109 | case OP_NOTEXACT: | case OP_NOTEXACT: |
| 3110 | case OP_NOTEXACTI: | |
| 3111 | min = max = GET2(ecode, 1); | min = max = GET2(ecode, 1); |
| 3112 | ecode += 3; | ecode += 3; |
| 3113 | goto REPEATNOTCHAR; | goto REPEATNOTCHAR; |
| 3114 | ||
| 3115 | case OP_NOTUPTO: | case OP_NOTUPTO: |
| 3116 | case OP_NOTUPTOI: | |
| 3117 | case OP_NOTMINUPTO: | case OP_NOTMINUPTO: |
| 3118 | case OP_NOTMINUPTOI: | |
| 3119 | min = 0; | min = 0; |
| 3120 | max = GET2(ecode, 1); | max = GET2(ecode, 1); |
| 3121 | minimize = *ecode == OP_NOTMINUPTO; | minimize = *ecode == OP_NOTMINUPTO || *ecode == OP_NOTMINUPTOI; |
| 3122 | ecode += 3; | ecode += 3; |
| 3123 | goto REPEATNOTCHAR; | goto REPEATNOTCHAR; |
| 3124 | ||
| 3125 | case OP_NOTPOSSTAR: | case OP_NOTPOSSTAR: |
| 3126 | case OP_NOTPOSSTARI: | |
| 3127 | possessive = TRUE; | possessive = TRUE; |
| 3128 | min = 0; | min = 0; |
| 3129 | max = INT_MAX; | max = INT_MAX; |
| # | Line 2935 for (;;) | Line 3131 for (;;) |
| 3131 | goto REPEATNOTCHAR; | goto REPEATNOTCHAR; |
| 3132 | ||
| 3133 | case OP_NOTPOSPLUS: | case OP_NOTPOSPLUS: |
| 3134 | case OP_NOTPOSPLUSI: | |
| 3135 | possessive = TRUE; | possessive = TRUE; |
| 3136 | min = 1; | min = 1; |
| 3137 | max = INT_MAX; | max = INT_MAX; |
| # | Line 2942 for (;;) | Line 3139 for (;;) |
| 3139 | goto REPEATNOTCHAR; | goto REPEATNOTCHAR; |
| 3140 | ||
| 3141 | case OP_NOTPOSQUERY: | case OP_NOTPOSQUERY: |
| 3142 | case OP_NOTPOSQUERYI: | |
| 3143 | possessive = TRUE; | possessive = TRUE; |
| 3144 | min = 0; | min = 0; |
| 3145 | max = 1; | max = 1; |
| # | Line 2949 for (;;) | Line 3147 for (;;) |
| 3147 | goto REPEATNOTCHAR; | goto REPEATNOTCHAR; |
| 3148 | ||
| 3149 | case OP_NOTPOSUPTO: | case OP_NOTPOSUPTO: |
| 3150 | case OP_NOTPOSUPTOI: | |
| 3151 | possessive = TRUE; | possessive = TRUE; |
| 3152 | min = 0; | min = 0; |
| 3153 | max = GET2(ecode, 1); | max = GET2(ecode, 1); |
| # | Line 2956 for (;;) | Line 3155 for (;;) |
| 3155 | goto REPEATNOTCHAR; | goto REPEATNOTCHAR; |
| 3156 | ||
| 3157 | case OP_NOTSTAR: | case OP_NOTSTAR: |
| 3158 | case OP_NOTSTARI: | |
| 3159 | case OP_NOTMINSTAR: | case OP_NOTMINSTAR: |
| 3160 | case OP_NOTMINSTARI: | |
| 3161 | case OP_NOTPLUS: | case OP_NOTPLUS: |
| 3162 | case OP_NOTPLUSI: | |
| 3163 | case OP_NOTMINPLUS: | case OP_NOTMINPLUS: |
| 3164 | case OP_NOTMINPLUSI: | |
| 3165 | case OP_NOTQUERY: | case OP_NOTQUERY: |
| 3166 | case OP_NOTQUERYI: | |
| 3167 | case OP_NOTMINQUERY: | case OP_NOTMINQUERY: |
| 3168 | c = *ecode++ - OP_NOTSTAR; | case OP_NOTMINQUERYI: |
| 3169 | c = *ecode++ - ((op >= OP_NOTSTARI)? OP_NOTSTARI: OP_NOTSTAR); | |
| 3170 | minimize = (c & 1) != 0; | minimize = (c & 1) != 0; |
| 3171 | min = rep_min[c]; /* Pick up values from tables; */ | min = rep_min[c]; /* Pick up values from tables; */ |
| 3172 | max = rep_max[c]; /* zero for max => infinity */ | max = rep_max[c]; /* zero for max => infinity */ |
| # | Line 2983 for (;;) | Line 3188 for (;;) |
| 3188 | DPRINTF(("negative matching %c{%d,%d} against subject %.*s\n", fc, min, max, | DPRINTF(("negative matching %c{%d,%d} against subject %.*s\n", fc, min, max, |
| 3189 | max, eptr)); | max, eptr)); |
| 3190 | ||
| 3191 | if ((ims & PCRE_CASELESS) != 0) | if (op >= OP_NOTSTARI) /* Caseless */ |
| 3192 | { | { |
| 3193 | fc = md->lcc[fc]; | fc = md->lcc[fc]; |
| 3194 | ||
| # | Line 2997 for (;;) | Line 3202 for (;;) |
| 3202 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3203 | { | { |
| 3204 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3205 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3206 | } | } |
| 3207 | GETCHARINC(d, eptr); | GETCHARINC(d, eptr); |
| 3208 | if (d < 256) d = md->lcc[d]; | if (d < 256) d = md->lcc[d]; |
| 3209 | if (fc == d) RRETURN(MATCH_NOMATCH); | if (fc == d) MRRETURN(MATCH_NOMATCH); |
| 3210 | } | } |
| 3211 | } | } |
| 3212 | else | else |
| # | Line 3014 for (;;) | Line 3219 for (;;) |
| 3219 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3220 | { | { |
| 3221 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3222 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3223 | } | } |
| 3224 | if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); | if (fc == md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH); |
| 3225 | } | } |
| 3226 | } | } |
| 3227 | ||
| # | Line 3031 for (;;) | Line 3236 for (;;) |
| 3236 | register unsigned int d; | register unsigned int d; |
| 3237 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 3238 | { | { |
| 3239 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM28); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM28); |
| 3240 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3241 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 3242 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3243 | { | { |
| 3244 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3245 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3246 | } | } |
| 3247 | GETCHARINC(d, eptr); | GETCHARINC(d, eptr); |
| 3248 | if (d < 256) d = md->lcc[d]; | if (d < 256) d = md->lcc[d]; |
| 3249 | if (fc == d) RRETURN(MATCH_NOMATCH); | if (fc == d) MRRETURN(MATCH_NOMATCH); |
| 3250 | } | } |
| 3251 | } | } |
| 3252 | else | else |
| # | Line 3050 for (;;) | Line 3255 for (;;) |
| 3255 | { | { |
| 3256 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 3257 | { | { |
| 3258 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM29); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM29); |
| 3259 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3260 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 3261 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3262 | { | { |
| 3263 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3264 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3265 | } | } |
| 3266 | if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); | if (fc == md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH); |
| 3267 | } | } |
| 3268 | } | } |
| 3269 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 3091 for (;;) | Line 3296 for (;;) |
| 3296 | if (possessive) continue; | if (possessive) continue; |
| 3297 | for(;;) | for(;;) |
| 3298 | { | { |
| 3299 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM30); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM30); |
| 3300 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3301 | if (eptr-- == pp) break; /* Stop if tried at original pos */ | if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 3302 | BACKCHAR(eptr); | BACKCHAR(eptr); |
| # | Line 3114 for (;;) | Line 3319 for (;;) |
| 3319 | if (possessive) continue; | if (possessive) continue; |
| 3320 | while (eptr >= pp) | while (eptr >= pp) |
| 3321 | { | { |
| 3322 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM31); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM31); |
| 3323 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3324 | eptr--; | eptr--; |
| 3325 | } | } |
| 3326 | } | } |
| 3327 | ||
| 3328 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3329 | } | } |
| 3330 | /* Control never gets here */ | /* Control never gets here */ |
| 3331 | } | } |
| # | Line 3139 for (;;) | Line 3344 for (;;) |
| 3344 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3345 | { | { |
| 3346 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3347 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3348 | } | } |
| 3349 | GETCHARINC(d, eptr); | GETCHARINC(d, eptr); |
| 3350 | if (fc == d) RRETURN(MATCH_NOMATCH); | if (fc == d) MRRETURN(MATCH_NOMATCH); |
| 3351 | } | } |
| 3352 | } | } |
| 3353 | else | else |
| # | Line 3154 for (;;) | Line 3359 for (;;) |
| 3359 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3360 | { | { |
| 3361 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3362 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3363 | } | } |
| 3364 | if (fc == *eptr++) RRETURN(MATCH_NOMATCH); | if (fc == *eptr++) MRRETURN(MATCH_NOMATCH); |
| 3365 | } | } |
| 3366 | } | } |
| 3367 | ||
| # | Line 3171 for (;;) | Line 3376 for (;;) |
| 3376 | register unsigned int d; | register unsigned int d; |
| 3377 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 3378 | { | { |
| 3379 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM32); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM32); |
| 3380 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3381 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 3382 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3383 | { | { |
| 3384 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3385 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3386 | } | } |
| 3387 | GETCHARINC(d, eptr); | GETCHARINC(d, eptr); |
| 3388 | if (fc == d) RRETURN(MATCH_NOMATCH); | if (fc == d) MRRETURN(MATCH_NOMATCH); |
| 3389 | } | } |
| 3390 | } | } |
| 3391 | else | else |
| # | Line 3189 for (;;) | Line 3394 for (;;) |
| 3394 | { | { |
| 3395 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 3396 | { | { |
| 3397 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM33); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM33); |
| 3398 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3399 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 3400 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3401 | { | { |
| 3402 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3403 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3404 | } | } |
| 3405 | if (fc == *eptr++) RRETURN(MATCH_NOMATCH); | if (fc == *eptr++) MRRETURN(MATCH_NOMATCH); |
| 3406 | } | } |
| 3407 | } | } |
| 3408 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 3229 for (;;) | Line 3434 for (;;) |
| 3434 | if (possessive) continue; | if (possessive) continue; |
| 3435 | for(;;) | for(;;) |
| 3436 | { | { |
| 3437 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM34); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM34); |
| 3438 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3439 | if (eptr-- == pp) break; /* Stop if tried at original pos */ | if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 3440 | BACKCHAR(eptr); | BACKCHAR(eptr); |
| # | Line 3252 for (;;) | Line 3457 for (;;) |
| 3457 | if (possessive) continue; | if (possessive) continue; |
| 3458 | while (eptr >= pp) | while (eptr >= pp) |
| 3459 | { | { |
| 3460 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM35); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM35); |
| 3461 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3462 | eptr--; | eptr--; |
| 3463 | } | } |
| 3464 | } | } |
| 3465 | ||
| 3466 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3467 | } | } |
| 3468 | } | } |
| 3469 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 3352 for (;;) | Line 3557 for (;;) |
| 3557 | switch(prop_type) | switch(prop_type) |
| 3558 | { | { |
| 3559 | case PT_ANY: | case PT_ANY: |
| 3560 | if (prop_fail_result) RRETURN(MATCH_NOMATCH); | if (prop_fail_result) MRRETURN(MATCH_NOMATCH); |
| 3561 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3562 | { | { |
| 3563 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3564 | { | { |
| 3565 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3566 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3567 | } | } |
| 3568 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3569 | } | } |
| # | Line 3370 for (;;) | Line 3575 for (;;) |
| 3575 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3576 | { | { |
| 3577 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3578 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3579 | } | } |
| 3580 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3581 | prop_chartype = UCD_CHARTYPE(c); | prop_chartype = UCD_CHARTYPE(c); |
| 3582 | if ((prop_chartype == ucp_Lu || | if ((prop_chartype == ucp_Lu || |
| 3583 | prop_chartype == ucp_Ll || | prop_chartype == ucp_Ll || |
| 3584 | prop_chartype == ucp_Lt) == prop_fail_result) | prop_chartype == ucp_Lt) == prop_fail_result) |
| 3585 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3586 | } | } |
| 3587 | break; | break; |
| 3588 | ||
| # | Line 3387 for (;;) | Line 3592 for (;;) |
| 3592 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3593 | { | { |
| 3594 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3595 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3596 | } | } |
| 3597 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3598 | prop_category = UCD_CATEGORY(c); | prop_category = UCD_CATEGORY(c); |
| 3599 | if ((prop_category == prop_value) == prop_fail_result) | if ((prop_category == prop_value) == prop_fail_result) |
| 3600 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3601 | } | } |
| 3602 | break; | break; |
| 3603 | ||
| # | Line 3402 for (;;) | Line 3607 for (;;) |
| 3607 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3608 | { | { |
| 3609 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3610 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3611 | } | } |
| 3612 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3613 | prop_chartype = UCD_CHARTYPE(c); | prop_chartype = UCD_CHARTYPE(c); |
| 3614 | if ((prop_chartype == prop_value) == prop_fail_result) | if ((prop_chartype == prop_value) == prop_fail_result) |
| 3615 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3616 | } | } |
| 3617 | break; | break; |
| 3618 | ||
| # | Line 3417 for (;;) | Line 3622 for (;;) |
| 3622 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3623 | { | { |
| 3624 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3625 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3626 | } | } |
| 3627 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3628 | prop_script = UCD_SCRIPT(c); | prop_script = UCD_SCRIPT(c); |
| 3629 | if ((prop_script == prop_value) == prop_fail_result) | if ((prop_script == prop_value) == prop_fail_result) |
| 3630 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3631 | } | |
| 3632 | break; | |
| 3633 | ||
| 3634 | case PT_ALNUM: | |
| 3635 | for (i = 1; i <= min; i++) | |
| 3636 | { | |
| 3637 | if (eptr >= md->end_subject) | |
| 3638 | { | |
| 3639 | SCHECK_PARTIAL(); | |
| 3640 | MRRETURN(MATCH_NOMATCH); | |
| 3641 | } | |
| 3642 | GETCHARINCTEST(c, eptr); | |
| 3643 | prop_category = UCD_CATEGORY(c); | |
| 3644 | if ((prop_category == ucp_L || prop_category == ucp_N) | |
| 3645 | == prop_fail_result) | |
| 3646 | MRRETURN(MATCH_NOMATCH); | |
| 3647 | } | |
| 3648 | break; | |
| 3649 | ||
| 3650 | case PT_SPACE: /* Perl space */ | |
| 3651 | for (i = 1; i <= min; i++) | |
| 3652 | { | |
| 3653 | if (eptr >= md->end_subject) | |
| 3654 | { | |
| 3655 | SCHECK_PARTIAL(); | |
| 3656 | MRRETURN(MATCH_NOMATCH); | |
| 3657 | } | |
| 3658 | GETCHARINCTEST(c, eptr); | |
| 3659 | prop_category = UCD_CATEGORY(c); | |
| 3660 | if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL || | |
| 3661 | c == CHAR_FF || c == CHAR_CR) | |
| 3662 | == prop_fail_result) | |
| 3663 | MRRETURN(MATCH_NOMATCH); | |
| 3664 | } | |
| 3665 | break; | |
| 3666 | ||
| 3667 | case PT_PXSPACE: /* POSIX space */ | |
| 3668 | for (i = 1; i <= min; i++) | |
| 3669 | { | |
| 3670 | if (eptr >= md->end_subject) | |
| 3671 | { | |
| 3672 | SCHECK_PARTIAL(); | |
| 3673 | MRRETURN(MATCH_NOMATCH); | |
| 3674 | } | |
| 3675 | GETCHARINCTEST(c, eptr); | |
| 3676 | prop_category = UCD_CATEGORY(c); | |
| 3677 | if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL || | |
| 3678 | c == CHAR_VT || c == CHAR_FF || c == CHAR_CR) | |
| 3679 | == prop_fail_result) | |
| 3680 | MRRETURN(MATCH_NOMATCH); | |
| 3681 | } | } |
| 3682 | break; | break; |
| 3683 | ||
| 3684 | case PT_WORD: | |
| 3685 | for (i = 1; i <= min; i++) | |
| 3686 | { | |
| 3687 | if (eptr >= md->end_subject) | |
| 3688 | { | |
| 3689 | SCHECK_PARTIAL(); | |
| 3690 | MRRETURN(MATCH_NOMATCH); | |
| 3691 | } | |
| 3692 | GETCHARINCTEST(c, eptr); | |
| 3693 | prop_category = UCD_CATEGORY(c); | |
| 3694 | if ((prop_category == ucp_L || prop_category == ucp_N || | |
| 3695 | c == CHAR_UNDERSCORE) | |
| 3696 | == prop_fail_result) | |
| 3697 | MRRETURN(MATCH_NOMATCH); | |
| 3698 | } | |
| 3699 | break; | |
| 3700 | ||
| 3701 | /* This should not occur */ | |
| 3702 | ||
| 3703 | default: | default: |
| 3704 | RRETURN(PCRE_ERROR_INTERNAL); | RRETURN(PCRE_ERROR_INTERNAL); |
| 3705 | } | } |
| # | Line 3441 for (;;) | Line 3715 for (;;) |
| 3715 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3716 | { | { |
| 3717 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3718 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3719 | } | } |
| 3720 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3721 | prop_category = UCD_CATEGORY(c); | prop_category = UCD_CATEGORY(c); |
| 3722 | if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH); | if (prop_category == ucp_M) MRRETURN(MATCH_NOMATCH); |
| 3723 | while (eptr < md->end_subject) | while (eptr < md->end_subject) |
| 3724 | { | { |
| 3725 | int len = 1; | int len = 1; |
| # | Line 3472 for (;;) | Line 3746 for (;;) |
| 3746 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3747 | { | { |
| 3748 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3749 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3750 | } | } |
| 3751 | if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); | if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH); |
| 3752 | eptr++; | eptr++; |
| 3753 | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| 3754 | } | } |
| # | Line 3486 for (;;) | Line 3760 for (;;) |
| 3760 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3761 | { | { |
| 3762 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3763 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3764 | } | } |
| 3765 | eptr++; | eptr++; |
| 3766 | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| # | Line 3494 for (;;) | Line 3768 for (;;) |
| 3768 | break; | break; |
| 3769 | ||
| 3770 | case OP_ANYBYTE: | case OP_ANYBYTE: |
| 3771 | if (eptr > md->end_subject - min) RRETURN(MATCH_NOMATCH); | if (eptr > md->end_subject - min) MRRETURN(MATCH_NOMATCH); |
| 3772 | eptr += min; | eptr += min; |
| 3773 | break; | break; |
| 3774 | ||
| # | Line 3504 for (;;) | Line 3778 for (;;) |
| 3778 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3779 | { | { |
| 3780 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3781 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3782 | } | } |
| 3783 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 3784 | switch(c) | switch(c) |
| 3785 | { | { |
| 3786 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 3787 | ||
| 3788 | case 0x000d: | case 0x000d: |
| 3789 | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 3790 | break; | break; |
| # | Line 3522 for (;;) | Line 3797 for (;;) |
| 3797 | case 0x0085: | case 0x0085: |
| 3798 | case 0x2028: | case 0x2028: |
| 3799 | case 0x2029: | case 0x2029: |
| 3800 | if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); | if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH); |
| 3801 | break; | break; |
| 3802 | } | } |
| 3803 | } | } |
| # | Line 3534 for (;;) | Line 3809 for (;;) |
| 3809 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3810 | { | { |
| 3811 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3812 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3813 | } | } |
| 3814 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 3815 | switch(c) | switch(c) |
| # | Line 3559 for (;;) | Line 3834 for (;;) |
| 3834 | case 0x202f: /* NARROW NO-BREAK SPACE */ | case 0x202f: /* NARROW NO-BREAK SPACE */ |
| 3835 | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ |
| 3836 | case 0x3000: /* IDEOGRAPHIC SPACE */ | case 0x3000: /* IDEOGRAPHIC SPACE */ |
| 3837 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3838 | } | } |
| 3839 | } | } |
| 3840 | break; | break; |
| # | Line 3570 for (;;) | Line 3845 for (;;) |
| 3845 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3846 | { | { |
| 3847 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3848 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3849 | } | } |
| 3850 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 3851 | switch(c) | switch(c) |
| 3852 | { | { |
| 3853 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 3854 | case 0x09: /* HT */ | case 0x09: /* HT */ |
| 3855 | case 0x20: /* SPACE */ | case 0x20: /* SPACE */ |
| 3856 | case 0xa0: /* NBSP */ | case 0xa0: /* NBSP */ |
| # | Line 3606 for (;;) | Line 3881 for (;;) |
| 3881 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3882 | { | { |
| 3883 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3884 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3885 | } | } |
| 3886 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 3887 | switch(c) | switch(c) |
| # | Line 3619 for (;;) | Line 3894 for (;;) |
| 3894 | case 0x85: /* NEL */ | case 0x85: /* NEL */ |
| 3895 | case 0x2028: /* LINE SEPARATOR */ | case 0x2028: /* LINE SEPARATOR */ |
| 3896 | case 0x2029: /* PARAGRAPH SEPARATOR */ | case 0x2029: /* PARAGRAPH SEPARATOR */ |
| 3897 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3898 | } | } |
| 3899 | } | } |
| 3900 | break; | break; |
| # | Line 3630 for (;;) | Line 3905 for (;;) |
| 3905 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3906 | { | { |
| 3907 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3908 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3909 | } | } |
| 3910 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 3911 | switch(c) | switch(c) |
| 3912 | { | { |
| 3913 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 3914 | case 0x0a: /* LF */ | case 0x0a: /* LF */ |
| 3915 | case 0x0b: /* VT */ | case 0x0b: /* VT */ |
| 3916 | case 0x0c: /* FF */ | case 0x0c: /* FF */ |
| # | Line 3654 for (;;) | Line 3929 for (;;) |
| 3929 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3930 | { | { |
| 3931 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3932 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3933 | } | } |
| 3934 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 3935 | if (c < 128 && (md->ctypes[c] & ctype_digit) != 0) | if (c < 128 && (md->ctypes[c] & ctype_digit) != 0) |
| 3936 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3937 | } | } |
| 3938 | break; | break; |
| 3939 | ||
| # | Line 3668 for (;;) | Line 3943 for (;;) |
| 3943 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3944 | { | { |
| 3945 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3946 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3947 | } | } |
| 3948 | if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0) | if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0) |
| 3949 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3950 | /* 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 */ |
| 3951 | } | } |
| 3952 | break; | break; |
| # | Line 3682 for (;;) | Line 3957 for (;;) |
| 3957 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3958 | { | { |
| 3959 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3960 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3961 | } | } |
| 3962 | if (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0) | if (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0) |
| 3963 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3964 | while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80); | while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80); |
| 3965 | } | } |
| 3966 | break; | break; |
| # | Line 3696 for (;;) | Line 3971 for (;;) |
| 3971 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3972 | { | { |
| 3973 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3974 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3975 | } | } |
| 3976 | if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0) | if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0) |
| 3977 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3978 | /* 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 */ |
| 3979 | } | } |
| 3980 | break; | break; |
| # | Line 3710 for (;;) | Line 3985 for (;;) |
| 3985 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3986 | { | { |
| 3987 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3988 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3989 | } | } |
| 3990 | if (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0) | if (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0) |
| 3991 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3992 | while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80); | while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80); |
| 3993 | } | } |
| 3994 | break; | break; |
| # | Line 3724 for (;;) | Line 3999 for (;;) |
| 3999 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4000 | { | { |
| 4001 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4002 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4003 | } | } |
| 4004 | if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0) | if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0) |
| 4005 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4006 | /* 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 */ |
| 4007 | } | } |
| 4008 | break; | break; |
| # | Line 3750 for (;;) | Line 4025 for (;;) |
| 4025 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4026 | { | { |
| 4027 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4028 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4029 | } | } |
| 4030 | if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); | if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH); |
| 4031 | eptr++; | eptr++; |
| 4032 | } | } |
| 4033 | break; | break; |
| # | Line 3761 for (;;) | Line 4036 for (;;) |
| 4036 | if (eptr > md->end_subject - min) | if (eptr > md->end_subject - min) |
| 4037 | { | { |
| 4038 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4039 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4040 | } | } |
| 4041 | eptr += min; | eptr += min; |
| 4042 | break; | break; |
| # | Line 3770 for (;;) | Line 4045 for (;;) |
| 4045 | if (eptr > md->end_subject - min) | if (eptr > md->end_subject - min) |
| 4046 | { | { |
| 4047 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4048 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4049 | } | } |
| 4050 | eptr += min; | eptr += min; |
| 4051 | break; | break; |
| # | Line 3781 for (;;) | Line 4056 for (;;) |
| 4056 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4057 | { | { |
| 4058 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4059 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4060 | } | } |
| 4061 | switch(*eptr++) | switch(*eptr++) |
| 4062 | { | { |
| 4063 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4064 | ||
| 4065 | case 0x000d: | case 0x000d: |
| 4066 | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 4067 | break; | break; |
| 4068 | ||
| 4069 | case 0x000a: | case 0x000a: |
| 4070 | break; | break; |
| 4071 | ||
| 4072 | case 0x000b: | case 0x000b: |
| 4073 | case 0x000c: | case 0x000c: |
| 4074 | case 0x0085: | case 0x0085: |
| 4075 | if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); | if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH); |
| 4076 | break; | break; |
| 4077 | } | } |
| 4078 | } | } |
| # | Line 3807 for (;;) | Line 4084 for (;;) |
| 4084 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4085 | { | { |
| 4086 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4087 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4088 | } | } |
| 4089 | switch(*eptr++) | switch(*eptr++) |
| 4090 | { | { |
| # | Line 3815 for (;;) | Line 4092 for (;;) |
| 4092 | case 0x09: /* HT */ | case 0x09: /* HT */ |
| 4093 | case 0x20: /* SPACE */ | case 0x20: /* SPACE */ |
| 4094 | case 0xa0: /* NBSP */ | case 0xa0: /* NBSP */ |
| 4095 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4096 | } | } |
| 4097 | } | } |
| 4098 | break; | break; |
| # | Line 3826 for (;;) | Line 4103 for (;;) |
| 4103 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4104 | { | { |
| 4105 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4106 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4107 | } | } |
| 4108 | switch(*eptr++) | switch(*eptr++) |
| 4109 | { | { |
| 4110 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4111 | case 0x09: /* HT */ | case 0x09: /* HT */ |
| 4112 | case 0x20: /* SPACE */ | case 0x20: /* SPACE */ |
| 4113 | case 0xa0: /* NBSP */ | case 0xa0: /* NBSP */ |
| # | Line 3845 for (;;) | Line 4122 for (;;) |
| 4122 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4123 | { | { |
| 4124 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4125 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4126 | } | } |
| 4127 | switch(*eptr++) | switch(*eptr++) |
| 4128 | { | { |
| # | Line 3855 for (;;) | Line 4132 for (;;) |
| 4132 | case 0x0c: /* FF */ | case 0x0c: /* FF */ |
| 4133 | case 0x0d: /* CR */ | case 0x0d: /* CR */ |
| 4134 | case 0x85: /* NEL */ | case 0x85: /* NEL */ |
| 4135 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4136 | } | } |
| 4137 | } | } |
| 4138 | break; | break; |
| # | Line 3866 for (;;) | Line 4143 for (;;) |
| 4143 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4144 | { | { |
| 4145 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4146 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4147 | } | } |
| 4148 | switch(*eptr++) | switch(*eptr++) |
| 4149 | { | { |
| 4150 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4151 | case 0x0a: /* LF */ | case 0x0a: /* LF */ |
| 4152 | case 0x0b: /* VT */ | case 0x0b: /* VT */ |
| 4153 | case 0x0c: /* FF */ | case 0x0c: /* FF */ |
| # | Line 3887 for (;;) | Line 4164 for (;;) |
| 4164 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4165 | { | { |
| 4166 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4167 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4168 | } | } |
| 4169 | if ((md->ctypes[*eptr++] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[*eptr++] & ctype_digit) != 0) MRRETURN(MATCH_NOMATCH); |
| 4170 | } | } |
| 4171 | break; | break; |
| 4172 | ||
| # | Line 3899 for (;;) | Line 4176 for (;;) |
| 4176 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4177 | { | { |
| 4178 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4179 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4180 | } | } |
| 4181 | if ((md->ctypes[*eptr++] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[*eptr++] & ctype_digit) == 0) MRRETURN(MATCH_NOMATCH); |
| 4182 | } | } |
| 4183 | break; | break; |
| 4184 | ||
| # | Line 3911 for (;;) | Line 4188 for (;;) |
| 4188 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4189 | { | { |
| 4190 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4191 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4192 | } | } |
| 4193 | if ((md->ctypes[*eptr++] & ctype_space) != 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[*eptr++] & ctype_space) != 0) MRRETURN(MATCH_NOMATCH); |
| 4194 | } | } |
| 4195 | break; | break; |
| 4196 | ||
| # | Line 3923 for (;;) | Line 4200 for (;;) |
| 4200 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4201 | { | { |
| 4202 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4203 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4204 | } | } |
| 4205 | if ((md->ctypes[*eptr++] & ctype_space) == 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[*eptr++] & ctype_space) == 0) MRRETURN(MATCH_NOMATCH); |
| 4206 | } | } |
| 4207 | break; | break; |
| 4208 | ||
| # | Line 3935 for (;;) | Line 4212 for (;;) |
| 4212 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4213 | { | { |
| 4214 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4215 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4216 | } | } |
| 4217 | if ((md->ctypes[*eptr++] & ctype_word) != 0) | if ((md->ctypes[*eptr++] & ctype_word) != 0) |
| 4218 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4219 | } | } |
| 4220 | break; | break; |
| 4221 | ||
| # | Line 3948 for (;;) | Line 4225 for (;;) |
| 4225 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4226 | { | { |
| 4227 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4228 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4229 | } | } |
| 4230 | if ((md->ctypes[*eptr++] & ctype_word) == 0) | if ((md->ctypes[*eptr++] & ctype_word) == 0) |
| 4231 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4232 | } | } |
| 4233 | break; | break; |
| 4234 | ||
| # | Line 3978 for (;;) | Line 4255 for (;;) |
| 4255 | case PT_ANY: | case PT_ANY: |
| 4256 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 4257 | { | { |
| 4258 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM36); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM36); |
| 4259 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4260 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4261 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4262 | { | { |
| 4263 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4264 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4265 | } | } |
| 4266 | GETCHARINC(c, eptr); | GETCHARINCTEST(c, eptr); |
| 4267 | if (prop_fail_result) RRETURN(MATCH_NOMATCH); | if (prop_fail_result) MRRETURN(MATCH_NOMATCH); |
| 4268 | } | } |
| 4269 | /* Control never gets here */ | /* Control never gets here */ |
| 4270 | ||
| 4271 | case PT_LAMP: | case PT_LAMP: |
| 4272 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 4273 | { | { |
| 4274 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM37); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM37); |
| 4275 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4276 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4277 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4278 | { | { |
| 4279 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4280 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4281 | } | } |
| 4282 | GETCHARINC(c, eptr); | GETCHARINCTEST(c, eptr); |
| 4283 | prop_chartype = UCD_CHARTYPE(c); | prop_chartype = UCD_CHARTYPE(c); |
| 4284 | if ((prop_chartype == ucp_Lu || | if ((prop_chartype == ucp_Lu || |
| 4285 | prop_chartype == ucp_Ll || | prop_chartype == ucp_Ll || |
| 4286 | prop_chartype == ucp_Lt) == prop_fail_result) | prop_chartype == ucp_Lt) == prop_fail_result) |
| 4287 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4288 | } | } |
| 4289 | /* Control never gets here */ | /* Control never gets here */ |
| 4290 | ||
| 4291 | case PT_GC: | case PT_GC: |
| 4292 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 4293 | { | { |
| 4294 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM38); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM38); |
| 4295 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4296 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4297 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4298 | { | { |
| 4299 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4300 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4301 | } | } |
| 4302 | GETCHARINC(c, eptr); | GETCHARINCTEST(c, eptr); |
| 4303 | prop_category = UCD_CATEGORY(c); | prop_category = UCD_CATEGORY(c); |
| 4304 | if ((prop_category == prop_value) == prop_fail_result) | if ((prop_category == prop_value) == prop_fail_result) |
| 4305 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4306 | } | } |
| 4307 | /* Control never gets here */ | /* Control never gets here */ |
| 4308 | ||
| 4309 | case PT_PC: | case PT_PC: |
| 4310 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 4311 | { | { |
| 4312 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM39); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM39); |
| 4313 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4314 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4315 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4316 | { | { |
| 4317 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4318 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4319 | } | } |
| 4320 | GETCHARINC(c, eptr); | GETCHARINCTEST(c, eptr); |
| 4321 | prop_chartype = UCD_CHARTYPE(c); | prop_chartype = UCD_CHARTYPE(c); |
| 4322 | if ((prop_chartype == prop_value) == prop_fail_result) | if ((prop_chartype == prop_value) == prop_fail_result) |
| 4323 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4324 | } | } |
| 4325 | /* Control never gets here */ | /* Control never gets here */ |
| 4326 | ||
| 4327 | case PT_SC: | case PT_SC: |
| 4328 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 4329 | { | { |
| 4330 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM40); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM40); |
| 4331 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4332 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4333 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4334 | { | { |
| 4335 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4336 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4337 | } | } |
| 4338 | GETCHARINC(c, eptr); | GETCHARINCTEST(c, eptr); |
| 4339 | prop_script = UCD_SCRIPT(c); | prop_script = UCD_SCRIPT(c); |
| 4340 | if ((prop_script == prop_value) == prop_fail_result) | if ((prop_script == prop_value) == prop_fail_result) |
| 4341 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4342 | } | |
| 4343 | /* Control never gets here */ | |
| 4344 | ||
| 4345 | case PT_ALNUM: | |
| 4346 | for (fi = min;; fi++) | |
| 4347 | { | |
| 4348 | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM59); | |
| 4349 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | |
| 4350 | if (fi >= max) MRRETURN(MATCH_NOMATCH); | |
| 4351 | if (eptr >= md->end_subject) | |
| 4352 | { | |
| 4353 | SCHECK_PARTIAL(); | |
| 4354 | MRRETURN(MATCH_NOMATCH); | |
| 4355 | } | |
| 4356 | GETCHARINCTEST(c, eptr); | |
| 4357 | prop_category = UCD_CATEGORY(c); | |
| 4358 | if ((prop_category == ucp_L || prop_category == ucp_N) | |
| 4359 | == prop_fail_result) | |
| 4360 | MRRETURN(MATCH_NOMATCH); | |
| 4361 | } | |
| 4362 | /* Control never gets here */ | |
| 4363 | ||
| 4364 | case PT_SPACE: /* Perl space */ | |
| 4365 | for (fi = min;; fi++) | |
| 4366 | { | |
| 4367 | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM60); | |
| 4368 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | |
| 4369 | if (fi >= max) MRRETURN(MATCH_NOMATCH); | |
| 4370 | if (eptr >= md->end_subject) | |
| 4371 | { | |
| 4372 | SCHECK_PARTIAL(); | |
| 4373 | MRRETURN(MATCH_NOMATCH); | |
| 4374 | } | |
| 4375 | GETCHARINCTEST(c, eptr); | |
| 4376 | prop_category = UCD_CATEGORY(c); | |
| 4377 | if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL || | |
| 4378 | c == CHAR_FF || c == CHAR_CR) | |
| 4379 | == prop_fail_result) | |
| 4380 | MRRETURN(MATCH_NOMATCH); | |
| 4381 | } | |
| 4382 | /* Control never gets here */ | |
| 4383 | ||
| 4384 | case PT_PXSPACE: /* POSIX space */ | |
| 4385 | for (fi = min;; fi++) | |
| 4386 | { | |
| 4387 | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM61); | |
| 4388 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | |
| 4389 | if (fi >= max) MRRETURN(MATCH_NOMATCH); | |
| 4390 | if (eptr >= md->end_subject) | |
| 4391 | { | |
| 4392 | SCHECK_PARTIAL(); | |
| 4393 | MRRETURN(MATCH_NOMATCH); | |
| 4394 | } | |
| 4395 | GETCHARINCTEST(c, eptr); | |
| 4396 | prop_category = UCD_CATEGORY(c); | |
| 4397 | if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL || | |
| 4398 | c == CHAR_VT || c == CHAR_FF || c == CHAR_CR) | |
| 4399 | == prop_fail_result) | |
| 4400 | MRRETURN(MATCH_NOMATCH); | |
| 4401 | } | |
| 4402 | /* Control never gets here */ | |
| 4403 | ||
| 4404 | case PT_WORD: | |
| 4405 | for (fi = min;; fi++) | |
| 4406 | { | |
| 4407 | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM62); | |
| 4408 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | |
| 4409 | if (fi >= max) MRRETURN(MATCH_NOMATCH); | |
| 4410 | if (eptr >= md->end_subject) | |
| 4411 | { | |
| 4412 | SCHECK_PARTIAL(); | |
| 4413 | MRRETURN(MATCH_NOMATCH); | |
| 4414 | } | |
| 4415 | GETCHARINCTEST(c, eptr); | |
| 4416 | prop_category = UCD_CATEGORY(c); | |
| 4417 | if ((prop_category == ucp_L || | |
| 4418 | prop_category == ucp_N || | |
| 4419 | c == CHAR_UNDERSCORE) | |
| 4420 | == prop_fail_result) | |
| 4421 | MRRETURN(MATCH_NOMATCH); | |
| 4422 | } | } |
| 4423 | /* Control never gets here */ | /* Control never gets here */ |
| 4424 | ||
| 4425 | /* This should never occur */ | |
| 4426 | ||
| 4427 | default: | default: |
| 4428 | RRETURN(PCRE_ERROR_INTERNAL); | RRETURN(PCRE_ERROR_INTERNAL); |
| 4429 | } | } |
| # | Line 4077 for (;;) | Line 4436 for (;;) |
| 4436 | { | { |
| 4437 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 4438 | { | { |
| 4439 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM41); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM41); |
| 4440 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4441 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4442 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4443 | { | { |
| 4444 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4445 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4446 | } | } |
| 4447 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 4448 | prop_category = UCD_CATEGORY(c); | prop_category = UCD_CATEGORY(c); |
| 4449 | if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH); | if (prop_category == ucp_M) MRRETURN(MATCH_NOMATCH); |
| 4450 | while (eptr < md->end_subject) | while (eptr < md->end_subject) |
| 4451 | { | { |
| 4452 | int len = 1; | int len = 1; |
| # | Line 4109 for (;;) | Line 4468 for (;;) |
| 4468 | { | { |
| 4469 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 4470 | { | { |
| 4471 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM42); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM42); |
| 4472 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4473 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4474 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4475 | { | { |
| 4476 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4477 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4478 | } | } |
| 4479 | if (ctype == OP_ANY && IS_NEWLINE(eptr)) | if (ctype == OP_ANY && IS_NEWLINE(eptr)) |
| 4480 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4481 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 4482 | switch(ctype) | switch(ctype) |
| 4483 | { | { |
| # | Line 4130 for (;;) | Line 4489 for (;;) |
| 4489 | case OP_ANYNL: | case OP_ANYNL: |
| 4490 | switch(c) | switch(c) |
| 4491 | { | { |
| 4492 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4493 | case 0x000d: | case 0x000d: |
| 4494 | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 4495 | break; | break; |
| # | Line 4142 for (;;) | Line 4501 for (;;) |
| 4501 | case 0x0085: | case 0x0085: |
| 4502 | case 0x2028: | case 0x2028: |
| 4503 | case 0x2029: | case 0x2029: |
| 4504 | if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); | if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH); |
| 4505 | break; | break; |
| 4506 | } | } |
| 4507 | break; | break; |
| # | Line 4170 for (;;) | Line 4529 for (;;) |
| 4529 | case 0x202f: /* NARROW NO-BREAK SPACE */ | case 0x202f: /* NARROW NO-BREAK SPACE */ |
| 4530 | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ |
| 4531 | case 0x3000: /* IDEOGRAPHIC SPACE */ | case 0x3000: /* IDEOGRAPHIC SPACE */ |
| 4532 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4533 | } | } |
| 4534 | break; | break; |
| 4535 | ||
| 4536 | case OP_HSPACE: | case OP_HSPACE: |
| 4537 | switch(c) | switch(c) |
| 4538 | { | { |
| 4539 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4540 | case 0x09: /* HT */ | case 0x09: /* HT */ |
| 4541 | case 0x20: /* SPACE */ | case 0x20: /* SPACE */ |
| 4542 | case 0xa0: /* NBSP */ | case 0xa0: /* NBSP */ |
| # | Line 4212 for (;;) | Line 4571 for (;;) |
| 4571 | case 0x85: /* NEL */ | case 0x85: /* NEL */ |
| 4572 | case 0x2028: /* LINE SEPARATOR */ | case 0x2028: /* LINE SEPARATOR */ |
| 4573 | case 0x2029: /* PARAGRAPH SEPARATOR */ | case 0x2029: /* PARAGRAPH SEPARATOR */ |
| 4574 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4575 | } | } |
| 4576 | break; | break; |
| 4577 | ||
| 4578 | case OP_VSPACE: | case OP_VSPACE: |
| 4579 | switch(c) | switch(c) |
| 4580 | { | { |
| 4581 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4582 | case 0x0a: /* LF */ | case 0x0a: /* LF */ |
| 4583 | case 0x0b: /* VT */ | case 0x0b: /* VT */ |
| 4584 | case 0x0c: /* FF */ | case 0x0c: /* FF */ |
| # | Line 4233 for (;;) | Line 4592 for (;;) |
| 4592 | ||
| 4593 | case OP_NOT_DIGIT: | case OP_NOT_DIGIT: |
| 4594 | if (c < 256 && (md->ctypes[c] & ctype_digit) != 0) | if (c < 256 && (md->ctypes[c] & ctype_digit) != 0) |
| 4595 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4596 | break; | break; |
| 4597 | ||
| 4598 | case OP_DIGIT: | case OP_DIGIT: |
| 4599 | if (c >= 256 || (md->ctypes[c] & ctype_digit) == 0) | if (c >= 256 || (md->ctypes[c] & ctype_digit) == 0) |
| 4600 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4601 | break; | break; |
| 4602 | ||
| 4603 | case OP_NOT_WHITESPACE: | case OP_NOT_WHITESPACE: |
| 4604 | if (c < 256 && (md->ctypes[c] & ctype_space) != 0) | if (c < 256 && (md->ctypes[c] & ctype_space) != 0) |
| 4605 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4606 | break; | break; |
| 4607 | ||
| 4608 | case OP_WHITESPACE: | case OP_WHITESPACE: |
| 4609 | if (c >= 256 || (md->ctypes[c] & ctype_space) == 0) | if (c >= 256 || (md->ctypes[c] & ctype_space) == 0) |
| 4610 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4611 | break; | break; |
| 4612 | ||
| 4613 | case OP_NOT_WORDCHAR: | case OP_NOT_WORDCHAR: |
| 4614 | if (c < 256 && (md->ctypes[c] & ctype_word) != 0) | if (c < 256 && (md->ctypes[c] & ctype_word) != 0) |
| 4615 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4616 | break; | break; |
| 4617 | ||
| 4618 | case OP_WORDCHAR: | case OP_WORDCHAR: |
| 4619 | if (c >= 256 || (md->ctypes[c] & ctype_word) == 0) | if (c >= 256 || (md->ctypes[c] & ctype_word) == 0) |
| 4620 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4621 | break; | break; |
| 4622 | ||
| 4623 | default: | default: |
| # | Line 4272 for (;;) | Line 4631 for (;;) |
| 4631 | { | { |
| 4632 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 4633 | { | { |
| 4634 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM43); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM43); |
| 4635 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4636 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4637 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4638 | { | { |
| 4639 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4640 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4641 | } | } |
| 4642 | if (ctype == OP_ANY && IS_NEWLINE(eptr)) | if (ctype == OP_ANY && IS_NEWLINE(eptr)) |
| 4643 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4644 | c = *eptr++; | c = *eptr++; |
| 4645 | switch(ctype) | switch(ctype) |
| 4646 | { | { |
| # | Line 4293 for (;;) | Line 4652 for (;;) |
| 4652 | case OP_ANYNL: | case OP_ANYNL: |
| 4653 | switch(c) | switch(c) |
| 4654 | { | { |
| 4655 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4656 | case 0x000d: | case 0x000d: |
| 4657 | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 4658 | break; | break; |
| # | Line 4304 for (;;) | Line 4663 for (;;) |
| 4663 | case 0x000b: | case 0x000b: |
| 4664 | case 0x000c: | case 0x000c: |
| 4665 | case 0x0085: | case 0x0085: |
| 4666 | if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); | if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH); |
| 4667 | break; | break; |
| 4668 | } | } |
| 4669 | break; | break; |
| # | Line 4316 for (;;) | Line 4675 for (;;) |
| 4675 | case 0x09: /* HT */ | case 0x09: /* HT */ |
| 4676 | case 0x20: /* SPACE */ | case 0x20: /* SPACE */ |
| 4677 | case 0xa0: /* NBSP */ | case 0xa0: /* NBSP */ |
| 4678 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4679 | } | } |
| 4680 | break; | break; |
| 4681 | ||
| 4682 | case OP_HSPACE: | case OP_HSPACE: |
| 4683 | switch(c) | switch(c) |
| 4684 | { | { |
| 4685 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4686 | case 0x09: /* HT */ | case 0x09: /* HT */ |
| 4687 | case 0x20: /* SPACE */ | case 0x20: /* SPACE */ |
| 4688 | case 0xa0: /* NBSP */ | case 0xa0: /* NBSP */ |
| # | Line 4340 for (;;) | Line 4699 for (;;) |
| 4699 | case 0x0c: /* FF */ | case 0x0c: /* FF */ |
| 4700 | case 0x0d: /* CR */ | case 0x0d: /* CR */ |
| 4701 | case 0x85: /* NEL */ | case 0x85: /* NEL */ |
| 4702 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4703 | } | } |
| 4704 | break; | break; |
| 4705 | ||
| 4706 | case OP_VSPACE: | case OP_VSPACE: |
| 4707 | switch(c) | switch(c) |
| 4708 | { | { |
| 4709 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4710 | case 0x0a: /* LF */ | case 0x0a: /* LF */ |
| 4711 | case 0x0b: /* VT */ | case 0x0b: /* VT */ |
| 4712 | case 0x0c: /* FF */ | case 0x0c: /* FF */ |
| # | Line 4358 for (;;) | Line 4717 for (;;) |
| 4717 | break; | break; |
| 4718 | ||
| 4719 | case OP_NOT_DIGIT: | case OP_NOT_DIGIT: |
| 4720 | if ((md->ctypes[c] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[c] & ctype_digit) != 0) MRRETURN(MATCH_NOMATCH); |
| 4721 | break; | break; |
| 4722 | ||
| 4723 | case OP_DIGIT: | case OP_DIGIT: |
| 4724 | if ((md->ctypes[c] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[c] & ctype_digit) == 0) MRRETURN(MATCH_NOMATCH); |
| 4725 | break; | break; |
| 4726 | ||
| 4727 | case OP_NOT_WHITESPACE: | case OP_NOT_WHITESPACE: |
| 4728 | if ((md->ctypes[c] & ctype_space) != 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[c] & ctype_space) != 0) MRRETURN(MATCH_NOMATCH); |
| 4729 | break; | break; |
| 4730 | ||
| 4731 | case OP_WHITESPACE: | case OP_WHITESPACE: |
| 4732 | if ((md->ctypes[c] & ctype_space) == 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[c] & ctype_space) == 0) MRRETURN(MATCH_NOMATCH); |
| 4733 | break; | break; |
| 4734 | ||
| 4735 | case OP_NOT_WORDCHAR: | case OP_NOT_WORDCHAR: |
| 4736 | if ((md->ctypes[c] & ctype_word) != 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[c] & ctype_word) != 0) MRRETURN(MATCH_NOMATCH); |
| 4737 | break; | break; |
| 4738 | ||
| 4739 | case OP_WORDCHAR: | case OP_WORDCHAR: |
| 4740 | if ((md->ctypes[c] & ctype_word) == 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[c] & ctype_word) == 0) MRRETURN(MATCH_NOMATCH); |
| 4741 | break; | break; |
| 4742 | ||
| 4743 | default: | default: |
| # | Line 4411 for (;;) | Line 4770 for (;;) |
| 4770 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4771 | break; | break; |
| 4772 | } | } |
| 4773 | GETCHARLEN(c, eptr, len); | GETCHARLENTEST(c, eptr, len); |
| 4774 | if (prop_fail_result) break; | if (prop_fail_result) break; |
| 4775 | eptr+= len; | eptr+= len; |
| 4776 | } | } |
| # | Line 4426 for (;;) | Line 4785 for (;;) |
| 4785 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4786 | break; | break; |
| 4787 | } | } |
| 4788 | GETCHARLEN(c, eptr, len); | GETCHARLENTEST(c, eptr, len); |
| 4789 | prop_chartype = UCD_CHARTYPE(c); | prop_chartype = UCD_CHARTYPE(c); |
| 4790 | if ((prop_chartype == ucp_Lu || | if ((prop_chartype == ucp_Lu || |
| 4791 | prop_chartype == ucp_Ll || | prop_chartype == ucp_Ll || |
| # | Line 4445 for (;;) | Line 4804 for (;;) |
| 4804 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4805 | break; | break; |
| 4806 | } | } |
| 4807 | GETCHARLEN(c, eptr, len); | GETCHARLENTEST(c, eptr, len); |
| 4808 | prop_category = UCD_CATEGORY(c); | prop_category = UCD_CATEGORY(c); |
| 4809 | if ((prop_category == prop_value) == prop_fail_result) | if ((prop_category == prop_value) == prop_fail_result) |
| 4810 | break; | break; |
| # | Line 4462 for (;;) | Line 4821 for (;;) |
| 4821 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4822 | break; | break; |
| 4823 | } | } |
| 4824 | GETCHARLEN(c, eptr, len); | GETCHARLENTEST(c, eptr, len); |
| 4825 | prop_chartype = UCD_CHARTYPE(c); | prop_chartype = UCD_CHARTYPE(c); |
| 4826 | if ((prop_chartype == prop_value) == prop_fail_result) | if ((prop_chartype == prop_value) == prop_fail_result) |
| 4827 | break; | break; |
| # | Line 4479 for (;;) | Line 4838 for (;;) |
| 4838 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4839 | break; | break; |
| 4840 | } | } |
| 4841 | GETCHARLEN(c, eptr, len); | GETCHARLENTEST(c, eptr, len); |
| 4842 | prop_script = UCD_SCRIPT(c); | prop_script = UCD_SCRIPT(c); |
| 4843 | if ((prop_script == prop_value) == prop_fail_result) | if ((prop_script == prop_value) == prop_fail_result) |
| 4844 | break; | break; |
| 4845 | eptr+= len; | eptr+= len; |
| 4846 | } | } |
| 4847 | break; | break; |
| 4848 | ||
| 4849 | case PT_ALNUM: | |
| 4850 | for (i = min; i < max; i++) | |
| 4851 | { | |
| 4852 | int len = 1; | |
| 4853 | if (eptr >= md->end_subject) | |
| 4854 | { | |
| 4855 | SCHECK_PARTIAL(); | |
| 4856 | break; | |
| 4857 | } | |
| 4858 | GETCHARLENTEST(c, eptr, len); | |
| 4859 | prop_category = UCD_CATEGORY(c); | |
| 4860 | if ((prop_category == ucp_L || prop_category == ucp_N) | |
| 4861 | == prop_fail_result) | |
| 4862 | break; | |
| 4863 | eptr+= len; | |
| 4864 | } | |
| 4865 | break; | |
| 4866 | ||
| 4867 | case PT_SPACE: /* Perl space */ | |
| 4868 | for (i = min; i < max; i++) | |
| 4869 | { | |
| 4870 | int len = 1; | |
| 4871 | if (eptr >= md->end_subject) | |
| 4872 | { | |
| 4873 | SCHECK_PARTIAL(); | |
| 4874 | break; | |
| 4875 | } | |
| 4876 | GETCHARLENTEST(c, eptr, len); | |
| 4877 | prop_category = UCD_CATEGORY(c); | |
| 4878 | if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL || | |
| 4879 | c == CHAR_FF || c == CHAR_CR) | |
| 4880 | == prop_fail_result) | |
| 4881 | break; | |
| 4882 | eptr+= len; | |
| 4883 | } | |
| 4884 | break; | |
| 4885 | ||
| 4886 | case PT_PXSPACE: /* POSIX space */ | |
| 4887 | for (i = min; i < max; i++) | |
| 4888 | { | |
| 4889 | int len = 1; | |
| 4890 | if (eptr >= md->end_subject) | |
| 4891 | { | |
| 4892 | SCHECK_PARTIAL(); | |
| 4893 | break; | |
| 4894 | } | |
| 4895 | GETCHARLENTEST(c, eptr, len); | |
| 4896 | prop_category = UCD_CATEGORY(c); | |
| 4897 | if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL || | |
| 4898 | c == CHAR_VT || c == CHAR_FF || c == CHAR_CR) | |
| 4899 | == prop_fail_result) | |
| 4900 | break; | |
| 4901 | eptr+= len; | |
| 4902 | } | |
| 4903 | break; | |
| 4904 | ||
| 4905 | case PT_WORD: | |
| 4906 | for (i = min; i < max; i++) | |
| 4907 | { | |
| 4908 | int len = 1; | |
| 4909 | if (eptr >= md->end_subject) | |
| 4910 | { | |
| 4911 | SCHECK_PARTIAL(); | |
| 4912 | break; | |
| 4913 | } | |
| 4914 | GETCHARLENTEST(c, eptr, len); | |
| 4915 | prop_category = UCD_CATEGORY(c); | |
| 4916 | if ((prop_category == ucp_L || prop_category == ucp_N || | |
| 4917 | c == CHAR_UNDERSCORE) == prop_fail_result) | |
| 4918 | break; | |
| 4919 | eptr+= len; | |
| 4920 | } | |
| 4921 | break; | |
| 4922 | ||
| 4923 | default: | |
| 4924 | RRETURN(PCRE_ERROR_INTERNAL); | |
| 4925 | } | } |
| 4926 | ||
| 4927 | /* eptr is now past the end of the maximum run */ | /* eptr is now past the end of the maximum run */ |
| # | Line 4493 for (;;) | Line 4929 for (;;) |
| 4929 | if (possessive) continue; | if (possessive) continue; |
| 4930 | for(;;) | for(;;) |
| 4931 | { | { |
| 4932 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM44); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM44); |
| 4933 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4934 | if (eptr-- == pp) break; /* Stop if tried at original pos */ | if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 4935 | if (utf8) BACKCHAR(eptr); | if (utf8) BACKCHAR(eptr); |
| # | Line 4534 for (;;) | Line 4970 for (;;) |
| 4970 | ||
| 4971 | for(;;) | for(;;) |
| 4972 | { | { |
| 4973 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM45); | RMATCH(eptr, ecode, offset_top, md, eptrb, 0, RM45); |
| 4974 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4975 | if (eptr-- == pp) break; /* Stop if tried at original pos */ | if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 4976 | for (;;) /* Move back over one extended */ | for (;;) /* Move back over one extended */ |
| # | Line 4818 for (;;) | Line 5254 for (;;) |
| 5254 | RRETURN(PCRE_ERROR_INTERNAL); | RRETURN(PCRE_ERROR_INTERNAL); |
| 5255 | } | } |
| 5256 | ||