| 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-2009 University of Cambridge |
Copyright (c) 1997-2010 University of Cambridge |
| 10 |
|
|
| 11 |
----------------------------------------------------------------------------- |
----------------------------------------------------------------------------- |
| 12 |
Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
| 89 |
|
|
| 90 |
|
|
| 91 |
|
|
| 92 |
#ifdef DEBUG |
#ifdef PCRE_DEBUG |
| 93 |
/************************************************* |
/************************************************* |
| 94 |
* Debugging function to print chars * |
* Debugging function to print chars * |
| 95 |
*************************************************/ |
*************************************************/ |
| 141 |
{ |
{ |
| 142 |
USPTR p = md->start_subject + md->offset_vector[offset]; |
USPTR p = md->start_subject + md->offset_vector[offset]; |
| 143 |
|
|
| 144 |
#ifdef DEBUG |
#ifdef PCRE_DEBUG |
| 145 |
if (eptr >= md->end_subject) |
if (eptr >= md->end_subject) |
| 146 |
printf("matching subject <null>"); |
printf("matching subject <null>"); |
| 147 |
else |
else |
| 254 |
#ifndef NO_RECURSE |
#ifndef NO_RECURSE |
| 255 |
#define REGISTER register |
#define REGISTER register |
| 256 |
|
|
| 257 |
#ifdef DEBUG |
#ifdef PCRE_DEBUG |
| 258 |
#define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \ |
#define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \ |
| 259 |
{ \ |
{ \ |
| 260 |
printf("match() called in line %d\n", __LINE__); \ |
printf("match() called in line %d\n", __LINE__); \ |
| 415 |
} |
} |
| 416 |
|
|
| 417 |
#define SCHECK_PARTIAL()\ |
#define SCHECK_PARTIAL()\ |
| 418 |
if (md->partial && eptr > mstart)\ |
if (md->partial != 0 && eptr > mstart)\ |
| 419 |
{\ |
{\ |
| 420 |
md->hitend = TRUE;\ |
md->hitend = TRUE;\ |
| 421 |
if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);\ |
if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);\ |
| 622 |
/* OK, now we can get on with the real code of the function. Recursive calls |
/* OK, now we can get on with the real code of the function. Recursive calls |
| 623 |
are specified by the macro RMATCH and RRETURN is used to return. When |
are specified by the macro RMATCH and RRETURN is used to return. When |
| 624 |
NO_RECURSE is *not* defined, these just turn into a recursive call to match() |
NO_RECURSE is *not* defined, these just turn into a recursive call to match() |
| 625 |
and a "return", respectively (possibly with some debugging if DEBUG is |
and a "return", respectively (possibly with some debugging if PCRE_DEBUG is |
| 626 |
defined). However, RMATCH isn't like a function call because it's quite a |
defined). However, RMATCH isn't like a function call because it's quite a |
| 627 |
complicated macro. It has to be used in one particular way. This shouldn't, |
complicated macro. It has to be used in one particular way. This shouldn't, |
| 628 |
however, impact performance when true recursion is being used. */ |
however, impact performance when true recursion is being used. */ |
| 713 |
number = GET2(ecode, 1+LINK_SIZE); |
number = GET2(ecode, 1+LINK_SIZE); |
| 714 |
offset = number << 1; |
offset = number << 1; |
| 715 |
|
|
| 716 |
#ifdef DEBUG |
#ifdef PCRE_DEBUG |
| 717 |
printf("start bracket %d\n", number); |
printf("start bracket %d\n", number); |
| 718 |
printf("subject="); |
printf("subject="); |
| 719 |
pchars(eptr, 16, TRUE, md); |
pchars(eptr, 16, TRUE, md); |
| 839 |
|
|
| 840 |
/* Now see what the actual condition is */ |
/* Now see what the actual condition is */ |
| 841 |
|
|
| 842 |
if (condcode == OP_RREF) /* Recursion test */ |
if (condcode == OP_RREF || condcode == OP_NRREF) /* Recursion test */ |
| 843 |
{ |
{ |
| 844 |
offset = GET2(ecode, LINK_SIZE + 2); /* Recursion group number*/ |
if (md->recursive == NULL) /* Not recursing => FALSE */ |
| 845 |
condition = md->recursive != NULL && |
{ |
| 846 |
(offset == RREF_ANY || offset == md->recursive->group_num); |
condition = FALSE; |
| 847 |
ecode += condition? 3 : GET(ecode, 1); |
ecode += GET(ecode, 1); |
| 848 |
|
} |
| 849 |
|
else |
| 850 |
|
{ |
| 851 |
|
int recno = GET2(ecode, LINK_SIZE + 2); /* Recursion group number*/ |
| 852 |
|
condition = (recno == RREF_ANY || recno == md->recursive->group_num); |
| 853 |
|
|
| 854 |
|
/* If the test is for recursion into a specific subpattern, and it is |
| 855 |
|
false, but the test was set up by name, scan the table to see if the |
| 856 |
|
name refers to any other numbers, and test them. The condition is true |
| 857 |
|
if any one is set. */ |
| 858 |
|
|
| 859 |
|
if (!condition && condcode == OP_NRREF && recno != RREF_ANY) |
| 860 |
|
{ |
| 861 |
|
uschar *slotA = md->name_table; |
| 862 |
|
for (i = 0; i < md->name_count; i++) |
| 863 |
|
{ |
| 864 |
|
if (GET2(slotA, 0) == recno) break; |
| 865 |
|
slotA += md->name_entry_size; |
| 866 |
|
} |
| 867 |
|
|
| 868 |
|
/* Found a name for the number - there can be only one; duplicate |
| 869 |
|
names for different numbers are allowed, but not vice versa. First |
| 870 |
|
scan down for duplicates. */ |
| 871 |
|
|
| 872 |
|
if (i < md->name_count) |
| 873 |
|
{ |
| 874 |
|
uschar *slotB = slotA; |
| 875 |
|
while (slotB > md->name_table) |
| 876 |
|
{ |
| 877 |
|
slotB -= md->name_entry_size; |
| 878 |
|
if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) |
| 879 |
|
{ |
| 880 |
|
condition = GET2(slotB, 0) == md->recursive->group_num; |
| 881 |
|
if (condition) break; |
| 882 |
|
} |
| 883 |
|
else break; |
| 884 |
|
} |
| 885 |
|
|
| 886 |
|
/* Scan up for duplicates */ |
| 887 |
|
|
| 888 |
|
if (!condition) |
| 889 |
|
{ |
| 890 |
|
slotB = slotA; |
| 891 |
|
for (i++; i < md->name_count; i++) |
| 892 |
|
{ |
| 893 |
|
slotB += md->name_entry_size; |
| 894 |
|
if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) |
| 895 |
|
{ |
| 896 |
|
condition = GET2(slotB, 0) == md->recursive->group_num; |
| 897 |
|
if (condition) break; |
| 898 |
|
} |
| 899 |
|
else break; |
| 900 |
|
} |
| 901 |
|
} |
| 902 |
|
} |
| 903 |
|
} |
| 904 |
|
|
| 905 |
|
/* Chose branch according to the condition */ |
| 906 |
|
|
| 907 |
|
ecode += condition? 3 : GET(ecode, 1); |
| 908 |
|
} |
| 909 |
} |
} |
| 910 |
|
|
| 911 |
else if (condcode == OP_CREF) /* Group used test */ |
else if (condcode == OP_CREF || condcode == OP_NCREF) /* Group used test */ |
| 912 |
{ |
{ |
| 913 |
offset = GET2(ecode, LINK_SIZE+2) << 1; /* Doubled ref number */ |
offset = GET2(ecode, LINK_SIZE+2) << 1; /* Doubled ref number */ |
| 914 |
condition = offset < offset_top && md->offset_vector[offset] >= 0; |
condition = offset < offset_top && md->offset_vector[offset] >= 0; |
| 915 |
|
|
| 916 |
|
/* If the numbered capture is unset, but the reference was by name, |
| 917 |
|
scan the table to see if the name refers to any other numbers, and test |
| 918 |
|
them. The condition is true if any one is set. This is tediously similar |
| 919 |
|
to the code above, but not close enough to try to amalgamate. */ |
| 920 |
|
|
| 921 |
|
if (!condition && condcode == OP_NCREF) |
| 922 |
|
{ |
| 923 |
|
int refno = offset >> 1; |
| 924 |
|
uschar *slotA = md->name_table; |
| 925 |
|
|
| 926 |
|
for (i = 0; i < md->name_count; i++) |
| 927 |
|
{ |
| 928 |
|
if (GET2(slotA, 0) == refno) break; |
| 929 |
|
slotA += md->name_entry_size; |
| 930 |
|
} |
| 931 |
|
|
| 932 |
|
/* Found a name for the number - there can be only one; duplicate names |
| 933 |
|
for different numbers are allowed, but not vice versa. First scan down |
| 934 |
|
for duplicates. */ |
| 935 |
|
|
| 936 |
|
if (i < md->name_count) |
| 937 |
|
{ |
| 938 |
|
uschar *slotB = slotA; |
| 939 |
|
while (slotB > md->name_table) |
| 940 |
|
{ |
| 941 |
|
slotB -= md->name_entry_size; |
| 942 |
|
if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) |
| 943 |
|
{ |
| 944 |
|
offset = GET2(slotB, 0) << 1; |
| 945 |
|
condition = offset < offset_top && |
| 946 |
|
md->offset_vector[offset] >= 0; |
| 947 |
|
if (condition) break; |
| 948 |
|
} |
| 949 |
|
else break; |
| 950 |
|
} |
| 951 |
|
|
| 952 |
|
/* Scan up for duplicates */ |
| 953 |
|
|
| 954 |
|
if (!condition) |
| 955 |
|
{ |
| 956 |
|
slotB = slotA; |
| 957 |
|
for (i++; i < md->name_count; i++) |
| 958 |
|
{ |
| 959 |
|
slotB += md->name_entry_size; |
| 960 |
|
if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) |
| 961 |
|
{ |
| 962 |
|
offset = GET2(slotB, 0) << 1; |
| 963 |
|
condition = offset < offset_top && |
| 964 |
|
md->offset_vector[offset] >= 0; |
| 965 |
|
if (condition) break; |
| 966 |
|
} |
| 967 |
|
else break; |
| 968 |
|
} |
| 969 |
|
} |
| 970 |
|
} |
| 971 |
|
} |
| 972 |
|
|
| 973 |
|
/* Chose branch according to the condition */ |
| 974 |
|
|
| 975 |
ecode += condition? 3 : GET(ecode, 1); |
ecode += condition? 3 : GET(ecode, 1); |
| 976 |
} |
} |
| 977 |
|
|
| 1032 |
break; |
break; |
| 1033 |
|
|
| 1034 |
|
|
| 1035 |
|
/* Before OP_ACCEPT there may be any number of OP_CLOSE opcodes, |
| 1036 |
|
to close any currently open capturing brackets. */ |
| 1037 |
|
|
| 1038 |
|
case OP_CLOSE: |
| 1039 |
|
number = GET2(ecode, 1); |
| 1040 |
|
offset = number << 1; |
| 1041 |
|
|
| 1042 |
|
#ifdef PCRE_DEBUG |
| 1043 |
|
printf("end bracket %d at *ACCEPT", number); |
| 1044 |
|
printf("\n"); |
| 1045 |
|
#endif |
| 1046 |
|
|
| 1047 |
|
md->capture_last = number; |
| 1048 |
|
if (offset >= md->offset_max) md->offset_overflow = TRUE; else |
| 1049 |
|
{ |
| 1050 |
|
md->offset_vector[offset] = |
| 1051 |
|
md->offset_vector[md->offset_end - number]; |
| 1052 |
|
md->offset_vector[offset+1] = eptr - md->start_subject; |
| 1053 |
|
if (offset_top <= offset) offset_top = offset + 2; |
| 1054 |
|
} |
| 1055 |
|
ecode += 3; |
| 1056 |
|
break; |
| 1057 |
|
|
| 1058 |
|
|
| 1059 |
/* End of the pattern, either real or forced. If we are in a top-level |
/* End of the pattern, either real or forced. If we are in a top-level |
| 1060 |
recursion, we should restore the offsets appropriately and continue from |
recursion, we should restore the offsets appropriately and continue from |
| 1061 |
after the call. */ |
after the call. */ |
| 1069 |
md->recursive = rec->prevrec; |
md->recursive = rec->prevrec; |
| 1070 |
memmove(md->offset_vector, rec->offset_save, |
memmove(md->offset_vector, rec->offset_save, |
| 1071 |
rec->saved_max * sizeof(int)); |
rec->saved_max * sizeof(int)); |
| 1072 |
|
offset_top = rec->save_offset_top; |
| 1073 |
mstart = rec->save_start; |
mstart = rec->save_start; |
| 1074 |
ims = original_ims; |
ims = original_ims; |
| 1075 |
ecode = rec->after_call; |
ecode = rec->after_call; |
| 1133 |
offset_top = md->end_offset_top; |
offset_top = md->end_offset_top; |
| 1134 |
continue; |
continue; |
| 1135 |
|
|
| 1136 |
/* Negative assertion: all branches must fail to match */ |
/* Negative assertion: all branches must fail to match. Encountering SKIP, |
| 1137 |
|
PRUNE, or COMMIT means we must assume failure without checking subsequent |
| 1138 |
|
branches. */ |
| 1139 |
|
|
| 1140 |
case OP_ASSERT_NOT: |
case OP_ASSERT_NOT: |
| 1141 |
case OP_ASSERTBACK_NOT: |
case OP_ASSERTBACK_NOT: |
| 1144 |
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0, |
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0, |
| 1145 |
RM5); |
RM5); |
| 1146 |
if (rrc == MATCH_MATCH) RRETURN(MATCH_NOMATCH); |
if (rrc == MATCH_MATCH) RRETURN(MATCH_NOMATCH); |
| 1147 |
|
if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT) |
| 1148 |
|
{ |
| 1149 |
|
do ecode += GET(ecode,1); while (*ecode == OP_ALT); |
| 1150 |
|
break; |
| 1151 |
|
} |
| 1152 |
if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); |
if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc); |
| 1153 |
ecode += GET(ecode,1); |
ecode += GET(ecode,1); |
| 1154 |
} |
} |
| 1268 |
memcpy(new_recursive.offset_save, md->offset_vector, |
memcpy(new_recursive.offset_save, md->offset_vector, |
| 1269 |
new_recursive.saved_max * sizeof(int)); |
new_recursive.saved_max * sizeof(int)); |
| 1270 |
new_recursive.save_start = mstart; |
new_recursive.save_start = mstart; |
| 1271 |
|
new_recursive.save_offset_top = offset_top; |
| 1272 |
mstart = eptr; |
mstart = eptr; |
| 1273 |
|
|
| 1274 |
/* 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 |
| 1468 |
number = GET2(prev, 1+LINK_SIZE); |
number = GET2(prev, 1+LINK_SIZE); |
| 1469 |
offset = number << 1; |
offset = number << 1; |
| 1470 |
|
|
| 1471 |
#ifdef DEBUG |
#ifdef PCRE_DEBUG |
| 1472 |
printf("end bracket %d", number); |
printf("end bracket %d", number); |
| 1473 |
printf("\n"); |
printf("\n"); |
| 1474 |
#endif |
#endif |
| 1493 |
mstart = rec->save_start; |
mstart = rec->save_start; |
| 1494 |
memcpy(md->offset_vector, rec->offset_save, |
memcpy(md->offset_vector, rec->offset_save, |
| 1495 |
rec->saved_max * sizeof(int)); |
rec->saved_max * sizeof(int)); |
| 1496 |
|
offset_top = rec->save_offset_top; |
| 1497 |
ecode = rec->after_call; |
ecode = rec->after_call; |
| 1498 |
ims = original_ims; |
ims = original_ims; |
| 1499 |
break; |
break; |
| 2153 |
pp = eptr; |
pp = eptr; |
| 2154 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 2155 |
{ |
{ |
| 2156 |
if (!match_ref(offset, eptr, length, md, ims)) break; |
if (!match_ref(offset, eptr, length, md, ims)) |
| 2157 |
|
{ |
| 2158 |
|
CHECK_PARTIAL(); |
| 2159 |
|
break; |
| 2160 |
|
} |
| 2161 |
eptr += length; |
eptr += length; |
| 2162 |
} |
} |
| 2163 |
while (eptr >= pp) |
while (eptr >= pp) |
| 2326 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 2327 |
{ |
{ |
| 2328 |
int len = 1; |
int len = 1; |
| 2329 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 2330 |
|
{ |
| 2331 |
|
SCHECK_PARTIAL(); |
| 2332 |
|
break; |
| 2333 |
|
} |
| 2334 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 2335 |
if (c > 255) |
if (c > 255) |
| 2336 |
{ |
{ |
| 2356 |
{ |
{ |
| 2357 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 2358 |
{ |
{ |
| 2359 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 2360 |
|
{ |
| 2361 |
|
SCHECK_PARTIAL(); |
| 2362 |
|
break; |
| 2363 |
|
} |
| 2364 |
c = *eptr; |
c = *eptr; |
| 2365 |
if ((data[c/8] & (1 << (c&7))) == 0) break; |
if ((data[c/8] & (1 << (c&7))) == 0) break; |
| 2366 |
eptr++; |
eptr++; |
| 2465 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 2466 |
{ |
{ |
| 2467 |
int len = 1; |
int len = 1; |
| 2468 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 2469 |
|
{ |
| 2470 |
|
SCHECK_PARTIAL(); |
| 2471 |
|
break; |
| 2472 |
|
} |
| 2473 |
GETCHARLENTEST(c, eptr, len); |
GETCHARLENTEST(c, eptr, len); |
| 2474 |
if (!_pcre_xclass(c, data)) break; |
if (!_pcre_xclass(c, data)) break; |
| 2475 |
eptr += len; |
eptr += len; |
| 2708 |
eptr <= md->end_subject - oclength && |
eptr <= md->end_subject - oclength && |
| 2709 |
memcmp(eptr, occhars, oclength) == 0) eptr += oclength; |
memcmp(eptr, occhars, oclength) == 0) eptr += oclength; |
| 2710 |
#endif /* SUPPORT_UCP */ |
#endif /* SUPPORT_UCP */ |
| 2711 |
else break; |
else |
| 2712 |
|
{ |
| 2713 |
|
CHECK_PARTIAL(); |
| 2714 |
|
break; |
| 2715 |
|
} |
| 2716 |
} |
} |
| 2717 |
|
|
| 2718 |
if (possessive) continue; |
if (possessive) continue; |
| 2790 |
pp = eptr; |
pp = eptr; |
| 2791 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 2792 |
{ |
{ |
| 2793 |
if (eptr >= md->end_subject || fc != md->lcc[*eptr]) break; |
if (eptr >= md->end_subject) |
| 2794 |
|
{ |
| 2795 |
|
SCHECK_PARTIAL(); |
| 2796 |
|
break; |
| 2797 |
|
} |
| 2798 |
|
if (fc != md->lcc[*eptr]) break; |
| 2799 |
eptr++; |
eptr++; |
| 2800 |
} |
} |
| 2801 |
|
|
| 2849 |
pp = eptr; |
pp = eptr; |
| 2850 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 2851 |
{ |
{ |
| 2852 |
if (eptr >= md->end_subject || fc != *eptr) break; |
if (eptr >= md->end_subject) |
| 2853 |
|
{ |
| 2854 |
|
SCHECK_PARTIAL(); |
| 2855 |
|
break; |
| 2856 |
|
} |
| 2857 |
|
if (fc != *eptr) break; |
| 2858 |
eptr++; |
eptr++; |
| 2859 |
} |
} |
| 2860 |
if (possessive) continue; |
if (possessive) continue; |
| 3066 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 3067 |
{ |
{ |
| 3068 |
int len = 1; |
int len = 1; |
| 3069 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 3070 |
|
{ |
| 3071 |
|
SCHECK_PARTIAL(); |
| 3072 |
|
break; |
| 3073 |
|
} |
| 3074 |
GETCHARLEN(d, eptr, len); |
GETCHARLEN(d, eptr, len); |
| 3075 |
if (d < 256) d = md->lcc[d]; |
if (d < 256) d = md->lcc[d]; |
| 3076 |
if (fc == d) break; |
if (fc == d) break; |
| 3091 |
{ |
{ |
| 3092 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 3093 |
{ |
{ |
| 3094 |
if (eptr >= md->end_subject || fc == md->lcc[*eptr]) break; |
if (eptr >= md->end_subject) |
| 3095 |
|
{ |
| 3096 |
|
SCHECK_PARTIAL(); |
| 3097 |
|
break; |
| 3098 |
|
} |
| 3099 |
|
if (fc == md->lcc[*eptr]) break; |
| 3100 |
eptr++; |
eptr++; |
| 3101 |
} |
} |
| 3102 |
if (possessive) continue; |
if (possessive) continue; |
| 3205 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 3206 |
{ |
{ |
| 3207 |
int len = 1; |
int len = 1; |
| 3208 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 3209 |
|
{ |
| 3210 |
|
SCHECK_PARTIAL(); |
| 3211 |
|
break; |
| 3212 |
|
} |
| 3213 |
GETCHARLEN(d, eptr, len); |
GETCHARLEN(d, eptr, len); |
| 3214 |
if (fc == d) break; |
if (fc == d) break; |
| 3215 |
eptr += len; |
eptr += len; |
| 3229 |
{ |
{ |
| 3230 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 3231 |
{ |
{ |
| 3232 |
if (eptr >= md->end_subject || fc == *eptr) break; |
if (eptr >= md->end_subject) |
| 3233 |
|
{ |
| 3234 |
|
SCHECK_PARTIAL(); |
| 3235 |
|
break; |
| 3236 |
|
} |
| 3237 |
|
if (fc == *eptr) break; |
| 3238 |
eptr++; |
eptr++; |
| 3239 |
} |
} |
| 3240 |
if (possessive) continue; |
if (possessive) continue; |
| 3695 |
case OP_NOT_WORDCHAR: |
case OP_NOT_WORDCHAR: |
| 3696 |
for (i = 1; i <= min; i++) |
for (i = 1; i <= min; i++) |
| 3697 |
{ |
{ |
| 3698 |
if (eptr >= md->end_subject || |
if (eptr >= md->end_subject) |
| 3699 |
(*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0)) |
{ |
| 3700 |
|
SCHECK_PARTIAL(); |
| 3701 |
|
RRETURN(MATCH_NOMATCH); |
| 3702 |
|
} |
| 3703 |
|
if (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0) |
| 3704 |
RRETURN(MATCH_NOMATCH); |
RRETURN(MATCH_NOMATCH); |
| 3705 |
while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80); |
while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80); |
| 3706 |
} |
} |
| 4394 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4395 |
{ |
{ |
| 4396 |
int len = 1; |
int len = 1; |
| 4397 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4398 |
|
{ |
| 4399 |
|
SCHECK_PARTIAL(); |
| 4400 |
|
break; |
| 4401 |
|
} |
| 4402 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4403 |
if (prop_fail_result) break; |
if (prop_fail_result) break; |
| 4404 |
eptr+= len; |
eptr+= len; |
| 4409 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4410 |
{ |
{ |
| 4411 |
int len = 1; |
int len = 1; |
| 4412 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4413 |
|
{ |
| 4414 |
|
SCHECK_PARTIAL(); |
| 4415 |
|
break; |
| 4416 |
|
} |
| 4417 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4418 |
prop_chartype = UCD_CHARTYPE(c); |
prop_chartype = UCD_CHARTYPE(c); |
| 4419 |
if ((prop_chartype == ucp_Lu || |
if ((prop_chartype == ucp_Lu || |
| 4428 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4429 |
{ |
{ |
| 4430 |
int len = 1; |
int len = 1; |
| 4431 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4432 |
|
{ |
| 4433 |
|
SCHECK_PARTIAL(); |
| 4434 |
|
break; |
| 4435 |
|
} |
| 4436 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4437 |
prop_category = UCD_CATEGORY(c); |
prop_category = UCD_CATEGORY(c); |
| 4438 |
if ((prop_category == prop_value) == prop_fail_result) |
if ((prop_category == prop_value) == prop_fail_result) |
| 4445 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4446 |
{ |
{ |
| 4447 |
int len = 1; |
int len = 1; |
| 4448 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4449 |
|
{ |
| 4450 |
|
SCHECK_PARTIAL(); |
| 4451 |
|
break; |
| 4452 |
|
} |
| 4453 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4454 |
prop_chartype = UCD_CHARTYPE(c); |
prop_chartype = UCD_CHARTYPE(c); |
| 4455 |
if ((prop_chartype == prop_value) == prop_fail_result) |
if ((prop_chartype == prop_value) == prop_fail_result) |
| 4462 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4463 |
{ |
{ |
| 4464 |
int len = 1; |
int len = 1; |
| 4465 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4466 |
|
{ |
| 4467 |
|
SCHECK_PARTIAL(); |
| 4468 |
|
break; |
| 4469 |
|
} |
| 4470 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4471 |
prop_script = UCD_SCRIPT(c); |
prop_script = UCD_SCRIPT(c); |
| 4472 |
if ((prop_script == prop_value) == prop_fail_result) |
if ((prop_script == prop_value) == prop_fail_result) |
| 4495 |
{ |
{ |
| 4496 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4497 |
{ |
{ |
| 4498 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4499 |
|
{ |
| 4500 |
|
SCHECK_PARTIAL(); |
| 4501 |
|
break; |
| 4502 |
|
} |
| 4503 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 4504 |
prop_category = UCD_CATEGORY(c); |
prop_category = UCD_CATEGORY(c); |
| 4505 |
if (prop_category == ucp_M) break; |
if (prop_category == ucp_M) break; |
| 4519 |
/* eptr is now past the end of the maximum run */ |
/* eptr is now past the end of the maximum run */ |
| 4520 |
|
|
| 4521 |
if (possessive) continue; |
if (possessive) continue; |
| 4522 |
|
|
| 4523 |
for(;;) |
for(;;) |
| 4524 |
{ |
{ |
| 4525 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM45); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM45); |
| 4555 |
{ |
{ |
| 4556 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4557 |
{ |
{ |
| 4558 |
if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break; |
if (eptr >= md->end_subject) |
| 4559 |
|
{ |
| 4560 |
|
SCHECK_PARTIAL(); |
| 4561 |
|
break; |
| 4562 |
|
} |
| 4563 |
|
if (IS_NEWLINE(eptr)) break; |
| 4564 |
eptr++; |
eptr++; |
| 4565 |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| 4566 |
} |
} |
| 4572 |
{ |
{ |
| 4573 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4574 |
{ |
{ |
| 4575 |
if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break; |
if (eptr >= md->end_subject) |
| 4576 |
|
{ |
| 4577 |
|
SCHECK_PARTIAL(); |
| 4578 |
|
break; |
| 4579 |
|
} |
| 4580 |
|
if (IS_NEWLINE(eptr)) break; |
| 4581 |
eptr++; |
eptr++; |
| 4582 |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| 4583 |
} |
} |
| 4589 |
{ |
{ |
| 4590 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4591 |
{ |
{ |
| 4592 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4593 |
|
{ |
| 4594 |
|
SCHECK_PARTIAL(); |
| 4595 |
|
break; |
| 4596 |
|
} |
| 4597 |
eptr++; |
eptr++; |
| 4598 |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| 4599 |
} |
} |
| 4606 |
case OP_ANYBYTE: |
case OP_ANYBYTE: |
| 4607 |
c = max - min; |
c = max - min; |
| 4608 |
if (c > (unsigned int)(md->end_subject - eptr)) |
if (c > (unsigned int)(md->end_subject - eptr)) |
| 4609 |
c = md->end_subject - eptr; |
{ |
| 4610 |
eptr += c; |
eptr = md->end_subject; |
| 4611 |
|
SCHECK_PARTIAL(); |
| 4612 |
|
} |
| 4613 |
|
else eptr += c; |
| 4614 |
break; |
break; |
| 4615 |
|
|
| 4616 |
case OP_ANYNL: |
case OP_ANYNL: |
| 4617 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4618 |
{ |
{ |
| 4619 |
int len = 1; |
int len = 1; |
| 4620 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4621 |
|
{ |
| 4622 |
|
SCHECK_PARTIAL(); |
| 4623 |
|
break; |
| 4624 |
|
} |
| 4625 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4626 |
if (c == 0x000d) |
if (c == 0x000d) |
| 4627 |
{ |
{ |
| 4646 |
{ |
{ |
| 4647 |
BOOL gotspace; |
BOOL gotspace; |
| 4648 |
int len = 1; |
int len = 1; |
| 4649 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4650 |
|
{ |
| 4651 |
|
SCHECK_PARTIAL(); |
| 4652 |
|
break; |
| 4653 |
|
} |
| 4654 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4655 |
switch(c) |
switch(c) |
| 4656 |
{ |
{ |
| 4688 |
{ |
{ |
| 4689 |
BOOL gotspace; |
BOOL gotspace; |
| 4690 |
int len = 1; |
int len = 1; |
| 4691 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4692 |
|
{ |
| 4693 |
|
SCHECK_PARTIAL(); |
| 4694 |
|
break; |
| 4695 |
|
} |
| 4696 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4697 |
switch(c) |
switch(c) |
| 4698 |
{ |
{ |
| 4716 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4717 |
{ |
{ |
| 4718 |
int len = 1; |
int len = 1; |
| 4719 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4720 |
|
{ |
| 4721 |
|
SCHECK_PARTIAL(); |
| 4722 |
|
break; |
| 4723 |
|
} |
| 4724 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4725 |
if (c < 256 && (md->ctypes[c] & ctype_digit) != 0) break; |
if (c < 256 && (md->ctypes[c] & ctype_digit) != 0) break; |
| 4726 |
eptr+= len; |
eptr+= len; |
| 4731 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4732 |
{ |
{ |
| 4733 |
int len = 1; |
int len = 1; |
| 4734 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4735 |
|
{ |
| 4736 |
|
SCHECK_PARTIAL(); |
| 4737 |
|
break; |
| 4738 |
|
} |
| 4739 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4740 |
if (c >= 256 ||(md->ctypes[c] & ctype_digit) == 0) break; |
if (c >= 256 ||(md->ctypes[c] & ctype_digit) == 0) break; |
| 4741 |
eptr+= len; |
eptr+= len; |
| 4746 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4747 |
{ |
{ |
| 4748 |
int len = 1; |
int len = 1; |
| 4749 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4750 |
|
{ |
| 4751 |
|
SCHECK_PARTIAL(); |
| 4752 |
|
break; |
| 4753 |
|
} |
| 4754 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4755 |
if (c < 256 && (md->ctypes[c] & ctype_space) != 0) break; |
if (c < 256 && (md->ctypes[c] & ctype_space) != 0) break; |
| 4756 |
eptr+= len; |
eptr+= len; |
| 4761 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4762 |
{ |
{ |
| 4763 |
int len = 1; |
int len = 1; |
| 4764 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4765 |
|
{ |
| 4766 |
|
SCHECK_PARTIAL(); |
| 4767 |
|
break; |
| 4768 |
|
} |
| 4769 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4770 |
if (c >= 256 ||(md->ctypes[c] & ctype_space) == 0) break; |
if (c >= 256 ||(md->ctypes[c] & ctype_space) == 0) break; |
| 4771 |
eptr+= len; |
eptr+= len; |
| 4776 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4777 |
{ |
{ |
| 4778 |
int len = 1; |
int len = 1; |
| 4779 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4780 |
|
{ |
| 4781 |
|
SCHECK_PARTIAL(); |
| 4782 |
|
break; |
| 4783 |
|
} |
| 4784 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4785 |
if (c < 256 && (md->ctypes[c] & ctype_word) != 0) break; |
if (c < 256 && (md->ctypes[c] & ctype_word) != 0) break; |
| 4786 |
eptr+= len; |
eptr+= len; |
| 4791 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4792 |
{ |
{ |
| 4793 |
int len = 1; |
int len = 1; |
| 4794 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4795 |
|
{ |
| 4796 |
|
SCHECK_PARTIAL(); |
| 4797 |
|
break; |
| 4798 |
|
} |
| 4799 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4800 |
if (c >= 256 || (md->ctypes[c] & ctype_word) == 0) break; |
if (c >= 256 || (md->ctypes[c] & ctype_word) == 0) break; |
| 4801 |
eptr+= len; |
eptr+= len; |
| 4827 |
case OP_ANY: |
case OP_ANY: |
| 4828 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4829 |
{ |
{ |
| 4830 |
if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break; |
if (eptr >= md->end_subject) |
| 4831 |
|
{ |
| 4832 |
|
SCHECK_PARTIAL(); |
| 4833 |
|
break; |
| 4834 |
|
} |
| 4835 |
|
if (IS_NEWLINE(eptr)) break; |
| 4836 |
eptr++; |
eptr++; |
| 4837 |
} |
} |
| 4838 |
break; |
break; |
| 4841 |
case OP_ANYBYTE: |
case OP_ANYBYTE: |
| 4842 |
c = max - min; |
c = max - min; |
| 4843 |
if (c > (unsigned int)(md->end_subject - eptr)) |
if (c > (unsigned int)(md->end_subject - eptr)) |
| 4844 |
c = md->end_subject - eptr; |
{ |
| 4845 |
eptr += c; |
eptr = md->end_subject; |
| 4846 |
|
SCHECK_PARTIAL(); |
| 4847 |
|
} |
| 4848 |
|
else eptr += c; |
| 4849 |
break; |
break; |
| 4850 |
|
|
| 4851 |
case OP_ANYNL: |
case OP_ANYNL: |
| 4852 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4853 |
{ |
{ |
| 4854 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4855 |
|
{ |
| 4856 |
|
SCHECK_PARTIAL(); |
| 4857 |
|
break; |
| 4858 |
|
} |
| 4859 |
c = *eptr; |
c = *eptr; |
| 4860 |
if (c == 0x000d) |
if (c == 0x000d) |
| 4861 |
{ |
{ |
| 4876 |
case OP_NOT_HSPACE: |
case OP_NOT_HSPACE: |
| 4877 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4878 |
{ |
{ |
| 4879 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4880 |
|
{ |
| 4881 |
|
SCHECK_PARTIAL(); |
| 4882 |
|
break; |
| 4883 |
|
} |
| 4884 |
c = *eptr; |
c = *eptr; |
| 4885 |
if (c == 0x09 || c == 0x20 || c == 0xa0) break; |
if (c == 0x09 || c == 0x20 || c == 0xa0) break; |
| 4886 |
eptr++; |
eptr++; |
| 4890 |
case OP_HSPACE: |
case OP_HSPACE: |
| 4891 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4892 |
{ |
{ |
| 4893 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4894 |
|
{ |
| 4895 |
|
SCHECK_PARTIAL(); |
| 4896 |
|
break; |
| 4897 |
|
} |
| 4898 |
c = *eptr; |
c = *eptr; |
| 4899 |
if (c != 0x09 && c != 0x20 && c != 0xa0) break; |
if (c != 0x09 && c != 0x20 && c != 0xa0) break; |
| 4900 |
eptr++; |
eptr++; |
| 4904 |
case OP_NOT_VSPACE: |
case OP_NOT_VSPACE: |
| 4905 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4906 |
{ |
{ |
| 4907 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4908 |
|
{ |
| 4909 |
|
SCHECK_PARTIAL(); |
| 4910 |
|
break; |
| 4911 |
|
} |
| 4912 |
c = *eptr; |
c = *eptr; |
| 4913 |
if (c == 0x0a || c == 0x0b || c == 0x0c || c == 0x0d || c == 0x85) |
if (c == 0x0a || c == 0x0b || c == 0x0c || c == 0x0d || c == 0x85) |
| 4914 |
break; |
break; |
| 4919 |
case OP_VSPACE: |
case OP_VSPACE: |
| 4920 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4921 |
{ |
{ |
| 4922 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4923 |
|
{ |
| 4924 |
|
SCHECK_PARTIAL(); |
| 4925 |
|
break; |
| 4926 |
|
} |
| 4927 |
c = *eptr; |
c = *eptr; |
| 4928 |
if (c != 0x0a && c != 0x0b && c != 0x0c && c != 0x0d && c != 0x85) |
if (c != 0x0a && c != 0x0b && c != 0x0c && c != 0x0d && c != 0x85) |
| 4929 |
break; |
break; |
| 4934 |
case OP_NOT_DIGIT: |
case OP_NOT_DIGIT: |
| 4935 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4936 |
{ |
{ |
| 4937 |
if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) != 0) |
if (eptr >= md->end_subject) |
| 4938 |
|
{ |
| 4939 |
|
SCHECK_PARTIAL(); |
| 4940 |
break; |
break; |
| 4941 |
|
} |
| 4942 |
|
if ((md->ctypes[*eptr] & ctype_digit) != 0) break; |
| 4943 |
eptr++; |
eptr++; |
| 4944 |
} |
} |
| 4945 |
break; |
break; |
| 4947 |
case OP_DIGIT: |
case OP_DIGIT: |
| 4948 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4949 |
{ |
{ |
| 4950 |
if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) == 0) |
if (eptr >= md->end_subject) |
| 4951 |
|
{ |
| 4952 |
|
SCHECK_PARTIAL(); |
| 4953 |
break; |
break; |
| 4954 |
|
} |
| 4955 |
|
if ((md->ctypes[*eptr] & ctype_digit) == 0) break; |
| 4956 |
eptr++; |
eptr++; |
| 4957 |
} |
} |
| 4958 |
break; |
break; |
| 4960 |
case OP_NOT_WHITESPACE: |
case OP_NOT_WHITESPACE: |
| 4961 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4962 |
{ |
{ |
| 4963 |
if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) != 0) |
if (eptr >= md->end_subject) |
| 4964 |
|
{ |
| 4965 |
|
SCHECK_PARTIAL(); |
| 4966 |
break; |
break; |
| 4967 |
|
} |
| 4968 |
|
if ((md->ctypes[*eptr] & ctype_space) != 0) break; |
| 4969 |
eptr++; |
eptr++; |
| 4970 |
} |
} |
| 4971 |
break; |
break; |
| 4973 |
case OP_WHITESPACE: |
case OP_WHITESPACE: |
| 4974 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4975 |
{ |
{ |
| 4976 |
if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) == 0) |
if (eptr >= md->end_subject) |
| 4977 |
|
{ |
| 4978 |
|
SCHECK_PARTIAL(); |
| 4979 |
break; |
break; |
| 4980 |
|
} |
| 4981 |
|
if ((md->ctypes[*eptr] & ctype_space) == 0) break; |
| 4982 |
eptr++; |
eptr++; |
| 4983 |
} |
} |
| 4984 |
break; |
break; |
| 4986 |
case OP_NOT_WORDCHAR: |
case OP_NOT_WORDCHAR: |
| 4987 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4988 |
{ |
{ |
| 4989 |
if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) != 0) |
if (eptr >= md->end_subject) |
| 4990 |
|
{ |
| 4991 |
|
SCHECK_PARTIAL(); |
| 4992 |
break; |
break; |
| 4993 |
|
} |
| 4994 |
|
if ((md->ctypes[*eptr] & ctype_word) != 0) break; |
| 4995 |
eptr++; |
eptr++; |
| 4996 |
} |
} |
| 4997 |
break; |
break; |
| 4999 |
case OP_WORDCHAR: |
case OP_WORDCHAR: |
| 5000 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 5001 |
{ |
{ |
| 5002 |
if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) == 0) |
if (eptr >= md->end_subject) |
| 5003 |
|
{ |
| 5004 |
|
SCHECK_PARTIAL(); |
| 5005 |
break; |
break; |
| 5006 |
|
} |
| 5007 |
|
if ((md->ctypes[*eptr] & ctype_word) == 0) break; |
| 5008 |
eptr++; |
eptr++; |
| 5009 |
} |
} |
| 5010 |
break; |
break; |
| 5199 |
(offsets == NULL && offsetcount > 0)) return PCRE_ERROR_NULL; |
(offsets == NULL && offsetcount > 0)) return PCRE_ERROR_NULL; |
| 5200 |
if (offsetcount < 0) return PCRE_ERROR_BADCOUNT; |
if (offsetcount < 0) return PCRE_ERROR_BADCOUNT; |
| 5201 |
|
|
| 5202 |
|
/* This information is for finding all the numbers associated with a given |
| 5203 |
|
name, for condition testing. */ |
| 5204 |
|
|
| 5205 |
|
md->name_table = (uschar *)re + re->name_table_offset; |
| 5206 |
|
md->name_count = re->name_count; |
| 5207 |
|
md->name_entry_size = re->name_entry_size; |
| 5208 |
|
|
| 5209 |
/* Fish out the optional data from the extra_data structure, first setting |
/* Fish out the optional data from the extra_data structure, first setting |
| 5210 |
the default values. */ |
the default values. */ |
| 5211 |
|
|
| 5438 |
} |
} |
| 5439 |
else |
else |
| 5440 |
if (!startline && study != NULL && |
if (!startline && study != NULL && |
| 5441 |
(study->options & PCRE_STUDY_MAPPED) != 0) |
(study->flags & PCRE_STUDY_MAPPED) != 0) |
| 5442 |
start_bits = study->start_bits; |
start_bits = study->start_bits; |
| 5443 |
} |
} |
| 5444 |
|
|
| 5565 |
|
|
| 5566 |
end_subject = save_end_subject; |
end_subject = save_end_subject; |
| 5567 |
|
|
| 5568 |
#ifdef DEBUG /* Sigh. Some compilers never learn. */ |
/* The following two optimizations are disabled for partial matching or if |
|
printf(">>>> Match against: "); |
|
|
pchars(start_match, end_subject - start_match, TRUE, md); |
|
|
printf("\n"); |
|
|
#endif |
|
|
|
|
|
/* If req_byte is set, we know that that character must appear in the |
|
|
subject for the match to succeed. If the first character is set, req_byte |
|
|
must be later in the subject; otherwise the test starts at the match point. |
|
|
This optimization can save a huge amount of backtracking in patterns with |
|
|
nested unlimited repeats that aren't going to match. Writing separate code |
|
|
for cased/caseless versions makes it go faster, as does using an |
|
|
autoincrement and backing off on a match. |
|
|
|
|
|
HOWEVER: when the subject string is very, very long, searching to its end |
|
|
can take a long time, and give bad performance on quite ordinary patterns. |
|
|
This showed up when somebody was matching something like /^\d+C/ on a |
|
|
32-megabyte string... so we don't do this when the string is sufficiently |
|
|
long. |
|
|
|
|
|
ALSO: this processing is disabled when partial matching is requested, or if |
|
| 5569 |
disabling is explicitly requested. */ |
disabling is explicitly requested. */ |
| 5570 |
|
|
| 5571 |
if ((options & PCRE_NO_START_OPTIMIZE) == 0 && |
if ((options & PCRE_NO_START_OPTIMIZE) == 0 && !md->partial) |
|
req_byte >= 0 && |
|
|
end_subject - start_match < REQ_BYTE_MAX && |
|
|
!md->partial) |
|
| 5572 |
{ |
{ |
| 5573 |
register USPTR p = start_match + ((first_byte >= 0)? 1 : 0); |
/* If the pattern was studied, a minimum subject length may be set. This is |
| 5574 |
|
a lower bound; no actual string of that length may actually match the |
| 5575 |
|
pattern. Although the value is, strictly, in characters, we treat it as |
| 5576 |
|
bytes to avoid spending too much time in this optimization. */ |
| 5577 |
|
|
| 5578 |
/* We don't need to repeat the search if we haven't yet reached the |
if (study != NULL && (study->flags & PCRE_STUDY_MINLEN) != 0 && |
| 5579 |
place we found it at last time. */ |
(pcre_uint32)(end_subject - start_match) < study->minlength) |
| 5580 |
|
{ |
| 5581 |
|
rc = MATCH_NOMATCH; |
| 5582 |
|
break; |
| 5583 |
|
} |
| 5584 |
|
|
| 5585 |
|
/* If req_byte is set, we know that that character must appear in the |
| 5586 |
|
subject for the match to succeed. If the first character is set, req_byte |
| 5587 |
|
must be later in the subject; otherwise the test starts at the match point. |
| 5588 |
|
This optimization can save a huge amount of backtracking in patterns with |
| 5589 |
|
nested unlimited repeats that aren't going to match. Writing separate code |
| 5590 |
|
for cased/caseless versions makes it go faster, as does using an |
| 5591 |
|
autoincrement and backing off on a match. |
| 5592 |
|
|
| 5593 |
if (p > req_byte_ptr) |
HOWEVER: when the subject string is very, very long, searching to its end |
| 5594 |
|
can take a long time, and give bad performance on quite ordinary patterns. |
| 5595 |
|
This showed up when somebody was matching something like /^\d+C/ on a |
| 5596 |
|
32-megabyte string... so we don't do this when the string is sufficiently |
| 5597 |
|
long. */ |
| 5598 |
|
|
| 5599 |
|
if (req_byte >= 0 && end_subject - start_match < REQ_BYTE_MAX) |
| 5600 |
{ |
{ |
| 5601 |
if (req_byte_caseless) |
register USPTR p = start_match + ((first_byte >= 0)? 1 : 0); |
| 5602 |
|
|
| 5603 |
|
/* We don't need to repeat the search if we haven't yet reached the |
| 5604 |
|
place we found it at last time. */ |
| 5605 |
|
|
| 5606 |
|
if (p > req_byte_ptr) |
| 5607 |
{ |
{ |
| 5608 |
while (p < end_subject) |
if (req_byte_caseless) |
| 5609 |
{ |
{ |
| 5610 |
register int pp = *p++; |
while (p < end_subject) |
| 5611 |
if (pp == req_byte || pp == req_byte2) { p--; break; } |
{ |
| 5612 |
|
register int pp = *p++; |
| 5613 |
|
if (pp == req_byte || pp == req_byte2) { p--; break; } |
| 5614 |
|
} |
| 5615 |
} |
} |
| 5616 |
} |
else |
|
else |
|
|
{ |
|
|
while (p < end_subject) |
|
| 5617 |
{ |
{ |
| 5618 |
if (*p++ == req_byte) { p--; break; } |
while (p < end_subject) |
| 5619 |
|
{ |
| 5620 |
|
if (*p++ == req_byte) { p--; break; } |
| 5621 |
|
} |
| 5622 |
} |
} |
|
} |
|
| 5623 |
|
|
| 5624 |
/* If we can't find the required character, break the matching loop, |
/* If we can't find the required character, break the matching loop, |
| 5625 |
forcing a match failure. */ |
forcing a match failure. */ |
| 5626 |
|
|
| 5627 |
if (p >= end_subject) |
if (p >= end_subject) |
| 5628 |
{ |
{ |
| 5629 |
rc = MATCH_NOMATCH; |
rc = MATCH_NOMATCH; |
| 5630 |
break; |
break; |
| 5631 |
} |
} |
| 5632 |
|
|
| 5633 |
/* If we have found the required character, save the point where we |
/* If we have found the required character, save the point where we |
| 5634 |
found it, so that we don't search again next time round the loop if |
found it, so that we don't search again next time round the loop if |
| 5635 |
the start hasn't passed this character yet. */ |
the start hasn't passed this character yet. */ |
| 5636 |
|
|
| 5637 |
req_byte_ptr = p; |
req_byte_ptr = p; |
| 5638 |
|
} |
| 5639 |
} |
} |
| 5640 |
} |
} |
| 5641 |
|
|
| 5642 |
|
#ifdef PCRE_DEBUG /* Sigh. Some compilers never learn. */ |
| 5643 |
|
printf(">>>> Match against: "); |
| 5644 |
|
pchars(start_match, end_subject - start_match, TRUE, md); |
| 5645 |
|
printf("\n"); |
| 5646 |
|
#endif |
| 5647 |
|
|
| 5648 |
/* OK, we can now run the match. If "hitend" is set afterwards, remember the |
/* OK, we can now run the match. If "hitend" is set afterwards, remember the |
| 5649 |
first starting point for which a partial match was found. */ |
first starting point for which a partial match was found. */ |
| 5650 |
|
|
| 5682 |
rc = MATCH_NOMATCH; |
rc = MATCH_NOMATCH; |
| 5683 |
goto ENDLOOP; |
goto ENDLOOP; |
| 5684 |
|
|
| 5685 |
/* Any other return is some kind of error. */ |
/* Any other return is either a match, or some kind of error. */ |
| 5686 |
|
|
| 5687 |
default: |
default: |
| 5688 |
goto ENDLOOP; |
goto ENDLOOP; |