| 6 |
and semantics are as close as possible to those of the Perl 5 language. |
and semantics are as close as possible to those of the Perl 5 language. |
| 7 |
|
|
| 8 |
Written by Philip Hazel |
Written by Philip Hazel |
| 9 |
Copyright (c) 1997-2008 University of Cambridge |
Copyright (c) 1997-2009 University of Cambridge |
| 10 |
|
|
| 11 |
----------------------------------------------------------------------------- |
----------------------------------------------------------------------------- |
| 12 |
Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
| 322 |
|
|
| 323 |
/* Function arguments that may change */ |
/* Function arguments that may change */ |
| 324 |
|
|
| 325 |
const uschar *Xeptr; |
USPTR Xeptr; |
| 326 |
const uschar *Xecode; |
const uschar *Xecode; |
| 327 |
const uschar *Xmstart; |
USPTR Xmstart; |
| 328 |
int Xoffset_top; |
int Xoffset_top; |
| 329 |
long int Xims; |
long int Xims; |
| 330 |
eptrblock *Xeptrb; |
eptrblock *Xeptrb; |
| 333 |
|
|
| 334 |
/* Function local variables */ |
/* Function local variables */ |
| 335 |
|
|
| 336 |
const uschar *Xcallpat; |
USPTR Xcallpat; |
| 337 |
const uschar *Xcharptr; |
#ifdef SUPPORT_UTF8 |
| 338 |
const uschar *Xdata; |
USPTR Xcharptr; |
| 339 |
const uschar *Xnext; |
#endif |
| 340 |
const uschar *Xpp; |
USPTR Xdata; |
| 341 |
const uschar *Xprev; |
USPTR Xnext; |
| 342 |
const uschar *Xsaved_eptr; |
USPTR Xpp; |
| 343 |
|
USPTR Xprev; |
| 344 |
|
USPTR Xsaved_eptr; |
| 345 |
|
|
| 346 |
recursion_info Xnew_recursive; |
recursion_info Xnew_recursive; |
| 347 |
|
|
| 362 |
uschar Xocchars[8]; |
uschar Xocchars[8]; |
| 363 |
#endif |
#endif |
| 364 |
|
|
| 365 |
|
int Xcodelink; |
| 366 |
int Xctype; |
int Xctype; |
| 367 |
unsigned int Xfc; |
unsigned int Xfc; |
| 368 |
int Xfi; |
int Xfi; |
| 398 |
|
|
| 399 |
/* This function is called recursively in many circumstances. Whenever it |
/* This function is called recursively in many circumstances. Whenever it |
| 400 |
returns a negative (error) response, the outer incarnation must also return the |
returns a negative (error) response, the outer incarnation must also return the |
| 401 |
same response. |
same response. */ |
| 402 |
|
|
| 403 |
|
/* These macros pack up tests that are used for partial matching, and which |
| 404 |
|
appears several times in the code. We set the "hit end" flag if the pointer is |
| 405 |
|
at the end of the subject and also past the start of the subject (i.e. |
| 406 |
|
something has been matched). For hard partial matching, we then return |
| 407 |
|
immediately. The second one is used when we already know we are past the end of |
| 408 |
|
the subject. */ |
| 409 |
|
|
| 410 |
|
#define CHECK_PARTIAL()\ |
| 411 |
|
if (md->partial != 0 && eptr >= md->end_subject && eptr > mstart)\ |
| 412 |
|
{\ |
| 413 |
|
md->hitend = TRUE;\ |
| 414 |
|
if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);\ |
| 415 |
|
} |
| 416 |
|
|
| 417 |
Performance note: It might be tempting to extract commonly used fields from the |
#define SCHECK_PARTIAL()\ |
| 418 |
md structure (e.g. utf8, end_subject) into individual variables to improve |
if (md->partial && eptr > mstart)\ |
| 419 |
|
{\ |
| 420 |
|
md->hitend = TRUE;\ |
| 421 |
|
if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);\ |
| 422 |
|
} |
| 423 |
|
|
| 424 |
|
|
| 425 |
|
/* Performance note: It might be tempting to extract commonly used fields from |
| 426 |
|
the md structure (e.g. utf8, end_subject) into individual variables to improve |
| 427 |
performance. Tests using gcc on a SPARC disproved this; in the first case, it |
performance. Tests using gcc on a SPARC disproved this; in the first case, it |
| 428 |
made performance worse. |
made performance worse. |
| 429 |
|
|
| 450 |
*/ |
*/ |
| 451 |
|
|
| 452 |
static int |
static int |
| 453 |
match(REGISTER USPTR eptr, REGISTER const uschar *ecode, const uschar *mstart, |
match(REGISTER USPTR eptr, REGISTER const uschar *ecode, USPTR mstart, |
| 454 |
int offset_top, match_data *md, unsigned long int ims, eptrblock *eptrb, |
int offset_top, match_data *md, unsigned long int ims, eptrblock *eptrb, |
| 455 |
int flags, unsigned int rdepth) |
int flags, unsigned int rdepth) |
| 456 |
{ |
{ |
| 464 |
register BOOL utf8; /* Local copy of UTF-8 flag for speed */ |
register BOOL utf8; /* Local copy of UTF-8 flag for speed */ |
| 465 |
|
|
| 466 |
BOOL minimize, possessive; /* Quantifier options */ |
BOOL minimize, possessive; /* Quantifier options */ |
| 467 |
|
int condcode; |
| 468 |
|
|
| 469 |
/* When recursion is not being used, all "local" variables that have to be |
/* When recursion is not being used, all "local" variables that have to be |
| 470 |
preserved over calls to RMATCH() are part of a "frame" which is obtained from |
preserved over calls to RMATCH() are part of a "frame" which is obtained from |
| 507 |
#define charptr frame->Xcharptr |
#define charptr frame->Xcharptr |
| 508 |
#endif |
#endif |
| 509 |
#define callpat frame->Xcallpat |
#define callpat frame->Xcallpat |
| 510 |
|
#define codelink frame->Xcodelink |
| 511 |
#define data frame->Xdata |
#define data frame->Xdata |
| 512 |
#define next frame->Xnext |
#define next frame->Xnext |
| 513 |
#define pp frame->Xpp |
#define pp frame->Xpp |
| 588 |
uschar occhars[8]; |
uschar occhars[8]; |
| 589 |
#endif |
#endif |
| 590 |
|
|
| 591 |
|
int codelink; |
| 592 |
int ctype; |
int ctype; |
| 593 |
int length; |
int length; |
| 594 |
int max; |
int max; |
| 663 |
{ |
{ |
| 664 |
minimize = possessive = FALSE; |
minimize = possessive = FALSE; |
| 665 |
op = *ecode; |
op = *ecode; |
| 666 |
|
|
|
/* For partial matching, remember if we ever hit the end of the subject after |
|
|
matching at least one subject character. */ |
|
|
|
|
|
if (md->partial && |
|
|
eptr >= md->end_subject && |
|
|
eptr > mstart) |
|
|
md->hitend = TRUE; |
|
|
|
|
| 667 |
switch(op) |
switch(op) |
| 668 |
{ |
{ |
| 669 |
case OP_FAIL: |
case OP_FAIL: |
| 807 |
|
|
| 808 |
case OP_COND: |
case OP_COND: |
| 809 |
case OP_SCOND: |
case OP_SCOND: |
| 810 |
if (ecode[LINK_SIZE+1] == OP_RREF) /* Recursion test */ |
codelink= GET(ecode, 1); |
| 811 |
|
|
| 812 |
|
/* Because of the way auto-callout works during compile, a callout item is |
| 813 |
|
inserted between OP_COND and an assertion condition. */ |
| 814 |
|
|
| 815 |
|
if (ecode[LINK_SIZE+1] == OP_CALLOUT) |
| 816 |
|
{ |
| 817 |
|
if (pcre_callout != NULL) |
| 818 |
|
{ |
| 819 |
|
pcre_callout_block cb; |
| 820 |
|
cb.version = 1; /* Version 1 of the callout block */ |
| 821 |
|
cb.callout_number = ecode[LINK_SIZE+2]; |
| 822 |
|
cb.offset_vector = md->offset_vector; |
| 823 |
|
cb.subject = (PCRE_SPTR)md->start_subject; |
| 824 |
|
cb.subject_length = md->end_subject - md->start_subject; |
| 825 |
|
cb.start_match = mstart - md->start_subject; |
| 826 |
|
cb.current_position = eptr - md->start_subject; |
| 827 |
|
cb.pattern_position = GET(ecode, LINK_SIZE + 3); |
| 828 |
|
cb.next_item_length = GET(ecode, 3 + 2*LINK_SIZE); |
| 829 |
|
cb.capture_top = offset_top/2; |
| 830 |
|
cb.capture_last = md->capture_last; |
| 831 |
|
cb.callout_data = md->callout_data; |
| 832 |
|
if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH); |
| 833 |
|
if (rrc < 0) RRETURN(rrc); |
| 834 |
|
} |
| 835 |
|
ecode += _pcre_OP_lengths[OP_CALLOUT]; |
| 836 |
|
} |
| 837 |
|
|
| 838 |
|
condcode = ecode[LINK_SIZE+1]; |
| 839 |
|
|
| 840 |
|
/* Now see what the actual condition is */ |
| 841 |
|
|
| 842 |
|
if (condcode == OP_RREF) /* Recursion test */ |
| 843 |
{ |
{ |
| 844 |
offset = GET2(ecode, LINK_SIZE + 2); /* Recursion group number*/ |
offset = GET2(ecode, LINK_SIZE + 2); /* Recursion group number*/ |
| 845 |
condition = md->recursive != NULL && |
condition = md->recursive != NULL && |
| 847 |
ecode += condition? 3 : GET(ecode, 1); |
ecode += condition? 3 : GET(ecode, 1); |
| 848 |
} |
} |
| 849 |
|
|
| 850 |
else if (ecode[LINK_SIZE+1] == OP_CREF) /* Group used test */ |
else if (condcode == OP_CREF) /* Group used test */ |
| 851 |
{ |
{ |
| 852 |
offset = GET2(ecode, LINK_SIZE+2) << 1; /* Doubled ref number */ |
offset = GET2(ecode, LINK_SIZE+2) << 1; /* Doubled ref number */ |
| 853 |
condition = offset < offset_top && md->offset_vector[offset] >= 0; |
condition = offset < offset_top && md->offset_vector[offset] >= 0; |
| 854 |
ecode += condition? 3 : GET(ecode, 1); |
ecode += condition? 3 : GET(ecode, 1); |
| 855 |
} |
} |
| 856 |
|
|
| 857 |
else if (ecode[LINK_SIZE+1] == OP_DEF) /* DEFINE - always false */ |
else if (condcode == OP_DEF) /* DEFINE - always false */ |
| 858 |
{ |
{ |
| 859 |
condition = FALSE; |
condition = FALSE; |
| 860 |
ecode += GET(ecode, 1); |
ecode += GET(ecode, 1); |
| 881 |
else |
else |
| 882 |
{ |
{ |
| 883 |
condition = FALSE; |
condition = FALSE; |
| 884 |
ecode += GET(ecode, 1); |
ecode += codelink; |
| 885 |
} |
} |
| 886 |
} |
} |
| 887 |
|
|
| 904 |
goto TAIL_RECURSE; |
goto TAIL_RECURSE; |
| 905 |
} |
} |
| 906 |
} |
} |
| 907 |
else /* Condition false & no 2nd alternative */ |
else /* Condition false & no alternative */ |
| 908 |
{ |
{ |
| 909 |
ecode += 1 + LINK_SIZE; |
ecode += 1 + LINK_SIZE; |
| 910 |
} |
} |
| 1024 |
if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH); |
if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH); |
| 1025 |
} |
} |
| 1026 |
|
|
| 1027 |
/* Skip to next op code */ |
/* Save the earliest consulted character, then skip to next op code */ |
| 1028 |
|
|
| 1029 |
|
if (eptr < md->start_used_ptr) md->start_used_ptr = eptr; |
| 1030 |
ecode += 1 + LINK_SIZE; |
ecode += 1 + LINK_SIZE; |
| 1031 |
break; |
break; |
| 1032 |
|
|
| 1128 |
else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) |
else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) |
| 1129 |
{ |
{ |
| 1130 |
DPRINTF(("Recursion gave error %d\n", rrc)); |
DPRINTF(("Recursion gave error %d\n", rrc)); |
| 1131 |
|
if (new_recursive.offset_save != stacksave) |
| 1132 |
|
(pcre_free)(new_recursive.offset_save); |
| 1133 |
RRETURN(rrc); |
RRETURN(rrc); |
| 1134 |
} |
} |
| 1135 |
|
|
| 1469 |
|
|
| 1470 |
/* Find out if the previous and current characters are "word" characters. |
/* Find out if the previous and current characters are "word" characters. |
| 1471 |
It takes a bit more work in UTF-8 mode. Characters > 255 are assumed to |
It takes a bit more work in UTF-8 mode. Characters > 255 are assumed to |
| 1472 |
be "non-word" characters. */ |
be "non-word" characters. Remember the earliest consulted character for |
| 1473 |
|
partial matching. */ |
| 1474 |
|
|
| 1475 |
#ifdef SUPPORT_UTF8 |
#ifdef SUPPORT_UTF8 |
| 1476 |
if (utf8) |
if (utf8) |
| 1477 |
{ |
{ |
| 1478 |
if (eptr == md->start_subject) prev_is_word = FALSE; else |
if (eptr == md->start_subject) prev_is_word = FALSE; else |
| 1479 |
{ |
{ |
| 1480 |
const uschar *lastptr = eptr - 1; |
USPTR lastptr = eptr - 1; |
| 1481 |
while((*lastptr & 0xc0) == 0x80) lastptr--; |
while((*lastptr & 0xc0) == 0x80) lastptr--; |
| 1482 |
|
if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr; |
| 1483 |
GETCHAR(c, lastptr); |
GETCHAR(c, lastptr); |
| 1484 |
prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; |
prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; |
| 1485 |
} |
} |
| 1486 |
if (eptr >= md->end_subject) cur_is_word = FALSE; else |
if (eptr >= md->end_subject) |
| 1487 |
|
{ |
| 1488 |
|
SCHECK_PARTIAL(); |
| 1489 |
|
cur_is_word = FALSE; |
| 1490 |
|
} |
| 1491 |
|
else |
| 1492 |
{ |
{ |
| 1493 |
GETCHAR(c, eptr); |
GETCHAR(c, eptr); |
| 1494 |
cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; |
cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0; |
| 1497 |
else |
else |
| 1498 |
#endif |
#endif |
| 1499 |
|
|
| 1500 |
/* More streamlined when not in UTF-8 mode */ |
/* Not in UTF-8 mode */ |
| 1501 |
|
|
| 1502 |
{ |
{ |
| 1503 |
prev_is_word = (eptr != md->start_subject) && |
if (eptr == md->start_subject) prev_is_word = FALSE; else |
| 1504 |
((md->ctypes[eptr[-1]] & ctype_word) != 0); |
{ |
| 1505 |
cur_is_word = (eptr < md->end_subject) && |
if (eptr <= md->start_used_ptr) md->start_used_ptr = eptr - 1; |
| 1506 |
((md->ctypes[*eptr] & ctype_word) != 0); |
prev_is_word = ((md->ctypes[eptr[-1]] & ctype_word) != 0); |
| 1507 |
|
} |
| 1508 |
|
if (eptr >= md->end_subject) |
| 1509 |
|
{ |
| 1510 |
|
SCHECK_PARTIAL(); |
| 1511 |
|
cur_is_word = FALSE; |
| 1512 |
|
} |
| 1513 |
|
else cur_is_word = ((md->ctypes[*eptr] & ctype_word) != 0); |
| 1514 |
} |
} |
| 1515 |
|
|
| 1516 |
/* Now see if the situation is what we want */ |
/* Now see if the situation is what we want */ |
| 1528 |
/* Fall through */ |
/* Fall through */ |
| 1529 |
|
|
| 1530 |
case OP_ALLANY: |
case OP_ALLANY: |
| 1531 |
if (eptr++ >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr++ >= md->end_subject) |
| 1532 |
|
{ |
| 1533 |
|
SCHECK_PARTIAL(); |
| 1534 |
|
RRETURN(MATCH_NOMATCH); |
| 1535 |
|
} |
| 1536 |
if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| 1537 |
ecode++; |
ecode++; |
| 1538 |
break; |
break; |
| 1541 |
any byte, even newline, independent of the setting of PCRE_DOTALL. */ |
any byte, even newline, independent of the setting of PCRE_DOTALL. */ |
| 1542 |
|
|
| 1543 |
case OP_ANYBYTE: |
case OP_ANYBYTE: |
| 1544 |
if (eptr++ >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr++ >= md->end_subject) |
| 1545 |
|
{ |
| 1546 |
|
SCHECK_PARTIAL(); |
| 1547 |
|
RRETURN(MATCH_NOMATCH); |
| 1548 |
|
} |
| 1549 |
ecode++; |
ecode++; |
| 1550 |
break; |
break; |
| 1551 |
|
|
| 1552 |
case OP_NOT_DIGIT: |
case OP_NOT_DIGIT: |
| 1553 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 1554 |
|
{ |
| 1555 |
|
SCHECK_PARTIAL(); |
| 1556 |
|
RRETURN(MATCH_NOMATCH); |
| 1557 |
|
} |
| 1558 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 1559 |
if ( |
if ( |
| 1560 |
#ifdef SUPPORT_UTF8 |
#ifdef SUPPORT_UTF8 |
| 1567 |
break; |
break; |
| 1568 |
|
|
| 1569 |
case OP_DIGIT: |
case OP_DIGIT: |
| 1570 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 1571 |
|
{ |
| 1572 |
|
SCHECK_PARTIAL(); |
| 1573 |
|
RRETURN(MATCH_NOMATCH); |
| 1574 |
|
} |
| 1575 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 1576 |
if ( |
if ( |
| 1577 |
#ifdef SUPPORT_UTF8 |
#ifdef SUPPORT_UTF8 |
| 1584 |
break; |
break; |
| 1585 |
|
|
| 1586 |
case OP_NOT_WHITESPACE: |
case OP_NOT_WHITESPACE: |
| 1587 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 1588 |
|
{ |
| 1589 |
|
SCHECK_PARTIAL(); |
| 1590 |
|
RRETURN(MATCH_NOMATCH); |
| 1591 |
|
} |
| 1592 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 1593 |
if ( |
if ( |
| 1594 |
#ifdef SUPPORT_UTF8 |
#ifdef SUPPORT_UTF8 |
| 1601 |
break; |
break; |
| 1602 |
|
|
| 1603 |
case OP_WHITESPACE: |
case OP_WHITESPACE: |
| 1604 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 1605 |
|
{ |
| 1606 |
|
SCHECK_PARTIAL(); |
| 1607 |
|
RRETURN(MATCH_NOMATCH); |
| 1608 |
|
} |
| 1609 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 1610 |
if ( |
if ( |
| 1611 |
#ifdef SUPPORT_UTF8 |
#ifdef SUPPORT_UTF8 |
| 1618 |
break; |
break; |
| 1619 |
|
|
| 1620 |
case OP_NOT_WORDCHAR: |
case OP_NOT_WORDCHAR: |
| 1621 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 1622 |
|
{ |
| 1623 |
|
SCHECK_PARTIAL(); |
| 1624 |
|
RRETURN(MATCH_NOMATCH); |
| 1625 |
|
} |
| 1626 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 1627 |
if ( |
if ( |
| 1628 |
#ifdef SUPPORT_UTF8 |
#ifdef SUPPORT_UTF8 |
| 1635 |
break; |
break; |
| 1636 |
|
|
| 1637 |
case OP_WORDCHAR: |
case OP_WORDCHAR: |
| 1638 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 1639 |
|
{ |
| 1640 |
|
SCHECK_PARTIAL(); |
| 1641 |
|
RRETURN(MATCH_NOMATCH); |
| 1642 |
|
} |
| 1643 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 1644 |
if ( |
if ( |
| 1645 |
#ifdef SUPPORT_UTF8 |
#ifdef SUPPORT_UTF8 |
| 1652 |
break; |
break; |
| 1653 |
|
|
| 1654 |
case OP_ANYNL: |
case OP_ANYNL: |
| 1655 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 1656 |
|
{ |
| 1657 |
|
SCHECK_PARTIAL(); |
| 1658 |
|
RRETURN(MATCH_NOMATCH); |
| 1659 |
|
} |
| 1660 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 1661 |
switch(c) |
switch(c) |
| 1662 |
{ |
{ |
| 1680 |
break; |
break; |
| 1681 |
|
|
| 1682 |
case OP_NOT_HSPACE: |
case OP_NOT_HSPACE: |
| 1683 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 1684 |
|
{ |
| 1685 |
|
SCHECK_PARTIAL(); |
| 1686 |
|
RRETURN(MATCH_NOMATCH); |
| 1687 |
|
} |
| 1688 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 1689 |
switch(c) |
switch(c) |
| 1690 |
{ |
{ |
| 1714 |
break; |
break; |
| 1715 |
|
|
| 1716 |
case OP_HSPACE: |
case OP_HSPACE: |
| 1717 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 1718 |
|
{ |
| 1719 |
|
SCHECK_PARTIAL(); |
| 1720 |
|
RRETURN(MATCH_NOMATCH); |
| 1721 |
|
} |
| 1722 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 1723 |
switch(c) |
switch(c) |
| 1724 |
{ |
{ |
| 1748 |
break; |
break; |
| 1749 |
|
|
| 1750 |
case OP_NOT_VSPACE: |
case OP_NOT_VSPACE: |
| 1751 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 1752 |
|
{ |
| 1753 |
|
SCHECK_PARTIAL(); |
| 1754 |
|
RRETURN(MATCH_NOMATCH); |
| 1755 |
|
} |
| 1756 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 1757 |
switch(c) |
switch(c) |
| 1758 |
{ |
{ |
| 1770 |
break; |
break; |
| 1771 |
|
|
| 1772 |
case OP_VSPACE: |
case OP_VSPACE: |
| 1773 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 1774 |
|
{ |
| 1775 |
|
SCHECK_PARTIAL(); |
| 1776 |
|
RRETURN(MATCH_NOMATCH); |
| 1777 |
|
} |
| 1778 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 1779 |
switch(c) |
switch(c) |
| 1780 |
{ |
{ |
| 1797 |
|
|
| 1798 |
case OP_PROP: |
case OP_PROP: |
| 1799 |
case OP_NOTPROP: |
case OP_NOTPROP: |
| 1800 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 1801 |
|
{ |
| 1802 |
|
SCHECK_PARTIAL(); |
| 1803 |
|
RRETURN(MATCH_NOMATCH); |
| 1804 |
|
} |
| 1805 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 1806 |
{ |
{ |
| 1807 |
const ucd_record * prop = GET_UCD(c); |
const ucd_record *prop = GET_UCD(c); |
| 1808 |
|
|
| 1809 |
switch(ecode[1]) |
switch(ecode[1]) |
| 1810 |
{ |
{ |
| 1846 |
is in the binary; otherwise a compile-time error occurs. */ |
is in the binary; otherwise a compile-time error occurs. */ |
| 1847 |
|
|
| 1848 |
case OP_EXTUNI: |
case OP_EXTUNI: |
| 1849 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 1850 |
|
{ |
| 1851 |
|
SCHECK_PARTIAL(); |
| 1852 |
|
RRETURN(MATCH_NOMATCH); |
| 1853 |
|
} |
| 1854 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 1855 |
{ |
{ |
| 1856 |
int category = UCD_CATEGORY(c); |
int category = UCD_CATEGORY(c); |
| 1930 |
break; |
break; |
| 1931 |
|
|
| 1932 |
default: /* No repeat follows */ |
default: /* No repeat follows */ |
| 1933 |
if (!match_ref(offset, eptr, length, md, ims)) RRETURN(MATCH_NOMATCH); |
if (!match_ref(offset, eptr, length, md, ims)) |
| 1934 |
|
{ |
| 1935 |
|
CHECK_PARTIAL(); |
| 1936 |
|
RRETURN(MATCH_NOMATCH); |
| 1937 |
|
} |
| 1938 |
eptr += length; |
eptr += length; |
| 1939 |
continue; /* With the main loop */ |
continue; /* With the main loop */ |
| 1940 |
} |
} |
| 1941 |
|
|
| 1942 |
/* If the length of the reference is zero, just continue with the |
/* If the length of the reference is zero, just continue with the |
| 1943 |
main loop. */ |
main loop. */ |
| 1944 |
|
|
| 1945 |
if (length == 0) continue; |
if (length == 0) continue; |
| 1946 |
|
|
| 1947 |
/* First, ensure the minimum number of matches are present. We get back |
/* First, ensure the minimum number of matches are present. We get back |
| 1950 |
|
|
| 1951 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 1952 |
{ |
{ |
| 1953 |
if (!match_ref(offset, eptr, length, md, ims)) RRETURN(MATCH_NOMATCH); |
if (!match_ref(offset, eptr, length, md, ims)) |
| 1954 |
|
{ |
| 1955 |
|
CHECK_PARTIAL(); |
| 1956 |
|
RRETURN(MATCH_NOMATCH); |
| 1957 |
|
} |
| 1958 |
eptr += length; |
eptr += length; |
| 1959 |
} |
} |
| 1960 |
|
|
| 1971 |
{ |
{ |
| 1972 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM14); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM14); |
| 1973 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 1974 |
if (fi >= max || !match_ref(offset, eptr, length, md, ims)) |
if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 1975 |
|
if (!match_ref(offset, eptr, length, md, ims)) |
| 1976 |
|
{ |
| 1977 |
|
CHECK_PARTIAL(); |
| 1978 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 1979 |
|
} |
| 1980 |
eptr += length; |
eptr += length; |
| 1981 |
} |
} |
| 1982 |
/* Control never gets here */ |
/* Control never gets here */ |
| 2003 |
} |
} |
| 2004 |
/* Control never gets here */ |
/* Control never gets here */ |
| 2005 |
|
|
|
|
|
|
|
|
| 2006 |
/* Match a bit-mapped character class, possibly repeatedly. This op code is |
/* Match a bit-mapped character class, possibly repeatedly. This op code is |
| 2007 |
used when all the characters in the class have values in the range 0-255, |
used when all the characters in the class have values in the range 0-255, |
| 2008 |
and either the matching is caseful, or the characters are in the range |
and either the matching is caseful, or the characters are in the range |
| 2057 |
{ |
{ |
| 2058 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 2059 |
{ |
{ |
| 2060 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 2061 |
|
{ |
| 2062 |
|
SCHECK_PARTIAL(); |
| 2063 |
|
RRETURN(MATCH_NOMATCH); |
| 2064 |
|
} |
| 2065 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 2066 |
if (c > 255) |
if (c > 255) |
| 2067 |
{ |
{ |
| 2079 |
{ |
{ |
| 2080 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 2081 |
{ |
{ |
| 2082 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 2083 |
|
{ |
| 2084 |
|
SCHECK_PARTIAL(); |
| 2085 |
|
RRETURN(MATCH_NOMATCH); |
| 2086 |
|
} |
| 2087 |
c = *eptr++; |
c = *eptr++; |
| 2088 |
if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH); |
if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH); |
| 2089 |
} |
} |
| 2107 |
{ |
{ |
| 2108 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM16); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM16); |
| 2109 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2110 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 2111 |
|
if (eptr >= md->end_subject) |
| 2112 |
|
{ |
| 2113 |
|
SCHECK_PARTIAL(); |
| 2114 |
|
RRETURN(MATCH_NOMATCH); |
| 2115 |
|
} |
| 2116 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 2117 |
if (c > 255) |
if (c > 255) |
| 2118 |
{ |
{ |
| 2132 |
{ |
{ |
| 2133 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM17); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM17); |
| 2134 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2135 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 2136 |
|
if (eptr >= md->end_subject) |
| 2137 |
|
{ |
| 2138 |
|
SCHECK_PARTIAL(); |
| 2139 |
|
RRETURN(MATCH_NOMATCH); |
| 2140 |
|
} |
| 2141 |
c = *eptr++; |
c = *eptr++; |
| 2142 |
if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH); |
if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH); |
| 2143 |
} |
} |
| 2204 |
|
|
| 2205 |
|
|
| 2206 |
/* Match an extended character class. This opcode is encountered only |
/* Match an extended character class. This opcode is encountered only |
| 2207 |
in UTF-8 mode, because that's the only time it is compiled. */ |
when UTF-8 mode mode is supported. Nevertheless, we may not be in UTF-8 |
| 2208 |
|
mode, because Unicode properties are supported in non-UTF-8 mode. */ |
| 2209 |
|
|
| 2210 |
#ifdef SUPPORT_UTF8 |
#ifdef SUPPORT_UTF8 |
| 2211 |
case OP_XCLASS: |
case OP_XCLASS: |
| 2246 |
|
|
| 2247 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 2248 |
{ |
{ |
| 2249 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 2250 |
GETCHARINC(c, eptr); |
{ |
| 2251 |
|
SCHECK_PARTIAL(); |
| 2252 |
|
RRETURN(MATCH_NOMATCH); |
| 2253 |
|
} |
| 2254 |
|
GETCHARINCTEST(c, eptr); |
| 2255 |
if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH); |
if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH); |
| 2256 |
} |
} |
| 2257 |
|
|
| 2269 |
{ |
{ |
| 2270 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM20); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM20); |
| 2271 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2272 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 2273 |
GETCHARINC(c, eptr); |
if (eptr >= md->end_subject) |
| 2274 |
|
{ |
| 2275 |
|
SCHECK_PARTIAL(); |
| 2276 |
|
RRETURN(MATCH_NOMATCH); |
| 2277 |
|
} |
| 2278 |
|
GETCHARINCTEST(c, eptr); |
| 2279 |
if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH); |
if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH); |
| 2280 |
} |
} |
| 2281 |
/* Control never gets here */ |
/* Control never gets here */ |
| 2290 |
{ |
{ |
| 2291 |
int len = 1; |
int len = 1; |
| 2292 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) break; |
| 2293 |
GETCHARLEN(c, eptr, len); |
GETCHARLENTEST(c, eptr, len); |
| 2294 |
if (!_pcre_xclass(c, data)) break; |
if (!_pcre_xclass(c, data)) break; |
| 2295 |
eptr += len; |
eptr += len; |
| 2296 |
} |
} |
| 2317 |
length = 1; |
length = 1; |
| 2318 |
ecode++; |
ecode++; |
| 2319 |
GETCHARLEN(fc, ecode, length); |
GETCHARLEN(fc, ecode, length); |
| 2320 |
if (length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH); |
if (length > md->end_subject - eptr) |
| 2321 |
|
{ |
| 2322 |
|
CHECK_PARTIAL(); /* Not SCHECK_PARTIAL() */ |
| 2323 |
|
RRETURN(MATCH_NOMATCH); |
| 2324 |
|
} |
| 2325 |
while (length-- > 0) if (*ecode++ != *eptr++) RRETURN(MATCH_NOMATCH); |
while (length-- > 0) if (*ecode++ != *eptr++) RRETURN(MATCH_NOMATCH); |
| 2326 |
} |
} |
| 2327 |
else |
else |
| 2329 |
|
|
| 2330 |
/* Non-UTF-8 mode */ |
/* Non-UTF-8 mode */ |
| 2331 |
{ |
{ |
| 2332 |
if (md->end_subject - eptr < 1) RRETURN(MATCH_NOMATCH); |
if (md->end_subject - eptr < 1) |
| 2333 |
|
{ |
| 2334 |
|
SCHECK_PARTIAL(); /* This one can use SCHECK_PARTIAL() */ |
| 2335 |
|
RRETURN(MATCH_NOMATCH); |
| 2336 |
|
} |
| 2337 |
if (ecode[1] != *eptr++) RRETURN(MATCH_NOMATCH); |
if (ecode[1] != *eptr++) RRETURN(MATCH_NOMATCH); |
| 2338 |
ecode += 2; |
ecode += 2; |
| 2339 |
} |
} |
| 2349 |
ecode++; |
ecode++; |
| 2350 |
GETCHARLEN(fc, ecode, length); |
GETCHARLEN(fc, ecode, length); |
| 2351 |
|
|
| 2352 |
if (length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH); |
if (length > md->end_subject - eptr) |
| 2353 |
|
{ |
| 2354 |
|
CHECK_PARTIAL(); /* Not SCHECK_PARTIAL() */ |
| 2355 |
|
RRETURN(MATCH_NOMATCH); |
| 2356 |
|
} |
| 2357 |
|
|
| 2358 |
/* 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 |
| 2359 |
can use the fast lookup table. */ |
can use the fast lookup table. */ |
| 2388 |
|
|
| 2389 |
/* Non-UTF-8 mode */ |
/* Non-UTF-8 mode */ |
| 2390 |
{ |
{ |
| 2391 |
if (md->end_subject - eptr < 1) RRETURN(MATCH_NOMATCH); |
if (md->end_subject - eptr < 1) |
| 2392 |
|
{ |
| 2393 |
|
SCHECK_PARTIAL(); /* This one can use SCHECK_PARTIAL() */ |
| 2394 |
|
RRETURN(MATCH_NOMATCH); |
| 2395 |
|
} |
| 2396 |
if (md->lcc[ecode[1]] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); |
if (md->lcc[ecode[1]] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); |
| 2397 |
ecode += 2; |
ecode += 2; |
| 2398 |
} |
} |
| 2446 |
case OP_MINQUERY: |
case OP_MINQUERY: |
| 2447 |
c = *ecode++ - OP_STAR; |
c = *ecode++ - OP_STAR; |
| 2448 |
minimize = (c & 1) != 0; |
minimize = (c & 1) != 0; |
| 2449 |
|
|
| 2450 |
min = rep_min[c]; /* Pick up values from tables; */ |
min = rep_min[c]; /* Pick up values from tables; */ |
| 2451 |
max = rep_max[c]; /* zero for max => infinity */ |
max = rep_max[c]; /* zero for max => infinity */ |
| 2452 |
if (max == 0) max = INT_MAX; |
if (max == 0) max = INT_MAX; |
| 2453 |
|
|
| 2454 |
/* Common code for all repeated single-character matches. We can give |
/* Common code for all repeated single-character matches. */ |
|
up quickly if there are fewer than the minimum number of characters left in |
|
|
the subject. */ |
|
| 2455 |
|
|
| 2456 |
REPEATCHAR: |
REPEATCHAR: |
| 2457 |
#ifdef SUPPORT_UTF8 |
#ifdef SUPPORT_UTF8 |
| 2460 |
length = 1; |
length = 1; |
| 2461 |
charptr = ecode; |
charptr = ecode; |
| 2462 |
GETCHARLEN(fc, ecode, length); |
GETCHARLEN(fc, ecode, length); |
|
if (min * length > md->end_subject - eptr) RRETURN(MATCH_NOMATCH); |
|
| 2463 |
ecode += length; |
ecode += length; |
| 2464 |
|
|
| 2465 |
/* Handle multibyte character matching specially here. There is |
/* Handle multibyte character matching specially here. There is |
| 2477 |
|
|
| 2478 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 2479 |
{ |
{ |
| 2480 |
if (memcmp(eptr, charptr, length) == 0) eptr += length; |
if (eptr <= md->end_subject - length && |
| 2481 |
|
memcmp(eptr, charptr, length) == 0) eptr += length; |
| 2482 |
#ifdef SUPPORT_UCP |
#ifdef SUPPORT_UCP |
| 2483 |
/* Need braces because of following else */ |
else if (oclength > 0 && |
| 2484 |
else if (oclength == 0) { RRETURN(MATCH_NOMATCH); } |
eptr <= md->end_subject - oclength && |
| 2485 |
|
memcmp(eptr, occhars, oclength) == 0) eptr += oclength; |
| 2486 |
|
#endif /* SUPPORT_UCP */ |
| 2487 |
else |
else |
| 2488 |
{ |
{ |
| 2489 |
if (memcmp(eptr, occhars, oclength) != 0) RRETURN(MATCH_NOMATCH); |
CHECK_PARTIAL(); |
| 2490 |
eptr += oclength; |
RRETURN(MATCH_NOMATCH); |
| 2491 |
} |
} |
|
#else /* without SUPPORT_UCP */ |
|
|
else { RRETURN(MATCH_NOMATCH); } |
|
|
#endif /* SUPPORT_UCP */ |
|
| 2492 |
} |
} |
| 2493 |
|
|
| 2494 |
if (min == max) continue; |
if (min == max) continue; |
| 2499 |
{ |
{ |
| 2500 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM22); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM22); |
| 2501 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2502 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 2503 |
if (memcmp(eptr, charptr, length) == 0) eptr += length; |
if (eptr <= md->end_subject - length && |
| 2504 |
|
memcmp(eptr, charptr, length) == 0) eptr += length; |
| 2505 |
#ifdef SUPPORT_UCP |
#ifdef SUPPORT_UCP |
| 2506 |
/* Need braces because of following else */ |
else if (oclength > 0 && |
| 2507 |
else if (oclength == 0) { RRETURN(MATCH_NOMATCH); } |
eptr <= md->end_subject - oclength && |
| 2508 |
|
memcmp(eptr, occhars, oclength) == 0) eptr += oclength; |
| 2509 |
|
#endif /* SUPPORT_UCP */ |
| 2510 |
else |
else |
| 2511 |
{ |
{ |
| 2512 |
if (memcmp(eptr, occhars, oclength) != 0) RRETURN(MATCH_NOMATCH); |
CHECK_PARTIAL(); |
| 2513 |
eptr += oclength; |
RRETURN(MATCH_NOMATCH); |
| 2514 |
} |
} |
|
#else /* without SUPPORT_UCP */ |
|
|
else { RRETURN (MATCH_NOMATCH); } |
|
|
#endif /* SUPPORT_UCP */ |
|
| 2515 |
} |
} |
| 2516 |
/* Control never gets here */ |
/* Control never gets here */ |
| 2517 |
} |
} |
| 2521 |
pp = eptr; |
pp = eptr; |
| 2522 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 2523 |
{ |
{ |
| 2524 |
if (eptr > md->end_subject - length) break; |
if (eptr <= md->end_subject - length && |
| 2525 |
if (memcmp(eptr, charptr, length) == 0) eptr += length; |
memcmp(eptr, charptr, length) == 0) eptr += length; |
| 2526 |
#ifdef SUPPORT_UCP |
#ifdef SUPPORT_UCP |
| 2527 |
else if (oclength == 0) break; |
else if (oclength > 0 && |
| 2528 |
else |
eptr <= md->end_subject - oclength && |
| 2529 |
{ |
memcmp(eptr, occhars, oclength) == 0) eptr += oclength; |
|
if (memcmp(eptr, occhars, oclength) != 0) break; |
|
|
eptr += oclength; |
|
|
} |
|
|
#else /* without SUPPORT_UCP */ |
|
|
else break; |
|
| 2530 |
#endif /* SUPPORT_UCP */ |
#endif /* SUPPORT_UCP */ |
| 2531 |
|
else break; |
| 2532 |
} |
} |
| 2533 |
|
|
| 2534 |
if (possessive) continue; |
if (possessive) continue; |
| 2535 |
|
|
| 2536 |
for(;;) |
for(;;) |
| 2537 |
{ |
{ |
| 2538 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM23); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM23); |
| 2539 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2540 |
if (eptr == pp) RRETURN(MATCH_NOMATCH); |
if (eptr == pp) { RRETURN(MATCH_NOMATCH); } |
| 2541 |
#ifdef SUPPORT_UCP |
#ifdef SUPPORT_UCP |
| 2542 |
eptr--; |
eptr--; |
| 2543 |
BACKCHAR(eptr); |
BACKCHAR(eptr); |
| 2544 |
#else /* without SUPPORT_UCP */ |
#else /* without SUPPORT_UCP */ |
| 2545 |
eptr -= length; |
eptr -= length; |
| 2546 |
#endif /* SUPPORT_UCP */ |
#endif /* SUPPORT_UCP */ |
| 2547 |
} |
} |
| 2548 |
} |
} |
| 2549 |
/* Control never gets here */ |
/* Control never gets here */ |
| 2550 |
} |
} |
| 2557 |
#endif /* SUPPORT_UTF8 */ |
#endif /* SUPPORT_UTF8 */ |
| 2558 |
|
|
| 2559 |
/* When not in UTF-8 mode, load a single-byte character. */ |
/* When not in UTF-8 mode, load a single-byte character. */ |
|
{ |
|
|
if (min > md->end_subject - eptr) RRETURN(MATCH_NOMATCH); |
|
|
fc = *ecode++; |
|
|
} |
|
| 2560 |
|
|
| 2561 |
|
fc = *ecode++; |
| 2562 |
|
|
| 2563 |
/* The value of fc at this point is always less than 256, though we may or |
/* The value of fc at this point is always less than 256, though we may or |
| 2564 |
may not be in UTF-8 mode. The code is duplicated for the caseless and |
may not be in UTF-8 mode. The code is duplicated for the caseless and |
| 2565 |
caseful cases, for speed, since matching characters is likely to be quite |
caseful cases, for speed, since matching characters is likely to be quite |
| 2576 |
{ |
{ |
| 2577 |
fc = md->lcc[fc]; |
fc = md->lcc[fc]; |
| 2578 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 2579 |
|
{ |
| 2580 |
|
if (eptr >= md->end_subject) |
| 2581 |
|
{ |
| 2582 |
|
SCHECK_PARTIAL(); |
| 2583 |
|
RRETURN(MATCH_NOMATCH); |
| 2584 |
|
} |
| 2585 |
if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); |
if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); |
| 2586 |
|
} |
| 2587 |
if (min == max) continue; |
if (min == max) continue; |
| 2588 |
if (minimize) |
if (minimize) |
| 2589 |
{ |
{ |
| 2591 |
{ |
{ |
| 2592 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM24); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM24); |
| 2593 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2594 |
if (fi >= max || eptr >= md->end_subject || |
if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 2595 |
fc != md->lcc[*eptr++]) |
if (eptr >= md->end_subject) |
| 2596 |
|
{ |
| 2597 |
|
SCHECK_PARTIAL(); |
| 2598 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 2599 |
|
} |
| 2600 |
|
if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); |
| 2601 |
} |
} |
| 2602 |
/* Control never gets here */ |
/* Control never gets here */ |
| 2603 |
} |
} |
| 2609 |
if (eptr >= md->end_subject || fc != md->lcc[*eptr]) break; |
if (eptr >= md->end_subject || fc != md->lcc[*eptr]) break; |
| 2610 |
eptr++; |
eptr++; |
| 2611 |
} |
} |
| 2612 |
|
|
| 2613 |
if (possessive) continue; |
if (possessive) continue; |
| 2614 |
|
|
| 2615 |
while (eptr >= pp) |
while (eptr >= pp) |
| 2616 |
{ |
{ |
| 2617 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM25); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM25); |
| 2627 |
|
|
| 2628 |
else |
else |
| 2629 |
{ |
{ |
| 2630 |
for (i = 1; i <= min; i++) if (fc != *eptr++) RRETURN(MATCH_NOMATCH); |
for (i = 1; i <= min; i++) |
| 2631 |
|
{ |
| 2632 |
|
if (eptr >= md->end_subject) |
| 2633 |
|
{ |
| 2634 |
|
SCHECK_PARTIAL(); |
| 2635 |
|
RRETURN(MATCH_NOMATCH); |
| 2636 |
|
} |
| 2637 |
|
if (fc != *eptr++) RRETURN(MATCH_NOMATCH); |
| 2638 |
|
} |
| 2639 |
|
|
| 2640 |
if (min == max) continue; |
if (min == max) continue; |
| 2641 |
|
|
| 2642 |
if (minimize) |
if (minimize) |
| 2643 |
{ |
{ |
| 2644 |
for (fi = min;; fi++) |
for (fi = min;; fi++) |
| 2645 |
{ |
{ |
| 2646 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM26); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM26); |
| 2647 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2648 |
if (fi >= max || eptr >= md->end_subject || fc != *eptr++) |
if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 2649 |
|
if (eptr >= md->end_subject) |
| 2650 |
|
{ |
| 2651 |
|
SCHECK_PARTIAL(); |
| 2652 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 2653 |
|
} |
| 2654 |
|
if (fc != *eptr++) RRETURN(MATCH_NOMATCH); |
| 2655 |
} |
} |
| 2656 |
/* Control never gets here */ |
/* Control never gets here */ |
| 2657 |
} |
} |
| 2664 |
eptr++; |
eptr++; |
| 2665 |
} |
} |
| 2666 |
if (possessive) continue; |
if (possessive) continue; |
| 2667 |
|
|
| 2668 |
while (eptr >= pp) |
while (eptr >= pp) |
| 2669 |
{ |
{ |
| 2670 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM27); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM27); |
| 2680 |
checking can be multibyte. */ |
checking can be multibyte. */ |
| 2681 |
|
|
| 2682 |
case OP_NOT: |
case OP_NOT: |
| 2683 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 2684 |
|
{ |
| 2685 |
|
SCHECK_PARTIAL(); |
| 2686 |
|
RRETURN(MATCH_NOMATCH); |
| 2687 |
|
} |
| 2688 |
ecode++; |
ecode++; |
| 2689 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 2690 |
if ((ims & PCRE_CASELESS) != 0) |
if ((ims & PCRE_CASELESS) != 0) |
| 2761 |
max = rep_max[c]; /* zero for max => infinity */ |
max = rep_max[c]; /* zero for max => infinity */ |
| 2762 |
if (max == 0) max = INT_MAX; |
if (max == 0) max = INT_MAX; |
| 2763 |
|
|
| 2764 |
/* Common code for all repeated single-byte matches. We can give up quickly |
/* Common code for all repeated single-byte matches. */ |
|
if there are fewer than the minimum number of bytes left in the |
|
|
subject. */ |
|
| 2765 |
|
|
| 2766 |
REPEATNOTCHAR: |
REPEATNOTCHAR: |
|
if (min > md->end_subject - eptr) RRETURN(MATCH_NOMATCH); |
|
| 2767 |
fc = *ecode++; |
fc = *ecode++; |
| 2768 |
|
|
| 2769 |
/* The code is duplicated for the caseless and caseful cases, for speed, |
/* The code is duplicated for the caseless and caseful cases, for speed, |
| 2788 |
register unsigned int d; |
register unsigned int d; |
| 2789 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 2790 |
{ |
{ |
| 2791 |
|
if (eptr >= md->end_subject) |
| 2792 |
|
{ |
| 2793 |
|
SCHECK_PARTIAL(); |
| 2794 |
|
RRETURN(MATCH_NOMATCH); |
| 2795 |
|
} |
| 2796 |
GETCHARINC(d, eptr); |
GETCHARINC(d, eptr); |
| 2797 |
if (d < 256) d = md->lcc[d]; |
if (d < 256) d = md->lcc[d]; |
| 2798 |
if (fc == d) RRETURN(MATCH_NOMATCH); |
if (fc == d) RRETURN(MATCH_NOMATCH); |
| 2804 |
/* Not UTF-8 mode */ |
/* Not UTF-8 mode */ |
| 2805 |
{ |
{ |
| 2806 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 2807 |
|
{ |
| 2808 |
|
if (eptr >= md->end_subject) |
| 2809 |
|
{ |
| 2810 |
|
SCHECK_PARTIAL(); |
| 2811 |
|
RRETURN(MATCH_NOMATCH); |
| 2812 |
|
} |
| 2813 |
if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); |
if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); |
| 2814 |
|
} |
| 2815 |
} |
} |
| 2816 |
|
|
| 2817 |
if (min == max) continue; |
if (min == max) continue; |
| 2827 |
{ |
{ |
| 2828 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM28); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM28); |
| 2829 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2830 |
|
if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 2831 |
|
if (eptr >= md->end_subject) |
| 2832 |
|
{ |
| 2833 |
|
SCHECK_PARTIAL(); |
| 2834 |
|
RRETURN(MATCH_NOMATCH); |
| 2835 |
|
} |
| 2836 |
GETCHARINC(d, eptr); |
GETCHARINC(d, eptr); |
| 2837 |
if (d < 256) d = md->lcc[d]; |
if (d < 256) d = md->lcc[d]; |
| 2838 |
if (fi >= max || eptr >= md->end_subject || fc == d) |
if (fc == d) RRETURN(MATCH_NOMATCH); |
|
RRETURN(MATCH_NOMATCH); |
|
| 2839 |
} |
} |
| 2840 |
} |
} |
| 2841 |
else |
else |
| 2846 |
{ |
{ |
| 2847 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM29); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM29); |
| 2848 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2849 |
if (fi >= max || eptr >= md->end_subject || fc == md->lcc[*eptr++]) |
if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 2850 |
|
if (eptr >= md->end_subject) |
| 2851 |
|
{ |
| 2852 |
|
SCHECK_PARTIAL(); |
| 2853 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 2854 |
|
} |
| 2855 |
|
if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH); |
| 2856 |
} |
} |
| 2857 |
} |
} |
| 2858 |
/* Control never gets here */ |
/* Control never gets here */ |
| 2921 |
register unsigned int d; |
register unsigned int d; |
| 2922 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 2923 |
{ |
{ |
| 2924 |
|
if (eptr >= md->end_subject) |
| 2925 |
|
{ |
| 2926 |
|
SCHECK_PARTIAL(); |
| 2927 |
|
RRETURN(MATCH_NOMATCH); |
| 2928 |
|
} |
| 2929 |
GETCHARINC(d, eptr); |
GETCHARINC(d, eptr); |
| 2930 |
if (fc == d) RRETURN(MATCH_NOMATCH); |
if (fc == d) RRETURN(MATCH_NOMATCH); |
| 2931 |
} |
} |
| 2935 |
/* Not UTF-8 mode */ |
/* Not UTF-8 mode */ |
| 2936 |
{ |
{ |
| 2937 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 2938 |
|
{ |
| 2939 |
|
if (eptr >= md->end_subject) |
| 2940 |
|
{ |
| 2941 |
|
SCHECK_PARTIAL(); |
| 2942 |
|
RRETURN(MATCH_NOMATCH); |
| 2943 |
|
} |
| 2944 |
if (fc == *eptr++) RRETURN(MATCH_NOMATCH); |
if (fc == *eptr++) RRETURN(MATCH_NOMATCH); |
| 2945 |
|
} |
| 2946 |
} |
} |
| 2947 |
|
|
| 2948 |
if (min == max) continue; |
if (min == max) continue; |
| 2958 |
{ |
{ |
| 2959 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM32); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM32); |
| 2960 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2961 |
GETCHARINC(d, eptr); |
if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 2962 |
if (fi >= max || eptr >= md->end_subject || fc == d) |
if (eptr >= md->end_subject) |
| 2963 |
|
{ |
| 2964 |
|
SCHECK_PARTIAL(); |
| 2965 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 2966 |
|
} |
| 2967 |
|
GETCHARINC(d, eptr); |
| 2968 |
|
if (fc == d) RRETURN(MATCH_NOMATCH); |
| 2969 |
} |
} |
| 2970 |
} |
} |
| 2971 |
else |
else |
| 2976 |
{ |
{ |
| 2977 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM33); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM33); |
| 2978 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 2979 |
if (fi >= max || eptr >= md->end_subject || fc == *eptr++) |
if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 2980 |
|
if (eptr >= md->end_subject) |
| 2981 |
|
{ |
| 2982 |
|
SCHECK_PARTIAL(); |
| 2983 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 2984 |
|
} |
| 2985 |
|
if (fc == *eptr++) RRETURN(MATCH_NOMATCH); |
| 2986 |
} |
} |
| 2987 |
} |
} |
| 2988 |
/* Control never gets here */ |
/* Control never gets here */ |
| 3116 |
|
|
| 3117 |
/* First, ensure the minimum number of matches are present. Use inline |
/* First, ensure the minimum number of matches are present. Use inline |
| 3118 |
code for maximizing the speed, and do the type test once at the start |
code for maximizing the speed, and do the type test once at the start |
| 3119 |
(i.e. keep it out of the loop). Also we can test that there are at least |
(i.e. keep it out of the loop). Separate the UTF-8 code completely as that |
|
the minimum number of bytes before we start. This isn't as effective in |
|
|
UTF-8 mode, but it does no harm. Separate the UTF-8 code completely as that |
|
| 3120 |
is tidier. Also separate the UCP code, which can be the same for both UTF-8 |
is tidier. Also separate the UCP code, which can be the same for both UTF-8 |
| 3121 |
and single-bytes. */ |
and single-bytes. */ |
| 3122 |
|
|
|
if (min > md->end_subject - eptr) RRETURN(MATCH_NOMATCH); |
|
| 3123 |
if (min > 0) |
if (min > 0) |
| 3124 |
{ |
{ |
| 3125 |
#ifdef SUPPORT_UCP |
#ifdef SUPPORT_UCP |
| 3131 |
if (prop_fail_result) RRETURN(MATCH_NOMATCH); |
if (prop_fail_result) RRETURN(MATCH_NOMATCH); |
| 3132 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3133 |
{ |
{ |
| 3134 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 3135 |
|
{ |
| 3136 |
|
SCHECK_PARTIAL(); |
| 3137 |
|
RRETURN(MATCH_NOMATCH); |
| 3138 |
|
} |
| 3139 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 3140 |
} |
} |
| 3141 |
break; |
break; |
| 3143 |
case PT_LAMP: |
case PT_LAMP: |
| 3144 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3145 |
{ |
{ |
| 3146 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 3147 |
|
{ |
| 3148 |
|
SCHECK_PARTIAL(); |
| 3149 |
|
RRETURN(MATCH_NOMATCH); |
| 3150 |
|
} |
| 3151 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 3152 |
prop_chartype = UCD_CHARTYPE(c); |
prop_chartype = UCD_CHARTYPE(c); |
| 3153 |
if ((prop_chartype == ucp_Lu || |
if ((prop_chartype == ucp_Lu || |
| 3160 |
case PT_GC: |
case PT_GC: |
| 3161 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3162 |
{ |
{ |
| 3163 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 3164 |
|
{ |
| 3165 |
|
SCHECK_PARTIAL(); |
| 3166 |
|
RRETURN(MATCH_NOMATCH); |
| 3167 |
|
} |
| 3168 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 3169 |
prop_category = UCD_CATEGORY(c); |
prop_category = UCD_CATEGORY(c); |
| 3170 |
if ((prop_category == prop_value) == prop_fail_result) |
if ((prop_category == prop_value) == prop_fail_result) |
| 3175 |
case PT_PC: |
case PT_PC: |
| 3176 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3177 |
{ |
{ |
| 3178 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 3179 |
|
{ |
| 3180 |
|
SCHECK_PARTIAL(); |
| 3181 |
|
RRETURN(MATCH_NOMATCH); |
| 3182 |
|
} |
| 3183 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 3184 |
prop_chartype = UCD_CHARTYPE(c); |
prop_chartype = UCD_CHARTYPE(c); |
| 3185 |
if ((prop_chartype == prop_value) == prop_fail_result) |
if ((prop_chartype == prop_value) == prop_fail_result) |
| 3190 |
case PT_SC: |
case PT_SC: |
| 3191 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3192 |
{ |
{ |
| 3193 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 3194 |
|
{ |
| 3195 |
|
SCHECK_PARTIAL(); |
| 3196 |
|
RRETURN(MATCH_NOMATCH); |
| 3197 |
|
} |
| 3198 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 3199 |
prop_script = UCD_SCRIPT(c); |
prop_script = UCD_SCRIPT(c); |
| 3200 |
if ((prop_script == prop_value) == prop_fail_result) |
if ((prop_script == prop_value) == prop_fail_result) |
| 3214 |
{ |
{ |
| 3215 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3216 |
{ |
{ |
| 3217 |
|
if (eptr >= md->end_subject) |
| 3218 |
|
{ |
| 3219 |
|
SCHECK_PARTIAL(); |
| 3220 |
|
RRETURN(MATCH_NOMATCH); |
| 3221 |
|
} |
| 3222 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 3223 |
prop_category = UCD_CATEGORY(c); |
prop_category = UCD_CATEGORY(c); |
| 3224 |
if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH); |
if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH); |
| 3225 |
while (eptr < md->end_subject) |
while (eptr < md->end_subject) |
| 3226 |
{ |
{ |
| 3227 |
int len = 1; |
int len = 1; |
| 3228 |
if (!utf8) c = *eptr; else |
if (!utf8) c = *eptr; |
| 3229 |
{ |
else { GETCHARLEN(c, eptr, len); } |
|
GETCHARLEN(c, eptr, len); |
|
|
} |
|
| 3230 |
prop_category = UCD_CATEGORY(c); |
prop_category = UCD_CATEGORY(c); |
| 3231 |
if (prop_category != ucp_M) break; |
if (prop_category != ucp_M) break; |
| 3232 |
eptr += len; |
eptr += len; |
| 3245 |
case OP_ANY: |
case OP_ANY: |
| 3246 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3247 |
{ |
{ |
| 3248 |
if (eptr >= md->end_subject || IS_NEWLINE(eptr)) |
if (eptr >= md->end_subject) |
| 3249 |
|
{ |
| 3250 |
|
SCHECK_PARTIAL(); |
| 3251 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 3252 |
|
} |
| 3253 |
|
if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); |
| 3254 |
eptr++; |
eptr++; |
| 3255 |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| 3256 |
} |
} |
| 3259 |
case OP_ALLANY: |
case OP_ALLANY: |
| 3260 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3261 |
{ |
{ |
| 3262 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 3263 |
|
{ |
| 3264 |
|
SCHECK_PARTIAL(); |
| 3265 |
|
RRETURN(MATCH_NOMATCH); |
| 3266 |
|
} |
| 3267 |
eptr++; |
eptr++; |
| 3268 |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| 3269 |
} |
} |
| 3270 |
break; |
break; |
| 3271 |
|
|
| 3272 |
case OP_ANYBYTE: |
case OP_ANYBYTE: |
| 3273 |
|
if (eptr > md->end_subject - min) RRETURN(MATCH_NOMATCH); |
| 3274 |
eptr += min; |
eptr += min; |
| 3275 |
break; |
break; |
| 3276 |
|
|
| 3277 |
case OP_ANYNL: |
case OP_ANYNL: |
| 3278 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3279 |
{ |
{ |
| 3280 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 3281 |
|
{ |
| 3282 |
|
SCHECK_PARTIAL(); |
| 3283 |
|
RRETURN(MATCH_NOMATCH); |
| 3284 |
|
} |
| 3285 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 3286 |
switch(c) |
switch(c) |
| 3287 |
{ |
{ |
| 3307 |
case OP_NOT_HSPACE: |
case OP_NOT_HSPACE: |
| 3308 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3309 |
{ |
{ |
| 3310 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 3311 |
|
{ |
| 3312 |
|
SCHECK_PARTIAL(); |
| 3313 |
|
RRETURN(MATCH_NOMATCH); |
| 3314 |
|
} |
| 3315 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 3316 |
switch(c) |
switch(c) |
| 3317 |
{ |
{ |
| 3343 |
case OP_HSPACE: |
case OP_HSPACE: |
| 3344 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3345 |
{ |
{ |
| 3346 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 3347 |
|
{ |
| 3348 |
|
SCHECK_PARTIAL(); |
| 3349 |
|
RRETURN(MATCH_NOMATCH); |
| 3350 |
|
} |
| 3351 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 3352 |
switch(c) |
switch(c) |
| 3353 |
{ |
{ |
| 3379 |
case OP_NOT_VSPACE: |
case OP_NOT_VSPACE: |
| 3380 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3381 |
{ |
{ |
| 3382 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 3383 |
|
{ |
| 3384 |
|
SCHECK_PARTIAL(); |
| 3385 |
|
RRETURN(MATCH_NOMATCH); |
| 3386 |
|
} |
| 3387 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 3388 |
switch(c) |
switch(c) |
| 3389 |
{ |
{ |
| 3403 |
case OP_VSPACE: |
case OP_VSPACE: |
| 3404 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3405 |
{ |
{ |
| 3406 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 3407 |
|
{ |
| 3408 |
|
SCHECK_PARTIAL(); |
| 3409 |
|
RRETURN(MATCH_NOMATCH); |
| 3410 |
|
} |
| 3411 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 3412 |
switch(c) |
switch(c) |
| 3413 |
{ |
{ |
| 3427 |
case OP_NOT_DIGIT: |
case OP_NOT_DIGIT: |
| 3428 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3429 |
{ |
{ |
| 3430 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 3431 |
|
{ |
| 3432 |
|
SCHECK_PARTIAL(); |
| 3433 |
|
RRETURN(MATCH_NOMATCH); |
| 3434 |
|
} |
| 3435 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 3436 |
if (c < 128 && (md->ctypes[c] & ctype_digit) != 0) |
if (c < 128 && (md->ctypes[c] & ctype_digit) != 0) |
| 3437 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 3441 |
case OP_DIGIT: |
case OP_DIGIT: |
| 3442 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3443 |
{ |
{ |
| 3444 |
if (eptr >= md->end_subject || |
if (eptr >= md->end_subject) |
| 3445 |
*eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0) |
{ |
| 3446 |
|
SCHECK_PARTIAL(); |
| 3447 |
|
RRETURN(MATCH_NOMATCH); |
| 3448 |
|
} |
| 3449 |
|
if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0) |
| 3450 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 3451 |
/* 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 */ |
| 3452 |
} |
} |
| 3455 |
case OP_NOT_WHITESPACE: |
case OP_NOT_WHITESPACE: |
| 3456 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3457 |
{ |
{ |
| 3458 |
if (eptr >= md->end_subject || |
if (eptr >= md->end_subject) |
| 3459 |
(*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0)) |
{ |
| 3460 |
|
SCHECK_PARTIAL(); |
| 3461 |
|
RRETURN(MATCH_NOMATCH); |
| 3462 |
|
} |
| 3463 |
|
if (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0) |
| 3464 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 3465 |
while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80); |
while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80); |
| 3466 |
} |
} |
| 3469 |
case OP_WHITESPACE: |
case OP_WHITESPACE: |
| 3470 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3471 |
{ |
{ |
| 3472 |
if (eptr >= md->end_subject || |
if (eptr >= md->end_subject) |
| 3473 |
*eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0) |
{ |
| 3474 |
|
SCHECK_PARTIAL(); |
| 3475 |
|
RRETURN(MATCH_NOMATCH); |
| 3476 |
|
} |
| 3477 |
|
if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0) |
| 3478 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 3479 |
/* 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 */ |
| 3480 |
} |
} |
| 3493 |
case OP_WORDCHAR: |
case OP_WORDCHAR: |
| 3494 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3495 |
{ |
{ |
| 3496 |
if (eptr >= md->end_subject || |
if (eptr >= md->end_subject) |
| 3497 |
*eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0) |
{ |
| 3498 |
|
SCHECK_PARTIAL(); |
| 3499 |
|
RRETURN(MATCH_NOMATCH); |
| 3500 |
|
} |
| 3501 |
|
if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0) |
| 3502 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 3503 |
/* 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 */ |
| 3504 |
} |
} |
| 3512 |
#endif /* SUPPORT_UTF8 */ |
#endif /* SUPPORT_UTF8 */ |
| 3513 |
|
|
| 3514 |
/* Code for the non-UTF-8 case for minimum matching of operators other |
/* Code for the non-UTF-8 case for minimum matching of operators other |
| 3515 |
than OP_PROP and OP_NOTPROP. We can assume that there are the minimum |
than OP_PROP and OP_NOTPROP. */ |
|
number of bytes present, as this was tested above. */ |
|
| 3516 |
|
|
| 3517 |
switch(ctype) |
switch(ctype) |
| 3518 |
{ |
{ |
| 3519 |
case OP_ANY: |
case OP_ANY: |
| 3520 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3521 |
{ |
{ |
| 3522 |
|
if (eptr >= md->end_subject) |
| 3523 |
|
{ |
| 3524 |
|
SCHECK_PARTIAL(); |
| 3525 |
|
RRETURN(MATCH_NOMATCH); |
| 3526 |
|
} |
| 3527 |
if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); |
if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); |
| 3528 |
eptr++; |
eptr++; |
| 3529 |
} |
} |
| 3530 |
break; |
break; |
| 3531 |
|
|
| 3532 |
case OP_ALLANY: |
case OP_ALLANY: |
| 3533 |
|
if (eptr > md->end_subject - min) |
| 3534 |
|
{ |
| 3535 |
|
SCHECK_PARTIAL(); |
| 3536 |
|
RRETURN(MATCH_NOMATCH); |
| 3537 |
|
} |
| 3538 |
eptr += min; |
eptr += min; |
| 3539 |
break; |
break; |
| 3540 |
|
|
| 3541 |
case OP_ANYBYTE: |
case OP_ANYBYTE: |
| 3542 |
|
if (eptr > md->end_subject - min) |
| 3543 |
|
{ |
| 3544 |
|
SCHECK_PARTIAL(); |
| 3545 |
|
RRETURN(MATCH_NOMATCH); |
| 3546 |
|
} |
| 3547 |
eptr += min; |
eptr += min; |
| 3548 |
break; |
break; |
| 3549 |
|
|
|
/* Because of the CRLF case, we can't assume the minimum number of |
|
|
bytes are present in this case. */ |
|
|
|
|
| 3550 |
case OP_ANYNL: |
case OP_ANYNL: |
| 3551 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3552 |
{ |
{ |
| 3553 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 3554 |
|
{ |
| 3555 |
|
SCHECK_PARTIAL(); |
| 3556 |
|
RRETURN(MATCH_NOMATCH); |
| 3557 |
|
} |
| 3558 |
switch(*eptr++) |
switch(*eptr++) |
| 3559 |
{ |
{ |
| 3560 |
default: RRETURN(MATCH_NOMATCH); |
default: RRETURN(MATCH_NOMATCH); |
| 3576 |
case OP_NOT_HSPACE: |
case OP_NOT_HSPACE: |
| 3577 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3578 |
{ |
{ |
| 3579 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 3580 |
|
{ |
| 3581 |
|
SCHECK_PARTIAL(); |
| 3582 |
|
RRETURN(MATCH_NOMATCH); |
| 3583 |
|
} |
| 3584 |
switch(*eptr++) |
switch(*eptr++) |
| 3585 |
{ |
{ |
| 3586 |
default: break; |
default: break; |
| 3595 |
case OP_HSPACE: |
case OP_HSPACE: |
| 3596 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3597 |
{ |
{ |
| 3598 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 3599 |
|
{ |
| 3600 |
|
SCHECK_PARTIAL(); |
| 3601 |
|
RRETURN(MATCH_NOMATCH); |
| 3602 |
|
} |
| 3603 |
switch(*eptr++) |
switch(*eptr++) |
| 3604 |
{ |
{ |
| 3605 |
default: RRETURN(MATCH_NOMATCH); |
default: RRETURN(MATCH_NOMATCH); |
| 3614 |
case OP_NOT_VSPACE: |
case OP_NOT_VSPACE: |
| 3615 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3616 |
{ |
{ |
| 3617 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 3618 |
|
{ |
| 3619 |
|
SCHECK_PARTIAL(); |
| 3620 |
|
RRETURN(MATCH_NOMATCH); |
| 3621 |
|
} |
| 3622 |
switch(*eptr++) |
switch(*eptr++) |
| 3623 |
{ |
{ |
| 3624 |
default: break; |
default: break; |
| 3635 |
case OP_VSPACE: |
case OP_VSPACE: |
| 3636 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3637 |
{ |
{ |
| 3638 |
if (eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (eptr >= md->end_subject) |
| 3639 |
|
{ |
| 3640 |
|
SCHECK_PARTIAL(); |
| 3641 |
|
RRETURN(MATCH_NOMATCH); |
| 3642 |
|
} |
| 3643 |
switch(*eptr++) |
switch(*eptr++) |
| 3644 |
{ |
{ |
| 3645 |
default: RRETURN(MATCH_NOMATCH); |
default: RRETURN(MATCH_NOMATCH); |
| 3655 |
|
|
| 3656 |
case OP_NOT_DIGIT: |
case OP_NOT_DIGIT: |
| 3657 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3658 |
|
{ |
| 3659 |
|
if (eptr >= md->end_subject) |
| 3660 |
|
{ |
| 3661 |
|
SCHECK_PARTIAL(); |
| 3662 |
|
RRETURN(MATCH_NOMATCH); |
| 3663 |
|
} |
| 3664 |
if ((md->ctypes[*eptr++] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH); |
if ((md->ctypes[*eptr++] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH); |
| 3665 |
|
} |
| 3666 |
break; |
break; |
| 3667 |
|
|
| 3668 |
case OP_DIGIT: |
case OP_DIGIT: |
| 3669 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3670 |
|
{ |
| 3671 |
|
if (eptr >= md->end_subject) |
| 3672 |
|
{ |
| 3673 |
|
SCHECK_PARTIAL(); |
| 3674 |
|
RRETURN(MATCH_NOMATCH); |
| 3675 |
|
} |
| 3676 |
if ((md->ctypes[*eptr++] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH); |
if ((md->ctypes[*eptr++] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH); |
| 3677 |
|
} |
| 3678 |
break; |
break; |
| 3679 |
|
|
| 3680 |
case OP_NOT_WHITESPACE: |
case OP_NOT_WHITESPACE: |
| 3681 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3682 |
|
{ |
| 3683 |
|
if (eptr >= md->end_subject) |
| 3684 |
|
{ |
| 3685 |
|
SCHECK_PARTIAL(); |
| 3686 |
|
RRETURN(MATCH_NOMATCH); |
| 3687 |
|
} |
| 3688 |
if ((md->ctypes[*eptr++] & ctype_space) != 0) RRETURN(MATCH_NOMATCH); |
if ((md->ctypes[*eptr++] & ctype_space) != 0) RRETURN(MATCH_NOMATCH); |
| 3689 |
|
} |
| 3690 |
break; |
break; |
| 3691 |
|
|
| 3692 |
case OP_WHITESPACE: |
case OP_WHITESPACE: |
| 3693 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3694 |
|
{ |
| 3695 |
|
if (eptr >= md->end_subject) |
| 3696 |
|
{ |
| 3697 |
|
SCHECK_PARTIAL(); |
| 3698 |
|
RRETURN(MATCH_NOMATCH); |
| 3699 |
|
} |
| 3700 |
if ((md->ctypes[*eptr++] & ctype_space) == 0) RRETURN(MATCH_NOMATCH); |
if ((md->ctypes[*eptr++] & ctype_space) == 0) RRETURN(MATCH_NOMATCH); |
| 3701 |
|
} |
| 3702 |
break; |
break; |
| 3703 |
|
|
| 3704 |
case OP_NOT_WORDCHAR: |
case OP_NOT_WORDCHAR: |
| 3705 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3706 |
|
{ |
| 3707 |
|
if (eptr >= md->end_subject) |
| 3708 |
|
{ |
| 3709 |
|
SCHECK_PARTIAL(); |
| 3710 |
|
RRETURN(MATCH_NOMATCH); |
| 3711 |
|
} |
| 3712 |
if ((md->ctypes[*eptr++] & ctype_word) != 0) |
if ((md->ctypes[*eptr++] & ctype_word) != 0) |
| 3713 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 3714 |
|
} |
| 3715 |
break; |
break; |
| 3716 |
|
|
| 3717 |
case OP_WORDCHAR: |
case OP_WORDCHAR: |
| 3718 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3719 |
|
{ |
| 3720 |
|
if (eptr >= md->end_subject) |
| 3721 |
|
{ |
| 3722 |
|
SCHECK_PARTIAL(); |
| 3723 |
|
RRETURN(MATCH_NOMATCH); |
| 3724 |
|
} |
| 3725 |
if ((md->ctypes[*eptr++] & ctype_word) == 0) |
if ((md->ctypes[*eptr++] & ctype_word) == 0) |
| 3726 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 3727 |
|
} |
| 3728 |
break; |
break; |
| 3729 |
|
|
| 3730 |
default: |
default: |
| 3752 |
{ |
{ |
| 3753 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM36); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM36); |
| 3754 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3755 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 3756 |
|
if (eptr >= md->end_subject) |
| 3757 |
|
{ |
| 3758 |
|
SCHECK_PARTIAL(); |
| 3759 |
|
RRETURN(MATCH_NOMATCH); |
| 3760 |
|
} |
| 3761 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 3762 |
if (prop_fail_result) RRETURN(MATCH_NOMATCH); |
if (prop_fail_result) RRETURN(MATCH_NOMATCH); |
| 3763 |
} |
} |
| 3768 |
{ |
{ |
| 3769 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM37); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM37); |
| 3770 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3771 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 3772 |
|
if (eptr >= md->end_subject) |
| 3773 |
|
{ |
| 3774 |
|
SCHECK_PARTIAL(); |
| 3775 |
|
RRETURN(MATCH_NOMATCH); |
| 3776 |
|
} |
| 3777 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 3778 |
prop_chartype = UCD_CHARTYPE(c); |
prop_chartype = UCD_CHARTYPE(c); |
| 3779 |
if ((prop_chartype == ucp_Lu || |
if ((prop_chartype == ucp_Lu || |
| 3788 |
{ |
{ |
| 3789 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM38); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM38); |
| 3790 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3791 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 3792 |
|
if (eptr >= md->end_subject) |
| 3793 |
|
{ |
| 3794 |
|
SCHECK_PARTIAL(); |
| 3795 |
|
RRETURN(MATCH_NOMATCH); |
| 3796 |
|
} |
| 3797 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 3798 |
prop_category = UCD_CATEGORY(c); |
prop_category = UCD_CATEGORY(c); |
| 3799 |
if ((prop_category == prop_value) == prop_fail_result) |
if ((prop_category == prop_value) == prop_fail_result) |
| 3806 |
{ |
{ |
| 3807 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM39); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM39); |
| 3808 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3809 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 3810 |
|
if (eptr >= md->end_subject) |
| 3811 |
|
{ |
| 3812 |
|
SCHECK_PARTIAL(); |
| 3813 |
|
RRETURN(MATCH_NOMATCH); |
| 3814 |
|
} |
| 3815 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 3816 |
prop_chartype = UCD_CHARTYPE(c); |
prop_chartype = UCD_CHARTYPE(c); |
| 3817 |
if ((prop_chartype == prop_value) == prop_fail_result) |
if ((prop_chartype == prop_value) == prop_fail_result) |
| 3824 |
{ |
{ |
| 3825 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM40); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM40); |
| 3826 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3827 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 3828 |
|
if (eptr >= md->end_subject) |
| 3829 |
|
{ |
| 3830 |
|
SCHECK_PARTIAL(); |
| 3831 |
|
RRETURN(MATCH_NOMATCH); |
| 3832 |
|
} |
| 3833 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 3834 |
prop_script = UCD_SCRIPT(c); |
prop_script = UCD_SCRIPT(c); |
| 3835 |
if ((prop_script == prop_value) == prop_fail_result) |
if ((prop_script == prop_value) == prop_fail_result) |
| 3851 |
{ |
{ |
| 3852 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM41); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM41); |
| 3853 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3854 |
if (fi >= max || eptr >= md->end_subject) RRETURN(MATCH_NOMATCH); |
if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 3855 |
|
if (eptr >= md->end_subject) |
| 3856 |
|
{ |
| 3857 |
|
SCHECK_PARTIAL(); |
| 3858 |
|
RRETURN(MATCH_NOMATCH); |
| 3859 |
|
} |
| 3860 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 3861 |
prop_category = UCD_CATEGORY(c); |
prop_category = UCD_CATEGORY(c); |
| 3862 |
if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH); |
if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH); |
| 3863 |
while (eptr < md->end_subject) |
while (eptr < md->end_subject) |
| 3864 |
{ |
{ |
| 3865 |
int len = 1; |
int len = 1; |
| 3866 |
if (!utf8) c = *eptr; else |
if (!utf8) c = *eptr; |
| 3867 |
{ |
else { GETCHARLEN(c, eptr, len); } |
|
GETCHARLEN(c, eptr, len); |
|
|
} |
|
| 3868 |
prop_category = UCD_CATEGORY(c); |
prop_category = UCD_CATEGORY(c); |
| 3869 |
if (prop_category != ucp_M) break; |
if (prop_category != ucp_M) break; |
| 3870 |
eptr += len; |
eptr += len; |
| 3883 |
{ |
{ |
| 3884 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM42); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM42); |
| 3885 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 3886 |
if (fi >= max || eptr >= md->end_subject || |
if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 3887 |
(ctype == OP_ANY && IS_NEWLINE(eptr))) |
if (eptr >= md->end_subject) |
| 3888 |
|
{ |
| 3889 |
|
SCHECK_PARTIAL(); |
| 3890 |
|
RRETURN(MATCH_NOMATCH); |
| 3891 |
|
} |
| 3892 |
|
if (ctype == OP_ANY && IS_NEWLINE(eptr)) |
| 3893 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
|
|
|
| 3894 |
GETCHARINC(c, eptr); |
GETCHARINC(c, eptr); |
| 3895 |
switch(ctype) |
switch(ctype) |
| 3896 |
{ |
{ |
| 4046 |
{ |
{ |
| 4047 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM43); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM43); |
| 4048 |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH) RRETURN(rrc); |
| 4049 |
if (fi >= max || eptr >= md->end_subject || |
if (fi >= max) RRETURN(MATCH_NOMATCH); |
| 4050 |
(ctype == OP_ANY && IS_NEWLINE(eptr))) |
if (eptr >= md->end_subject) |
| 4051 |
|
{ |
| 4052 |
|
SCHECK_PARTIAL(); |
| 4053 |
|
RRETURN(MATCH_NOMATCH); |
| 4054 |
|
} |
| 4055 |
|
if (ctype == OP_ANY && IS_NEWLINE(eptr)) |
| 4056 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
|
|
|
| 4057 |
c = *eptr++; |
c = *eptr++; |
| 4058 |
switch(ctype) |
switch(ctype) |
| 4059 |
{ |
{ |
| 4836 |
const uschar *start_bits = NULL; |
const uschar *start_bits = NULL; |
| 4837 |
USPTR start_match = (USPTR)subject + start_offset; |
USPTR start_match = (USPTR)subject + start_offset; |
| 4838 |
USPTR end_subject; |
USPTR end_subject; |
| 4839 |
|
USPTR start_partial = NULL; |
| 4840 |
USPTR req_byte_ptr = start_match - 1; |
USPTR req_byte_ptr = start_match - 1; |
| 4841 |
|
|
| 4842 |
pcre_study_data internal_study; |
pcre_study_data internal_study; |
| 4920 |
md->notbol = (options & PCRE_NOTBOL) != 0; |
md->notbol = (options & PCRE_NOTBOL) != 0; |
| 4921 |
md->noteol = (options & PCRE_NOTEOL) != 0; |
md->noteol = (options & PCRE_NOTEOL) != 0; |
| 4922 |
md->notempty = (options & PCRE_NOTEMPTY) != 0; |
md->notempty = (options & PCRE_NOTEMPTY) != 0; |
| 4923 |
md->partial = (options & PCRE_PARTIAL) != 0; |
md->partial = ((options & PCRE_PARTIAL_HARD) != 0)? 2 : |
| 4924 |
|
((options & PCRE_PARTIAL_SOFT) != 0)? 1 : 0; |
| 4925 |
md->hitend = FALSE; |
md->hitend = FALSE; |
| 4926 |
|
|
| 4927 |
md->recursive = NULL; /* No recursion at top level */ |
md->recursive = NULL; /* No recursion at top level */ |
| 4962 |
(pcre_uint32)options) & PCRE_NEWLINE_BITS) |
(pcre_uint32)options) & PCRE_NEWLINE_BITS) |
| 4963 |
{ |
{ |
| 4964 |
case 0: newline = NEWLINE; break; /* Compile-time default */ |
case 0: newline = NEWLINE; break; /* Compile-time default */ |
| 4965 |
case PCRE_NEWLINE_CR: newline = '\r'; break; |
case PCRE_NEWLINE_CR: newline = CHAR_CR; break; |
| 4966 |
case PCRE_NEWLINE_LF: newline = '\n'; break; |
case PCRE_NEWLINE_LF: newline = CHAR_NL; break; |
| 4967 |
case PCRE_NEWLINE_CR+ |
case PCRE_NEWLINE_CR+ |
| 4968 |
PCRE_NEWLINE_LF: newline = ('\r' << 8) | '\n'; break; |
PCRE_NEWLINE_LF: newline = (CHAR_CR << 8) | CHAR_NL; break; |
| 4969 |
case PCRE_NEWLINE_ANY: newline = -1; break; |
case PCRE_NEWLINE_ANY: newline = -1; break; |
| 4970 |
case PCRE_NEWLINE_ANYCRLF: newline = -2; break; |
case PCRE_NEWLINE_ANYCRLF: newline = -2; break; |
| 4971 |
default: return PCRE_ERROR_BADNEWLINE; |
default: return PCRE_ERROR_BADNEWLINE; |
| 4995 |
} |
} |
| 4996 |
} |
} |
| 4997 |
|
|
| 4998 |
/* Partial matching is supported only for a restricted set of regexes at the |
/* Partial matching was originally supported only for a restricted set of |
| 4999 |
moment. */ |
regexes; from release 8.00 there are no restrictions, but the bits are still |
| 5000 |
|
defined (though never set). So there's no harm in leaving this code. */ |
| 5001 |
|
|
| 5002 |
if (md->partial && (re->flags & PCRE_NOPARTIAL) != 0) |
if (md->partial && (re->flags & PCRE_NOPARTIAL) != 0) |
| 5003 |
return PCRE_ERROR_BADPARTIAL; |
return PCRE_ERROR_BADPARTIAL; |
| 5008 |
#ifdef SUPPORT_UTF8 |
#ifdef SUPPORT_UTF8 |
| 5009 |
if (utf8 && (options & PCRE_NO_UTF8_CHECK) == 0) |
if (utf8 && (options & PCRE_NO_UTF8_CHECK) == 0) |
| 5010 |
{ |
{ |
| 5011 |
if (_pcre_valid_utf8((uschar *)subject, length) >= 0) |
if (_pcre_valid_utf8((USPTR)subject, length) >= 0) |
| 5012 |
return PCRE_ERROR_BADUTF8; |
return PCRE_ERROR_BADUTF8; |
| 5013 |
if (start_offset > 0 && start_offset < length) |
if (start_offset > 0 && start_offset < length) |
| 5014 |
{ |
{ |
| 5015 |
int tb = ((uschar *)subject)[start_offset]; |
int tb = ((USPTR)subject)[start_offset]; |
| 5016 |
if (tb > 127) |
if (tb > 127) |
| 5017 |
{ |
{ |
| 5018 |
tb &= 0xc0; |
tb &= 0xc0; |
| 5118 |
while (iptr < iend) *iptr++ = -1; |
while (iptr < iend) *iptr++ = -1; |
| 5119 |
} |
} |
| 5120 |
|
|
| 5121 |
/* Advance to a unique first char if possible. If firstline is TRUE, the |
/* If firstline is TRUE, the start of the match is constrained to the first |
| 5122 |
start of the match is constrained to the first line of a multiline string. |
line of a multiline string. That is, the match must be before or at the first |
| 5123 |
That is, the match must be before or at the first newline. Implement this by |
newline. Implement this by temporarily adjusting end_subject so that we stop |
| 5124 |
temporarily adjusting end_subject so that we stop scanning at a newline. If |
scanning at a newline. If the match fails at the newline, later code breaks |
| 5125 |
the match fails at the newline, later code breaks this loop. */ |
this loop. */ |
| 5126 |
|
|
| 5127 |
if (firstline) |
if (firstline) |
| 5128 |
{ |
{ |
| 5129 |
USPTR t = start_match; |
USPTR t = start_match; |
| 5130 |
|
#ifdef SUPPORT_UTF8 |
| 5131 |
|
if (utf8) |
| 5132 |
|
{ |
| 5133 |
|
while (t < md->end_subject && !IS_NEWLINE(t)) |
| 5134 |
|
{ |
| 5135 |
|
t++; |
| 5136 |
|
while (t < end_subject && (*t & 0xc0) == 0x80) t++; |
| 5137 |
|
} |
| 5138 |
|
} |
| 5139 |
|
else |
| 5140 |
|
#endif |
| 5141 |
while (t < md->end_subject && !IS_NEWLINE(t)) t++; |
while (t < md->end_subject && !IS_NEWLINE(t)) t++; |
| 5142 |
end_subject = t; |
end_subject = t; |
| 5143 |
} |
} |
| 5144 |
|
|
| 5145 |
/* Now test for a unique first byte */ |
/* There are some optimizations that avoid running the match if a known |
| 5146 |
|
starting point is not found, or if a known later character is not present. |
| 5147 |
|
However, there is an option that disables these, for testing and for ensuring |
| 5148 |
|
that all callouts do actually occur. */ |
| 5149 |
|
|
| 5150 |
if (first_byte >= 0) |
if ((options & PCRE_NO_START_OPTIMIZE) == 0) |
| 5151 |
{ |
{ |
| 5152 |
if (first_byte_caseless) |
/* Advance to a unique first byte if there is one. */ |
|
while (start_match < end_subject && |
|
|
md->lcc[*start_match] != first_byte) |
|
|
{ NEXTCHAR(start_match); } |
|
|
else |
|
|
while (start_match < end_subject && *start_match != first_byte) |
|
|
{ NEXTCHAR(start_match); } |
|
|
} |
|
| 5153 |
|
|
| 5154 |
/* Or to just after a linebreak for a multiline match if possible */ |
if (first_byte >= 0) |
| 5155 |
|
{ |
| 5156 |
|
if (first_byte_caseless) |
| 5157 |
|
while (start_match < end_subject && md->lcc[*start_match] != first_byte) |
| 5158 |
|
start_match++; |
| 5159 |
|
else |
| 5160 |
|
while (start_match < end_subject && *start_match != first_byte) |
| 5161 |
|
start_match++; |
| 5162 |
|
} |
| 5163 |
|
|
| 5164 |
else if (startline) |
/* Or to just after a linebreak for a multiline match */ |
| 5165 |
{ |
|
| 5166 |
if (start_match > md->start_subject + start_offset) |
else if (startline) |
| 5167 |
{ |
{ |
| 5168 |
while (start_match < end_subject && !WAS_NEWLINE(start_match)) |
if (start_match > md->start_subject + start_offset) |
| 5169 |
{ NEXTCHAR(start_match); } |
{ |
| 5170 |
|
#ifdef SUPPORT_UTF8 |
| 5171 |
/* If we have just passed a CR and the newline option is ANY or ANYCRLF, |
if (utf8) |
| 5172 |
and we are now at a LF, advance the match position by one more character. |
{ |
| 5173 |
*/ |
while (start_match < end_subject && !WAS_NEWLINE(start_match)) |
| 5174 |
|
{ |
| 5175 |
if (start_match[-1] == '\r' && |
start_match++; |
| 5176 |
(md->nltype == NLTYPE_ANY || md->nltype == NLTYPE_ANYCRLF) && |
while(start_match < end_subject && (*start_match & 0xc0) == 0x80) |
| 5177 |
start_match < end_subject && |
start_match++; |
| 5178 |
*start_match == '\n') |
} |
| 5179 |
start_match++; |
} |
| 5180 |
|
else |
| 5181 |
|
#endif |
| 5182 |
|
while (start_match < end_subject && !WAS_NEWLINE(start_match)) |
| 5183 |
|
start_match++; |
| 5184 |
|
|
| 5185 |
|
/* If we have just passed a CR and the newline option is ANY or ANYCRLF, |
| 5186 |
|
and we are now at a LF, advance the match position by one more character. |
| 5187 |
|
*/ |
| 5188 |
|
|
| 5189 |
|
if (start_match[-1] == CHAR_CR && |
| 5190 |
|
(md->nltype == NLTYPE_ANY || md->nltype == NLTYPE_ANYCRLF) && |
| 5191 |
|
start_match < end_subject && |
| 5192 |
|
*start_match == CHAR_NL) |
| 5193 |
|
start_match++; |
| 5194 |
|
} |
| 5195 |
} |
} |
|
} |
|
| 5196 |
|
|
| 5197 |
/* Or to a non-unique first char after study */ |
/* Or to a non-unique first byte after study */ |
| 5198 |
|
|
| 5199 |
else if (start_bits != NULL) |
else if (start_bits != NULL) |
|
{ |
|
|
while (start_match < end_subject) |
|
| 5200 |
{ |
{ |
| 5201 |
register unsigned int c = *start_match; |
while (start_match < end_subject) |
| 5202 |
if ((start_bits[c/8] & (1 << (c&7))) == 0) |
{ |
| 5203 |
{ NEXTCHAR(start_match); } |
register unsigned int c = *start_match; |
| 5204 |
else break; |
if ((start_bits[c/8] & (1 << (c&7))) == 0) start_match++; |
| 5205 |
|
else break; |
| 5206 |
|
} |
| 5207 |
} |
} |
| 5208 |
} |
} /* Starting optimizations */ |
| 5209 |
|
|
| 5210 |
/* Restore fudged end_subject */ |
/* Restore fudged end_subject */ |
| 5211 |
|
|
| 5217 |
printf("\n"); |
printf("\n"); |
| 5218 |
#endif |
#endif |
| 5219 |
|
|
| 5220 |
/* If req_byte is set, we know that that character must appear in the subject |
/* If req_byte is set, we know that that character must appear in the |
| 5221 |
for the match to succeed. If the first character is set, req_byte must be |
subject for the match to succeed. If the first character is set, req_byte |
| 5222 |
later in the subject; otherwise the test starts at the match point. This |
must be later in the subject; otherwise the test starts at the match point. |
| 5223 |
optimization can save a huge amount of backtracking in patterns with nested |
This optimization can save a huge amount of backtracking in patterns with |
| 5224 |
unlimited repeats that aren't going to match. Writing separate code for |
nested unlimited repeats that aren't going to match. Writing separate code |
| 5225 |
cased/caseless versions makes it go faster, as does using an autoincrement |
for cased/caseless versions makes it go faster, as does using an |
| 5226 |
and backing off on a match. |
autoincrement and backing off on a match. |
| 5227 |
|
|
| 5228 |
HOWEVER: when the subject string is very, very long, searching to its end can |
HOWEVER: when the subject string is very, very long, searching to its end |
| 5229 |
take a long time, and give bad performance on quite ordinary patterns. This |
can take a long time, and give bad performance on quite ordinary patterns. |
| 5230 |
showed up when somebody was matching something like /^\d+C/ on a 32-megabyte |
This showed up when somebody was matching something like /^\d+C/ on a |
| 5231 |
string... so we don't do this when the string is sufficiently long. |
32-megabyte string... so we don't do this when the string is sufficiently |
| 5232 |
|
long. |
| 5233 |
|
|
| 5234 |
ALSO: this processing is disabled when partial matching is requested. |
ALSO: this processing is disabled when partial matching is requested, or if |
| 5235 |
*/ |
disabling is explicitly requested. */ |
| 5236 |
|
|
| 5237 |
if (req_byte >= 0 && |
if ((options & PCRE_NO_START_OPTIMIZE) == 0 && |
| 5238 |
|
req_byte >= 0 && |
| 5239 |
end_subject - start_match < REQ_BYTE_MAX && |
end_subject - start_match < REQ_BYTE_MAX && |
| 5240 |
!md->partial) |
!md->partial) |
| 5241 |
{ |
{ |
| 5279 |
} |
} |
| 5280 |
} |
} |
| 5281 |
|
|
| 5282 |
/* OK, we can now run the match. */ |
/* OK, we can now run the match. If "hitend" is set afterwards, remember the |
| 5283 |
|
first starting point for which a partial match was found. */ |
| 5284 |
|
|
| 5285 |
md->start_match_ptr = start_match; |
md->start_match_ptr = start_match; |
| 5286 |
|
md->start_used_ptr = start_match; |
| 5287 |
md->match_call_count = 0; |
md->match_call_count = 0; |
| 5288 |
rc = match(start_match, md->start_code, start_match, 2, md, ims, NULL, 0, 0); |
rc = match(start_match, md->start_code, start_match, 2, md, ims, NULL, 0, 0); |
| 5289 |
|
if (md->hitend && start_partial == NULL) start_partial = md->start_used_ptr; |
| 5290 |
|
|
| 5291 |
switch(rc) |
switch(rc) |
| 5292 |
{ |
{ |
| 5346 |
not contain any explicit matches for \r or \n, and the newline option is CRLF |
not contain any explicit matches for \r or \n, and the newline option is CRLF |
| 5347 |
or ANY or ANYCRLF, advance the match position by one more character. */ |
or ANY or ANYCRLF, advance the match position by one more character. */ |
| 5348 |
|
|
| 5349 |
if (start_match[-1] == '\r' && |
if (start_match[-1] == CHAR_CR && |
| 5350 |
start_match < end_subject && |
start_match < end_subject && |
| 5351 |
*start_match == '\n' && |
*start_match == CHAR_NL && |
| 5352 |
(re->flags & PCRE_HASCRORLF) == 0 && |
(re->flags & PCRE_HASCRORLF) == 0 && |
| 5353 |
(md->nltype == NLTYPE_ANY || |
(md->nltype == NLTYPE_ANY || |
| 5354 |
md->nltype == NLTYPE_ANYCRLF || |
md->nltype == NLTYPE_ANYCRLF || |
| 5422 |
(pcre_free)(md->offset_vector); |
(pcre_free)(md->offset_vector); |
| 5423 |
} |
} |
| 5424 |
|
|
| 5425 |
if (rc != MATCH_NOMATCH) |
if (rc != MATCH_NOMATCH && rc != PCRE_ERROR_PARTIAL) |
| 5426 |
{ |
{ |
| 5427 |
DPRINTF((">>>> error: returning %d\n", rc)); |
DPRINTF((">>>> error: returning %d\n", rc)); |
| 5428 |
return rc; |
return rc; |
| 5429 |
} |
} |
| 5430 |
else if (md->partial && md->hitend) |
else if (start_partial != NULL) |
| 5431 |
{ |
{ |
| 5432 |
DPRINTF((">>>> returning PCRE_ERROR_PARTIAL\n")); |
DPRINTF((">>>> returning PCRE_ERROR_PARTIAL\n")); |
| 5433 |
|
if (offsetcount > 1) |
| 5434 |
|
{ |
| 5435 |
|
offsets[0] = start_partial - (USPTR)subject; |
| 5436 |
|
offsets[1] = end_subject - (USPTR)subject; |
| 5437 |
|
} |
| 5438 |
return PCRE_ERROR_PARTIAL; |
return PCRE_ERROR_PARTIAL; |
| 5439 |
} |
} |
| 5440 |
else |
else |