| 48 |
|
|
| 49 |
#include "pcre_internal.h" |
#include "pcre_internal.h" |
| 50 |
|
|
| 51 |
|
#define SET_BIT(c) start_bits[c/8] |= (1 << (c&7)) |
| 52 |
|
|
| 53 |
/* Returns from set_start_bits() */ |
/* Returns from set_start_bits() */ |
| 54 |
|
|
| 414 |
#endif |
#endif |
| 415 |
break; |
break; |
| 416 |
|
|
| 417 |
|
/* Skip these, but we need to add in the name length. */ |
| 418 |
|
|
| 419 |
|
case OP_MARK: |
| 420 |
|
case OP_PRUNE_ARG: |
| 421 |
|
case OP_SKIP_ARG: |
| 422 |
|
case OP_THEN_ARG: |
| 423 |
|
cc += _pcre_OP_lengths[op] + cc[1]; |
| 424 |
|
break; |
| 425 |
|
|
| 426 |
/* For the record, these are the opcodes that are matched by "default": |
/* For the record, these are the opcodes that are matched by "default": |
| 427 |
OP_ACCEPT, OP_CLOSE, OP_COMMIT, OP_FAIL, OP_PRUNE, OP_SET_SOM, OP_SKIP, |
OP_ACCEPT, OP_CLOSE, OP_COMMIT, OP_FAIL, OP_PRUNE, OP_SET_SOM, OP_SKIP, |
| 428 |
OP_THEN. */ |
OP_THEN. */ |
| 441 |
* Set a bit and maybe its alternate case * |
* Set a bit and maybe its alternate case * |
| 442 |
*************************************************/ |
*************************************************/ |
| 443 |
|
|
| 444 |
/* Given a character, set its bit in the table, and also the bit for the other |
/* Given a character, set its first byte's bit in the table, and also the |
| 445 |
version of a letter if we are caseless. |
corresponding bit for the other version of a letter if we are caseless. In |
| 446 |
|
UTF-8 mode, for characters greater than 127, we can only do the caseless thing |
| 447 |
|
when Unicode property support is available. |
| 448 |
|
|
| 449 |
Arguments: |
Arguments: |
| 450 |
start_bits points to the bit map |
start_bits points to the bit map |
| 451 |
c is the character |
p points to the character |
| 452 |
caseless the caseless flag |
caseless the caseless flag |
| 453 |
cd the block with char table pointers |
cd the block with char table pointers |
| 454 |
|
utf8 TRUE for UTF-8 mode |
| 455 |
|
|
| 456 |
Returns: nothing |
Returns: pointer after the character |
| 457 |
*/ |
*/ |
| 458 |
|
|
| 459 |
static void |
static const uschar * |
| 460 |
set_table_bit(uschar *start_bits, unsigned int c, BOOL caseless, |
set_table_bit(uschar *start_bits, const uschar *p, BOOL caseless, |
| 461 |
compile_data *cd) |
compile_data *cd, BOOL utf8) |
| 462 |
{ |
{ |
| 463 |
start_bits[c/8] |= (1 << (c&7)); |
unsigned int c = *p; |
| 464 |
if (caseless && (cd->ctypes[c] & ctype_letter) != 0) |
|
| 465 |
start_bits[cd->fcc[c]/8] |= (1 << (cd->fcc[c]&7)); |
SET_BIT(c); |
| 466 |
|
|
| 467 |
|
#ifdef SUPPORT_UTF8 |
| 468 |
|
if (utf8 && c > 127) |
| 469 |
|
{ |
| 470 |
|
GETCHARINC(c, p); |
| 471 |
|
#ifdef SUPPORT_UCP |
| 472 |
|
if (caseless) |
| 473 |
|
{ |
| 474 |
|
uschar buff[8]; |
| 475 |
|
c = UCD_OTHERCASE(c); |
| 476 |
|
(void)_pcre_ord2utf8(c, buff); |
| 477 |
|
SET_BIT(buff[0]); |
| 478 |
|
} |
| 479 |
|
#endif |
| 480 |
|
return p; |
| 481 |
|
} |
| 482 |
|
#endif |
| 483 |
|
|
| 484 |
|
/* Not UTF-8 mode, or character is less than 127. */ |
| 485 |
|
|
| 486 |
|
if (caseless && (cd->ctypes[c] & ctype_letter) != 0) SET_BIT(cd->fcc[c]); |
| 487 |
|
return p + 1; |
| 488 |
} |
} |
| 489 |
|
|
| 490 |
|
|
| 642 |
case OP_QUERY: |
case OP_QUERY: |
| 643 |
case OP_MINQUERY: |
case OP_MINQUERY: |
| 644 |
case OP_POSQUERY: |
case OP_POSQUERY: |
| 645 |
set_table_bit(start_bits, tcode[1], caseless, cd); |
tcode = set_table_bit(start_bits, tcode + 1, caseless, cd, utf8); |
|
tcode += 2; |
|
|
#ifdef SUPPORT_UTF8 |
|
|
if (utf8 && tcode[-1] >= 0xc0) |
|
|
tcode += _pcre_utf8_table4[tcode[-1] & 0x3f]; |
|
|
#endif |
|
| 646 |
break; |
break; |
| 647 |
|
|
| 648 |
/* Single-char upto sets the bit and tries the next */ |
/* Single-char upto sets the bit and tries the next */ |
| 650 |
case OP_UPTO: |
case OP_UPTO: |
| 651 |
case OP_MINUPTO: |
case OP_MINUPTO: |
| 652 |
case OP_POSUPTO: |
case OP_POSUPTO: |
| 653 |
set_table_bit(start_bits, tcode[3], caseless, cd); |
tcode = set_table_bit(start_bits, tcode + 3, caseless, cd, utf8); |
|
tcode += 4; |
|
|
#ifdef SUPPORT_UTF8 |
|
|
if (utf8 && tcode[-1] >= 0xc0) |
|
|
tcode += _pcre_utf8_table4[tcode[-1] & 0x3f]; |
|
|
#endif |
|
| 654 |
break; |
break; |
| 655 |
|
|
| 656 |
/* At least one single char sets the bit and stops */ |
/* At least one single char sets the bit and stops */ |
| 663 |
case OP_PLUS: |
case OP_PLUS: |
| 664 |
case OP_MINPLUS: |
case OP_MINPLUS: |
| 665 |
case OP_POSPLUS: |
case OP_POSPLUS: |
| 666 |
set_table_bit(start_bits, tcode[1], caseless, cd); |
(void)set_table_bit(start_bits, tcode + 1, caseless, cd, utf8); |
| 667 |
try_next = FALSE; |
try_next = FALSE; |
| 668 |
break; |
break; |
| 669 |
|
|
| 670 |
|
/* Special spacing and line-terminating items. These recognize specific |
| 671 |
|
lists of characters. The difference between VSPACE and ANYNL is that the |
| 672 |
|
latter can match the two-character CRLF sequence, but that is not |
| 673 |
|
relevant for finding the first character, so their code here is |
| 674 |
|
identical. */ |
| 675 |
|
|
| 676 |
|
case OP_HSPACE: |
| 677 |
|
SET_BIT(0x09); |
| 678 |
|
SET_BIT(0x20); |
| 679 |
|
SET_BIT(0xA0); |
| 680 |
|
if (utf8) |
| 681 |
|
{ |
| 682 |
|
SET_BIT(0xE1); /* For U+1680, U+180E */ |
| 683 |
|
SET_BIT(0xE2); /* For U+2000 - U+200A, U+202F, U+205F */ |
| 684 |
|
SET_BIT(0xE3); /* For U+3000 */ |
| 685 |
|
} |
| 686 |
|
try_next = FALSE; |
| 687 |
|
break; |
| 688 |
|
|
| 689 |
|
case OP_ANYNL: |
| 690 |
|
case OP_VSPACE: |
| 691 |
|
SET_BIT(0x0A); |
| 692 |
|
SET_BIT(0x0B); |
| 693 |
|
SET_BIT(0x0C); |
| 694 |
|
SET_BIT(0x0D); |
| 695 |
|
SET_BIT(0x85); |
| 696 |
|
if (utf8) SET_BIT(0xE2); /* For U+2028, U+2029 */ |
| 697 |
|
try_next = FALSE; |
| 698 |
|
break; |
| 699 |
|
|
| 700 |
/* Single character type sets the bits and stops */ |
/* Single character types set the bits and stop. Note that if PCRE_UCP |
| 701 |
|
is set, we do not see these op codes because \d etc are converted to |
| 702 |
|
properties. Therefore, these apply in the case when only ASCII characters |
| 703 |
|
are recognized to match the types. */ |
| 704 |
|
|
| 705 |
case OP_NOT_DIGIT: |
case OP_NOT_DIGIT: |
| 706 |
for (c = 0; c < 32; c++) |
for (c = 0; c < 32; c++) |
| 757 |
|
|
| 758 |
case OP_TYPEPLUS: |
case OP_TYPEPLUS: |
| 759 |
case OP_TYPEMINPLUS: |
case OP_TYPEMINPLUS: |
| 760 |
|
case OP_TYPEPOSPLUS: |
| 761 |
tcode++; |
tcode++; |
| 762 |
break; |
break; |
| 763 |
|
|
| 781 |
case OP_TYPEPOSQUERY: |
case OP_TYPEPOSQUERY: |
| 782 |
switch(tcode[1]) |
switch(tcode[1]) |
| 783 |
{ |
{ |
| 784 |
|
default: |
| 785 |
case OP_ANY: |
case OP_ANY: |
| 786 |
case OP_ALLANY: |
case OP_ALLANY: |
| 787 |
return SSB_FAIL; |
return SSB_FAIL; |
| 788 |
|
|
| 789 |
|
case OP_HSPACE: |
| 790 |
|
SET_BIT(0x09); |
| 791 |
|
SET_BIT(0x20); |
| 792 |
|
SET_BIT(0xA0); |
| 793 |
|
if (utf8) |
| 794 |
|
{ |
| 795 |
|
SET_BIT(0xE1); /* For U+1680, U+180E */ |
| 796 |
|
SET_BIT(0xE2); /* For U+2000 - U+200A, U+202F, U+205F */ |
| 797 |
|
SET_BIT(0xE3); /* For U+3000 */ |
| 798 |
|
} |
| 799 |
|
break; |
| 800 |
|
|
| 801 |
|
case OP_ANYNL: |
| 802 |
|
case OP_VSPACE: |
| 803 |
|
SET_BIT(0x0A); |
| 804 |
|
SET_BIT(0x0B); |
| 805 |
|
SET_BIT(0x0C); |
| 806 |
|
SET_BIT(0x0D); |
| 807 |
|
SET_BIT(0x85); |
| 808 |
|
if (utf8) SET_BIT(0xE2); /* For U+2028, U+2029 */ |
| 809 |
|
break; |
| 810 |
|
|
| 811 |
case OP_NOT_DIGIT: |
case OP_NOT_DIGIT: |
| 812 |
for (c = 0; c < 32; c++) |
for (c = 0; c < 32; c++) |
| 813 |
start_bits[c] |= ~cd->cbits[c+cbit_digit]; |
start_bits[c] |= ~cd->cbits[c+cbit_digit]; |