Parent Directory
|
Revision Log
|
Patch
| revision 501 by ph10, Sun Mar 7 11:49:54 2010 UTC | revision 615 by ph10, Mon Jul 11 14:23:06 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 57 possible. There are also some static sup | Line 57 possible. There are also some static sup |
| 57 | #undef min | #undef min |
| 58 | #undef max | #undef max |
| 59 | ||
| 60 | /* Flag bits for the match() function */ | /* Values for setting in md->match_function_type to indicate two special types |
| 61 | of call to match(). We do it this way to save on using another stack variable, | |
| 62 | as stack usage is to be discouraged. */ | |
| 63 | ||
| 64 | #define match_condassert 0x01 /* Called to check a condition assertion */ | #define MATCH_CONDASSERT 1 /* Called to check a condition assertion */ |
| 65 | #define match_cbegroup 0x02 /* Could-be-empty unlimited repeat group */ | #define MATCH_CBEGROUP 2 /* Could-be-empty unlimited repeat group */ |
| 66 | ||
| 67 | /* Non-error returns from the match() function. Error returns are externally | /* Non-error returns from the match() function. Error returns are externally |
| 68 | defined PCRE_ERROR_xxx codes, which are all negative. */ | defined PCRE_ERROR_xxx codes, which are all negative. */ |
| # | Line 71 defined PCRE_ERROR_xxx codes, which are | Line 73 defined PCRE_ERROR_xxx codes, which are |
| 73 | /* Special internal returns from the match() function. Make them sufficiently | /* Special internal returns from the match() function. Make them sufficiently |
| 74 | negative to avoid the external error codes. */ | negative to avoid the external error codes. */ |
| 75 | ||
| 76 | #define MATCH_COMMIT (-999) | #define MATCH_ACCEPT (-999) |
| 77 | #define MATCH_PRUNE (-998) | #define MATCH_COMMIT (-998) |
| 78 | #define MATCH_SKIP (-997) | #define MATCH_KETRPOS (-997) |
| 79 | #define MATCH_THEN (-996) | #define MATCH_PRUNE (-996) |
| 80 | #define MATCH_SKIP (-995) | |
| 81 | #define MATCH_SKIP_ARG (-994) | |
| 82 | #define MATCH_THEN (-993) | |
| 83 | ||
| 84 | /* This is a convenience macro for code that occurs many times. */ | |
| 85 | ||
| 86 | #define MRRETURN(ra) \ | |
| 87 | { \ | |
| 88 | md->mark = markptr; \ | |
| 89 | RRETURN(ra); \ | |
| 90 | } | |
| 91 | ||
| 92 | /* 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. |
| 93 | 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 135 while (length-- > 0) |
| 135 | * Match a back-reference * | * Match a back-reference * |
| 136 | *************************************************/ | *************************************************/ |
| 137 | ||
| 138 | /* 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 |
| 139 | than the number of characters left in the string, so the match fails. | negative, so the match always fails. However, in JavaScript compatibility mode, |
| 140 | the length passed is zero. Note that in caseless UTF-8 mode, the number of | |
| 141 | subject bytes matched may be different to the number of reference bytes. | |
| 142 | ||
| 143 | Arguments: | Arguments: |
| 144 | offset index into the offset vector | offset index into the offset vector |
| 145 | eptr points into the subject | eptr pointer into the subject |
| 146 | length length to be matched | length length of reference to be matched (number of bytes) |
| 147 | md points to match data block | md points to match data block |
| 148 | ims the ims flags | caseless TRUE if caseless |
| 149 | ||
| 150 | Returns: TRUE if matched | Returns: < 0 if not matched, otherwise the number of subject bytes matched |
| 151 | */ | */ |
| 152 | ||
| 153 | static BOOL | static int |
| 154 | match_ref(int offset, register USPTR eptr, int length, match_data *md, | match_ref(int offset, register USPTR eptr, int length, match_data *md, |
| 155 | unsigned long int ims) | BOOL caseless) |
| 156 | { | { |
| 157 | USPTR p = md->start_subject + md->offset_vector[offset]; | USPTR eptr_start = eptr; |
| 158 | register USPTR p = md->start_subject + md->offset_vector[offset]; | |
| 159 | ||
| 160 | #ifdef PCRE_DEBUG | #ifdef PCRE_DEBUG |
| 161 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| # | Line 154 pchars(p, length, FALSE, md); | Line 170 pchars(p, length, FALSE, md); |
| 170 | printf("\n"); | printf("\n"); |
| 171 | #endif | #endif |
| 172 | ||
| 173 | /* Always fail if not enough characters left */ | /* Always fail if reference not set (and not JavaScript compatible). */ |
| 174 | ||
| 175 | if (length > md->end_subject - eptr) return FALSE; | if (length < 0) return -1; |
| 176 | ||
| 177 | /* 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 |
| 178 | properly if Unicode properties are supported. Otherwise, we can check only | properly if Unicode properties are supported. Otherwise, we can check only |
| 179 | ASCII characters. */ | ASCII characters. */ |
| 180 | ||
| 181 | if ((ims & PCRE_CASELESS) != 0) | if (caseless) |
| 182 | { | { |
| 183 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| 184 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 185 | if (md->utf8) | if (md->utf8) |
| 186 | { | { |
| 187 | USPTR endptr = eptr + length; | /* Match characters up to the end of the reference. NOTE: the number of |
| 188 | while (eptr < endptr) | bytes matched may differ, because there are some characters whose upper and |
| 189 | lower case versions code as different numbers of bytes. For example, U+023A | |
| 190 | (2 bytes in UTF-8) is the upper case version of U+2C65 (3 bytes in UTF-8); | |
| 191 | a sequence of 3 of the former uses 6 bytes, as does a sequence of two of | |
| 192 | the latter. It is important, therefore, to check the length along the | |
| 193 | reference, not along the subject (earlier code did this wrong). */ | |
| 194 | ||
| 195 | USPTR endptr = p + length; | |
| 196 | while (p < endptr) | |
| 197 | { | { |
| 198 | int c, d; | int c, d; |
| 199 | if (eptr >= md->end_subject) return -1; | |
| 200 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 201 | GETCHARINC(d, p); | GETCHARINC(d, p); |
| 202 | if (c != d && c != UCD_OTHERCASE(d)) return FALSE; | if (c != d && c != UCD_OTHERCASE(d)) return -1; |
| 203 | } | } |
| 204 | } | } |
| 205 | else | else |
| # | Line 183 if ((ims & PCRE_CASELESS) != 0) | Line 208 if ((ims & PCRE_CASELESS) != 0) |
| 208 | ||
| 209 | /* 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 |
| 210 | is no UCP support. */ | is no UCP support. */ |
| 211 | { | |
| 212 | while (length-- > 0) | if (eptr + length > md->end_subject) return -1; |
| 213 | { if (md->lcc[*p++] != md->lcc[*eptr++]) return FALSE; } | while (length-- > 0) |
| 214 | { if (md->lcc[*p++] != md->lcc[*eptr++]) return -1; } | |
| 215 | } | |
| 216 | } | } |
| 217 | ||
| 218 | /* 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 |
| 219 | are in UTF-8 mode. */ | are in UTF-8 mode. */ |
| 220 | ||
| 221 | else | else |
| 222 | { while (length-- > 0) if (*p++ != *eptr++) return FALSE; } | { |
| 223 | if (eptr + length > md->end_subject) return -1; | |
| 224 | while (length-- > 0) if (*p++ != *eptr++) return -1; | |
| 225 | } | |
| 226 | ||
| 227 | return TRUE; | return eptr - eptr_start; |
| 228 | } | } |
| 229 | ||
| 230 | ||
| # | Line 245 enum { RM1=1, RM2, RM3, RM4, RM5, RM | Line 275 enum { RM1=1, RM2, RM3, RM4, RM5, RM |
| 275 | RM21, RM22, RM23, RM24, RM25, RM26, RM27, RM28, RM29, RM30, | RM21, RM22, RM23, RM24, RM25, RM26, RM27, RM28, RM29, RM30, |
| 276 | RM31, RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40, | RM31, RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40, |
| 277 | RM41, RM42, RM43, RM44, RM45, RM46, RM47, RM48, RM49, RM50, | RM41, RM42, RM43, RM44, RM45, RM46, RM47, RM48, RM49, RM50, |
| 278 | RM51, RM52, RM53, RM54 }; | RM51, RM52, RM53, RM54, RM55, RM56, RM57, RM58, RM59, RM60, |
| 279 | RM61, RM62, RM63}; | |
| 280 | ||
| 281 | /* 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 |
| 282 | 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 286 actually used in this definition. */ |
| 286 | #define REGISTER register | #define REGISTER register |
| 287 | ||
| 288 | #ifdef PCRE_DEBUG | #ifdef PCRE_DEBUG |
| 289 | #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \ | #define RMATCH(ra,rb,rc,rd,re,rw) \ |
| 290 | { \ | { \ |
| 291 | printf("match() called in line %d\n", __LINE__); \ | printf("match() called in line %d\n", __LINE__); \ |
| 292 | rrc = match(ra,rb,mstart,markptr,rc,rd,re,rf,rg,rdepth+1); \ | rrc = match(ra,rb,mstart,markptr,rc,rd,re,rdepth+1); \ |
| 293 | printf("to line %d\n", __LINE__); \ | printf("to line %d\n", __LINE__); \ |
| 294 | } | } |
| 295 | #define RRETURN(ra) \ | #define RRETURN(ra) \ |
| # | Line 267 actually used in this definition. */ | Line 298 actually used in this definition. */ |
| 298 | return ra; \ | return ra; \ |
| 299 | } | } |
| 300 | #else | #else |
| 301 | #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \ | #define RMATCH(ra,rb,rc,rd,re,rw) \ |
| 302 | rrc = match(ra,rb,mstart,markptr,rc,rd,re,rf,rg,rdepth+1) | rrc = match(ra,rb,mstart,markptr,rc,rd,re,rdepth+1) |
| 303 | #define RRETURN(ra) return ra | #define RRETURN(ra) return ra |
| 304 | #endif | #endif |
| 305 | ||
| # | Line 281 argument of match(), which never changes | Line 312 argument of match(), which never changes |
| 312 | ||
| 313 | #define REGISTER | #define REGISTER |
| 314 | ||
| 315 | #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw)\ | #define RMATCH(ra,rb,rc,rd,re,rw)\ |
| 316 | {\ | {\ |
| 317 | heapframe *newframe = (pcre_stack_malloc)(sizeof(heapframe));\ | heapframe *newframe = (heapframe *)(pcre_stack_malloc)(sizeof(heapframe));\ |
| 318 | if (newframe == NULL) RRETURN(PCRE_ERROR_NOMEMORY);\ | |
| 319 | frame->Xwhere = rw; \ | frame->Xwhere = rw; \ |
| 320 | newframe->Xeptr = ra;\ | newframe->Xeptr = ra;\ |
| 321 | newframe->Xecode = rb;\ | newframe->Xecode = rb;\ |
| 322 | newframe->Xmstart = mstart;\ | newframe->Xmstart = mstart;\ |
| 323 | newframe->Xmarkptr = markptr;\ | newframe->Xmarkptr = markptr;\ |
| 324 | newframe->Xoffset_top = rc;\ | newframe->Xoffset_top = rc;\ |
| 325 | newframe->Xims = re;\ | newframe->Xeptrb = re;\ |
| newframe->Xeptrb = rf;\ | ||
| newframe->Xflags = rg;\ | ||
| 326 | newframe->Xrdepth = frame->Xrdepth + 1;\ | newframe->Xrdepth = frame->Xrdepth + 1;\ |
| 327 | newframe->Xprevframe = frame;\ | newframe->Xprevframe = frame;\ |
| 328 | frame = newframe;\ | frame = newframe;\ |
| # | Line 304 argument of match(), which never changes | Line 334 argument of match(), which never changes |
| 334 | ||
| 335 | #define RRETURN(ra)\ | #define RRETURN(ra)\ |
| 336 | {\ | {\ |
| 337 | heapframe *newframe = frame;\ | heapframe *oldframe = frame;\ |
| 338 | frame = newframe->Xprevframe;\ | frame = oldframe->Xprevframe;\ |
| 339 | (pcre_stack_free)(newframe);\ | (pcre_stack_free)(oldframe);\ |
| 340 | if (frame != NULL)\ | if (frame != NULL)\ |
| 341 | {\ | {\ |
| 342 | rrc = ra;\ | rrc = ra;\ |
| # | Line 328 typedef struct heapframe { | Line 358 typedef struct heapframe { |
| 358 | USPTR Xmstart; | USPTR Xmstart; |
| 359 | USPTR Xmarkptr; | USPTR Xmarkptr; |
| 360 | int Xoffset_top; | int Xoffset_top; |
| long int Xims; | ||
| 361 | eptrblock *Xeptrb; | eptrblock *Xeptrb; |
| int Xflags; | ||
| 362 | unsigned int Xrdepth; | unsigned int Xrdepth; |
| 363 | ||
| 364 | /* Function local variables */ | /* Function local variables */ |
| # | Line 351 typedef struct heapframe { | Line 379 typedef struct heapframe { |
| 379 | BOOL Xcondition; | BOOL Xcondition; |
| 380 | BOOL Xprev_is_word; | BOOL Xprev_is_word; |
| 381 | ||
| unsigned long int Xoriginal_ims; | ||
| 382 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 383 | int Xprop_type; | int Xprop_type; |
| 384 | int Xprop_value; | int Xprop_value; |
| # | Line 410 immediately. The second one is used when | Line 436 immediately. The second one is used when |
| 436 | the subject. */ | the subject. */ |
| 437 | ||
| 438 | #define CHECK_PARTIAL()\ | #define CHECK_PARTIAL()\ |
| 439 | if (md->partial != 0 && eptr >= md->end_subject && eptr > mstart)\ | if (md->partial != 0 && eptr >= md->end_subject && \ |
| 440 | {\ | eptr > md->start_used_ptr) \ |
| 441 | md->hitend = TRUE;\ | { \ |
| 442 | if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);\ | md->hitend = TRUE; \ |
| 443 | if (md->partial > 1) MRRETURN(PCRE_ERROR_PARTIAL); \ | |
| 444 | } | } |
| 445 | ||
| 446 | #define SCHECK_PARTIAL()\ | #define SCHECK_PARTIAL()\ |
| 447 | if (md->partial != 0 && eptr > mstart)\ | if (md->partial != 0 && eptr > md->start_used_ptr) \ |
| 448 | {\ | { \ |
| 449 | md->hitend = TRUE;\ | md->hitend = TRUE; \ |
| 450 | if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);\ | if (md->partial > 1) MRRETURN(PCRE_ERROR_PARTIAL); \ |
| 451 | } | } |
| 452 | ||
| 453 | ||
| # | Line 437 Arguments: | Line 464 Arguments: |
| 464 | markptr pointer to the most recent MARK name, or NULL | markptr pointer to the most recent MARK name, or NULL |
| 465 | offset_top current top pointer | offset_top current top pointer |
| 466 | md pointer to "static" info for the match | md pointer to "static" info for the match |
| ims current /i, /m, and /s options | ||
| 467 | eptrb pointer to chain of blocks containing eptr at start of | eptrb pointer to chain of blocks containing eptr at start of |
| 468 | brackets - for testing for empty matches | brackets - for testing for empty matches |
| flags can contain | ||
| match_condassert - this is an assertion condition | ||
| match_cbegroup - this is the start of an unlimited repeat | ||
| group that can match an empty string | ||
| 469 | rdepth the recursion depth | rdepth the recursion depth |
| 470 | ||
| 471 | Returns: MATCH_MATCH if matched ) these values are >= 0 | Returns: MATCH_MATCH if matched ) these values are >= 0 |
| 472 | MATCH_NOMATCH if failed to match ) | MATCH_NOMATCH if failed to match ) |
| 473 | a negative MATCH_xxx value for PRUNE, SKIP, etc | |
| 474 | a negative PCRE_ERROR_xxx value if aborted by an error condition | a negative PCRE_ERROR_xxx value if aborted by an error condition |
| 475 | (e.g. stopped by repeated call or recursion limit) | (e.g. stopped by repeated call or recursion limit) |
| 476 | */ | */ |
| 477 | ||
| 478 | static int | static int |
| 479 | match(REGISTER USPTR eptr, REGISTER const uschar *ecode, USPTR mstart, USPTR | match(REGISTER USPTR eptr, REGISTER const uschar *ecode, USPTR mstart, |
| 480 | markptr, int offset_top, match_data *md, unsigned long int ims, | const uschar *markptr, int offset_top, match_data *md, eptrblock *eptrb, |
| 481 | eptrblock *eptrb, int flags, unsigned int rdepth) | unsigned int rdepth) |
| 482 | { | { |
| 483 | /* 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, |
| 484 | 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 490 register unsigned int c; /* Character |
| 490 | register BOOL utf8; /* Local copy of UTF-8 flag for speed */ | register BOOL utf8; /* Local copy of UTF-8 flag for speed */ |
| 491 | ||
| 492 | BOOL minimize, possessive; /* Quantifier options */ | BOOL minimize, possessive; /* Quantifier options */ |
| 493 | BOOL caseless; | |
| 494 | int condcode; | int condcode; |
| 495 | ||
| 496 | /* 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 499 heap storage. Set up the top-level frame |
| 499 | heap whenever RMATCH() does a "recursion". See the macro definitions above. */ | heap whenever RMATCH() does a "recursion". See the macro definitions above. */ |
| 500 | ||
| 501 | #ifdef NO_RECURSE | #ifdef NO_RECURSE |
| 502 | heapframe *frame = (pcre_stack_malloc)(sizeof(heapframe)); | heapframe *frame = (heapframe *)(pcre_stack_malloc)(sizeof(heapframe)); |
| 503 | if (frame == NULL) RRETURN(PCRE_ERROR_NOMEMORY); | |
| 504 | frame->Xprevframe = NULL; /* Marks the top level */ | frame->Xprevframe = NULL; /* Marks the top level */ |
| 505 | ||
| 506 | /* Copy in the original argument variables */ | /* Copy in the original argument variables */ |
| # | Line 485 frame->Xecode = ecode; | Line 510 frame->Xecode = ecode; |
| 510 | frame->Xmstart = mstart; | frame->Xmstart = mstart; |
| 511 | frame->Xmarkptr = markptr; | frame->Xmarkptr = markptr; |
| 512 | frame->Xoffset_top = offset_top; | frame->Xoffset_top = offset_top; |
| frame->Xims = ims; | ||
| 513 | frame->Xeptrb = eptrb; | frame->Xeptrb = eptrb; |
| frame->Xflags = flags; | ||
| 514 | frame->Xrdepth = rdepth; | frame->Xrdepth = rdepth; |
| 515 | ||
| 516 | /* This is where control jumps back to to effect "recursion" */ | /* This is where control jumps back to to effect "recursion" */ |
| # | Line 501 HEAP_RECURSE: | Line 524 HEAP_RECURSE: |
| 524 | #define mstart frame->Xmstart | #define mstart frame->Xmstart |
| 525 | #define markptr frame->Xmarkptr | #define markptr frame->Xmarkptr |
| 526 | #define offset_top frame->Xoffset_top | #define offset_top frame->Xoffset_top |
| #define ims frame->Xims | ||
| 527 | #define eptrb frame->Xeptrb | #define eptrb frame->Xeptrb |
| #define flags frame->Xflags | ||
| 528 | #define rdepth frame->Xrdepth | #define rdepth frame->Xrdepth |
| 529 | ||
| 530 | /* Ditto for the local variables */ | /* Ditto for the local variables */ |
| # | Line 525 HEAP_RECURSE: | Line 546 HEAP_RECURSE: |
| 546 | #define condition frame->Xcondition | #define condition frame->Xcondition |
| 547 | #define prev_is_word frame->Xprev_is_word | #define prev_is_word frame->Xprev_is_word |
| 548 | ||
| #define original_ims frame->Xoriginal_ims | ||
| 549 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 550 | #define prop_type frame->Xprop_type | #define prop_type frame->Xprop_type |
| 551 | #define prop_value frame->Xprop_value | #define prop_value frame->Xprop_value |
| # | Line 563 i, and fc and c, can be the same variabl | Line 582 i, and fc and c, can be the same variabl |
| 582 | #define fi i | #define fi i |
| 583 | #define fc c | #define fc c |
| 584 | ||
| 585 | /* Many of the following variables are used only in small blocks of the code. | |
| 586 | #ifdef SUPPORT_UTF8 /* Many of these variables are used only */ | My normal style of coding would have declared them within each of those blocks. |
| 587 | const uschar *charptr; /* in small blocks of the code. My normal */ | However, in order to accommodate the version of this code that uses an external |
| 588 | #endif /* style of coding would have declared */ | "stack" implemented on the heap, it is easier to declare them all here, so the |
| 589 | const uschar *callpat; /* them within each of those blocks. */ | declarations can be cut out in a block. The only declarations within blocks |
| 590 | const uschar *data; /* However, in order to accommodate the */ | below are for variables that do not have to be preserved over a recursive call |
| 591 | const uschar *next; /* version of this code that uses an */ | to RMATCH(). */ |
| 592 | USPTR pp; /* external "stack" implemented on the */ | |
| 593 | const uschar *prev; /* heap, it is easier to declare them all */ | #ifdef SUPPORT_UTF8 |
| 594 | USPTR saved_eptr; /* here, so the declarations can be cut */ | const uschar *charptr; |
| 595 | /* out in a block. The only declarations */ | #endif |
| 596 | recursion_info new_recursive; /* within blocks below are for variables */ | const uschar *callpat; |
| 597 | /* that do not have to be preserved over */ | const uschar *data; |
| 598 | BOOL cur_is_word; /* a recursive call to RMATCH(). */ | const uschar *next; |
| 599 | USPTR pp; | |
| 600 | const uschar *prev; | |
| 601 | USPTR saved_eptr; | |
| 602 | ||
| 603 | recursion_info new_recursive; | |
| 604 | ||
| 605 | BOOL cur_is_word; | |
| 606 | BOOL condition; | BOOL condition; |
| 607 | BOOL prev_is_word; | BOOL prev_is_word; |
| 608 | ||
| unsigned long int original_ims; | ||
| 609 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 610 | int prop_type; | int prop_type; |
| 611 | int prop_value; | int prop_value; |
| # | Line 608 int stacksave[REC_STACK_SAVE_MAX]; | Line 632 int stacksave[REC_STACK_SAVE_MAX]; |
| 632 | eptrblock newptrb; | eptrblock newptrb; |
| 633 | #endif /* NO_RECURSE */ | #endif /* NO_RECURSE */ |
| 634 | ||
| 635 | /* To save space on the stack and in the heap frame, I have doubled up on some | |
| 636 | of the local variables that are used only in localised parts of the code, but | |
| 637 | still need to be preserved over recursive calls of match(). These macros define | |
| 638 | the alternative names that are used. */ | |
| 639 | ||
| 640 | #define allow_zero cur_is_word | |
| 641 | #define cbegroup condition | |
| 642 | #define code_offset codelink | |
| 643 | #define condassert condition | |
| 644 | #define matched_once prev_is_word | |
| 645 | ||
| 646 | /* These statements are here to stop the compiler complaining about unitialized | /* These statements are here to stop the compiler complaining about unitialized |
| 647 | variables. */ | variables. */ |
| 648 | ||
| # | Line 644 haven't exceeded the recursive call limi | Line 679 haven't exceeded the recursive call limi |
| 679 | if (md->match_call_count++ >= md->match_limit) RRETURN(PCRE_ERROR_MATCHLIMIT); | if (md->match_call_count++ >= md->match_limit) RRETURN(PCRE_ERROR_MATCHLIMIT); |
| 680 | if (rdepth >= md->match_limit_recursion) RRETURN(PCRE_ERROR_RECURSIONLIMIT); | if (rdepth >= md->match_limit_recursion) RRETURN(PCRE_ERROR_RECURSIONLIMIT); |
| 681 | ||
| original_ims = ims; /* Save for resetting on ')' */ | ||
| 682 | /* 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 |
| 683 | string, the match_cbegroup flag is set. When this is the case, add the current | string, the variable md->match_function_type is set to MATCH_CBEGROUP. It is |
| 684 | subject pointer to the chain of such remembered pointers, to be checked when we | done this way to save having to use another function argument, which would take |
| 685 | hit the closing ket, in order to break infinite loops that match no characters. | up space on the stack. See also MATCH_CONDASSERT below. |
| 686 | When match() is called in other circumstances, don't add to the chain. The | |
| 687 | match_cbegroup flag must NOT be used with tail recursion, because the memory | When MATCH_CBEGROUP is set, add the current subject pointer to the chain of |
| 688 | block that is used is on the stack, so a new one may be required for each | such remembered pointers, to be checked when we hit the closing ket, in order |
| 689 | match(). */ | to break infinite loops that match no characters. When match() is called in |
| 690 | other circumstances, don't add to the chain. The MATCH_CBEGROUP feature must | |
| 691 | NOT be used with tail recursion, because the memory block that is used is on | |
| 692 | the stack, so a new one may be required for each match(). */ | |
| 693 | ||
| 694 | if ((flags & match_cbegroup) != 0) | if (md->match_function_type == MATCH_CBEGROUP) |
| 695 | { | { |
| 696 | newptrb.epb_saved_eptr = eptr; | newptrb.epb_saved_eptr = eptr; |
| 697 | newptrb.epb_prev = eptrb; | newptrb.epb_prev = eptrb; |
| 698 | eptrb = &newptrb; | eptrb = &newptrb; |
| 699 | md->match_function_type = 0; | |
| 700 | } | } |
| 701 | ||
| 702 | /* Now start processing the opcodes. */ | /* Now start processing the opcodes. */ |
| # | Line 668 for (;;) | Line 705 for (;;) |
| 705 | { | { |
| 706 | minimize = possessive = FALSE; | minimize = possessive = FALSE; |
| 707 | op = *ecode; | op = *ecode; |
| 708 | ||
| 709 | switch(op) | switch(op) |
| 710 | { | { |
| 711 | case OP_MARK: | |
| 712 | markptr = ecode + 2; | |
| 713 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md, | |
| 714 | eptrb, RM55); | |
| 715 | ||
| 716 | /* A return of MATCH_SKIP_ARG means that matching failed at SKIP with an | |
| 717 | argument, and we must check whether that argument matches this MARK's | |
| 718 | argument. It is passed back in md->start_match_ptr (an overloading of that | |
| 719 | variable). If it does match, we reset that variable to the current subject | |
| 720 | position and return MATCH_SKIP. Otherwise, pass back the return code | |
| 721 | unaltered. */ | |
| 722 | ||
| 723 | if (rrc == MATCH_SKIP_ARG && | |
| 724 | strcmp((char *)markptr, (char *)(md->start_match_ptr)) == 0) | |
| 725 | { | |
| 726 | md->start_match_ptr = eptr; | |
| 727 | RRETURN(MATCH_SKIP); | |
| 728 | } | |
| 729 | ||
| 730 | if (md->mark == NULL) md->mark = markptr; | |
| 731 | RRETURN(rrc); | |
| 732 | ||
| 733 | case OP_FAIL: | case OP_FAIL: |
| 734 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 735 | ||
| 736 | /* COMMIT overrides PRUNE, SKIP, and THEN */ | |
| 737 | ||
| 738 | case OP_COMMIT: | |
| 739 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | |
| 740 | eptrb, RM52); | |
| 741 | if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && | |
| 742 | rrc != MATCH_SKIP && rrc != MATCH_SKIP_ARG && | |
| 743 | rrc != MATCH_THEN) | |
| 744 | RRETURN(rrc); | |
| 745 | MRRETURN(MATCH_COMMIT); | |
| 746 | ||
| 747 | /* PRUNE overrides THEN */ | |
| 748 | ||
| 749 | case OP_PRUNE: | case OP_PRUNE: |
| 750 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
| 751 | ims, eptrb, flags, RM51); | eptrb, RM51); |
| 752 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); |
| 753 | MRRETURN(MATCH_PRUNE); | |
| 754 | ||
| 755 | case OP_PRUNE_ARG: | |
| 756 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md, | |
| 757 | eptrb, RM56); | |
| 758 | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); | |
| 759 | md->mark = ecode + 2; | |
| 760 | RRETURN(MATCH_PRUNE); | RRETURN(MATCH_PRUNE); |
| 761 | ||
| 762 | 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); | ||
| 763 | ||
| 764 | case OP_SKIP: | case OP_SKIP: |
| 765 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
| 766 | ims, eptrb, flags, RM53); | eptrb, RM53); |
| 767 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN) |
| 768 | RRETURN(rrc); | |
| 769 | md->start_match_ptr = eptr; /* Pass back current position */ | md->start_match_ptr = eptr; /* Pass back current position */ |
| 770 | RRETURN(MATCH_SKIP); | MRRETURN(MATCH_SKIP); |
| 771 | ||
| 772 | case OP_SKIP_ARG: | |
| 773 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md, | |
| 774 | eptrb, RM57); | |
| 775 | if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN) | |
| 776 | RRETURN(rrc); | |
| 777 | ||
| 778 | /* Pass back the current skip name by overloading md->start_match_ptr and | |
| 779 | returning the special MATCH_SKIP_ARG return code. This will either be | |
| 780 | caught by a matching MARK, or get to the top, where it is treated the same | |
| 781 | as PRUNE. */ | |
| 782 | ||
| 783 | md->start_match_ptr = ecode + 2; | |
| 784 | RRETURN(MATCH_SKIP_ARG); | |
| 785 | ||
| 786 | /* For THEN (and THEN_ARG) we pass back the address of the bracket or | |
| 787 | the alt that is at the start of the current branch. This makes it possible | |
| 788 | to skip back past alternatives that precede the THEN within the current | |
| 789 | branch. */ | |
| 790 | ||
| 791 | case OP_THEN: | case OP_THEN: |
| 792 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
| 793 | ims, eptrb, flags, RM54); | eptrb, RM54); |
| 794 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 795 | RRETURN(MATCH_THEN); | md->start_match_ptr = ecode - GET(ecode, 1); |
| 796 | MRRETURN(MATCH_THEN); | |
| 797 | ||
| 798 | /* Handle a capturing bracket. If there is space in the offset vector, save | case OP_THEN_ARG: |
| 799 | the current subject position in the working slot at the top of the vector. | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1+LINK_SIZE], |
| 800 | We mustn't change the current values of the data slot, because they may be | offset_top, md, eptrb, RM58); |
| 801 | set from a previous iteration of this group, and be referred to by a | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 802 | reference inside the group. | md->start_match_ptr = ecode - GET(ecode, 1); |
| 803 | md->mark = ecode + LINK_SIZE + 2; | |
| 804 | RRETURN(MATCH_THEN); | |
| 805 | ||
| 806 | If the bracket fails to match, we need to restore this value and also the | /* Handle a capturing bracket, other than those that are possessive with an |
| 807 | unlimited repeat. If there is space in the offset vector, save the current | |
| 808 | subject position in the working slot at the top of the vector. We mustn't | |
| 809 | change the current values of the data slot, because they may be set from a | |
| 810 | previous iteration of this group, and be referred to by a reference inside | |
| 811 | the group. If we fail to match, we need to restore this value and also the | |
| 812 | values of the final offsets, in case they were set by a previous iteration | values of the final offsets, in case they were set by a previous iteration |
| 813 | of the same bracket. | of the same bracket. |
| 814 | ||
| # | Line 717 for (;;) | Line 820 for (;;) |
| 820 | case OP_SCBRA: | case OP_SCBRA: |
| 821 | number = GET2(ecode, 1+LINK_SIZE); | number = GET2(ecode, 1+LINK_SIZE); |
| 822 | offset = number << 1; | offset = number << 1; |
| 823 | ||
| 824 | #ifdef PCRE_DEBUG | #ifdef PCRE_DEBUG |
| 825 | printf("start bracket %d\n", number); | printf("start bracket %d\n", number); |
| 826 | printf("subject="); | printf("subject="); |
| # | Line 733 for (;;) | Line 836 for (;;) |
| 836 | save_capture_last = md->capture_last; | save_capture_last = md->capture_last; |
| 837 | ||
| 838 | DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3)); | DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3)); |
| 839 | md->offset_vector[md->offset_end - number] = eptr - md->start_subject; | md->offset_vector[md->offset_end - number] = |
| 840 | (int)(eptr - md->start_subject); | |
| 841 | ||
| 842 | flags = (op == OP_SCBRA)? match_cbegroup : 0; | for (;;) |
| do | ||
| 843 | { | { |
| 844 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP; |
| 845 | ims, eptrb, flags, RM1); | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, |
| 846 | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); | eptrb, RM1); |
| 847 | if (rrc != MATCH_NOMATCH && | |
| 848 | (rrc != MATCH_THEN || md->start_match_ptr != ecode)) | |
| 849 | RRETURN(rrc); | |
| 850 | md->capture_last = save_capture_last; | md->capture_last = save_capture_last; |
| 851 | ecode += GET(ecode, 1); | ecode += GET(ecode, 1); |
| 852 | if (*ecode != OP_ALT) break; | |
| 853 | } | } |
| while (*ecode == OP_ALT); | ||
| 854 | ||
| 855 | DPRINTF(("bracket %d failed\n", number)); | DPRINTF(("bracket %d failed\n", number)); |
| 856 | ||
| # | Line 752 for (;;) | Line 858 for (;;) |
| 858 | md->offset_vector[offset+1] = save_offset2; | md->offset_vector[offset+1] = save_offset2; |
| 859 | md->offset_vector[md->offset_end - number] = save_offset3; | md->offset_vector[md->offset_end - number] = save_offset3; |
| 860 | ||
| 861 | if (rrc != MATCH_THEN && md->mark == NULL) md->mark = markptr; | |
| 862 | RRETURN(MATCH_NOMATCH); | RRETURN(MATCH_NOMATCH); |
| 863 | } | } |
| 864 | ||
| # | Line 766 for (;;) | Line 873 for (;;) |
| 873 | /* VVVVVVVVVVVVVVVVVVVVVVVVV */ | /* VVVVVVVVVVVVVVVVVVVVVVVVV */ |
| 874 | /* VVVVVVVVVVVVVVVVVVVVVVVVV */ | /* VVVVVVVVVVVVVVVVVVVVVVVVV */ |
| 875 | ||
| 876 | /* Non-capturing bracket. Loop for all the alternatives. When we get to the | /* Non-capturing bracket, except for possessive with unlimited repeat. Loop |
| 877 | final alternative within the brackets, we would return the result of a | for all the alternatives. When we get to the final alternative within the |
| 878 | recursive call to match() whatever happened. We can reduce stack usage by | brackets, we used to return the result of a recursive call to match() |
| 879 | turning this into a tail recursion, except in the case when match_cbegroup | whatever happened so it was possible to reduce stack usage by turning this |
| 880 | is set.*/ | into a tail recursion, except in the case of a possibly empty group. |
| 881 | However, now that there is the possiblity of (*THEN) occurring in the final | |
| 882 | alternative, this optimization is no longer possible. */ | |
| 883 | ||
| 884 | case OP_BRA: | case OP_BRA: |
| 885 | case OP_SBRA: | case OP_SBRA: |
| 886 | DPRINTF(("start non-capturing bracket\n")); | DPRINTF(("start non-capturing bracket\n")); |
| flags = (op >= OP_SBRA)? match_cbegroup : 0; | ||
| 887 | for (;;) | for (;;) |
| 888 | { | { |
| 889 | if (ecode[GET(ecode, 1)] != OP_ALT) /* Final alternative */ | if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP; |
| 890 | { | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, eptrb, |
| 891 | if (flags == 0) /* Not a possibly empty group */ | RM2); |
| 892 | { | if (rrc != MATCH_NOMATCH && |
| 893 | ecode += _pcre_OP_lengths[*ecode]; | (rrc != MATCH_THEN || md->start_match_ptr != ecode)) |
| 894 | DPRINTF(("bracket 0 tail recursion\n")); | RRETURN(rrc); |
| 895 | goto TAIL_RECURSE; | ecode += GET(ecode, 1); |
| 896 | } | if (*ecode != OP_ALT) break; |
| 897 | } | |
| 898 | ||
| 899 | /* Possibly empty group; can't use tail recursion. */ | if (rrc != MATCH_THEN && md->mark == NULL) md->mark = markptr; |
| 900 | RRETURN(MATCH_NOMATCH); | |
| 901 | ||
| 902 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims, | /* Handle possessive capturing brackets with an unlimited repeat. We come |
| 903 | eptrb, flags, RM48); | here from BRAZERO with allow_zero set TRUE. The offset_vector values are |
| 904 | RRETURN(rrc); | handled similarly to the normal case above. However, the matching is |
| 905 | different. The end of these brackets will always be OP_KETRPOS, which | |
| 906 | returns MATCH_KETRPOS without going further in the pattern. By this means | |
| 907 | we can handle the group by iteration rather than recursion, thereby | |
| 908 | reducing the amount of stack needed. */ | |
| 909 | ||
| 910 | case OP_CBRAPOS: | |
| 911 | case OP_SCBRAPOS: | |
| 912 | allow_zero = FALSE; | |
| 913 | ||
| 914 | POSSESSIVE_CAPTURE: | |
| 915 | number = GET2(ecode, 1+LINK_SIZE); | |
| 916 | offset = number << 1; | |
| 917 | ||
| 918 | #ifdef PCRE_DEBUG | |
| 919 | printf("start possessive bracket %d\n", number); | |
| 920 | printf("subject="); | |
| 921 | pchars(eptr, 16, TRUE, md); | |
| 922 | printf("\n"); | |
| 923 | #endif | |
| 924 | ||
| 925 | if (offset < md->offset_max) | |
| 926 | { | |
| 927 | matched_once = FALSE; | |
| 928 | code_offset = ecode - md->start_code; | |
| 929 | ||
| 930 | save_offset1 = md->offset_vector[offset]; | |
| 931 | save_offset2 = md->offset_vector[offset+1]; | |
| 932 | save_offset3 = md->offset_vector[md->offset_end - number]; | |
| 933 | save_capture_last = md->capture_last; | |
| 934 | ||
| 935 | DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3)); | |
| 936 | ||
| 937 | /* Each time round the loop, save the current subject position for use | |
| 938 | when the group matches. For MATCH_MATCH, the group has matched, so we | |
| 939 | restart it with a new subject starting position, remembering that we had | |
| 940 | at least one match. For MATCH_NOMATCH, carry on with the alternatives, as | |
| 941 | usual. If we haven't matched any alternatives in any iteration, check to | |
| 942 | see if a previous iteration matched. If so, the group has matched; | |
| 943 | continue from afterwards. Otherwise it has failed; restore the previous | |
| 944 | capture values before returning NOMATCH. */ | |
| 945 | ||
| 946 | for (;;) | |
| 947 | { | |
| 948 | md->offset_vector[md->offset_end - number] = | |
| 949 | (int)(eptr - md->start_subject); | |
| 950 | if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP; | |
| 951 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | |
| 952 | eptrb, RM63); | |
| 953 | if (rrc == MATCH_KETRPOS) | |
| 954 | { | |
| 955 | offset_top = md->end_offset_top; | |
| 956 | eptr = md->end_match_ptr; | |
| 957 | ecode = md->start_code + code_offset; | |
| 958 | save_capture_last = md->capture_last; | |
| 959 | matched_once = TRUE; | |
| 960 | continue; | |
| 961 | } | |
| 962 | if (rrc != MATCH_NOMATCH && | |
| 963 | (rrc != MATCH_THEN || md->start_match_ptr != ecode)) | |
| 964 | RRETURN(rrc); | |
| 965 | md->capture_last = save_capture_last; | |
| 966 | ecode += GET(ecode, 1); | |
| 967 | if (*ecode != OP_ALT) break; | |
| 968 | } | } |
| 969 | ||
| 970 | /* For non-final alternatives, continue the loop for a NOMATCH result; | if (!matched_once) |
| 971 | otherwise return. */ | { |
| 972 | md->offset_vector[offset] = save_offset1; | |
| 973 | md->offset_vector[offset+1] = save_offset2; | |
| 974 | md->offset_vector[md->offset_end - number] = save_offset3; | |
| 975 | } | |
| 976 | ||
| 977 | if (rrc != MATCH_THEN && md->mark == NULL) md->mark = markptr; | |
| 978 | if (allow_zero || matched_once) | |
| 979 | { | |
| 980 | ecode += 1 + LINK_SIZE; | |
| 981 | break; | |
| 982 | } | |
| 983 | ||
| 984 | RRETURN(MATCH_NOMATCH); | |
| 985 | } | |
| 986 | ||
| 987 | /* FALL THROUGH ... Insufficient room for saving captured contents. Treat | |
| 988 | as a non-capturing bracket. */ | |
| 989 | ||
| 990 | /* VVVVVVVVVVVVVVVVVVVVVVVVV */ | |
| 991 | /* VVVVVVVVVVVVVVVVVVVVVVVVV */ | |
| 992 | ||
| 993 | DPRINTF(("insufficient capture room: treat as non-capturing\n")); | |
| 994 | ||
| 995 | /* VVVVVVVVVVVVVVVVVVVVVVVVV */ | |
| 996 | /* VVVVVVVVVVVVVVVVVVVVVVVVV */ | |
| 997 | ||
| 998 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims, | /* Non-capturing possessive bracket with unlimited repeat. We come here |
| 999 | eptrb, flags, RM2); | from BRAZERO with allow_zero = TRUE. The code is similar to the above, |
| 1000 | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); | without the capturing complication. It is written out separately for speed |
| 1001 | and cleanliness. */ | |
| 1002 | ||
| 1003 | case OP_BRAPOS: | |
| 1004 | case OP_SBRAPOS: | |
| 1005 | allow_zero = FALSE; | |
| 1006 | ||
| 1007 | POSSESSIVE_NON_CAPTURE: | |
| 1008 | matched_once = FALSE; | |
| 1009 | code_offset = ecode - md->start_code; | |
| 1010 | ||
| 1011 | for (;;) | |
| 1012 | { | |
| 1013 | if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP; | |
| 1014 | RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, | |
| 1015 | eptrb, RM48); | |
| 1016 | if (rrc == MATCH_KETRPOS) | |
| 1017 | { | |
| 1018 | offset_top = md->end_offset_top; | |
| 1019 | eptr = md->end_match_ptr; | |
| 1020 | ecode = md->start_code + code_offset; | |
| 1021 | matched_once = TRUE; | |
| 1022 | continue; | |
| 1023 | } | |
| 1024 | if (rrc != MATCH_NOMATCH && | |
| 1025 | (rrc != MATCH_THEN || md->start_match_ptr != ecode)) | |
| 1026 | RRETURN(rrc); | |
| 1027 | ecode += GET(ecode, 1); | ecode += GET(ecode, 1); |
| 1028 | if (*ecode != OP_ALT) break; | |
| 1029 | } | } |
| 1030 | ||
| 1031 | if (matched_once || allow_zero) | |
| 1032 | { | |
| 1033 | ecode += 1 + LINK_SIZE; | |
| 1034 | break; | |
| 1035 | } | |
| 1036 | RRETURN(MATCH_NOMATCH); | |
| 1037 | ||
| 1038 | /* Control never reaches here. */ | /* Control never reaches here. */ |
| 1039 | ||
| 1040 | /* Conditional group: compilation checked that there are no more than | /* Conditional group: compilation checked that there are no more than |
| 1041 | two branches. If the condition is false, skipping the first branch takes us | two branches. If the condition is false, skipping the first branch takes us |
| 1042 | past the end if there is only one branch, but that's OK because that is | past the end if there is only one branch, but that's OK because that is |
| 1043 | exactly what going to the ket would do. As there is only one branch to be | exactly what going to the ket would do. */ |
| obeyed, we can use tail recursion to avoid using another stack frame. */ | ||
| 1044 | ||
| 1045 | case OP_COND: | case OP_COND: |
| 1046 | case OP_SCOND: | case OP_SCOND: |
| 1047 | codelink= GET(ecode, 1); | codelink = GET(ecode, 1); |
| 1048 | ||
| 1049 | /* Because of the way auto-callout works during compile, a callout item is | /* Because of the way auto-callout works during compile, a callout item is |
| 1050 | inserted between OP_COND and an assertion condition. */ | inserted between OP_COND and an assertion condition. */ |
| # | Line 826 for (;;) | Line 1058 for (;;) |
| 1058 | cb.callout_number = ecode[LINK_SIZE+2]; | cb.callout_number = ecode[LINK_SIZE+2]; |
| 1059 | cb.offset_vector = md->offset_vector; | cb.offset_vector = md->offset_vector; |
| 1060 | cb.subject = (PCRE_SPTR)md->start_subject; | cb.subject = (PCRE_SPTR)md->start_subject; |
| 1061 | cb.subject_length = md->end_subject - md->start_subject; | cb.subject_length = (int)(md->end_subject - md->start_subject); |
| 1062 | cb.start_match = mstart - md->start_subject; | cb.start_match = (int)(mstart - md->start_subject); |
| 1063 | cb.current_position = eptr - md->start_subject; | cb.current_position = (int)(eptr - md->start_subject); |
| 1064 | cb.pattern_position = GET(ecode, LINK_SIZE + 3); | cb.pattern_position = GET(ecode, LINK_SIZE + 3); |
| 1065 | cb.next_item_length = GET(ecode, 3 + 2*LINK_SIZE); | cb.next_item_length = GET(ecode, 3 + 2*LINK_SIZE); |
| 1066 | cb.capture_top = offset_top/2; | cb.capture_top = offset_top/2; |
| 1067 | cb.capture_last = md->capture_last; | cb.capture_last = md->capture_last; |
| 1068 | cb.callout_data = md->callout_data; | cb.callout_data = md->callout_data; |
| 1069 | if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH); | if ((rrc = (*pcre_callout)(&cb)) > 0) MRRETURN(MATCH_NOMATCH); |
| 1070 | if (rrc < 0) RRETURN(rrc); | if (rrc < 0) RRETURN(rrc); |
| 1071 | } | } |
| 1072 | ecode += _pcre_OP_lengths[OP_CALLOUT]; | ecode += _pcre_OP_lengths[OP_CALLOUT]; |
| # | Line 987 for (;;) | Line 1219 for (;;) |
| 1219 | } | } |
| 1220 | ||
| 1221 | /* The condition is an assertion. Call match() to evaluate it - setting | /* The condition is an assertion. Call match() to evaluate it - setting |
| 1222 | the final argument match_condassert causes it to stop at the end of an | md->match_function_type to MATCH_CONDASSERT causes it to stop at the end of |
| 1223 | assertion. */ | an assertion. */ |
| 1224 | ||
| 1225 | else | else |
| 1226 | { | { |
| 1227 | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, | md->match_function_type = MATCH_CONDASSERT; |
| 1228 | match_condassert, RM3); | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM3); |
| 1229 | if (rrc == MATCH_MATCH) | if (rrc == MATCH_MATCH) |
| 1230 | { | { |
| 1231 | condition = TRUE; | condition = TRUE; |
| 1232 | ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2); | ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2); |
| 1233 | while (*ecode == OP_ALT) ecode += GET(ecode, 1); | while (*ecode == OP_ALT) ecode += GET(ecode, 1); |
| 1234 | } | } |
| 1235 | else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) | else if (rrc != MATCH_NOMATCH && |
| 1236 | (rrc != MATCH_THEN || md->start_match_ptr != ecode)) | |
| 1237 | { | { |
| 1238 | RRETURN(rrc); /* Need braces because of following else */ | RRETURN(rrc); /* Need braces because of following else */ |
| 1239 | } | } |
| # | Line 1012 for (;;) | Line 1245 for (;;) |
| 1245 | } | } |
| 1246 | ||
| 1247 | /* We are now at the branch that is to be obeyed. As there is only one, | /* We are now at the branch that is to be obeyed. As there is only one, |
| 1248 | we can use tail recursion to avoid using another stack frame, except when | we used to use tail recursion to avoid using another stack frame, except |
| 1249 | match_cbegroup is required for an unlimited repeat of a possibly empty | when there was unlimited repeat of a possibly empty group. However, that |
| 1250 | group. If the second alternative doesn't exist, we can just plough on. */ | strategy no longer works because of the possibilty of (*THEN) being |
| 1251 | encountered in the branch. A recursive call to match() is always required, | |
| 1252 | unless the second alternative doesn't exist, in which case we can just | |
| 1253 | plough on. */ | |
| 1254 | ||
| 1255 | if (condition || *ecode == OP_ALT) | if (condition || *ecode == OP_ALT) |
| 1256 | { | { |
| 1257 | ecode += 1 + LINK_SIZE; | if (op == OP_SCOND) md->match_function_type = MATCH_CBEGROUP; |
| 1258 | if (op == OP_SCOND) /* Possibly empty group */ | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM49); |
| 1259 | { | if (rrc == MATCH_THEN && md->start_match_ptr == ecode) |
| 1260 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, match_cbegroup, RM49); | rrc = MATCH_NOMATCH; |
| 1261 | RRETURN(rrc); | RRETURN(rrc); |
| } | ||
| else /* Group must match something */ | ||
| { | ||
| flags = 0; | ||
| goto TAIL_RECURSE; | ||
| } | ||
| 1262 | } | } |
| 1263 | else /* Condition false & no alternative */ | else /* Condition false & no alternative */ |
| 1264 | { | { |
| # | Line 1054 for (;;) | Line 1284 for (;;) |
| 1284 | { | { |
| 1285 | md->offset_vector[offset] = | md->offset_vector[offset] = |
| 1286 | md->offset_vector[md->offset_end - number]; | md->offset_vector[md->offset_end - number]; |
| 1287 | md->offset_vector[offset+1] = eptr - md->start_subject; | md->offset_vector[offset+1] = (int)(eptr - md->start_subject); |
| 1288 | if (offset_top <= offset) offset_top = offset + 2; | if (offset_top <= offset) offset_top = offset + 2; |
| 1289 | } | } |
| 1290 | ecode += 3; | ecode += 3; |
| 1291 | break; | break; |
| 1292 | ||
| 1293 | ||
| 1294 | /* End of the pattern, either real or forced. If we are in a top-level | /* End of the pattern, either real or forced. If we are in a recursion, we |
| 1295 | recursion, we should restore the offsets appropriately and continue from | should restore the offsets appropriately, and if it's a top-level |
| 1296 | after the call. */ | recursion, continue from after the call. */ |
| 1297 | ||
| 1298 | case OP_ACCEPT: | case OP_ACCEPT: |
| 1299 | case OP_ASSERT_ACCEPT: | |
| 1300 | case OP_END: | case OP_END: |
| 1301 | if (md->recursive != NULL && md->recursive->group_num == 0) | if (md->recursive != NULL) |
| 1302 | { | { |
| 1303 | recursion_info *rec = md->recursive; | recursion_info *rec = md->recursive; |
| DPRINTF(("End of pattern in a (?0) recursion\n")); | ||
| 1304 | md->recursive = rec->prevrec; | md->recursive = rec->prevrec; |
| 1305 | memmove(md->offset_vector, rec->offset_save, | memmove(md->offset_vector, rec->offset_save, |
| 1306 | rec->saved_max * sizeof(int)); | rec->saved_max * sizeof(int)); |
| 1307 | offset_top = rec->save_offset_top; | offset_top = rec->save_offset_top; |
| 1308 | ims = original_ims; | if (rec->group_num == 0) |
| 1309 | ecode = rec->after_call; | { |
| 1310 | break; | ecode = rec->after_call; |
| 1311 | break; | |
| 1312 | } | |
| 1313 | } | } |
| 1314 | ||
| 1315 | /* Otherwise, if we have matched an empty string, fail if PCRE_NOTEMPTY is | /* Otherwise, if we have matched an empty string, fail if not in an |
| 1316 | set, or if PCRE_NOTEMPTY_ATSTART is set and we have matched at the start of | assertion and if either PCRE_NOTEMPTY is set, or if PCRE_NOTEMPTY_ATSTART |
| 1317 | the subject. In both cases, backtracking will then try other alternatives, | is set and we have matched at the start of the subject. In both cases, |
| 1318 | if any. */ | backtracking will then try other alternatives, if any. */ |
| 1319 | ||
| 1320 | if (eptr == mstart && | else if (eptr == mstart && op != OP_ASSERT_ACCEPT && |
| 1321 | (md->notempty || | (md->notempty || |
| 1322 | (md->notempty_atstart && | (md->notempty_atstart && |
| 1323 | mstart == md->start_subject + md->start_offset))) | mstart == md->start_subject + md->start_offset))) |
| 1324 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1325 | ||
| 1326 | /* Otherwise, we have a match. */ | /* Otherwise, we have a match. */ |
| 1327 | ||
| 1328 | md->end_match_ptr = eptr; /* Record where we ended */ | md->end_match_ptr = eptr; /* Record where we ended */ |
| 1329 | md->end_offset_top = offset_top; /* and how many extracts were taken */ | md->end_offset_top = offset_top; /* and how many extracts were taken */ |
| 1330 | 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); | ||
| 1331 | ||
| 1332 | /* Change option settings */ | /* For some reason, the macros don't work properly if an expression is |
| 1333 | given as the argument to MRRETURN when the heap is in use. */ | |
| 1334 | ||
| 1335 | case OP_OPT: | rrc = (op == OP_END)? MATCH_MATCH : MATCH_ACCEPT; |
| 1336 | ims = ecode[1]; | MRRETURN(rrc); |
| ecode += 2; | ||
| DPRINTF(("ims set to %02lx\n", ims)); | ||
| break; | ||
| 1337 | ||
| 1338 | /* Assertion brackets. Check the alternative branches in turn - the | /* Assertion brackets. Check the alternative branches in turn - the |
| 1339 | 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, |
| 1340 | the assertion is true. Lookbehind assertions have an OP_REVERSE item at the | the assertion is true. Lookbehind assertions have an OP_REVERSE item at the |
| 1341 | start of each branch to move the current point backwards, so the code at | start of each branch to move the current point backwards, so the code at |
| 1342 | this level is identical to the lookahead case. */ | this level is identical to the lookahead case. When the assertion is part |
| 1343 | of a condition, we want to return immediately afterwards. The caller of | |
| 1344 | this incarnation of the match() function will have set MATCH_CONDASSERT in | |
| 1345 | md->match_function type, and one of these opcodes will be the first opcode | |
| 1346 | that is processed. We use a local variable that is preserved over calls to | |
| 1347 | match() to remember this case. */ | |
| 1348 | ||
| 1349 | case OP_ASSERT: | case OP_ASSERT: |
| 1350 | case OP_ASSERTBACK: | case OP_ASSERTBACK: |
| 1351 | if (md->match_function_type == MATCH_CONDASSERT) | |
| 1352 | { | |
| 1353 | condassert = TRUE; | |
| 1354 | md->match_function_type = 0; | |
| 1355 | } | |
| 1356 | else condassert = FALSE; | |
| 1357 | ||
| 1358 | do | do |
| 1359 | { | { |
| 1360 | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0, | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM4); |
| 1361 | RM4); | if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) |
| if (rrc == MATCH_MATCH) | ||
| 1362 | { | { |
| 1363 | mstart = md->start_match_ptr; /* In case \K reset it */ | mstart = md->start_match_ptr; /* In case \K reset it */ |
| 1364 | break; | break; |
| 1365 | } | } |
| 1366 | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); | if (rrc != MATCH_NOMATCH && |
| 1367 | (rrc != MATCH_THEN || md->start_match_ptr != ecode)) | |
| 1368 | RRETURN(rrc); | |
| 1369 | ecode += GET(ecode, 1); | ecode += GET(ecode, 1); |
| 1370 | } | } |
| 1371 | while (*ecode == OP_ALT); | while (*ecode == OP_ALT); |
| 1372 | if (*ecode == OP_KET) RRETURN(MATCH_NOMATCH); | |
| 1373 | if (*ecode == OP_KET) MRRETURN(MATCH_NOMATCH); | |
| 1374 | ||
| 1375 | /* If checking an assertion for a condition, return MATCH_MATCH. */ | /* If checking an assertion for a condition, return MATCH_MATCH. */ |
| 1376 | ||
| 1377 | if ((flags & match_condassert) != 0) RRETURN(MATCH_MATCH); | if (condassert) RRETURN(MATCH_MATCH); |
| 1378 | ||
| 1379 | /* Continue from after the assertion, updating the offsets high water | /* Continue from after the assertion, updating the offsets high water |
| 1380 | mark, since extracts may have been taken during the assertion. */ | mark, since extracts may have been taken during the assertion. */ |
| # | Line 1147 for (;;) | Line 1390 for (;;) |
| 1390 | ||
| 1391 | case OP_ASSERT_NOT: | case OP_ASSERT_NOT: |
| 1392 | case OP_ASSERTBACK_NOT: | case OP_ASSERTBACK_NOT: |
| 1393 | if (md->match_function_type == MATCH_CONDASSERT) | |
| 1394 | { | |
| 1395 | condassert = TRUE; | |
| 1396 | md->match_function_type = 0; | |
| 1397 | } | |
| 1398 | else condassert = FALSE; | |
| 1399 | ||
| 1400 | do | do |
| 1401 | { | { |
| 1402 | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0, | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM5); |
| 1403 | RM5); | if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) MRRETURN(MATCH_NOMATCH); |
| if (rrc == MATCH_MATCH) RRETURN(MATCH_NOMATCH); | ||
| 1404 | if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT) | if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT) |
| 1405 | { | { |
| 1406 | do ecode += GET(ecode,1); while (*ecode == OP_ALT); | do ecode += GET(ecode,1); while (*ecode == OP_ALT); |
| 1407 | break; | break; |
| 1408 | } | } |
| 1409 | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); | if (rrc != MATCH_NOMATCH && |
| 1410 | (rrc != MATCH_THEN || md->start_match_ptr != ecode)) | |
| 1411 | RRETURN(rrc); | |
| 1412 | ecode += GET(ecode,1); | ecode += GET(ecode,1); |
| 1413 | } | } |
| 1414 | while (*ecode == OP_ALT); | while (*ecode == OP_ALT); |
| 1415 | ||
| 1416 | if ((flags & match_condassert) != 0) RRETURN(MATCH_MATCH); | if (condassert) RRETURN(MATCH_MATCH); /* Condition assertion */ |
| 1417 | ||
| 1418 | ecode += 1 + LINK_SIZE; | ecode += 1 + LINK_SIZE; |
| 1419 | continue; | continue; |
| 1420 | ||
| # | Line 1180 for (;;) | Line 1431 for (;;) |
| 1431 | while (i-- > 0) | while (i-- > 0) |
| 1432 | { | { |
| 1433 | eptr--; | eptr--; |
| 1434 | if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH); | if (eptr < md->start_subject) MRRETURN(MATCH_NOMATCH); |
| 1435 | BACKCHAR(eptr); | BACKCHAR(eptr); |
| 1436 | } | } |
| 1437 | } | } |
| # | Line 1191 for (;;) | Line 1442 for (;;) |
| 1442 | ||
| 1443 | { | { |
| 1444 | eptr -= GET(ecode, 1); | eptr -= GET(ecode, 1); |
| 1445 | if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH); | if (eptr < md->start_subject) MRRETURN(MATCH_NOMATCH); |
| 1446 | } | } |
| 1447 | ||
| 1448 | /* 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 1463 for (;;) |
| 1463 | cb.callout_number = ecode[1]; | cb.callout_number = ecode[1]; |
| 1464 | cb.offset_vector = md->offset_vector; | cb.offset_vector = md->offset_vector; |
| 1465 | cb.subject = (PCRE_SPTR)md->start_subject; | cb.subject = (PCRE_SPTR)md->start_subject; |
| 1466 | cb.subject_length = md->end_subject - md->start_subject; | cb.subject_length = (int)(md->end_subject - md->start_subject); |
| 1467 | cb.start_match = mstart - md->start_subject; | cb.start_match = (int)(mstart - md->start_subject); |
| 1468 | cb.current_position = eptr - md->start_subject; | cb.current_position = (int)(eptr - md->start_subject); |
| 1469 | cb.pattern_position = GET(ecode, 2); | cb.pattern_position = GET(ecode, 2); |
| 1470 | cb.next_item_length = GET(ecode, 2 + LINK_SIZE); | cb.next_item_length = GET(ecode, 2 + LINK_SIZE); |
| 1471 | cb.capture_top = offset_top/2; | cb.capture_top = offset_top/2; |
| 1472 | cb.capture_last = md->capture_last; | cb.capture_last = md->capture_last; |
| 1473 | cb.callout_data = md->callout_data; | cb.callout_data = md->callout_data; |
| 1474 | if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH); | if ((rrc = (*pcre_callout)(&cb)) > 0) MRRETURN(MATCH_NOMATCH); |
| 1475 | if (rrc < 0) RRETURN(rrc); | if (rrc < 0) RRETURN(rrc); |
| 1476 | } | } |
| 1477 | ecode += 2 + 2*LINK_SIZE; | ecode += 2 + 2*LINK_SIZE; |
| # | Line 1276 for (;;) | Line 1527 for (;;) |
| 1527 | memcpy(new_recursive.offset_save, md->offset_vector, | memcpy(new_recursive.offset_save, md->offset_vector, |
| 1528 | new_recursive.saved_max * sizeof(int)); | new_recursive.saved_max * sizeof(int)); |
| 1529 | new_recursive.save_offset_top = offset_top; | new_recursive.save_offset_top = offset_top; |
| 1530 | ||
| 1531 | /* OK, now we can do the recursion. For each top-level alternative we | /* OK, now we can do the recursion. For each top-level alternative we |
| 1532 | restore the offset and recursion data. */ | restore the offset and recursion data. */ |
| 1533 | ||
| 1534 | DPRINTF(("Recursing into group %d\n", new_recursive.group_num)); | DPRINTF(("Recursing into group %d\n", new_recursive.group_num)); |
| 1535 | flags = (*callpat >= OP_SBRA)? match_cbegroup : 0; | cbegroup = (*callpat >= OP_SBRA); |
| 1536 | do | do |
| 1537 | { | { |
| 1538 | if (cbegroup) md->match_function_type = MATCH_CBEGROUP; | |
| 1539 | RMATCH(eptr, callpat + _pcre_OP_lengths[*callpat], offset_top, | RMATCH(eptr, callpat + _pcre_OP_lengths[*callpat], offset_top, |
| 1540 | md, ims, eptrb, flags, RM6); | md, eptrb, RM6); |
| 1541 | if (rrc == MATCH_MATCH) | if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) |
| 1542 | { | { |
| 1543 | DPRINTF(("Recursion matched\n")); | DPRINTF(("Recursion matched\n")); |
| 1544 | md->recursive = new_recursive.prevrec; | md->recursive = new_recursive.prevrec; |
| 1545 | if (new_recursive.offset_save != stacksave) | if (new_recursive.offset_save != stacksave) |
| 1546 | (pcre_free)(new_recursive.offset_save); | (pcre_free)(new_recursive.offset_save); |
| 1547 | RRETURN(MATCH_MATCH); | MRRETURN(MATCH_MATCH); |
| 1548 | } | } |
| 1549 | else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) | else if (rrc != MATCH_NOMATCH && |
| 1550 | (rrc != MATCH_THEN || md->start_match_ptr != ecode)) | |
| 1551 | { | { |
| 1552 | DPRINTF(("Recursion gave error %d\n", rrc)); | DPRINTF(("Recursion gave error %d\n", rrc)); |
| 1553 | if (new_recursive.offset_save != stacksave) | if (new_recursive.offset_save != stacksave) |
| # | Line 1313 for (;;) | Line 1566 for (;;) |
| 1566 | md->recursive = new_recursive.prevrec; | md->recursive = new_recursive.prevrec; |
| 1567 | if (new_recursive.offset_save != stacksave) | if (new_recursive.offset_save != stacksave) |
| 1568 | (pcre_free)(new_recursive.offset_save); | (pcre_free)(new_recursive.offset_save); |
| 1569 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1570 | } | } |
| 1571 | /* Control never reaches here */ | /* Control never reaches here */ |
| 1572 | ||
| # | Line 1331 for (;;) | Line 1584 for (;;) |
| 1584 | ||
| 1585 | do | do |
| 1586 | { | { |
| 1587 | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM7); | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM7); |
| 1588 | if (rrc == MATCH_MATCH) | if (rrc == MATCH_MATCH) /* Note: _not_ MATCH_ACCEPT */ |
| 1589 | { | { |
| 1590 | mstart = md->start_match_ptr; | mstart = md->start_match_ptr; |
| 1591 | break; | break; |
| 1592 | } | } |
| 1593 | if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); | if (rrc != MATCH_NOMATCH && |
| 1594 | (rrc != MATCH_THEN || md->start_match_ptr != ecode)) | |
| 1595 | RRETURN(rrc); | |
| 1596 | ecode += GET(ecode,1); | ecode += GET(ecode,1); |
| 1597 | } | } |
| 1598 | while (*ecode == OP_ALT); | while (*ecode == OP_ALT); |
| # | Line 1346 for (;;) | Line 1601 for (;;) |
| 1601 | ||
| 1602 | if (*ecode != OP_ONCE && *ecode != OP_ALT) RRETURN(MATCH_NOMATCH); | if (*ecode != OP_ONCE && *ecode != OP_ALT) RRETURN(MATCH_NOMATCH); |
| 1603 | ||
| 1604 | /* Continue as from after the assertion, updating the offsets high water | /* Continue after the group, updating the offsets high water mark, since |
| 1605 | mark, since extracts may have been taken. */ | extracts may have been taken. */ |
| 1606 | ||
| 1607 | do ecode += GET(ecode, 1); while (*ecode == OP_ALT); | do ecode += GET(ecode, 1); while (*ecode == OP_ALT); |
| 1608 | ||
| # | Line 1368 for (;;) | Line 1623 for (;;) |
| 1623 | ||
| 1624 | /* 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 |
| 1625 | preceding bracket, in the appropriate order. The second "call" of match() | preceding bracket, in the appropriate order. The second "call" of match() |
| 1626 | 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)); | ||
| } | ||
| 1627 | ||
| 1628 | if (*ecode == OP_KETRMIN) | if (*ecode == OP_KETRMIN) |
| 1629 | { | { |
| 1630 | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM8); | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM8); |
| 1631 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1632 | ecode = prev; | ecode = prev; |
| flags = 0; | ||
| 1633 | goto TAIL_RECURSE; | goto TAIL_RECURSE; |
| 1634 | } | } |
| 1635 | else /* OP_KETRMAX */ | else /* OP_KETRMAX */ |
| 1636 | { | { |
| 1637 | RMATCH(eptr, prev, offset_top, md, ims, eptrb, match_cbegroup, RM9); | md->match_function_type = MATCH_CBEGROUP; |
| 1638 | RMATCH(eptr, prev, offset_top, md, eptrb, RM9); | |
| 1639 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1640 | ecode += 1 + LINK_SIZE; | ecode += 1 + LINK_SIZE; |
| flags = 0; | ||
| 1641 | goto TAIL_RECURSE; | goto TAIL_RECURSE; |
| 1642 | } | } |
| 1643 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 1408 for (;;) | Line 1654 for (;;) |
| 1654 | at all - i.e. it could be ()* or ()? or even (){0} in the pattern. Brackets | at all - i.e. it could be ()* or ()? or even (){0} in the pattern. Brackets |
| 1655 | with fixed upper repeat limits are compiled as a number of copies, with the | with fixed upper repeat limits are compiled as a number of copies, with the |
| 1656 | optional ones preceded by BRAZERO or BRAMINZERO. */ | optional ones preceded by BRAZERO or BRAMINZERO. */ |
| 1657 | ||
| 1658 | case OP_BRAZERO: | case OP_BRAZERO: |
| 1659 | { | next = ecode + 1; |
| 1660 | next = ecode+1; | RMATCH(eptr, next, offset_top, md, eptrb, RM10); |
| 1661 | RMATCH(eptr, next, offset_top, md, ims, eptrb, 0, RM10); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1662 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | do next += GET(next, 1); while (*next == OP_ALT); |
| 1663 | do next += GET(next,1); while (*next == OP_ALT); | ecode = next + 1 + LINK_SIZE; |
| ecode = next + 1 + LINK_SIZE; | ||
| } | ||
| 1664 | break; | break; |
| 1665 | ||
| 1666 | case OP_BRAMINZERO: | case OP_BRAMINZERO: |
| 1667 | { | next = ecode + 1; |
| 1668 | next = ecode+1; | do next += GET(next, 1); while (*next == OP_ALT); |
| 1669 | do next += GET(next, 1); while (*next == OP_ALT); | RMATCH(eptr, next + 1+LINK_SIZE, offset_top, md, eptrb, RM11); |
| 1670 | RMATCH(eptr, next + 1+LINK_SIZE, offset_top, md, ims, eptrb, 0, RM11); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1671 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | ecode++; |
| ecode++; | ||
| } | ||
| 1672 | break; | break; |
| 1673 | ||
| 1674 | case OP_SKIPZERO: | case OP_SKIPZERO: |
| 1675 | { | next = ecode+1; |
| 1676 | next = ecode+1; | do next += GET(next,1); while (*next == OP_ALT); |
| 1677 | do next += GET(next,1); while (*next == OP_ALT); | ecode = next + 1 + LINK_SIZE; |
| ecode = next + 1 + LINK_SIZE; | ||
| } | ||
| 1678 | break; | break; |
| 1679 | ||
| 1680 | /* BRAPOSZERO occurs before a possessive bracket group. Don't do anything | |
| 1681 | here; just jump to the group, with allow_zero set TRUE. */ | |
| 1682 | ||
| 1683 | case OP_BRAPOSZERO: | |
| 1684 | op = *(++ecode); | |
| 1685 | allow_zero = TRUE; | |
| 1686 | if (op == OP_CBRAPOS || op == OP_SCBRAPOS) goto POSSESSIVE_CAPTURE; | |
| 1687 | goto POSSESSIVE_NON_CAPTURE; | |
| 1688 | ||
| 1689 | /* End of a group, repeated or non-repeating. */ | /* End of a group, repeated or non-repeating. */ |
| 1690 | ||
| 1691 | case OP_KET: | case OP_KET: |
| 1692 | case OP_KETRMIN: | case OP_KETRMIN: |
| 1693 | case OP_KETRMAX: | case OP_KETRMAX: |
| 1694 | case OP_KETRPOS: | |
| 1695 | prev = ecode - GET(ecode, 1); | prev = ecode - GET(ecode, 1); |
| 1696 | ||
| 1697 | /* If this was a group that remembered the subject start, in order to break | /* If this was a group that remembered the subject start, in order to break |
| # | Line 1467 for (;;) | Line 1717 for (;;) |
| 1717 | md->end_match_ptr = eptr; /* For ONCE */ | md->end_match_ptr = eptr; /* For ONCE */ |
| 1718 | md->end_offset_top = offset_top; | md->end_offset_top = offset_top; |
| 1719 | md->start_match_ptr = mstart; | md->start_match_ptr = mstart; |
| 1720 | RRETURN(MATCH_MATCH); | MRRETURN(MATCH_MATCH); |
| 1721 | } | } |
| 1722 | ||
| 1723 | /* 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 1476 for (;;) | Line 1726 for (;;) |
| 1726 | a recurse into group 0, so it won't be picked up here. Instead, we catch it | a recurse into group 0, so it won't be picked up here. Instead, we catch it |
| 1727 | when the OP_END is reached. Other recursion is handled here. */ | when the OP_END is reached. Other recursion is handled here. */ |
| 1728 | ||
| 1729 | if (*prev == OP_CBRA || *prev == OP_SCBRA) | if (*prev == OP_CBRA || *prev == OP_SCBRA || |
| 1730 | *prev == OP_CBRAPOS || *prev == OP_SCBRAPOS) | |
| 1731 | { | { |
| 1732 | number = GET2(prev, 1+LINK_SIZE); | number = GET2(prev, 1+LINK_SIZE); |
| 1733 | offset = number << 1; | offset = number << 1; |
| # | Line 1489 for (;;) | Line 1740 for (;;) |
| 1740 | md->capture_last = number; | md->capture_last = number; |
| 1741 | if (offset >= md->offset_max) md->offset_overflow = TRUE; else | if (offset >= md->offset_max) md->offset_overflow = TRUE; else |
| 1742 | { | { |
| 1743 | /* If offset is greater than offset_top, it means that we are | |
| 1744 | "skipping" a capturing group, and that group's offsets must be marked | |
| 1745 | unset. In earlier versions of PCRE, all the offsets were unset at the | |
| 1746 | start of matching, but this doesn't work because atomic groups and | |
| 1747 | assertions can cause a value to be set that should later be unset. | |
| 1748 | Example: matching /(?>(a))b|(a)c/ against "ac". This sets group 1 as | |
| 1749 | part of the atomic group, but this is not on the final matching path, | |
| 1750 | so must be unset when 2 is set. (If there is no group 2, there is no | |
| 1751 | problem, because offset_top will then be 2, indicating no capture.) */ | |
| 1752 | ||
| 1753 | if (offset > offset_top) | |
| 1754 | { | |
| 1755 | register int *iptr = md->offset_vector + offset_top; | |
| 1756 | register int *iend = md->offset_vector + offset; | |
| 1757 | while (iptr < iend) *iptr++ = -1; | |
| 1758 | } | |
| 1759 | ||
| 1760 | /* Now make the extraction */ | |
| 1761 | ||
| 1762 | md->offset_vector[offset] = | md->offset_vector[offset] = |
| 1763 | md->offset_vector[md->offset_end - number]; | md->offset_vector[md->offset_end - number]; |
| 1764 | md->offset_vector[offset+1] = eptr - md->start_subject; | md->offset_vector[offset+1] = (int)(eptr - md->start_subject); |
| 1765 | if (offset_top <= offset) offset_top = offset + 2; | if (offset_top <= offset) offset_top = offset + 2; |
| 1766 | } | } |
| 1767 | ||
| # | Line 1507 for (;;) | Line 1777 for (;;) |
| 1777 | rec->saved_max * sizeof(int)); | rec->saved_max * sizeof(int)); |
| 1778 | offset_top = rec->save_offset_top; | offset_top = rec->save_offset_top; |
| 1779 | ecode = rec->after_call; | ecode = rec->after_call; |
| ims = original_ims; | ||
| 1780 | break; | break; |
| 1781 | } | } |
| 1782 | } | } |
| 1783 | ||
| /* 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)); | ||
| 1784 | /* For a non-repeating ket, just continue at this level. This also | /* For a non-repeating ket, just continue at this level. This also |
| 1785 | 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. |
| 1786 | 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 1529 for (;;) | Line 1792 for (;;) |
| 1792 | ecode += 1 + LINK_SIZE; | ecode += 1 + LINK_SIZE; |
| 1793 | break; | break; |
| 1794 | } | } |
| 1795 | ||
| 1796 | /* The repeating kets try the rest of the pattern or restart from the | /* OP_KETRPOS is a possessive repeating ket. Remember the current position, |
| 1797 | preceding bracket, in the appropriate order. In the second case, we can use | and return the MATCH_KETRPOS. This makes it possible to do the repeats one |
| 1798 | tail recursion to avoid using another stack frame, unless we have an | at a time from the outer level, thus saving stack. */ |
| 1799 | ||
| 1800 | if (*ecode == OP_KETRPOS) | |
| 1801 | { | |
| 1802 | md->end_match_ptr = eptr; | |
| 1803 | md->end_offset_top = offset_top; | |
| 1804 | RRETURN(MATCH_KETRPOS); | |
| 1805 | } | |
| 1806 | ||
| 1807 | /* The normal repeating kets try the rest of the pattern or restart from | |
| 1808 | the preceding bracket, in the appropriate order. In the second case, we can | |
| 1809 | use tail recursion to avoid using another stack frame, unless we have an | |
| 1810 | unlimited repeat of a group that can match an empty string. */ | unlimited repeat of a group that can match an empty string. */ |
| 1811 | ||
| flags = (*prev >= OP_SBRA)? match_cbegroup : 0; | ||
| 1812 | if (*ecode == OP_KETRMIN) | if (*ecode == OP_KETRMIN) |
| 1813 | { | { |
| 1814 | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM12); | RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM12); |
| 1815 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1816 | if (flags != 0) /* Could match an empty string */ | if (*prev >= OP_SBRA) /* Could match an empty string */ |
| 1817 | { | { |
| 1818 | RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM50); | md->match_function_type = MATCH_CBEGROUP; |
| 1819 | RMATCH(eptr, prev, offset_top, md, eptrb, RM50); | |
| 1820 | RRETURN(rrc); | RRETURN(rrc); |
| 1821 | } | } |
| 1822 | ecode = prev; | ecode = prev; |
| # | Line 1551 for (;;) | Line 1824 for (;;) |
| 1824 | } | } |
| 1825 | else /* OP_KETRMAX */ | else /* OP_KETRMAX */ |
| 1826 | { | { |
| 1827 | RMATCH(eptr, prev, offset_top, md, ims, eptrb, flags, RM13); | if (*prev >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP; |
| 1828 | RMATCH(eptr, prev, offset_top, md, eptrb, RM13); | |
| 1829 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1830 | ecode += 1 + LINK_SIZE; | ecode += 1 + LINK_SIZE; |
| flags = 0; | ||
| 1831 | goto TAIL_RECURSE; | goto TAIL_RECURSE; |
| 1832 | } | } |
| 1833 | /* Control never gets here */ | /* Control never gets here */ |
| 1834 | ||
| 1835 | /* Start of subject unless notbol, or after internal newline if multiline */ | /* Not multiline mode: start of subject assertion, unless notbol. */ |
| 1836 | ||
| 1837 | case OP_CIRC: | case OP_CIRC: |
| 1838 | if (md->notbol && eptr == md->start_subject) RRETURN(MATCH_NOMATCH); | if (md->notbol && eptr == md->start_subject) MRRETURN(MATCH_NOMATCH); |
| 1839 | 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 */ | ||
| 1840 | /* Start of subject assertion */ | /* Start of subject assertion */ |
| 1841 | ||
| 1842 | case OP_SOD: | case OP_SOD: |
| 1843 | if (eptr != md->start_subject) RRETURN(MATCH_NOMATCH); | if (eptr != md->start_subject) MRRETURN(MATCH_NOMATCH); |
| 1844 | ecode++; | |
| 1845 | break; | |
| 1846 | ||
| 1847 | /* Multiline mode: start of subject unless notbol, or after any newline. */ | |
| 1848 | ||
| 1849 | case OP_CIRCM: | |
| 1850 | if (md->notbol && eptr == md->start_subject) MRRETURN(MATCH_NOMATCH); | |
| 1851 | if (eptr != md->start_subject && | |
| 1852 | (eptr == md->end_subject || !WAS_NEWLINE(eptr))) | |
| 1853 | MRRETURN(MATCH_NOMATCH); | |
| 1854 | ecode++; | ecode++; |
| 1855 | break; | break; |
| 1856 | ||
| 1857 | /* Start of match assertion */ | /* Start of match assertion */ |
| 1858 | ||
| 1859 | case OP_SOM: | case OP_SOM: |
| 1860 | if (eptr != md->start_subject + md->start_offset) RRETURN(MATCH_NOMATCH); | if (eptr != md->start_subject + md->start_offset) MRRETURN(MATCH_NOMATCH); |
| 1861 | ecode++; | ecode++; |
| 1862 | break; | break; |
| 1863 | ||
| # | Line 1594 for (;;) | Line 1868 for (;;) |
| 1868 | ecode++; | ecode++; |
| 1869 | break; | break; |
| 1870 | ||
| 1871 | /* Assert before internal newline if multiline, or before a terminating | /* Multiline mode: assert before any newline, or before end of subject |
| 1872 | newline unless endonly is set, else end of subject unless noteol is set. */ | unless noteol is set. */ |
| 1873 | ||
| 1874 | case OP_DOLL: | case OP_DOLLM: |
| 1875 | if ((ims & PCRE_MULTILINE) != 0) | if (eptr < md->end_subject) |
| 1876 | { | { 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; | ||
| } | ||
| 1877 | else | else |
| 1878 | { | { |
| 1879 | if (md->noteol) RRETURN(MATCH_NOMATCH); | if (md->noteol) MRRETURN(MATCH_NOMATCH); |
| 1880 | if (!md->endonly) | SCHECK_PARTIAL(); |
| { | ||
| if (eptr != md->end_subject && | ||
| (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen)) | ||
| RRETURN(MATCH_NOMATCH); | ||
| ecode++; | ||
| break; | ||
| } | ||
| 1881 | } | } |
| 1882 | ecode++; | |
| 1883 | break; | |
| 1884 | ||
| 1885 | /* Not multiline mode: assert before a terminating newline or before end of | |
| 1886 | subject unless noteol is set. */ | |
| 1887 | ||
| 1888 | case OP_DOLL: | |
| 1889 | if (md->noteol) MRRETURN(MATCH_NOMATCH); | |
| 1890 | if (!md->endonly) goto ASSERT_NL_OR_EOS; | |
| 1891 | ||
| 1892 | /* ... else fall through for endonly */ | /* ... else fall through for endonly */ |
| 1893 | ||
| 1894 | /* End of subject assertion (\z) */ | /* End of subject assertion (\z) */ |
| 1895 | ||
| 1896 | case OP_EOD: | case OP_EOD: |
| 1897 | if (eptr < md->end_subject) RRETURN(MATCH_NOMATCH); | if (eptr < md->end_subject) MRRETURN(MATCH_NOMATCH); |
| 1898 | SCHECK_PARTIAL(); | |
| 1899 | ecode++; | ecode++; |
| 1900 | break; | break; |
| 1901 | ||
| 1902 | /* End of subject or ending \n assertion (\Z) */ | /* End of subject or ending \n assertion (\Z) */ |
| 1903 | ||
| 1904 | case OP_EODN: | case OP_EODN: |
| 1905 | if (eptr != md->end_subject && | ASSERT_NL_OR_EOS: |
| 1906 | if (eptr < md->end_subject && | |
| 1907 | (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen)) | (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen)) |
| 1908 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 1909 | ||
| 1910 | /* Either at end of string or \n before end. */ | |
| 1911 | ||
| 1912 | SCHECK_PARTIAL(); | |
| 1913 | ecode++; | ecode++; |
| 1914 | break; | break; |
| 1915 | ||
| # | Line 1651 for (;;) | Line 1927 for (;;) |
| 1927 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| 1928 | if (utf8) | if (utf8) |
| 1929 | { | { |
| 1930 | /* Get status of previous character */ | |
| 1931 | ||
| 1932 | if (eptr == md->start_subject) prev_is_word = FALSE; else | if (eptr == md->start_subject) prev_is_word = FALSE; else |
| 1933 | { | { |
| 1934 | USPTR lastptr = eptr - 1; | USPTR lastptr = eptr - 1; |
| 1935 | while((*lastptr & 0xc0) == 0x80) lastptr--; | while((*lastptr & 0xc0) == 0x80) lastptr--; |
| 1936 | if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr; | if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr; |
| 1937 | GETCHAR(c, lastptr); | GETCHAR(c, lastptr); |
| 1938 | #ifdef SUPPORT_UCP | |
| 1939 | if (md->use_ucp) | |
| 1940 | { | |
| 1941 | if (c == '_') prev_is_word = TRUE; else | |
| 1942 | { | |
| 1943 | int cat = UCD_CATEGORY(c); | |
| 1944 | prev_is_word = (cat == ucp_L || cat == ucp_N); | |
| 1945 | } | |
| 1946 | } | |
| 1947 | else | |
| 1948 | #endif | |
| 1949 | prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; | prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; |
| 1950 | } | } |
| 1951 | ||
| 1952 | /* Get status of next character */ | |
| 1953 | ||
| 1954 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 1955 | { | { |
| 1956 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| # | Line 1667 for (;;) | Line 1959 for (;;) |
| 1959 | else | else |
| 1960 | { | { |
| 1961 | GETCHAR(c, eptr); | GETCHAR(c, eptr); |
| 1962 | #ifdef SUPPORT_UCP | |
| 1963 | if (md->use_ucp) | |
| 1964 | { | |
| 1965 | if (c == '_') cur_is_word = TRUE; else | |
| 1966 | { | |
| 1967 | int cat = UCD_CATEGORY(c); | |
| 1968 | cur_is_word = (cat == ucp_L || cat == ucp_N); | |
| 1969 | } | |
| 1970 | } | |
| 1971 | else | |
| 1972 | #endif | |
| 1973 | cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; | cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; |
| 1974 | } | } |
| 1975 | } | } |
| 1976 | else | else |
| 1977 | #endif | #endif |
| 1978 | ||
| 1979 | /* Not in UTF-8 mode */ | /* Not in UTF-8 mode, but we may still have PCRE_UCP set, and for |
| 1980 | consistency with the behaviour of \w we do use it in this case. */ | |
| 1981 | ||
| 1982 | { | { |
| 1983 | /* Get status of previous character */ | |
| 1984 | ||
| 1985 | if (eptr == md->start_subject) prev_is_word = FALSE; else | if (eptr == md->start_subject) prev_is_word = FALSE; else |
| 1986 | { | { |
| 1987 | if (eptr <= md->start_used_ptr) md->start_used_ptr = eptr - 1; | if (eptr <= md->start_used_ptr) md->start_used_ptr = eptr - 1; |
| 1988 | #ifdef SUPPORT_UCP | |
| 1989 | if (md->use_ucp) | |
| 1990 | { | |
| 1991 | c = eptr[-1]; | |
| 1992 | if (c == '_') prev_is_word = TRUE; else | |
| 1993 | { | |
| 1994 | int cat = UCD_CATEGORY(c); | |
| 1995 | prev_is_word = (cat == ucp_L || cat == ucp_N); | |
| 1996 | } | |
| 1997 | } | |
| 1998 | else | |
| 1999 | #endif | |
| 2000 | prev_is_word = ((md->ctypes[eptr[-1]] & ctype_word) != 0); | prev_is_word = ((md->ctypes[eptr[-1]] & ctype_word) != 0); |
| 2001 | } | } |
| 2002 | ||
| 2003 | /* Get status of next character */ | |
| 2004 | ||
| 2005 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2006 | { | { |
| 2007 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2008 | cur_is_word = FALSE; | cur_is_word = FALSE; |
| 2009 | } | } |
| 2010 | else cur_is_word = ((md->ctypes[*eptr] & ctype_word) != 0); | else |
| 2011 | #ifdef SUPPORT_UCP | |
| 2012 | if (md->use_ucp) | |
| 2013 | { | |
| 2014 | c = *eptr; | |
| 2015 | if (c == '_') cur_is_word = TRUE; else | |
| 2016 | { | |
| 2017 | int cat = UCD_CATEGORY(c); | |
| 2018 | cur_is_word = (cat == ucp_L || cat == ucp_N); | |
| 2019 | } | |
| 2020 | } | |
| 2021 | else | |
| 2022 | #endif | |
| 2023 | cur_is_word = ((md->ctypes[*eptr] & ctype_word) != 0); | |
| 2024 | } | } |
| 2025 | ||
| 2026 | /* Now see if the situation is what we want */ | /* Now see if the situation is what we want */ |
| 2027 | ||
| 2028 | if ((*ecode++ == OP_WORD_BOUNDARY)? | if ((*ecode++ == OP_WORD_BOUNDARY)? |
| 2029 | cur_is_word == prev_is_word : cur_is_word != prev_is_word) | cur_is_word == prev_is_word : cur_is_word != prev_is_word) |
| 2030 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2031 | } | } |
| 2032 | break; | break; |
| 2033 | ||
| 2034 | /* Match a single character type; inline for speed */ | /* Match a single character type; inline for speed */ |
| 2035 | ||
| 2036 | case OP_ANY: | case OP_ANY: |
| 2037 | if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); | if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH); |
| 2038 | /* Fall through */ | /* Fall through */ |
| 2039 | ||
| 2040 | case OP_ALLANY: | case OP_ALLANY: |
| 2041 | if (eptr++ >= md->end_subject) | if (eptr++ >= md->end_subject) |
| 2042 | { | { |
| 2043 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2044 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2045 | } | } |
| 2046 | if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| 2047 | ecode++; | ecode++; |
| # | Line 1720 for (;;) | Line 2054 for (;;) |
| 2054 | if (eptr++ >= md->end_subject) | if (eptr++ >= md->end_subject) |
| 2055 | { | { |
| 2056 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2057 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2058 | } | } |
| 2059 | ecode++; | ecode++; |
| 2060 | break; | break; |
| # | Line 1729 for (;;) | Line 2063 for (;;) |
| 2063 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2064 | { | { |
| 2065 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2066 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2067 | } | } |
| 2068 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2069 | if ( | if ( |
| # | Line 1738 for (;;) | Line 2072 for (;;) |
| 2072 | #endif | #endif |
| 2073 | (md->ctypes[c] & ctype_digit) != 0 | (md->ctypes[c] & ctype_digit) != 0 |
| 2074 | ) | ) |
| 2075 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2076 | ecode++; | ecode++; |
| 2077 | break; | break; |
| 2078 | ||
| # | Line 1746 for (;;) | Line 2080 for (;;) |
| 2080 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2081 | { | { |
| 2082 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2083 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2084 | } | } |
| 2085 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2086 | if ( | if ( |
| # | Line 1755 for (;;) | Line 2089 for (;;) |
| 2089 | #endif | #endif |
| 2090 | (md->ctypes[c] & ctype_digit) == 0 | (md->ctypes[c] & ctype_digit) == 0 |
| 2091 | ) | ) |
| 2092 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2093 | ecode++; | ecode++; |
| 2094 | break; | break; |
| 2095 | ||
| # | Line 1763 for (;;) | Line 2097 for (;;) |
| 2097 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2098 | { | { |
| 2099 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2100 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2101 | } | } |
| 2102 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2103 | if ( | if ( |
| # | Line 1772 for (;;) | Line 2106 for (;;) |
| 2106 | #endif | #endif |
| 2107 | (md->ctypes[c] & ctype_space) != 0 | (md->ctypes[c] & ctype_space) != 0 |
| 2108 | ) | ) |
| 2109 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2110 | ecode++; | ecode++; |
| 2111 | break; | break; |
| 2112 | ||
| # | Line 1780 for (;;) | Line 2114 for (;;) |
| 2114 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2115 | { | { |
| 2116 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2117 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2118 | } | } |
| 2119 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2120 | if ( | if ( |
| # | Line 1789 for (;;) | Line 2123 for (;;) |
| 2123 | #endif | #endif |
| 2124 | (md->ctypes[c] & ctype_space) == 0 | (md->ctypes[c] & ctype_space) == 0 |
| 2125 | ) | ) |
| 2126 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2127 | ecode++; | ecode++; |
| 2128 | break; | break; |
| 2129 | ||
| # | Line 1797 for (;;) | Line 2131 for (;;) |
| 2131 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2132 | { | { |
| 2133 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2134 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2135 | } | } |
| 2136 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2137 | if ( | if ( |
| # | Line 1806 for (;;) | Line 2140 for (;;) |
| 2140 | #endif | #endif |
| 2141 | (md->ctypes[c] & ctype_word) != 0 | (md->ctypes[c] & ctype_word) != 0 |
| 2142 | ) | ) |
| 2143 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2144 | ecode++; | ecode++; |
| 2145 | break; | break; |
| 2146 | ||
| # | Line 1814 for (;;) | Line 2148 for (;;) |
| 2148 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2149 | { | { |
| 2150 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2151 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2152 | } | } |
| 2153 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2154 | if ( | if ( |
| # | Line 1823 for (;;) | Line 2157 for (;;) |
| 2157 | #endif | #endif |
| 2158 | (md->ctypes[c] & ctype_word) == 0 | (md->ctypes[c] & ctype_word) == 0 |
| 2159 | ) | ) |
| 2160 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2161 | ecode++; | ecode++; |
| 2162 | break; | break; |
| 2163 | ||
| # | Line 1831 for (;;) | Line 2165 for (;;) |
| 2165 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2166 | { | { |
| 2167 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2168 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2169 | } | } |
| 2170 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2171 | switch(c) | switch(c) |
| 2172 | { | { |
| 2173 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 2174 | ||
| 2175 | case 0x000d: | case 0x000d: |
| 2176 | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 2177 | break; | break; |
| # | Line 1849 for (;;) | Line 2184 for (;;) |
| 2184 | case 0x0085: | case 0x0085: |
| 2185 | case 0x2028: | case 0x2028: |
| 2186 | case 0x2029: | case 0x2029: |
| 2187 | if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); | if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH); |
| 2188 | break; | break; |
| 2189 | } | } |
| 2190 | ecode++; | ecode++; |
| # | Line 1859 for (;;) | Line 2194 for (;;) |
| 2194 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2195 | { | { |
| 2196 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2197 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2198 | } | } |
| 2199 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2200 | switch(c) | switch(c) |
| # | Line 1884 for (;;) | Line 2219 for (;;) |
| 2219 | case 0x202f: /* NARROW NO-BREAK SPACE */ | case 0x202f: /* NARROW NO-BREAK SPACE */ |
| 2220 | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ |
| 2221 | case 0x3000: /* IDEOGRAPHIC SPACE */ | case 0x3000: /* IDEOGRAPHIC SPACE */ |
| 2222 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2223 | } | } |
| 2224 | ecode++; | ecode++; |
| 2225 | break; | break; |
| # | Line 1893 for (;;) | Line 2228 for (;;) |
| 2228 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2229 | { | { |
| 2230 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2231 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2232 | } | } |
| 2233 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2234 | switch(c) | switch(c) |
| 2235 | { | { |
| 2236 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 2237 | case 0x09: /* HT */ | case 0x09: /* HT */ |
| 2238 | case 0x20: /* SPACE */ | case 0x20: /* SPACE */ |
| 2239 | case 0xa0: /* NBSP */ | case 0xa0: /* NBSP */ |
| # | Line 1927 for (;;) | Line 2262 for (;;) |
| 2262 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2263 | { | { |
| 2264 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2265 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2266 | } | } |
| 2267 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2268 | switch(c) | switch(c) |
| # | Line 1940 for (;;) | Line 2275 for (;;) |
| 2275 | case 0x85: /* NEL */ | case 0x85: /* NEL */ |
| 2276 | case 0x2028: /* LINE SEPARATOR */ | case 0x2028: /* LINE SEPARATOR */ |
| 2277 | case 0x2029: /* PARAGRAPH SEPARATOR */ | case 0x2029: /* PARAGRAPH SEPARATOR */ |
| 2278 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2279 | } | } |
| 2280 | ecode++; | ecode++; |
| 2281 | break; | break; |
| # | Line 1949 for (;;) | Line 2284 for (;;) |
| 2284 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2285 | { | { |
| 2286 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2287 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2288 | } | } |
| 2289 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2290 | switch(c) | switch(c) |
| 2291 | { | { |
| 2292 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 2293 | case 0x0a: /* LF */ | case 0x0a: /* LF */ |
| 2294 | case 0x0b: /* VT */ | case 0x0b: /* VT */ |
| 2295 | case 0x0c: /* FF */ | case 0x0c: /* FF */ |
| # | Line 1976 for (;;) | Line 2311 for (;;) |
| 2311 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2312 | { | { |
| 2313 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2314 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2315 | } | } |
| 2316 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2317 | { | { |
| # | Line 1985 for (;;) | Line 2320 for (;;) |
| 2320 | switch(ecode[1]) | switch(ecode[1]) |
| 2321 | { | { |
| 2322 | case PT_ANY: | case PT_ANY: |
| 2323 | if (op == OP_NOTPROP) RRETURN(MATCH_NOMATCH); | if (op == OP_NOTPROP) MRRETURN(MATCH_NOMATCH); |
| 2324 | break; | break; |
| 2325 | ||
| 2326 | case PT_LAMP: | case PT_LAMP: |
| 2327 | if ((prop->chartype == ucp_Lu || | if ((prop->chartype == ucp_Lu || |
| 2328 | prop->chartype == ucp_Ll || | prop->chartype == ucp_Ll || |
| 2329 | prop->chartype == ucp_Lt) == (op == OP_NOTPROP)) | prop->chartype == ucp_Lt) == (op == OP_NOTPROP)) |
| 2330 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2331 | break; | break; |
| 2332 | ||
| 2333 | case PT_GC: | case PT_GC: |
| 2334 | if ((ecode[2] != _pcre_ucp_gentype[prop->chartype]) == (op == OP_PROP)) | if ((ecode[2] != _pcre_ucp_gentype[prop->chartype]) == (op == OP_PROP)) |
| 2335 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2336 | break; | break; |
| 2337 | ||
| 2338 | case PT_PC: | case PT_PC: |
| 2339 | if ((ecode[2] != prop->chartype) == (op == OP_PROP)) | if ((ecode[2] != prop->chartype) == (op == OP_PROP)) |
| 2340 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2341 | break; | break; |
| 2342 | ||
| 2343 | case PT_SC: | case PT_SC: |
| 2344 | if ((ecode[2] != prop->script) == (op == OP_PROP)) | if ((ecode[2] != prop->script) == (op == OP_PROP)) |
| 2345 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2346 | break; | break; |
| 2347 | ||
| 2348 | /* These are specials */ | |
| 2349 | ||
| 2350 | case PT_ALNUM: | |
| 2351 | if ((_pcre_ucp_gentype[prop->chartype] == ucp_L || | |
| 2352 | _pcre_ucp_gentype[prop->chartype] == ucp_N) == (op == OP_NOTPROP)) | |
| 2353 | MRRETURN(MATCH_NOMATCH); | |
| 2354 | break; | |
| 2355 | ||
| 2356 | case PT_SPACE: /* Perl space */ | |
| 2357 | if ((_pcre_ucp_gentype[prop->chartype] == ucp_Z || | |
| 2358 | c == CHAR_HT || c == CHAR_NL || c == CHAR_FF || c == CHAR_CR) | |
| 2359 | == (op == OP_NOTPROP)) | |
| 2360 | MRRETURN(MATCH_NOMATCH); | |
| 2361 | break; | |
| 2362 | ||
| 2363 | case PT_PXSPACE: /* POSIX space */ | |
| 2364 | if ((_pcre_ucp_gentype[prop->chartype] == ucp_Z || | |
| 2365 | c == CHAR_HT || c == CHAR_NL || c == CHAR_VT || | |
| 2366 | c == CHAR_FF || c == CHAR_CR) | |
| 2367 | == (op == OP_NOTPROP)) | |
| 2368 | MRRETURN(MATCH_NOMATCH); | |
| 2369 | break; | |
| 2370 | ||
| 2371 | case PT_WORD: | |
| 2372 | if ((_pcre_ucp_gentype[prop->chartype] == ucp_L || | |
| 2373 | _pcre_ucp_gentype[prop->chartype] == ucp_N || | |
| 2374 | c == CHAR_UNDERSCORE) == (op == OP_NOTPROP)) | |
| 2375 | MRRETURN(MATCH_NOMATCH); | |
| 2376 | break; | |
| 2377 | ||
| 2378 | /* This should never occur */ | |
| 2379 | ||
| 2380 | default: | default: |
| 2381 | RRETURN(PCRE_ERROR_INTERNAL); | RRETURN(PCRE_ERROR_INTERNAL); |
| 2382 | } | } |
| # | Line 2025 for (;;) | Line 2392 for (;;) |
| 2392 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2393 | { | { |
| 2394 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2395 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2396 | } | } |
| 2397 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2398 | { | { |
| 2399 | int category = UCD_CATEGORY(c); | int category = UCD_CATEGORY(c); |
| 2400 | if (category == ucp_M) RRETURN(MATCH_NOMATCH); | if (category == ucp_M) MRRETURN(MATCH_NOMATCH); |
| 2401 | while (eptr < md->end_subject) | while (eptr < md->end_subject) |
| 2402 | { | { |
| 2403 | int len = 1; | int len = 1; |
| # | Line 2057 for (;;) | Line 2424 for (;;) |
| 2424 | loops). */ | loops). */ |
| 2425 | ||
| 2426 | case OP_REF: | case OP_REF: |
| 2427 | { | case OP_REFI: |
| 2428 | offset = GET2(ecode, 1) << 1; /* Doubled ref number */ | caseless = op == OP_REFI; |
| 2429 | ecode += 3; | offset = GET2(ecode, 1) << 1; /* Doubled ref number */ |
| 2430 | ecode += 3; | |
| 2431 | ||
| 2432 | /* If the reference is unset, there are two possibilities: | /* If the reference is unset, there are two possibilities: |
| 2433 | ||
| 2434 | (a) In the default, Perl-compatible state, set the length to be longer | (a) In the default, Perl-compatible state, set the length negative; |
| 2435 | 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 |
| 2436 | 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. | ||
| 2437 | ||
| 2438 | (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 |
| 2439 | so that the back reference matches an empty string. | so that the back reference matches an empty string. |
| 2440 | ||
| 2441 | 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 |
| 2442 | referenced subpattern. */ | referenced subpattern. */ |
| 2443 | ||
| 2444 | if (offset >= offset_top || md->offset_vector[offset] < 0) | if (offset >= offset_top || md->offset_vector[offset] < 0) |
| 2445 | length = (md->jscript_compat)? 0 : md->end_subject - eptr + 1; | length = (md->jscript_compat)? 0 : -1; |
| 2446 | else | else |
| 2447 | length = md->offset_vector[offset+1] - md->offset_vector[offset]; | length = md->offset_vector[offset+1] - md->offset_vector[offset]; |
| 2448 | ||
| 2449 | /* Set up for repetition, or handle the non-repeated case */ | /* Set up for repetition, or handle the non-repeated case */ |
| 2450 | ||
| 2451 | switch (*ecode) | switch (*ecode) |
| 2452 | { | |
| 2453 | case OP_CRSTAR: | |
| 2454 | case OP_CRMINSTAR: | |
| 2455 | case OP_CRPLUS: | |
| 2456 | case OP_CRMINPLUS: | |
| 2457 | case OP_CRQUERY: | |
| 2458 | case OP_CRMINQUERY: | |
| 2459 | c = *ecode++ - OP_CRSTAR; | |
| 2460 | minimize = (c & 1) != 0; | |
| 2461 | min = rep_min[c]; /* Pick up values from tables; */ | |
| 2462 | max = rep_max[c]; /* zero for max => infinity */ | |
| 2463 | if (max == 0) max = INT_MAX; | |
| 2464 | break; | |
| 2465 | ||
| 2466 | case OP_CRRANGE: | |
| 2467 | case OP_CRMINRANGE: | |
| 2468 | minimize = (*ecode == OP_CRMINRANGE); | |
| 2469 | min = GET2(ecode, 1); | |
| 2470 | max = GET2(ecode, 3); | |
| 2471 | if (max == 0) max = INT_MAX; | |
| 2472 | ecode += 5; | |
| 2473 | break; | |
| 2474 | ||
| 2475 | default: /* No repeat follows */ | |
| 2476 | if ((length = match_ref(offset, eptr, length, md, caseless)) < 0) | |
| 2477 | { | { |
| 2478 | case OP_CRSTAR: | CHECK_PARTIAL(); |
| 2479 | case OP_CRMINSTAR: | MRRETURN(MATCH_NOMATCH); |
| 2480 | case OP_CRPLUS: | } |
| 2481 | case OP_CRMINPLUS: | eptr += length; |
| 2482 | case OP_CRQUERY: | continue; /* With the main loop */ |
| 2483 | case OP_CRMINQUERY: | } |
| c = *ecode++ - OP_CRSTAR; | ||
| minimize = (c & 1) != 0; | ||
| min = rep_min[c]; /* Pick up values from tables; */ | ||
| max = rep_max[c]; /* zero for max => infinity */ | ||
| if (max == 0) max = INT_MAX; | ||
| break; | ||
| 2484 | ||
| 2485 | case OP_CRRANGE: | /* Handle repeated back references. If the length of the reference is |
| 2486 | case OP_CRMINRANGE: | zero, just continue with the main loop. */ |
| minimize = (*ecode == OP_CRMINRANGE); | ||
| min = GET2(ecode, 1); | ||
| max = GET2(ecode, 3); | ||
| if (max == 0) max = INT_MAX; | ||
| ecode += 5; | ||
| break; | ||
| 2487 | ||
| 2488 | default: /* No repeat follows */ | if (length == 0) continue; |
| 2489 | if (!match_ref(offset, eptr, length, md, ims)) | |
| 2490 | { | /* First, ensure the minimum number of matches are present. We get back |
| 2491 | CHECK_PARTIAL(); | the length of the reference string explicitly rather than passing the |
| 2492 | RRETURN(MATCH_NOMATCH); | address of eptr, so that eptr can be a register variable. */ |
| 2493 | } | |
| 2494 | eptr += length; | for (i = 1; i <= min; i++) |
| 2495 | continue; /* With the main loop */ | { |
| 2496 | int slength; | |
| 2497 | if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0) | |
| 2498 | { | |
| 2499 | CHECK_PARTIAL(); | |
| 2500 | MRRETURN(MATCH_NOMATCH); | |
| 2501 | } | } |
| 2502 | eptr += slength; | |
| 2503 | } | |
| 2504 | ||
| 2505 | /* If the length of the reference is zero, just continue with the | /* If min = max, continue at the same level without recursion. |
| 2506 | main loop. */ | They are not both allowed to be zero. */ |
| 2507 | ||
| 2508 | if (length == 0) continue; | if (min == max) continue; |
| 2509 | ||
| 2510 | /* First, ensure the minimum number of matches are present. We get back | /* If minimizing, keep trying and advancing the pointer */ |
| the length of the reference string explicitly rather than passing the | ||
| address of eptr, so that eptr can be a register variable. */ | ||
| 2511 | ||
| 2512 | for (i = 1; i <= min; i++) | if (minimize) |
| 2513 | { | |
| 2514 | for (fi = min;; fi++) | |
| 2515 | { | { |
| 2516 | if (!match_ref(offset, eptr, length, md, ims)) | int slength; |
| 2517 | RMATCH(eptr, ecode, offset_top, md, eptrb, RM14); | |
| 2518 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | |
| 2519 | if (fi >= max) MRRETURN(MATCH_NOMATCH); | |
| 2520 | if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0) | |
| 2521 | { | { |
| 2522 | CHECK_PARTIAL(); | CHECK_PARTIAL(); |
| 2523 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2524 | } | } |
| 2525 | eptr += length; | eptr += slength; |
| 2526 | } | } |
| 2527 | /* Control never gets here */ | |
| 2528 | } | |
| 2529 | ||
| 2530 | /* If min = max, continue at the same level without recursion. | /* If maximizing, find the longest string and work backwards */ |
| They are not both allowed to be zero. */ | ||
| if (min == max) continue; | ||
| /* If minimizing, keep trying and advancing the pointer */ | ||
| 2531 | ||
| 2532 | if (minimize) | else |
| 2533 | { | |
| 2534 | pp = eptr; | |
| 2535 | for (i = min; i < max; i++) | |
| 2536 | { | { |
| 2537 | for (fi = min;; fi++) | int slength; |
| 2538 | if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0) | |
| 2539 | { | { |
| 2540 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM14); | CHECK_PARTIAL(); |
| 2541 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | break; |
| if (fi >= max) RRETURN(MATCH_NOMATCH); | ||
| if (!match_ref(offset, eptr, length, md, ims)) | ||
| { | ||
| CHECK_PARTIAL(); | ||
| RRETURN(MATCH_NOMATCH); | ||
| } | ||
| eptr += length; | ||
| 2542 | } | } |
| 2543 | /* Control never gets here */ | eptr += slength; |
| 2544 | } | } |
| 2545 | while (eptr >= pp) | |
| /* If maximizing, find the longest string and work backwards */ | ||
| else | ||
| 2546 | { | { |
| 2547 | pp = eptr; | RMATCH(eptr, ecode, offset_top, md, eptrb, RM15); |
| 2548 | for (i = min; i < max; i++) | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2549 | { | eptr -= length; |
| if (!match_ref(offset, eptr, length, md, ims)) | ||
| { | ||
| 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; | ||
| } | ||
| RRETURN(MATCH_NOMATCH); | ||
| 2550 | } | } |
| 2551 | MRRETURN(MATCH_NOMATCH); | |
| 2552 | } | } |
| 2553 | /* Control never gets here */ | /* Control never gets here */ |
| 2554 | ||
| # | Line 2240 for (;;) | Line 2609 for (;;) |
| 2609 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2610 | { | { |
| 2611 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2612 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2613 | } | } |
| 2614 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 2615 | if (c > 255) | if (c > 255) |
| 2616 | { | { |
| 2617 | if (op == OP_CLASS) RRETURN(MATCH_NOMATCH); | if (op == OP_CLASS) MRRETURN(MATCH_NOMATCH); |
| 2618 | } | } |
| 2619 | else | else |
| 2620 | { | { |
| 2621 | if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH); | if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH); |
| 2622 | } | } |
| 2623 | } | } |
| 2624 | } | } |
| # | Line 2262 for (;;) | Line 2631 for (;;) |
| 2631 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2632 | { | { |
| 2633 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2634 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2635 | } | } |
| 2636 | c = *eptr++; | c = *eptr++; |
| 2637 | if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH); | if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH); |
| 2638 | } | } |
| 2639 | } | } |
| 2640 | ||
| # | Line 2285 for (;;) | Line 2654 for (;;) |
| 2654 | { | { |
| 2655 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 2656 | { | { |
| 2657 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM16); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM16); |
| 2658 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2659 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 2660 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2661 | { | { |
| 2662 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2663 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2664 | } | } |
| 2665 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 2666 | if (c > 255) | if (c > 255) |
| 2667 | { | { |
| 2668 | if (op == OP_CLASS) RRETURN(MATCH_NOMATCH); | if (op == OP_CLASS) MRRETURN(MATCH_NOMATCH); |
| 2669 | } | } |
| 2670 | else | else |
| 2671 | { | { |
| 2672 | if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH); | if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH); |
| 2673 | } | } |
| 2674 | } | } |
| 2675 | } | } |
| # | Line 2310 for (;;) | Line 2679 for (;;) |
| 2679 | { | { |
| 2680 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 2681 | { | { |
| 2682 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM17); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM17); |
| 2683 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2684 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 2685 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2686 | { | { |
| 2687 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2688 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2689 | } | } |
| 2690 | c = *eptr++; | c = *eptr++; |
| 2691 | if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH); | if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH); |
| 2692 | } | } |
| 2693 | } | } |
| 2694 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 2356 for (;;) | Line 2725 for (;;) |
| 2725 | } | } |
| 2726 | for (;;) | for (;;) |
| 2727 | { | { |
| 2728 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM18); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM18); |
| 2729 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2730 | if (eptr-- == pp) break; /* Stop if tried at original pos */ | if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 2731 | BACKCHAR(eptr); | BACKCHAR(eptr); |
| # | Line 2379 for (;;) | Line 2748 for (;;) |
| 2748 | } | } |
| 2749 | while (eptr >= pp) | while (eptr >= pp) |
| 2750 | { | { |
| 2751 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM19); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM19); |
| 2752 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2753 | eptr--; | eptr--; |
| 2754 | } | } |
| 2755 | } | } |
| 2756 | ||
| 2757 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2758 | } | } |
| 2759 | } | } |
| 2760 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 2437 for (;;) | Line 2806 for (;;) |
| 2806 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2807 | { | { |
| 2808 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2809 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2810 | } | } |
| 2811 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2812 | if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH); | if (!_pcre_xclass(c, data)) MRRETURN(MATCH_NOMATCH); |
| 2813 | } | } |
| 2814 | ||
| 2815 | /* 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 2824 for (;;) |
| 2824 | { | { |
| 2825 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 2826 | { | { |
| 2827 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM20); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM20); |
| 2828 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2829 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 2830 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 2831 | { | { |
| 2832 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 2833 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2834 | } | } |
| 2835 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 2836 | if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH); | if (!_pcre_xclass(c, data)) MRRETURN(MATCH_NOMATCH); |
| 2837 | } | } |
| 2838 | /* Control never gets here */ | /* Control never gets here */ |
| 2839 | } | } |
| # | Line 2488 for (;;) | Line 2857 for (;;) |
| 2857 | } | } |
| 2858 | for(;;) | for(;;) |
| 2859 | { | { |
| 2860 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM21); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM21); |
| 2861 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2862 | if (eptr-- == pp) break; /* Stop if tried at original pos */ | if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 2863 | if (utf8) BACKCHAR(eptr); | if (utf8) BACKCHAR(eptr); |
| 2864 | } | } |
| 2865 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2866 | } | } |
| 2867 | ||
| 2868 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 2512 for (;;) | Line 2881 for (;;) |
| 2881 | if (length > md->end_subject - eptr) | if (length > md->end_subject - eptr) |
| 2882 | { | { |
| 2883 | CHECK_PARTIAL(); /* Not SCHECK_PARTIAL() */ | CHECK_PARTIAL(); /* Not SCHECK_PARTIAL() */ |
| 2884 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2885 | } | } |
| 2886 | while (length-- > 0) if (*ecode++ != *eptr++) RRETURN(MATCH_NOMATCH); | while (length-- > 0) if (*ecode++ != *eptr++) MRRETURN(MATCH_NOMATCH); |
| 2887 | } | } |
| 2888 | else | else |
| 2889 | #endif | #endif |
| # | Line 2524 for (;;) | Line 2893 for (;;) |
| 2893 | if (md->end_subject - eptr < 1) | if (md->end_subject - eptr < 1) |
| 2894 | { | { |
| 2895 | SCHECK_PARTIAL(); /* This one can use SCHECK_PARTIAL() */ | SCHECK_PARTIAL(); /* This one can use SCHECK_PARTIAL() */ |
| 2896 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2897 | } | } |
| 2898 | if (ecode[1] != *eptr++) RRETURN(MATCH_NOMATCH); | if (ecode[1] != *eptr++) MRRETURN(MATCH_NOMATCH); |
| 2899 | ecode += 2; | ecode += 2; |
| 2900 | } | } |
| 2901 | break; | break; |
| 2902 | ||
| 2903 | /* Match a single character, caselessly */ | /* Match a single character, caselessly */ |
| 2904 | ||
| 2905 | case OP_CHARNC: | case OP_CHARI: |
| 2906 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| 2907 | if (utf8) | if (utf8) |
| 2908 | { | { |
| # | Line 2544 for (;;) | Line 2913 for (;;) |
| 2913 | if (length > md->end_subject - eptr) | if (length > md->end_subject - eptr) |
| 2914 | { | { |
| 2915 | CHECK_PARTIAL(); /* Not SCHECK_PARTIAL() */ | CHECK_PARTIAL(); /* Not SCHECK_PARTIAL() */ |
| 2916 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2917 | } | } |
| 2918 | ||
| 2919 | /* 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 2921 for (;;) |
| 2921 | ||
| 2922 | if (fc < 128) | if (fc < 128) |
| 2923 | { | { |
| 2924 | if (md->lcc[*ecode++] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); | if (md->lcc[*ecode++] != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH); |
| 2925 | } | } |
| 2926 | ||
| 2927 | /* Otherwise we must pick up the subject character */ | /* Otherwise we must pick up the subject character */ |
| # | Line 2571 for (;;) | Line 2940 for (;;) |
| 2940 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 2941 | if (dc != UCD_OTHERCASE(fc)) | if (dc != UCD_OTHERCASE(fc)) |
| 2942 | #endif | #endif |
| 2943 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2944 | } | } |
| 2945 | } | } |
| 2946 | } | } |
| # | Line 2583 for (;;) | Line 2952 for (;;) |
| 2952 | if (md->end_subject - eptr < 1) | if (md->end_subject - eptr < 1) |
| 2953 | { | { |
| 2954 | SCHECK_PARTIAL(); /* This one can use SCHECK_PARTIAL() */ | SCHECK_PARTIAL(); /* This one can use SCHECK_PARTIAL() */ |
| 2955 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 2956 | } | } |
| 2957 | if (md->lcc[ecode[1]] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); | if (md->lcc[ecode[1]] != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH); |
| 2958 | ecode += 2; | ecode += 2; |
| 2959 | } | } |
| 2960 | break; | break; |
| # | Line 2593 for (;;) | Line 2962 for (;;) |
| 2962 | /* Match a single character repeatedly. */ | /* Match a single character repeatedly. */ |
| 2963 | ||
| 2964 | case OP_EXACT: | case OP_EXACT: |
| 2965 | case OP_EXACTI: | |
| 2966 | min = max = GET2(ecode, 1); | min = max = GET2(ecode, 1); |
| 2967 | ecode += 3; | ecode += 3; |
| 2968 | goto REPEATCHAR; | goto REPEATCHAR; |
| 2969 | ||
| 2970 | case OP_POSUPTO: | case OP_POSUPTO: |
| 2971 | case OP_POSUPTOI: | |
| 2972 | possessive = TRUE; | possessive = TRUE; |
| 2973 | /* Fall through */ | /* Fall through */ |
| 2974 | ||
| 2975 | case OP_UPTO: | case OP_UPTO: |
| 2976 | case OP_UPTOI: | |
| 2977 | case OP_MINUPTO: | case OP_MINUPTO: |
| 2978 | case OP_MINUPTOI: | |
| 2979 | min = 0; | min = 0; |
| 2980 | max = GET2(ecode, 1); | max = GET2(ecode, 1); |
| 2981 | minimize = *ecode == OP_MINUPTO; | minimize = *ecode == OP_MINUPTO || *ecode == OP_MINUPTOI; |
| 2982 | ecode += 3; | ecode += 3; |
| 2983 | goto REPEATCHAR; | goto REPEATCHAR; |
| 2984 | ||
| 2985 | case OP_POSSTAR: | case OP_POSSTAR: |
| 2986 | case OP_POSSTARI: | |
| 2987 | possessive = TRUE; | possessive = TRUE; |
| 2988 | min = 0; | min = 0; |
| 2989 | max = INT_MAX; | max = INT_MAX; |
| # | Line 2617 for (;;) | Line 2991 for (;;) |
| 2991 | goto REPEATCHAR; | goto REPEATCHAR; |
| 2992 | ||
| 2993 | case OP_POSPLUS: | case OP_POSPLUS: |
| 2994 | case OP_POSPLUSI: | |
| 2995 | possessive = TRUE; | possessive = TRUE; |
| 2996 | min = 1; | min = 1; |
| 2997 | max = INT_MAX; | max = INT_MAX; |
| # | Line 2624 for (;;) | Line 2999 for (;;) |
| 2999 | goto REPEATCHAR; | goto REPEATCHAR; |
| 3000 | ||
| 3001 | case OP_POSQUERY: | case OP_POSQUERY: |
| 3002 | case OP_POSQUERYI: | |
| 3003 | possessive = TRUE; | possessive = TRUE; |
| 3004 | min = 0; | min = 0; |
| 3005 | max = 1; | max = 1; |
| # | Line 2631 for (;;) | Line 3007 for (;;) |
| 3007 | goto REPEATCHAR; | goto REPEATCHAR; |
| 3008 | ||
| 3009 | case OP_STAR: | case OP_STAR: |
| 3010 | case OP_STARI: | |
| 3011 | case OP_MINSTAR: | case OP_MINSTAR: |
| 3012 | case OP_MINSTARI: | |
| 3013 | case OP_PLUS: | case OP_PLUS: |
| 3014 | case OP_PLUSI: | |
| 3015 | case OP_MINPLUS: | case OP_MINPLUS: |
| 3016 | case OP_MINPLUSI: | |
| 3017 | case OP_QUERY: | case OP_QUERY: |
| 3018 | case OP_QUERYI: | |
| 3019 | case OP_MINQUERY: | case OP_MINQUERY: |
| 3020 | c = *ecode++ - OP_STAR; | case OP_MINQUERYI: |
| 3021 | c = *ecode++ - ((op < OP_STARI)? OP_STAR : OP_STARI); | |
| 3022 | minimize = (c & 1) != 0; | minimize = (c & 1) != 0; |
| 3023 | min = rep_min[c]; /* Pick up values from tables; */ | min = rep_min[c]; /* Pick up values from tables; */ |
| 3024 | max = rep_max[c]; /* zero for max => infinity */ | max = rep_max[c]; /* zero for max => infinity */ |
| 3025 | if (max == 0) max = INT_MAX; | if (max == 0) max = INT_MAX; |
| # | Line 2661 for (;;) | Line 3042 for (;;) |
| 3042 | { | { |
| 3043 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 3044 | unsigned int othercase; | unsigned int othercase; |
| 3045 | if ((ims & PCRE_CASELESS) != 0 && | if (op >= OP_STARI && /* Caseless */ |
| 3046 | (othercase = UCD_OTHERCASE(fc)) != fc) | (othercase = UCD_OTHERCASE(fc)) != fc) |
| 3047 | oclength = _pcre_ord2utf8(othercase, occhars); | oclength = _pcre_ord2utf8(othercase, occhars); |
| 3048 | else oclength = 0; | else oclength = 0; |
| # | Line 2679 for (;;) | Line 3060 for (;;) |
| 3060 | else | else |
| 3061 | { | { |
| 3062 | CHECK_PARTIAL(); | CHECK_PARTIAL(); |
| 3063 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3064 | } | } |
| 3065 | } | } |
| 3066 | ||
| # | Line 2689 for (;;) | Line 3070 for (;;) |
| 3070 | { | { |
| 3071 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 3072 | { | { |
| 3073 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM22); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM22); |
| 3074 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3075 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 3076 | if (eptr <= md->end_subject - length && | if (eptr <= md->end_subject - length && |
| 3077 | memcmp(eptr, charptr, length) == 0) eptr += length; | memcmp(eptr, charptr, length) == 0) eptr += length; |
| 3078 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| # | Line 2702 for (;;) | Line 3083 for (;;) |
| 3083 | else | else |
| 3084 | { | { |
| 3085 | CHECK_PARTIAL(); | CHECK_PARTIAL(); |
| 3086 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3087 | } | } |
| 3088 | } | } |
| 3089 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 2731 for (;;) | Line 3112 for (;;) |
| 3112 | ||
| 3113 | for(;;) | for(;;) |
| 3114 | { | { |
| 3115 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM23); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM23); |
| 3116 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3117 | if (eptr == pp) { RRETURN(MATCH_NOMATCH); } | if (eptr == pp) { MRRETURN(MATCH_NOMATCH); } |
| 3118 | #ifdef SUPPORT_UCP | #ifdef SUPPORT_UCP |
| 3119 | eptr--; | eptr--; |
| 3120 | BACKCHAR(eptr); | BACKCHAR(eptr); |
| # | Line 2768 for (;;) | Line 3149 for (;;) |
| 3149 | DPRINTF(("matching %c{%d,%d} against subject %.*s\n", fc, min, max, | DPRINTF(("matching %c{%d,%d} against subject %.*s\n", fc, min, max, |
| 3150 | max, eptr)); | max, eptr)); |
| 3151 | ||
| 3152 | if ((ims & PCRE_CASELESS) != 0) | if (op >= OP_STARI) /* Caseless */ |
| 3153 | { | { |
| 3154 | fc = md->lcc[fc]; | fc = md->lcc[fc]; |
| 3155 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| # | Line 2776 for (;;) | Line 3157 for (;;) |
| 3157 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3158 | { | { |
| 3159 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3160 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3161 | } | } |
| 3162 | if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); | if (fc != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH); |
| 3163 | } | } |
| 3164 | if (min == max) continue; | if (min == max) continue; |
| 3165 | if (minimize) | if (minimize) |
| 3166 | { | { |
| 3167 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 3168 | { | { |
| 3169 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM24); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM24); |
| 3170 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3171 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 3172 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3173 | { | { |
| 3174 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3175 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3176 | } | } |
| 3177 | if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); | if (fc != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH); |
| 3178 | } | } |
| 3179 | /* Control never gets here */ | /* Control never gets here */ |
| 3180 | } | } |
| # | Line 2815 for (;;) | Line 3196 for (;;) |
| 3196 | ||
| 3197 | while (eptr >= pp) | while (eptr >= pp) |
| 3198 | { | { |
| 3199 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM25); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM25); |
| 3200 | eptr--; | eptr--; |
| 3201 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3202 | } | } |
| 3203 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3204 | } | } |
| 3205 | /* Control never gets here */ | /* Control never gets here */ |
| 3206 | } | } |
| # | Line 2833 for (;;) | Line 3214 for (;;) |
| 3214 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3215 | { | { |
| 3216 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3217 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3218 | } | } |
| 3219 | if (fc != *eptr++) RRETURN(MATCH_NOMATCH); | if (fc != *eptr++) MRRETURN(MATCH_NOMATCH); |
| 3220 | } | } |
| 3221 | ||
| 3222 | if (min == max) continue; | if (min == max) continue; |
| # | Line 2844 for (;;) | Line 3225 for (;;) |
| 3225 | { | { |
| 3226 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 3227 | { | { |
| 3228 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM26); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM26); |
| 3229 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3230 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 3231 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3232 | { | { |
| 3233 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3234 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3235 | } | } |
| 3236 | if (fc != *eptr++) RRETURN(MATCH_NOMATCH); | if (fc != *eptr++) MRRETURN(MATCH_NOMATCH); |
| 3237 | } | } |
| 3238 | /* Control never gets here */ | /* Control never gets here */ |
| 3239 | } | } |
| # | Line 2873 for (;;) | Line 3254 for (;;) |
| 3254 | ||
| 3255 | while (eptr >= pp) | while (eptr >= pp) |
| 3256 | { | { |
| 3257 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM27); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM27); |
| 3258 | eptr--; | eptr--; |
| 3259 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3260 | } | } |
| 3261 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3262 | } | } |
| 3263 | } | } |
| 3264 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 2886 for (;;) | Line 3267 for (;;) |
| 3267 | checking can be multibyte. */ | checking can be multibyte. */ |
| 3268 | ||
| 3269 | case OP_NOT: | case OP_NOT: |
| 3270 | case OP_NOTI: | |
| 3271 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3272 | { | { |
| 3273 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3274 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3275 | } | } |
| 3276 | ecode++; | ecode++; |
| 3277 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3278 | if ((ims & PCRE_CASELESS) != 0) | if (op == OP_NOTI) /* The caseless case */ |
| 3279 | { | { |
| 3280 | #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF8 |
| 3281 | if (c < 256) | if (c < 256) |
| 3282 | #endif | #endif |
| 3283 | c = md->lcc[c]; | c = md->lcc[c]; |
| 3284 | if (md->lcc[*ecode++] == c) RRETURN(MATCH_NOMATCH); | if (md->lcc[*ecode++] == c) MRRETURN(MATCH_NOMATCH); |
| 3285 | } | } |
| 3286 | else | else /* Caseful */ |
| 3287 | { | { |
| 3288 | if (*ecode++ == c) RRETURN(MATCH_NOMATCH); | if (*ecode++ == c) MRRETURN(MATCH_NOMATCH); |
| 3289 | } | } |
| 3290 | break; | break; |
| 3291 | ||
| # | Line 2915 for (;;) | Line 3297 for (;;) |
| 3297 | about... */ | about... */ |
| 3298 | ||
| 3299 | case OP_NOTEXACT: | case OP_NOTEXACT: |
| 3300 | case OP_NOTEXACTI: | |
| 3301 | min = max = GET2(ecode, 1); | min = max = GET2(ecode, 1); |
| 3302 | ecode += 3; | ecode += 3; |
| 3303 | goto REPEATNOTCHAR; | goto REPEATNOTCHAR; |
| 3304 | ||
| 3305 | case OP_NOTUPTO: | case OP_NOTUPTO: |
| 3306 | case OP_NOTUPTOI: | |
| 3307 | case OP_NOTMINUPTO: | case OP_NOTMINUPTO: |
| 3308 | case OP_NOTMINUPTOI: | |
| 3309 | min = 0; | min = 0; |
| 3310 | max = GET2(ecode, 1); | max = GET2(ecode, 1); |
| 3311 | minimize = *ecode == OP_NOTMINUPTO; | minimize = *ecode == OP_NOTMINUPTO || *ecode == OP_NOTMINUPTOI; |
| 3312 | ecode += 3; | ecode += 3; |
| 3313 | goto REPEATNOTCHAR; | goto REPEATNOTCHAR; |
| 3314 | ||
| 3315 | case OP_NOTPOSSTAR: | case OP_NOTPOSSTAR: |
| 3316 | case OP_NOTPOSSTARI: | |
| 3317 | possessive = TRUE; | possessive = TRUE; |
| 3318 | min = 0; | min = 0; |
| 3319 | max = INT_MAX; | max = INT_MAX; |
| # | Line 2935 for (;;) | Line 3321 for (;;) |
| 3321 | goto REPEATNOTCHAR; | goto REPEATNOTCHAR; |
| 3322 | ||
| 3323 | case OP_NOTPOSPLUS: | case OP_NOTPOSPLUS: |
| 3324 | case OP_NOTPOSPLUSI: | |
| 3325 | possessive = TRUE; | possessive = TRUE; |
| 3326 | min = 1; | min = 1; |
| 3327 | max = INT_MAX; | max = INT_MAX; |
| # | Line 2942 for (;;) | Line 3329 for (;;) |
| 3329 | goto REPEATNOTCHAR; | goto REPEATNOTCHAR; |
| 3330 | ||
| 3331 | case OP_NOTPOSQUERY: | case OP_NOTPOSQUERY: |
| 3332 | case OP_NOTPOSQUERYI: | |
| 3333 | possessive = TRUE; | possessive = TRUE; |
| 3334 | min = 0; | min = 0; |
| 3335 | max = 1; | max = 1; |
| # | Line 2949 for (;;) | Line 3337 for (;;) |
| 3337 | goto REPEATNOTCHAR; | goto REPEATNOTCHAR; |
| 3338 | ||
| 3339 | case OP_NOTPOSUPTO: | case OP_NOTPOSUPTO: |
| 3340 | case OP_NOTPOSUPTOI: | |
| 3341 | possessive = TRUE; | possessive = TRUE; |
| 3342 | min = 0; | min = 0; |
| 3343 | max = GET2(ecode, 1); | max = GET2(ecode, 1); |
| # | Line 2956 for (;;) | Line 3345 for (;;) |
| 3345 | goto REPEATNOTCHAR; | goto REPEATNOTCHAR; |
| 3346 | ||
| 3347 | case OP_NOTSTAR: | case OP_NOTSTAR: |
| 3348 | case OP_NOTSTARI: | |
| 3349 | case OP_NOTMINSTAR: | case OP_NOTMINSTAR: |
| 3350 | case OP_NOTMINSTARI: | |
| 3351 | case OP_NOTPLUS: | case OP_NOTPLUS: |
| 3352 | case OP_NOTPLUSI: | |
| 3353 | case OP_NOTMINPLUS: | case OP_NOTMINPLUS: |
| 3354 | case OP_NOTMINPLUSI: | |
| 3355 | case OP_NOTQUERY: | case OP_NOTQUERY: |
| 3356 | case OP_NOTQUERYI: | |
| 3357 | case OP_NOTMINQUERY: | case OP_NOTMINQUERY: |
| 3358 | c = *ecode++ - OP_NOTSTAR; | case OP_NOTMINQUERYI: |
| 3359 | c = *ecode++ - ((op >= OP_NOTSTARI)? OP_NOTSTARI: OP_NOTSTAR); | |
| 3360 | minimize = (c & 1) != 0; | minimize = (c & 1) != 0; |
| 3361 | min = rep_min[c]; /* Pick up values from tables; */ | min = rep_min[c]; /* Pick up values from tables; */ |
| 3362 | max = rep_max[c]; /* zero for max => infinity */ | max = rep_max[c]; /* zero for max => infinity */ |
| # | Line 2983 for (;;) | Line 3378 for (;;) |
| 3378 | 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, |
| 3379 | max, eptr)); | max, eptr)); |
| 3380 | ||
| 3381 | if ((ims & PCRE_CASELESS) != 0) | if (op >= OP_NOTSTARI) /* Caseless */ |
| 3382 | { | { |
| 3383 | fc = md->lcc[fc]; | fc = md->lcc[fc]; |
| 3384 | ||
| # | Line 2997 for (;;) | Line 3392 for (;;) |
| 3392 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3393 | { | { |
| 3394 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3395 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3396 | } | } |
| 3397 | GETCHARINC(d, eptr); | GETCHARINC(d, eptr); |
| 3398 | if (d < 256) d = md->lcc[d]; | if (d < 256) d = md->lcc[d]; |
| 3399 | if (fc == d) RRETURN(MATCH_NOMATCH); | if (fc == d) MRRETURN(MATCH_NOMATCH); |
| 3400 | } | } |
| 3401 | } | } |
| 3402 | else | else |
| # | Line 3014 for (;;) | Line 3409 for (;;) |
| 3409 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3410 | { | { |
| 3411 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3412 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3413 | } | } |
| 3414 | if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); | if (fc == md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH); |
| 3415 | } | } |
| 3416 | } | } |
| 3417 | ||
| # | Line 3031 for (;;) | Line 3426 for (;;) |
| 3426 | register unsigned int d; | register unsigned int d; |
| 3427 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 3428 | { | { |
| 3429 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM28); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM28); |
| 3430 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3431 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 3432 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3433 | { | { |
| 3434 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3435 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3436 | } | } |
| 3437 | GETCHARINC(d, eptr); | GETCHARINC(d, eptr); |
| 3438 | if (d < 256) d = md->lcc[d]; | if (d < 256) d = md->lcc[d]; |
| 3439 | if (fc == d) RRETURN(MATCH_NOMATCH); | if (fc == d) MRRETURN(MATCH_NOMATCH); |
| 3440 | } | } |
| 3441 | } | } |
| 3442 | else | else |
| # | Line 3050 for (;;) | Line 3445 for (;;) |
| 3445 | { | { |
| 3446 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 3447 | { | { |
| 3448 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM29); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM29); |
| 3449 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3450 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 3451 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3452 | { | { |
| 3453 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3454 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3455 | } | } |
| 3456 | if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); | if (fc == md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH); |
| 3457 | } | } |
| 3458 | } | } |
| 3459 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 3091 for (;;) | Line 3486 for (;;) |
| 3486 | if (possessive) continue; | if (possessive) continue; |
| 3487 | for(;;) | for(;;) |
| 3488 | { | { |
| 3489 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM30); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM30); |
| 3490 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3491 | if (eptr-- == pp) break; /* Stop if tried at original pos */ | if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 3492 | BACKCHAR(eptr); | BACKCHAR(eptr); |
| # | Line 3114 for (;;) | Line 3509 for (;;) |
| 3509 | if (possessive) continue; | if (possessive) continue; |
| 3510 | while (eptr >= pp) | while (eptr >= pp) |
| 3511 | { | { |
| 3512 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM31); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM31); |
| 3513 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3514 | eptr--; | eptr--; |
| 3515 | } | } |
| 3516 | } | } |
| 3517 | ||
| 3518 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3519 | } | } |
| 3520 | /* Control never gets here */ | /* Control never gets here */ |
| 3521 | } | } |
| # | Line 3139 for (;;) | Line 3534 for (;;) |
| 3534 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3535 | { | { |
| 3536 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3537 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3538 | } | } |
| 3539 | GETCHARINC(d, eptr); | GETCHARINC(d, eptr); |
| 3540 | if (fc == d) RRETURN(MATCH_NOMATCH); | if (fc == d) MRRETURN(MATCH_NOMATCH); |
| 3541 | } | } |
| 3542 | } | } |
| 3543 | else | else |
| # | Line 3154 for (;;) | Line 3549 for (;;) |
| 3549 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3550 | { | { |
| 3551 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3552 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3553 | } | } |
| 3554 | if (fc == *eptr++) RRETURN(MATCH_NOMATCH); | if (fc == *eptr++) MRRETURN(MATCH_NOMATCH); |
| 3555 | } | } |
| 3556 | } | } |
| 3557 | ||
| # | Line 3171 for (;;) | Line 3566 for (;;) |
| 3566 | register unsigned int d; | register unsigned int d; |
| 3567 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 3568 | { | { |
| 3569 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM32); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM32); |
| 3570 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3571 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 3572 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3573 | { | { |
| 3574 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3575 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3576 | } | } |
| 3577 | GETCHARINC(d, eptr); | GETCHARINC(d, eptr); |
| 3578 | if (fc == d) RRETURN(MATCH_NOMATCH); | if (fc == d) MRRETURN(MATCH_NOMATCH); |
| 3579 | } | } |
| 3580 | } | } |
| 3581 | else | else |
| # | Line 3189 for (;;) | Line 3584 for (;;) |
| 3584 | { | { |
| 3585 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 3586 | { | { |
| 3587 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM33); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM33); |
| 3588 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3589 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 3590 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3591 | { | { |
| 3592 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3593 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3594 | } | } |
| 3595 | if (fc == *eptr++) RRETURN(MATCH_NOMATCH); | if (fc == *eptr++) MRRETURN(MATCH_NOMATCH); |
| 3596 | } | } |
| 3597 | } | } |
| 3598 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 3229 for (;;) | Line 3624 for (;;) |
| 3624 | if (possessive) continue; | if (possessive) continue; |
| 3625 | for(;;) | for(;;) |
| 3626 | { | { |
| 3627 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM34); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM34); |
| 3628 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3629 | if (eptr-- == pp) break; /* Stop if tried at original pos */ | if (eptr-- == pp) break; /* Stop if tried at original pos */ |
| 3630 | BACKCHAR(eptr); | BACKCHAR(eptr); |
| # | Line 3252 for (;;) | Line 3647 for (;;) |
| 3647 | if (possessive) continue; | if (possessive) continue; |
| 3648 | while (eptr >= pp) | while (eptr >= pp) |
| 3649 | { | { |
| 3650 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM35); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM35); |
| 3651 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3652 | eptr--; | eptr--; |
| 3653 | } | } |
| 3654 | } | } |
| 3655 | ||
| 3656 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3657 | } | } |
| 3658 | } | } |
| 3659 | /* Control never gets here */ | /* Control never gets here */ |
| # | Line 3352 for (;;) | Line 3747 for (;;) |
| 3747 | switch(prop_type) | switch(prop_type) |
| 3748 | { | { |
| 3749 | case PT_ANY: | case PT_ANY: |
| 3750 | if (prop_fail_result) RRETURN(MATCH_NOMATCH); | if (prop_fail_result) MRRETURN(MATCH_NOMATCH); |
| 3751 | for (i = 1; i <= min; i++) | for (i = 1; i <= min; i++) |
| 3752 | { | { |
| 3753 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3754 | { | { |
| 3755 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3756 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3757 | } | } |
| 3758 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3759 | } | } |
| # | Line 3370 for (;;) | Line 3765 for (;;) |
| 3765 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3766 | { | { |
| 3767 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3768 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3769 | } | } |
| 3770 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3771 | prop_chartype = UCD_CHARTYPE(c); | prop_chartype = UCD_CHARTYPE(c); |
| 3772 | if ((prop_chartype == ucp_Lu || | if ((prop_chartype == ucp_Lu || |
| 3773 | prop_chartype == ucp_Ll || | prop_chartype == ucp_Ll || |
| 3774 | prop_chartype == ucp_Lt) == prop_fail_result) | prop_chartype == ucp_Lt) == prop_fail_result) |
| 3775 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3776 | } | } |
| 3777 | break; | break; |
| 3778 | ||
| # | Line 3387 for (;;) | Line 3782 for (;;) |
| 3782 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3783 | { | { |
| 3784 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3785 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3786 | } | } |
| 3787 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3788 | prop_category = UCD_CATEGORY(c); | prop_category = UCD_CATEGORY(c); |
| 3789 | if ((prop_category == prop_value) == prop_fail_result) | if ((prop_category == prop_value) == prop_fail_result) |
| 3790 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3791 | } | } |
| 3792 | break; | break; |
| 3793 | ||
| # | Line 3402 for (;;) | Line 3797 for (;;) |
| 3797 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3798 | { | { |
| 3799 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3800 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3801 | } | } |
| 3802 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3803 | prop_chartype = UCD_CHARTYPE(c); | prop_chartype = UCD_CHARTYPE(c); |
| 3804 | if ((prop_chartype == prop_value) == prop_fail_result) | if ((prop_chartype == prop_value) == prop_fail_result) |
| 3805 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3806 | } | } |
| 3807 | break; | break; |
| 3808 | ||
| # | Line 3417 for (;;) | Line 3812 for (;;) |
| 3812 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3813 | { | { |
| 3814 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3815 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3816 | } | } |
| 3817 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3818 | prop_script = UCD_SCRIPT(c); | prop_script = UCD_SCRIPT(c); |
| 3819 | if ((prop_script == prop_value) == prop_fail_result) | if ((prop_script == prop_value) == prop_fail_result) |
| 3820 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3821 | } | |
| 3822 | break; | |
| 3823 | ||
| 3824 | case PT_ALNUM: | |
| 3825 | for (i = 1; i <= min; i++) | |
| 3826 | { | |
| 3827 | if (eptr >= md->end_subject) | |
| 3828 | { | |
| 3829 | SCHECK_PARTIAL(); | |
| 3830 | MRRETURN(MATCH_NOMATCH); | |
| 3831 | } | |
| 3832 | GETCHARINCTEST(c, eptr); | |
| 3833 | prop_category = UCD_CATEGORY(c); | |
| 3834 | if ((prop_category == ucp_L || prop_category == ucp_N) | |
| 3835 | == prop_fail_result) | |
| 3836 | MRRETURN(MATCH_NOMATCH); | |
| 3837 | } | |
| 3838 | break; | |
| 3839 | ||
| 3840 | case PT_SPACE: /* Perl space */ | |
| 3841 | for (i = 1; i <= min; i++) | |
| 3842 | { | |
| 3843 | if (eptr >= md->end_subject) | |
| 3844 | { | |
| 3845 | SCHECK_PARTIAL(); | |
| 3846 | MRRETURN(MATCH_NOMATCH); | |
| 3847 | } | |
| 3848 | GETCHARINCTEST(c, eptr); | |
| 3849 | prop_category = UCD_CATEGORY(c); | |
| 3850 | if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL || | |
| 3851 | c == CHAR_FF || c == CHAR_CR) | |
| 3852 | == prop_fail_result) | |
| 3853 | MRRETURN(MATCH_NOMATCH); | |
| 3854 | } | |
| 3855 | break; | |
| 3856 | ||
| 3857 | case PT_PXSPACE: /* POSIX space */ | |
| 3858 | for (i = 1; i <= min; i++) | |
| 3859 | { | |
| 3860 | if (eptr >= md->end_subject) | |
| 3861 | { | |
| 3862 | SCHECK_PARTIAL(); | |
| 3863 | MRRETURN(MATCH_NOMATCH); | |
| 3864 | } | |
| 3865 | GETCHARINCTEST(c, eptr); | |
| 3866 | prop_category = UCD_CATEGORY(c); | |
| 3867 | if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL || | |
| 3868 | c == CHAR_VT || c == CHAR_FF || c == CHAR_CR) | |
| 3869 | == prop_fail_result) | |
| 3870 | MRRETURN(MATCH_NOMATCH); | |
| 3871 | } | |
| 3872 | break; | |
| 3873 | ||
| 3874 | case PT_WORD: | |
| 3875 | for (i = 1; i <= min; i++) | |
| 3876 | { | |
| 3877 | if (eptr >= md->end_subject) | |
| 3878 | { | |
| 3879 | SCHECK_PARTIAL(); | |
| 3880 | MRRETURN(MATCH_NOMATCH); | |
| 3881 | } | |
| 3882 | GETCHARINCTEST(c, eptr); | |
| 3883 | prop_category = UCD_CATEGORY(c); | |
| 3884 | if ((prop_category == ucp_L || prop_category == ucp_N || | |
| 3885 | c == CHAR_UNDERSCORE) | |
| 3886 | == prop_fail_result) | |
| 3887 | MRRETURN(MATCH_NOMATCH); | |
| 3888 | } | } |
| 3889 | break; | break; |
| 3890 | ||
| 3891 | /* This should not occur */ | |
| 3892 | ||
| 3893 | default: | default: |
| 3894 | RRETURN(PCRE_ERROR_INTERNAL); | RRETURN(PCRE_ERROR_INTERNAL); |
| 3895 | } | } |
| # | Line 3441 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 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 3911 | prop_category = UCD_CATEGORY(c); | prop_category = UCD_CATEGORY(c); |
| 3912 | if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH); | if (prop_category == ucp_M) MRRETURN(MATCH_NOMATCH); |
| 3913 | while (eptr < md->end_subject) | while (eptr < md->end_subject) |
| 3914 | { | { |
| 3915 | int len = 1; | int len = 1; |
| # | Line 3472 for (;;) | Line 3936 for (;;) |
| 3936 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3937 | { | { |
| 3938 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3939 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3940 | } | } |
| 3941 | if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); | if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH); |
| 3942 | eptr++; | eptr++; |
| 3943 | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| 3944 | } | } |
| # | Line 3486 for (;;) | Line 3950 for (;;) |
| 3950 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3951 | { | { |
| 3952 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3953 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3954 | } | } |
| 3955 | eptr++; | eptr++; |
| 3956 | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; | while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| # | Line 3494 for (;;) | Line 3958 for (;;) |
| 3958 | break; | break; |
| 3959 | ||
| 3960 | case OP_ANYBYTE: | case OP_ANYBYTE: |
| 3961 | if (eptr > md->end_subject - min) RRETURN(MATCH_NOMATCH); | if (eptr > md->end_subject - min) MRRETURN(MATCH_NOMATCH); |
| 3962 | eptr += min; | eptr += min; |
| 3963 | break; | break; |
| 3964 | ||
| # | Line 3504 for (;;) | Line 3968 for (;;) |
| 3968 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 3969 | { | { |
| 3970 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 3971 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 3972 | } | } |
| 3973 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 3974 | switch(c) | switch(c) |
| 3975 | { | { |
| 3976 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 3977 | ||
| 3978 | case 0x000d: | case 0x000d: |
| 3979 | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 3980 | break; | break; |
| # | Line 3522 for (;;) | Line 3987 for (;;) |
| 3987 | case 0x0085: | case 0x0085: |
| 3988 | case 0x2028: | case 0x2028: |
| 3989 | case 0x2029: | case 0x2029: |
| 3990 | if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); | if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH); |
| 3991 | break; | break; |
| 3992 | } | } |
| 3993 | } | } |
| # | Line 3534 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 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 4005 | switch(c) | switch(c) |
| # | Line 3559 for (;;) | Line 4024 for (;;) |
| 4024 | case 0x202f: /* NARROW NO-BREAK SPACE */ | case 0x202f: /* NARROW NO-BREAK SPACE */ |
| 4025 | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ | case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ |
| 4026 | case 0x3000: /* IDEOGRAPHIC SPACE */ | case 0x3000: /* IDEOGRAPHIC SPACE */ |
| 4027 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4028 | } | } |
| 4029 | } | } |
| 4030 | break; | break; |
| # | Line 3570 for (;;) | Line 4035 for (;;) |
| 4035 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4036 | { | { |
| 4037 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4038 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4039 | } | } |
| 4040 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 4041 | switch(c) | switch(c) |
| 4042 | { | { |
| 4043 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4044 | case 0x09: /* HT */ | case 0x09: /* HT */ |
| 4045 | case 0x20: /* SPACE */ | case 0x20: /* SPACE */ |
| 4046 | case 0xa0: /* NBSP */ | case 0xa0: /* NBSP */ |
| # | Line 3606 for (;;) | Line 4071 for (;;) |
| 4071 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4072 | { | { |
| 4073 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4074 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4075 | } | } |
| 4076 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 4077 | switch(c) | switch(c) |
| # | Line 3619 for (;;) | Line 4084 for (;;) |
| 4084 | case 0x85: /* NEL */ | case 0x85: /* NEL */ |
| 4085 | case 0x2028: /* LINE SEPARATOR */ | case 0x2028: /* LINE SEPARATOR */ |
| 4086 | case 0x2029: /* PARAGRAPH SEPARATOR */ | case 0x2029: /* PARAGRAPH SEPARATOR */ |
| 4087 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4088 | } | } |
| 4089 | } | } |
| 4090 | break; | break; |
| # | Line 3630 for (;;) | Line 4095 for (;;) |
| 4095 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4096 | { | { |
| 4097 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4098 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4099 | } | } |
| 4100 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 4101 | switch(c) | switch(c) |
| 4102 | { | { |
| 4103 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4104 | case 0x0a: /* LF */ | case 0x0a: /* LF */ |
| 4105 | case 0x0b: /* VT */ | case 0x0b: /* VT */ |
| 4106 | case 0x0c: /* FF */ | case 0x0c: /* FF */ |
| # | Line 3654 for (;;) | Line 4119 for (;;) |
| 4119 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4120 | { | { |
| 4121 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4122 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4123 | } | } |
| 4124 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 4125 | if (c < 128 && (md->ctypes[c] & ctype_digit) != 0) | if (c < 128 && (md->ctypes[c] & ctype_digit) != 0) |
| 4126 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4127 | } | } |
| 4128 | break; | break; |
| 4129 | ||
| # | Line 3668 for (;;) | Line 4133 for (;;) |
| 4133 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4134 | { | { |
| 4135 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4136 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4137 | } | } |
| 4138 | if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0) | if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0) |
| 4139 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4140 | /* 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 */ |
| 4141 | } | } |
| 4142 | break; | break; |
| # | Line 3682 for (;;) | Line 4147 for (;;) |
| 4147 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4148 | { | { |
| 4149 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4150 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4151 | } | } |
| 4152 | if (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0) | if (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0) |
| 4153 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4154 | while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80); | while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80); |
| 4155 | } | } |
| 4156 | break; | break; |
| # | Line 3696 for (;;) | Line 4161 for (;;) |
| 4161 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4162 | { | { |
| 4163 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4164 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4165 | } | } |
| 4166 | if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0) | if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0) |
| 4167 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4168 | /* 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 */ |
| 4169 | } | } |
| 4170 | break; | break; |
| # | Line 3710 for (;;) | Line 4175 for (;;) |
| 4175 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4176 | { | { |
| 4177 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4178 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4179 | } | } |
| 4180 | if (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0) | if (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0) |
| 4181 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4182 | while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80); | while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80); |
| 4183 | } | } |
| 4184 | break; | break; |
| # | Line 3724 for (;;) | Line 4189 for (;;) |
| 4189 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4190 | { | { |
| 4191 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4192 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4193 | } | } |
| 4194 | if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0) | if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0) |
| 4195 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4196 | /* 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 */ |
| 4197 | } | } |
| 4198 | break; | break; |
| # | Line 3750 for (;;) | Line 4215 for (;;) |
| 4215 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4216 | { | { |
| 4217 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4218 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4219 | } | } |
| 4220 | if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); | if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH); |
| 4221 | eptr++; | eptr++; |
| 4222 | } | } |
| 4223 | break; | break; |
| # | Line 3761 for (;;) | Line 4226 for (;;) |
| 4226 | if (eptr > md->end_subject - min) | if (eptr > md->end_subject - min) |
| 4227 | { | { |
| 4228 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4229 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4230 | } | } |
| 4231 | eptr += min; | eptr += min; |
| 4232 | break; | break; |
| # | Line 3770 for (;;) | Line 4235 for (;;) |
| 4235 | if (eptr > md->end_subject - min) | if (eptr > md->end_subject - min) |
| 4236 | { | { |
| 4237 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4238 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4239 | } | } |
| 4240 | eptr += min; | eptr += min; |
| 4241 | break; | break; |
| # | Line 3781 for (;;) | Line 4246 for (;;) |
| 4246 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4247 | { | { |
| 4248 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4249 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4250 | } | } |
| 4251 | switch(*eptr++) | switch(*eptr++) |
| 4252 | { | { |
| 4253 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4254 | ||
| 4255 | case 0x000d: | case 0x000d: |
| 4256 | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 4257 | break; | break; |
| 4258 | ||
| 4259 | case 0x000a: | case 0x000a: |
| 4260 | break; | break; |
| 4261 | ||
| 4262 | case 0x000b: | case 0x000b: |
| 4263 | case 0x000c: | case 0x000c: |
| 4264 | case 0x0085: | case 0x0085: |
| 4265 | if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); | if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH); |
| 4266 | break; | break; |
| 4267 | } | } |
| 4268 | } | } |
| # | Line 3807 for (;;) | Line 4274 for (;;) |
| 4274 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4275 | { | { |
| 4276 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4277 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4278 | } | } |
| 4279 | switch(*eptr++) | switch(*eptr++) |
| 4280 | { | { |
| # | Line 3815 for (;;) | Line 4282 for (;;) |
| 4282 | case 0x09: /* HT */ | case 0x09: /* HT */ |
| 4283 | case 0x20: /* SPACE */ | case 0x20: /* SPACE */ |
| 4284 | case 0xa0: /* NBSP */ | case 0xa0: /* NBSP */ |
| 4285 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4286 | } | } |
| 4287 | } | } |
| 4288 | break; | break; |
| # | Line 3826 for (;;) | Line 4293 for (;;) |
| 4293 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4294 | { | { |
| 4295 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4296 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4297 | } | } |
| 4298 | switch(*eptr++) | switch(*eptr++) |
| 4299 | { | { |
| 4300 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4301 | case 0x09: /* HT */ | case 0x09: /* HT */ |
| 4302 | case 0x20: /* SPACE */ | case 0x20: /* SPACE */ |
| 4303 | case 0xa0: /* NBSP */ | case 0xa0: /* NBSP */ |
| # | Line 3845 for (;;) | Line 4312 for (;;) |
| 4312 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4313 | { | { |
| 4314 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4315 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4316 | } | } |
| 4317 | switch(*eptr++) | switch(*eptr++) |
| 4318 | { | { |
| # | Line 3855 for (;;) | Line 4322 for (;;) |
| 4322 | case 0x0c: /* FF */ | case 0x0c: /* FF */ |
| 4323 | case 0x0d: /* CR */ | case 0x0d: /* CR */ |
| 4324 | case 0x85: /* NEL */ | case 0x85: /* NEL */ |
| 4325 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4326 | } | } |
| 4327 | } | } |
| 4328 | break; | break; |
| # | Line 3866 for (;;) | Line 4333 for (;;) |
| 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 | switch(*eptr++) | switch(*eptr++) |
| 4339 | { | { |
| 4340 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4341 | case 0x0a: /* LF */ | case 0x0a: /* LF */ |
| 4342 | case 0x0b: /* VT */ | case 0x0b: /* VT */ |
| 4343 | case 0x0c: /* FF */ | case 0x0c: /* FF */ |
| # | Line 3887 for (;;) | Line 4354 for (;;) |
| 4354 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4355 | { | { |
| 4356 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4357 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4358 | } | } |
| 4359 | if ((md->ctypes[*eptr++] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[*eptr++] & ctype_digit) != 0) MRRETURN(MATCH_NOMATCH); |
| 4360 | } | } |
| 4361 | break; | break; |
| 4362 | ||
| # | Line 3899 for (;;) | Line 4366 for (;;) |
| 4366 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4367 | { | { |
| 4368 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4369 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4370 | } | } |
| 4371 | if ((md->ctypes[*eptr++] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[*eptr++] & ctype_digit) == 0) MRRETURN(MATCH_NOMATCH); |
| 4372 | } | } |
| 4373 | break; | break; |
| 4374 | ||
| # | Line 3911 for (;;) | Line 4378 for (;;) |
| 4378 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4379 | { | { |
| 4380 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4381 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4382 | } | } |
| 4383 | if ((md->ctypes[*eptr++] & ctype_space) != 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[*eptr++] & ctype_space) != 0) MRRETURN(MATCH_NOMATCH); |
| 4384 | } | } |
| 4385 | break; | break; |
| 4386 | ||
| # | Line 3923 for (;;) | Line 4390 for (;;) |
| 4390 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4391 | { | { |
| 4392 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4393 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4394 | } | } |
| 4395 | if ((md->ctypes[*eptr++] & ctype_space) == 0) RRETURN(MATCH_NOMATCH); | if ((md->ctypes[*eptr++] & ctype_space) == 0) MRRETURN(MATCH_NOMATCH); |
| 4396 | } | } |
| 4397 | break; | break; |
| 4398 | ||
| # | Line 3935 for (;;) | Line 4402 for (;;) |
| 4402 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4403 | { | { |
| 4404 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4405 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4406 | } | } |
| 4407 | if ((md->ctypes[*eptr++] & ctype_word) != 0) | if ((md->ctypes[*eptr++] & ctype_word) != 0) |
| 4408 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4409 | } | } |
| 4410 | break; | break; |
| 4411 | ||
| # | Line 3948 for (;;) | Line 4415 for (;;) |
| 4415 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4416 | { | { |
| 4417 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4418 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4419 | } | } |
| 4420 | if ((md->ctypes[*eptr++] & ctype_word) == 0) | if ((md->ctypes[*eptr++] & ctype_word) == 0) |
| 4421 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4422 | } | } |
| 4423 | break; | break; |
| 4424 | ||
| # | Line 3978 for (;;) | Line 4445 for (;;) |
| 4445 | case PT_ANY: | case PT_ANY: |
| 4446 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 4447 | { | { |
| 4448 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM36); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM36); |
| 4449 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4450 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4451 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4452 | { | { |
| 4453 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4454 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4455 | } | } |
| 4456 | GETCHARINC(c, eptr); | GETCHARINCTEST(c, eptr); |
| 4457 | if (prop_fail_result) RRETURN(MATCH_NOMATCH); | if (prop_fail_result) MRRETURN(MATCH_NOMATCH); |
| 4458 | } | } |
| 4459 | /* Control never gets here */ | /* Control never gets here */ |
| 4460 | ||
| 4461 | case PT_LAMP: | case PT_LAMP: |
| 4462 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 4463 | { | { |
| 4464 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM37); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM37); |
| 4465 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4466 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4467 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4468 | { | { |
| 4469 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4470 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4471 | } | } |
| 4472 | GETCHARINC(c, eptr); | GETCHARINCTEST(c, eptr); |
| 4473 | prop_chartype = UCD_CHARTYPE(c); | prop_chartype = UCD_CHARTYPE(c); |
| 4474 | if ((prop_chartype == ucp_Lu || | if ((prop_chartype == ucp_Lu || |
| 4475 | prop_chartype == ucp_Ll || | prop_chartype == ucp_Ll || |
| 4476 | prop_chartype == ucp_Lt) == prop_fail_result) | prop_chartype == ucp_Lt) == prop_fail_result) |
| 4477 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4478 | } | } |
| 4479 | /* Control never gets here */ | /* Control never gets here */ |
| 4480 | ||
| 4481 | case PT_GC: | case PT_GC: |
| 4482 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 4483 | { | { |
| 4484 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM38); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM38); |
| 4485 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4486 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4487 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4488 | { | { |
| 4489 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4490 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4491 | } | } |
| 4492 | GETCHARINC(c, eptr); | GETCHARINCTEST(c, eptr); |
| 4493 | prop_category = UCD_CATEGORY(c); | prop_category = UCD_CATEGORY(c); |
| 4494 | if ((prop_category == prop_value) == prop_fail_result) | if ((prop_category == prop_value) == prop_fail_result) |
| 4495 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4496 | } | } |
| 4497 | /* Control never gets here */ | /* Control never gets here */ |
| 4498 | ||
| 4499 | case PT_PC: | case PT_PC: |
| 4500 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 4501 | { | { |
| 4502 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM39); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM39); |
| 4503 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4504 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4505 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4506 | { | { |
| 4507 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4508 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4509 | } | } |
| 4510 | GETCHARINC(c, eptr); | GETCHARINCTEST(c, eptr); |
| 4511 | prop_chartype = UCD_CHARTYPE(c); | prop_chartype = UCD_CHARTYPE(c); |
| 4512 | if ((prop_chartype == prop_value) == prop_fail_result) | if ((prop_chartype == prop_value) == prop_fail_result) |
| 4513 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4514 | } | } |
| 4515 | /* Control never gets here */ | /* Control never gets here */ |
| 4516 | ||
| 4517 | case PT_SC: | case PT_SC: |
| 4518 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 4519 | { | { |
| 4520 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM40); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM40); |
| 4521 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4522 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4523 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4524 | { | { |
| 4525 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4526 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4527 | } | } |
| 4528 | GETCHARINC(c, eptr); | GETCHARINCTEST(c, eptr); |
| 4529 | prop_script = UCD_SCRIPT(c); | prop_script = UCD_SCRIPT(c); |
| 4530 | if ((prop_script == prop_value) == prop_fail_result) | if ((prop_script == prop_value) == prop_fail_result) |
| 4531 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4532 | } | |
| 4533 | /* Control never gets here */ | |
| 4534 | ||
| 4535 | case PT_ALNUM: | |
| 4536 | for (fi = min;; fi++) | |
| 4537 | { | |
| 4538 | RMATCH(eptr, ecode, offset_top, md, eptrb, RM59); | |
| 4539 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | |
| 4540 | if (fi >= max) MRRETURN(MATCH_NOMATCH); | |
| 4541 | if (eptr >= md->end_subject) | |
| 4542 | { | |
| 4543 | SCHECK_PARTIAL(); | |
| 4544 | MRRETURN(MATCH_NOMATCH); | |
| 4545 | } | |
| 4546 | GETCHARINCTEST(c, eptr); | |
| 4547 | prop_category = UCD_CATEGORY(c); | |
| 4548 | if ((prop_category == ucp_L || prop_category == ucp_N) | |
| 4549 | == prop_fail_result) | |
| 4550 | MRRETURN(MATCH_NOMATCH); | |
| 4551 | } | |
| 4552 | /* Control never gets here */ | |
| 4553 | ||
| 4554 | case PT_SPACE: /* Perl space */ | |
| 4555 | for (fi = min;; fi++) | |
| 4556 | { | |
| 4557 | RMATCH(eptr, ecode, offset_top, md, eptrb, RM60); | |
| 4558 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | |
| 4559 | if (fi >= max) MRRETURN(MATCH_NOMATCH); | |
| 4560 | if (eptr >= md->end_subject) | |
| 4561 | { | |
| 4562 | SCHECK_PARTIAL(); | |
| 4563 | MRRETURN(MATCH_NOMATCH); | |
| 4564 | } | |
| 4565 | GETCHARINCTEST(c, eptr); | |
| 4566 | prop_category = UCD_CATEGORY(c); | |
| 4567 | if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL || | |
| 4568 | c == CHAR_FF || c == CHAR_CR) | |
| 4569 | == prop_fail_result) | |
| 4570 | MRRETURN(MATCH_NOMATCH); | |
| 4571 | } | |
| 4572 | /* Control never gets here */ | |
| 4573 | ||
| 4574 | case PT_PXSPACE: /* POSIX space */ | |
| 4575 | for (fi = min;; fi++) | |
| 4576 | { | |
| 4577 | RMATCH(eptr, ecode, offset_top, md, eptrb, RM61); | |
| 4578 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | |
| 4579 | if (fi >= max) MRRETURN(MATCH_NOMATCH); | |
| 4580 | if (eptr >= md->end_subject) | |
| 4581 | { | |
| 4582 | SCHECK_PARTIAL(); | |
| 4583 | MRRETURN(MATCH_NOMATCH); | |
| 4584 | } | |
| 4585 | GETCHARINCTEST(c, eptr); | |
| 4586 | prop_category = UCD_CATEGORY(c); | |
| 4587 | if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL || | |
| 4588 | c == CHAR_VT || c == CHAR_FF || c == CHAR_CR) | |
| 4589 | == prop_fail_result) | |
| 4590 | MRRETURN(MATCH_NOMATCH); | |
| 4591 | } | |
| 4592 | /* Control never gets here */ | |
| 4593 | ||
| 4594 | case PT_WORD: | |
| 4595 | for (fi = min;; fi++) | |
| 4596 | { | |
| 4597 | RMATCH(eptr, ecode, offset_top, md, eptrb, RM62); | |
| 4598 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | |
| 4599 | if (fi >= max) MRRETURN(MATCH_NOMATCH); | |
| 4600 | if (eptr >= md->end_subject) | |
| 4601 | { | |
| 4602 | SCHECK_PARTIAL(); | |
| 4603 | MRRETURN(MATCH_NOMATCH); | |
| 4604 | } | |
| 4605 | GETCHARINCTEST(c, eptr); | |
| 4606 | prop_category = UCD_CATEGORY(c); | |
| 4607 | if ((prop_category == ucp_L || | |
| 4608 | prop_category == ucp_N || | |
| 4609 | c == CHAR_UNDERSCORE) | |
| 4610 | == prop_fail_result) | |
| 4611 | MRRETURN(MATCH_NOMATCH); | |
| 4612 | } | } |
| 4613 | /* Control never gets here */ | /* Control never gets here */ |
| 4614 | ||
| 4615 | /* This should never occur */ | |
| 4616 | ||
| 4617 | default: | default: |
| 4618 | RRETURN(PCRE_ERROR_INTERNAL); | RRETURN(PCRE_ERROR_INTERNAL); |
| 4619 | } | } |
| # | Line 4077 for (;;) | Line 4626 for (;;) |
| 4626 | { | { |
| 4627 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 4628 | { | { |
| 4629 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM41); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM41); |
| 4630 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4631 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4632 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4633 | { | { |
| 4634 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4635 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4636 | } | } |
| 4637 | GETCHARINCTEST(c, eptr); | GETCHARINCTEST(c, eptr); |
| 4638 | prop_category = UCD_CATEGORY(c); | prop_category = UCD_CATEGORY(c); |
| 4639 | if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH); | if (prop_category == ucp_M) MRRETURN(MATCH_NOMATCH); |
| 4640 | while (eptr < md->end_subject) | while (eptr < md->end_subject) |
| 4641 | { | { |
| 4642 | int len = 1; | int len = 1; |
| # | Line 4109 for (;;) | Line 4658 for (;;) |
| 4658 | { | { |
| 4659 | for (fi = min;; fi++) | for (fi = min;; fi++) |
| 4660 | { | { |
| 4661 | RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM42); | RMATCH(eptr, ecode, offset_top, md, eptrb, RM42); |
| 4662 | if (rrc != MATCH_NOMATCH) RRETURN(rrc); | if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4663 | if (fi >= max) RRETURN(MATCH_NOMATCH); | if (fi >= max) MRRETURN(MATCH_NOMATCH); |
| 4664 | if (eptr >= md->end_subject) | if (eptr >= md->end_subject) |
| 4665 | { | { |
| 4666 | SCHECK_PARTIAL(); | SCHECK_PARTIAL(); |
| 4667 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4668 | } | } |
| 4669 | if (ctype == OP_ANY && IS_NEWLINE(eptr)) | if (ctype == OP_ANY && IS_NEWLINE(eptr)) |
| 4670 | RRETURN(MATCH_NOMATCH); | MRRETURN(MATCH_NOMATCH); |
| 4671 | GETCHARINC(c, eptr); | GETCHARINC(c, eptr); |
| 4672 | switch(ctype) | switch(ctype) |
| 4673 | { | { |
| # | Line 4130 for (;;) | Line 4679 for (;;) |
| 4679 | case OP_ANYNL: | case OP_ANYNL: |
| 4680 | switch(c) | switch(c) |
| 4681 | { | { |
| 4682 | default: RRETURN(MATCH_NOMATCH); | default: MRRETURN(MATCH_NOMATCH); |
| 4683 | case 0x000d: | case 0x000d: |
| 4684 | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; | if (eptr < md->end_subject && *eptr == 0x0a) eptr++; |
| 4685 | break; | break; |
| # | Line 4142 for (;;) | Line 4691 for (;;) |
| 4691 | case 0x0085: | case 0x0085: |
| 4692 | case 0x2028: | case 0x2028: |
| 4693 | case 0x2029: | case 0x2029: |
| 4694 | if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH); | if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH); |
| 4695 | break; | break; |
| 4696 | } | } |