| 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 |
| 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);\ |
| 843 |
{ |
{ |
| 844 |
if (md->recursive == NULL) /* Not recursing => FALSE */ |
if (md->recursive == NULL) /* Not recursing => FALSE */ |
| 845 |
{ |
{ |
| 846 |
condition = FALSE; |
condition = FALSE; |
| 847 |
ecode += GET(ecode, 1); |
ecode += GET(ecode, 1); |
| 848 |
} |
} |
| 849 |
else |
else |
| 850 |
{ |
{ |
| 851 |
int recno = GET2(ecode, LINK_SIZE + 2); /* Recursion group number*/ |
int recno = GET2(ecode, LINK_SIZE + 2); /* Recursion group number*/ |
| 852 |
condition = (recno == RREF_ANY || recno == md->recursive->group_num); |
condition = (recno == RREF_ANY || recno == md->recursive->group_num); |
| 853 |
|
|
| 854 |
/* If the test is for recursion into a specific subpattern, and it is |
/* 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 |
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 |
name refers to any other numbers, and test them. The condition is true |
| 857 |
if any one is set. */ |
if any one is set. */ |
| 858 |
|
|
| 859 |
if (!condition && condcode == OP_NRREF && recno != RREF_ANY) |
if (!condition && condcode == OP_NRREF && recno != RREF_ANY) |
| 860 |
{ |
{ |
| 861 |
uschar *slotA = md->name_table; |
uschar *slotA = md->name_table; |
| 862 |
for (i = 0; i < md->name_count; i++) |
for (i = 0; i < md->name_count; i++) |
| 863 |
{ |
{ |
| 864 |
if (GET2(slotA, 0) == recno) break; |
if (GET2(slotA, 0) == recno) break; |
| 865 |
slotA += md->name_entry_size; |
slotA += md->name_entry_size; |
| 866 |
} |
} |
| 867 |
|
|
| 868 |
/* Found a name for the number - there can be only one; duplicate |
/* Found a name for the number - there can be only one; duplicate |
| 869 |
names for different numbers are allowed, but not vice versa. First |
names for different numbers are allowed, but not vice versa. First |
| 870 |
scan down for duplicates. */ |
scan down for duplicates. */ |
| 871 |
|
|
| 872 |
if (i < md->name_count) |
if (i < md->name_count) |
| 873 |
{ |
{ |
| 874 |
uschar *slotB = slotA; |
uschar *slotB = slotA; |
| 875 |
while (slotB > md->name_table) |
while (slotB > md->name_table) |
| 876 |
{ |
{ |
| 878 |
if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) |
if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) |
| 879 |
{ |
{ |
| 880 |
condition = GET2(slotB, 0) == md->recursive->group_num; |
condition = GET2(slotB, 0) == md->recursive->group_num; |
| 881 |
if (condition) break; |
if (condition) break; |
| 882 |
} |
} |
| 883 |
else break; |
else break; |
| 884 |
} |
} |
| 885 |
|
|
| 886 |
/* Scan up for duplicates */ |
/* Scan up for duplicates */ |
| 887 |
|
|
| 888 |
if (!condition) |
if (!condition) |
| 889 |
{ |
{ |
| 890 |
slotB = slotA; |
slotB = slotA; |
| 891 |
for (i++; i < md->name_count; i++) |
for (i++; i < md->name_count; i++) |
| 892 |
{ |
{ |
| 895 |
{ |
{ |
| 896 |
condition = GET2(slotB, 0) == md->recursive->group_num; |
condition = GET2(slotB, 0) == md->recursive->group_num; |
| 897 |
if (condition) break; |
if (condition) break; |
| 898 |
} |
} |
| 899 |
else break; |
else break; |
| 900 |
} |
} |
| 901 |
} |
} |
| 902 |
} |
} |
| 903 |
} |
} |
| 904 |
|
|
| 905 |
/* Chose branch according to the condition */ |
/* Chose branch according to the condition */ |
| 906 |
|
|
| 907 |
ecode += condition? 3 : GET(ecode, 1); |
ecode += condition? 3 : GET(ecode, 1); |
| 908 |
} |
} |
| 909 |
} |
} |
| 910 |
|
|
| 911 |
else if (condcode == OP_CREF || condcode == OP_NCREF) /* 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, |
/* 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 |
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 |
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. */ |
to the code above, but not close enough to try to amalgamate. */ |
| 920 |
|
|
| 921 |
if (!condition && condcode == OP_NCREF) |
if (!condition && condcode == OP_NCREF) |
| 922 |
{ |
{ |
| 923 |
int refno = offset >> 1; |
int refno = offset >> 1; |
| 924 |
uschar *slotA = md->name_table; |
uschar *slotA = md->name_table; |
| 925 |
|
|
| 926 |
for (i = 0; i < md->name_count; i++) |
for (i = 0; i < md->name_count; i++) |
| 927 |
{ |
{ |
| 928 |
if (GET2(slotA, 0) == refno) break; |
if (GET2(slotA, 0) == refno) break; |
| 929 |
slotA += md->name_entry_size; |
slotA += md->name_entry_size; |
| 930 |
} |
} |
| 931 |
|
|
| 932 |
/* Found a name for the number - there can be only one; duplicate names |
/* 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 |
for different numbers are allowed, but not vice versa. First scan down |
| 934 |
for duplicates. */ |
for duplicates. */ |
| 935 |
|
|
| 936 |
if (i < md->name_count) |
if (i < md->name_count) |
| 937 |
{ |
{ |
| 938 |
uschar *slotB = slotA; |
uschar *slotB = slotA; |
| 939 |
while (slotB > md->name_table) |
while (slotB > md->name_table) |
| 940 |
{ |
{ |
| 942 |
if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) |
if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) |
| 943 |
{ |
{ |
| 944 |
offset = GET2(slotB, 0) << 1; |
offset = GET2(slotB, 0) << 1; |
| 945 |
condition = offset < offset_top && |
condition = offset < offset_top && |
| 946 |
md->offset_vector[offset] >= 0; |
md->offset_vector[offset] >= 0; |
| 947 |
if (condition) break; |
if (condition) break; |
| 948 |
} |
} |
| 949 |
else break; |
else break; |
| 950 |
} |
} |
| 951 |
|
|
| 952 |
/* Scan up for duplicates */ |
/* Scan up for duplicates */ |
| 953 |
|
|
| 954 |
if (!condition) |
if (!condition) |
| 955 |
{ |
{ |
| 956 |
slotB = slotA; |
slotB = slotA; |
| 957 |
for (i++; i < md->name_count; i++) |
for (i++; i < md->name_count; i++) |
| 958 |
{ |
{ |
| 960 |
if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) |
if (strcmp((char *)slotA + 2, (char *)slotB + 2) == 0) |
| 961 |
{ |
{ |
| 962 |
offset = GET2(slotB, 0) << 1; |
offset = GET2(slotB, 0) << 1; |
| 963 |
condition = offset < offset_top && |
condition = offset < offset_top && |
| 964 |
md->offset_vector[offset] >= 0; |
md->offset_vector[offset] >= 0; |
| 965 |
if (condition) break; |
if (condition) break; |
| 966 |
} |
} |
| 967 |
else break; |
else break; |
| 968 |
} |
} |
| 969 |
} |
} |
| 970 |
} |
} |
| 971 |
} |
} |
| 972 |
|
|
| 973 |
/* Chose branch according to the condition */ |
/* Chose branch according to the condition */ |
| 974 |
|
|
| 975 |
ecode += condition? 3 : GET(ecode, 1); |
ecode += condition? 3 : GET(ecode, 1); |
| 1030 |
ecode += 1 + LINK_SIZE; |
ecode += 1 + LINK_SIZE; |
| 1031 |
} |
} |
| 1032 |
break; |
break; |
| 1033 |
|
|
| 1034 |
|
|
| 1035 |
/* Before OP_ACCEPT there may be any number of OP_CLOSE opcodes, |
/* Before OP_ACCEPT there may be any number of OP_CLOSE opcodes, |
| 1036 |
to close any currently open capturing brackets. */ |
to close any currently open capturing brackets. */ |
| 1037 |
|
|
| 1038 |
case OP_CLOSE: |
case OP_CLOSE: |
| 1039 |
number = GET2(ecode, 1); |
number = GET2(ecode, 1); |
| 1040 |
offset = number << 1; |
offset = number << 1; |
| 1041 |
|
|
| 1042 |
#ifdef DEBUG |
#ifdef DEBUG |
| 1043 |
printf("end bracket %d at *ACCEPT", number); |
printf("end bracket %d at *ACCEPT", number); |
| 1044 |
printf("\n"); |
printf("\n"); |
| 1053 |
if (offset_top <= offset) offset_top = offset + 2; |
if (offset_top <= offset) offset_top = offset + 2; |
| 1054 |
} |
} |
| 1055 |
ecode += 3; |
ecode += 3; |
| 1056 |
break; |
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 |
| 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->offset_top; |
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.offset_top = offset_top; |
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 |
| 1467 |
{ |
{ |
| 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 DEBUG |
| 1472 |
printf("end bracket %d", number); |
printf("end bracket %d", number); |
| 1473 |
printf("\n"); |
printf("\n"); |
| 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->offset_top; |
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; |
| 4390 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4391 |
{ |
{ |
| 4392 |
int len = 1; |
int len = 1; |
| 4393 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4394 |
|
{ |
| 4395 |
|
SCHECK_PARTIAL(); |
| 4396 |
|
break; |
| 4397 |
|
} |
| 4398 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4399 |
if (prop_fail_result) break; |
if (prop_fail_result) break; |
| 4400 |
eptr+= len; |
eptr+= len; |
| 4405 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4406 |
{ |
{ |
| 4407 |
int len = 1; |
int len = 1; |
| 4408 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4409 |
|
{ |
| 4410 |
|
SCHECK_PARTIAL(); |
| 4411 |
|
break; |
| 4412 |
|
} |
| 4413 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4414 |
prop_chartype = UCD_CHARTYPE(c); |
prop_chartype = UCD_CHARTYPE(c); |
| 4415 |
if ((prop_chartype == ucp_Lu || |
if ((prop_chartype == ucp_Lu || |
| 4424 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4425 |
{ |
{ |
| 4426 |
int len = 1; |
int len = 1; |
| 4427 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4428 |
|
{ |
| 4429 |
|
SCHECK_PARTIAL(); |
| 4430 |
|
break; |
| 4431 |
|
} |
| 4432 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4433 |
prop_category = UCD_CATEGORY(c); |
prop_category = UCD_CATEGORY(c); |
| 4434 |
if ((prop_category == prop_value) == prop_fail_result) |
if ((prop_category == prop_value) == prop_fail_result) |
| 4441 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4442 |
{ |
{ |
| 4443 |
int len = 1; |
int len = 1; |
| 4444 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4445 |
|
{ |
| 4446 |
|
SCHECK_PARTIAL(); |
| 4447 |
|
break; |
| 4448 |
|
} |
| 4449 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4450 |
prop_chartype = UCD_CHARTYPE(c); |
prop_chartype = UCD_CHARTYPE(c); |
| 4451 |
if ((prop_chartype == prop_value) == prop_fail_result) |
if ((prop_chartype == prop_value) == prop_fail_result) |
| 4458 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4459 |
{ |
{ |
| 4460 |
int len = 1; |
int len = 1; |
| 4461 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4462 |
|
{ |
| 4463 |
|
SCHECK_PARTIAL(); |
| 4464 |
|
break; |
| 4465 |
|
} |
| 4466 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4467 |
prop_script = UCD_SCRIPT(c); |
prop_script = UCD_SCRIPT(c); |
| 4468 |
if ((prop_script == prop_value) == prop_fail_result) |
if ((prop_script == prop_value) == prop_fail_result) |
| 4491 |
{ |
{ |
| 4492 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4493 |
{ |
{ |
| 4494 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4495 |
|
{ |
| 4496 |
|
SCHECK_PARTIAL(); |
| 4497 |
|
break; |
| 4498 |
|
} |
| 4499 |
GETCHARINCTEST(c, eptr); |
GETCHARINCTEST(c, eptr); |
| 4500 |
prop_category = UCD_CATEGORY(c); |
prop_category = UCD_CATEGORY(c); |
| 4501 |
if (prop_category == ucp_M) break; |
if (prop_category == ucp_M) break; |
| 4515 |
/* eptr is now past the end of the maximum run */ |
/* eptr is now past the end of the maximum run */ |
| 4516 |
|
|
| 4517 |
if (possessive) continue; |
if (possessive) continue; |
| 4518 |
|
|
| 4519 |
for(;;) |
for(;;) |
| 4520 |
{ |
{ |
| 4521 |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM45); |
RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM45); |
| 4551 |
{ |
{ |
| 4552 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4553 |
{ |
{ |
| 4554 |
if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break; |
if (eptr >= md->end_subject) |
| 4555 |
|
{ |
| 4556 |
|
SCHECK_PARTIAL(); |
| 4557 |
|
break; |
| 4558 |
|
} |
| 4559 |
|
if (IS_NEWLINE(eptr)) break; |
| 4560 |
eptr++; |
eptr++; |
| 4561 |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| 4562 |
} |
} |
| 4568 |
{ |
{ |
| 4569 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4570 |
{ |
{ |
| 4571 |
if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break; |
if (eptr >= md->end_subject) |
| 4572 |
|
{ |
| 4573 |
|
SCHECK_PARTIAL(); |
| 4574 |
|
break; |
| 4575 |
|
} |
| 4576 |
|
if (IS_NEWLINE(eptr)) break; |
| 4577 |
eptr++; |
eptr++; |
| 4578 |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| 4579 |
} |
} |
| 4585 |
{ |
{ |
| 4586 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4587 |
{ |
{ |
| 4588 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4589 |
|
{ |
| 4590 |
|
SCHECK_PARTIAL(); |
| 4591 |
|
break; |
| 4592 |
|
} |
| 4593 |
eptr++; |
eptr++; |
| 4594 |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++; |
| 4595 |
} |
} |
| 4602 |
case OP_ANYBYTE: |
case OP_ANYBYTE: |
| 4603 |
c = max - min; |
c = max - min; |
| 4604 |
if (c > (unsigned int)(md->end_subject - eptr)) |
if (c > (unsigned int)(md->end_subject - eptr)) |
| 4605 |
c = md->end_subject - eptr; |
{ |
| 4606 |
eptr += c; |
eptr = md->end_subject; |
| 4607 |
|
SCHECK_PARTIAL(); |
| 4608 |
|
} |
| 4609 |
|
else eptr += c; |
| 4610 |
break; |
break; |
| 4611 |
|
|
| 4612 |
case OP_ANYNL: |
case OP_ANYNL: |
| 4613 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4614 |
{ |
{ |
| 4615 |
int len = 1; |
int len = 1; |
| 4616 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4617 |
|
{ |
| 4618 |
|
SCHECK_PARTIAL(); |
| 4619 |
|
break; |
| 4620 |
|
} |
| 4621 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4622 |
if (c == 0x000d) |
if (c == 0x000d) |
| 4623 |
{ |
{ |
| 4642 |
{ |
{ |
| 4643 |
BOOL gotspace; |
BOOL gotspace; |
| 4644 |
int len = 1; |
int len = 1; |
| 4645 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4646 |
|
{ |
| 4647 |
|
SCHECK_PARTIAL(); |
| 4648 |
|
break; |
| 4649 |
|
} |
| 4650 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4651 |
switch(c) |
switch(c) |
| 4652 |
{ |
{ |
| 4684 |
{ |
{ |
| 4685 |
BOOL gotspace; |
BOOL gotspace; |
| 4686 |
int len = 1; |
int len = 1; |
| 4687 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4688 |
|
{ |
| 4689 |
|
SCHECK_PARTIAL(); |
| 4690 |
|
break; |
| 4691 |
|
} |
| 4692 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4693 |
switch(c) |
switch(c) |
| 4694 |
{ |
{ |
| 4712 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4713 |
{ |
{ |
| 4714 |
int len = 1; |
int len = 1; |
| 4715 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4716 |
|
{ |
| 4717 |
|
SCHECK_PARTIAL(); |
| 4718 |
|
break; |
| 4719 |
|
} |
| 4720 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4721 |
if (c < 256 && (md->ctypes[c] & ctype_digit) != 0) break; |
if (c < 256 && (md->ctypes[c] & ctype_digit) != 0) break; |
| 4722 |
eptr+= len; |
eptr+= len; |
| 4727 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4728 |
{ |
{ |
| 4729 |
int len = 1; |
int len = 1; |
| 4730 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4731 |
|
{ |
| 4732 |
|
SCHECK_PARTIAL(); |
| 4733 |
|
break; |
| 4734 |
|
} |
| 4735 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4736 |
if (c >= 256 ||(md->ctypes[c] & ctype_digit) == 0) break; |
if (c >= 256 ||(md->ctypes[c] & ctype_digit) == 0) break; |
| 4737 |
eptr+= len; |
eptr+= len; |
| 4742 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4743 |
{ |
{ |
| 4744 |
int len = 1; |
int len = 1; |
| 4745 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4746 |
|
{ |
| 4747 |
|
SCHECK_PARTIAL(); |
| 4748 |
|
break; |
| 4749 |
|
} |
| 4750 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4751 |
if (c < 256 && (md->ctypes[c] & ctype_space) != 0) break; |
if (c < 256 && (md->ctypes[c] & ctype_space) != 0) break; |
| 4752 |
eptr+= len; |
eptr+= len; |
| 4757 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4758 |
{ |
{ |
| 4759 |
int len = 1; |
int len = 1; |
| 4760 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4761 |
|
{ |
| 4762 |
|
SCHECK_PARTIAL(); |
| 4763 |
|
break; |
| 4764 |
|
} |
| 4765 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4766 |
if (c >= 256 ||(md->ctypes[c] & ctype_space) == 0) break; |
if (c >= 256 ||(md->ctypes[c] & ctype_space) == 0) break; |
| 4767 |
eptr+= len; |
eptr+= len; |
| 4772 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4773 |
{ |
{ |
| 4774 |
int len = 1; |
int len = 1; |
| 4775 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4776 |
|
{ |
| 4777 |
|
SCHECK_PARTIAL(); |
| 4778 |
|
break; |
| 4779 |
|
} |
| 4780 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4781 |
if (c < 256 && (md->ctypes[c] & ctype_word) != 0) break; |
if (c < 256 && (md->ctypes[c] & ctype_word) != 0) break; |
| 4782 |
eptr+= len; |
eptr+= len; |
| 4787 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4788 |
{ |
{ |
| 4789 |
int len = 1; |
int len = 1; |
| 4790 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4791 |
|
{ |
| 4792 |
|
SCHECK_PARTIAL(); |
| 4793 |
|
break; |
| 4794 |
|
} |
| 4795 |
GETCHARLEN(c, eptr, len); |
GETCHARLEN(c, eptr, len); |
| 4796 |
if (c >= 256 || (md->ctypes[c] & ctype_word) == 0) break; |
if (c >= 256 || (md->ctypes[c] & ctype_word) == 0) break; |
| 4797 |
eptr+= len; |
eptr+= len; |
| 4823 |
case OP_ANY: |
case OP_ANY: |
| 4824 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4825 |
{ |
{ |
| 4826 |
if (eptr >= md->end_subject || IS_NEWLINE(eptr)) break; |
if (eptr >= md->end_subject) |
| 4827 |
|
{ |
| 4828 |
|
SCHECK_PARTIAL(); |
| 4829 |
|
break; |
| 4830 |
|
} |
| 4831 |
|
if (IS_NEWLINE(eptr)) break; |
| 4832 |
eptr++; |
eptr++; |
| 4833 |
} |
} |
| 4834 |
break; |
break; |
| 4837 |
case OP_ANYBYTE: |
case OP_ANYBYTE: |
| 4838 |
c = max - min; |
c = max - min; |
| 4839 |
if (c > (unsigned int)(md->end_subject - eptr)) |
if (c > (unsigned int)(md->end_subject - eptr)) |
| 4840 |
c = md->end_subject - eptr; |
{ |
| 4841 |
eptr += c; |
eptr = md->end_subject; |
| 4842 |
|
SCHECK_PARTIAL(); |
| 4843 |
|
} |
| 4844 |
|
else eptr += c; |
| 4845 |
break; |
break; |
| 4846 |
|
|
| 4847 |
case OP_ANYNL: |
case OP_ANYNL: |
| 4848 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4849 |
{ |
{ |
| 4850 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4851 |
|
{ |
| 4852 |
|
SCHECK_PARTIAL(); |
| 4853 |
|
break; |
| 4854 |
|
} |
| 4855 |
c = *eptr; |
c = *eptr; |
| 4856 |
if (c == 0x000d) |
if (c == 0x000d) |
| 4857 |
{ |
{ |
| 4872 |
case OP_NOT_HSPACE: |
case OP_NOT_HSPACE: |
| 4873 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4874 |
{ |
{ |
| 4875 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4876 |
|
{ |
| 4877 |
|
SCHECK_PARTIAL(); |
| 4878 |
|
break; |
| 4879 |
|
} |
| 4880 |
c = *eptr; |
c = *eptr; |
| 4881 |
if (c == 0x09 || c == 0x20 || c == 0xa0) break; |
if (c == 0x09 || c == 0x20 || c == 0xa0) break; |
| 4882 |
eptr++; |
eptr++; |
| 4886 |
case OP_HSPACE: |
case OP_HSPACE: |
| 4887 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4888 |
{ |
{ |
| 4889 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4890 |
|
{ |
| 4891 |
|
SCHECK_PARTIAL(); |
| 4892 |
|
break; |
| 4893 |
|
} |
| 4894 |
c = *eptr; |
c = *eptr; |
| 4895 |
if (c != 0x09 && c != 0x20 && c != 0xa0) break; |
if (c != 0x09 && c != 0x20 && c != 0xa0) break; |
| 4896 |
eptr++; |
eptr++; |
| 4900 |
case OP_NOT_VSPACE: |
case OP_NOT_VSPACE: |
| 4901 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4902 |
{ |
{ |
| 4903 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4904 |
|
{ |
| 4905 |
|
SCHECK_PARTIAL(); |
| 4906 |
|
break; |
| 4907 |
|
} |
| 4908 |
c = *eptr; |
c = *eptr; |
| 4909 |
if (c == 0x0a || c == 0x0b || c == 0x0c || c == 0x0d || c == 0x85) |
if (c == 0x0a || c == 0x0b || c == 0x0c || c == 0x0d || c == 0x85) |
| 4910 |
break; |
break; |
| 4915 |
case OP_VSPACE: |
case OP_VSPACE: |
| 4916 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4917 |
{ |
{ |
| 4918 |
if (eptr >= md->end_subject) break; |
if (eptr >= md->end_subject) |
| 4919 |
|
{ |
| 4920 |
|
SCHECK_PARTIAL(); |
| 4921 |
|
break; |
| 4922 |
|
} |
| 4923 |
c = *eptr; |
c = *eptr; |
| 4924 |
if (c != 0x0a && c != 0x0b && c != 0x0c && c != 0x0d && c != 0x85) |
if (c != 0x0a && c != 0x0b && c != 0x0c && c != 0x0d && c != 0x85) |
| 4925 |
break; |
break; |
| 4930 |
case OP_NOT_DIGIT: |
case OP_NOT_DIGIT: |
| 4931 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4932 |
{ |
{ |
| 4933 |
if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) != 0) |
if (eptr >= md->end_subject) |
| 4934 |
|
{ |
| 4935 |
|
SCHECK_PARTIAL(); |
| 4936 |
break; |
break; |
| 4937 |
|
} |
| 4938 |
|
if ((md->ctypes[*eptr] & ctype_digit) != 0) break; |
| 4939 |
eptr++; |
eptr++; |
| 4940 |
} |
} |
| 4941 |
break; |
break; |
| 4943 |
case OP_DIGIT: |
case OP_DIGIT: |
| 4944 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4945 |
{ |
{ |
| 4946 |
if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) == 0) |
if (eptr >= md->end_subject) |
| 4947 |
|
{ |
| 4948 |
|
SCHECK_PARTIAL(); |
| 4949 |
break; |
break; |
| 4950 |
|
} |
| 4951 |
|
if ((md->ctypes[*eptr] & ctype_digit) == 0) break; |
| 4952 |
eptr++; |
eptr++; |
| 4953 |
} |
} |
| 4954 |
break; |
break; |
| 4956 |
case OP_NOT_WHITESPACE: |
case OP_NOT_WHITESPACE: |
| 4957 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4958 |
{ |
{ |
| 4959 |
if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) != 0) |
if (eptr >= md->end_subject) |
| 4960 |
|
{ |
| 4961 |
|
SCHECK_PARTIAL(); |
| 4962 |
break; |
break; |
| 4963 |
|
} |
| 4964 |
|
if ((md->ctypes[*eptr] & ctype_space) != 0) break; |
| 4965 |
eptr++; |
eptr++; |
| 4966 |
} |
} |
| 4967 |
break; |
break; |
| 4969 |
case OP_WHITESPACE: |
case OP_WHITESPACE: |
| 4970 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4971 |
{ |
{ |
| 4972 |
if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) == 0) |
if (eptr >= md->end_subject) |
| 4973 |
|
{ |
| 4974 |
|
SCHECK_PARTIAL(); |
| 4975 |
break; |
break; |
| 4976 |
|
} |
| 4977 |
|
if ((md->ctypes[*eptr] & ctype_space) == 0) break; |
| 4978 |
eptr++; |
eptr++; |
| 4979 |
} |
} |
| 4980 |
break; |
break; |
| 4982 |
case OP_NOT_WORDCHAR: |
case OP_NOT_WORDCHAR: |
| 4983 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4984 |
{ |
{ |
| 4985 |
if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) != 0) |
if (eptr >= md->end_subject) |
| 4986 |
|
{ |
| 4987 |
|
SCHECK_PARTIAL(); |
| 4988 |
break; |
break; |
| 4989 |
|
} |
| 4990 |
|
if ((md->ctypes[*eptr] & ctype_word) != 0) break; |
| 4991 |
eptr++; |
eptr++; |
| 4992 |
} |
} |
| 4993 |
break; |
break; |
| 4995 |
case OP_WORDCHAR: |
case OP_WORDCHAR: |
| 4996 |
for (i = min; i < max; i++) |
for (i = min; i < max; i++) |
| 4997 |
{ |
{ |
| 4998 |
if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) == 0) |
if (eptr >= md->end_subject) |
| 4999 |
|
{ |
| 5000 |
|
SCHECK_PARTIAL(); |
| 5001 |
break; |
break; |
| 5002 |
|
} |
| 5003 |
|
if ((md->ctypes[*eptr] & ctype_word) == 0) break; |
| 5004 |
eptr++; |
eptr++; |
| 5005 |
} |
} |
| 5006 |
break; |
break; |
| 5195 |
(offsets == NULL && offsetcount > 0)) return PCRE_ERROR_NULL; |
(offsets == NULL && offsetcount > 0)) return PCRE_ERROR_NULL; |
| 5196 |
if (offsetcount < 0) return PCRE_ERROR_BADCOUNT; |
if (offsetcount < 0) return PCRE_ERROR_BADCOUNT; |
| 5197 |
|
|
| 5198 |
/* This information is for finding all the numbers associated with a given |
/* This information is for finding all the numbers associated with a given |
| 5199 |
name, for condition testing. */ |
name, for condition testing. */ |
| 5200 |
|
|
| 5201 |
md->name_table = (uschar *)re + re->name_table_offset; |
md->name_table = (uschar *)re + re->name_table_offset; |
| 5560 |
/* Restore fudged end_subject */ |
/* Restore fudged end_subject */ |
| 5561 |
|
|
| 5562 |
end_subject = save_end_subject; |
end_subject = save_end_subject; |
| 5563 |
|
|
| 5564 |
/* The following two optimizations are disabled for partial matching or if |
/* The following two optimizations are disabled for partial matching or if |
| 5565 |
disabling is explicitly requested. */ |
disabling is explicitly requested. */ |
| 5566 |
|
|
| 5567 |
if ((options & PCRE_NO_START_OPTIMIZE) == 0 && !md->partial) |
if ((options & PCRE_NO_START_OPTIMIZE) == 0 && !md->partial) |
| 5568 |
{ |
{ |
| 5569 |
/* If the pattern was studied, a minimum subject length may be set. This is |
/* If the pattern was studied, a minimum subject length may be set. This is |
| 5570 |
a lower bound; no actual string of that length may actually match the |
a lower bound; no actual string of that length may actually match the |
| 5571 |
pattern. Although the value is, strictly, in characters, we treat it as |
pattern. Although the value is, strictly, in characters, we treat it as |
| 5572 |
bytes to avoid spending too much time in this optimization. */ |
bytes to avoid spending too much time in this optimization. */ |
| 5573 |
|
|
| 5574 |
if (study != NULL && (study->flags & PCRE_STUDY_MINLEN) != 0 && |
if (study != NULL && (study->flags & PCRE_STUDY_MINLEN) != 0 && |
| 5575 |
end_subject - start_match < study->minlength) |
end_subject - start_match < study->minlength) |
| 5576 |
{ |
{ |
| 5577 |
rc = MATCH_NOMATCH; |
rc = MATCH_NOMATCH; |
| 5578 |
break; |
break; |
| 5579 |
} |
} |
| 5580 |
|
|
| 5581 |
/* If req_byte is set, we know that that character must appear in the |
/* If req_byte is set, we know that that character must appear in the |
| 5582 |
subject for the match to succeed. If the first character is set, req_byte |
subject for the match to succeed. If the first character is set, req_byte |
| 5583 |
must be later in the subject; otherwise the test starts at the match point. |
must be later in the subject; otherwise the test starts at the match point. |
| 5585 |
nested unlimited repeats that aren't going to match. Writing separate code |
nested unlimited repeats that aren't going to match. Writing separate code |
| 5586 |
for cased/caseless versions makes it go faster, as does using an |
for cased/caseless versions makes it go faster, as does using an |
| 5587 |
autoincrement and backing off on a match. |
autoincrement and backing off on a match. |
| 5588 |
|
|
| 5589 |
HOWEVER: when the subject string is very, very long, searching to its end |
HOWEVER: when the subject string is very, very long, searching to its end |
| 5590 |
can take a long time, and give bad performance on quite ordinary patterns. |
can take a long time, and give bad performance on quite ordinary patterns. |
| 5591 |
This showed up when somebody was matching something like /^\d+C/ on a |
This showed up when somebody was matching something like /^\d+C/ on a |
| 5592 |
32-megabyte string... so we don't do this when the string is sufficiently |
32-megabyte string... so we don't do this when the string is sufficiently |
| 5593 |
long. */ |
long. */ |
| 5594 |
|
|
| 5595 |
if (req_byte >= 0 && end_subject - start_match < REQ_BYTE_MAX) |
if (req_byte >= 0 && end_subject - start_match < REQ_BYTE_MAX) |
| 5596 |
{ |
{ |
| 5597 |
register USPTR p = start_match + ((first_byte >= 0)? 1 : 0); |
register USPTR p = start_match + ((first_byte >= 0)? 1 : 0); |
| 5598 |
|
|
| 5599 |
/* We don't need to repeat the search if we haven't yet reached the |
/* We don't need to repeat the search if we haven't yet reached the |
| 5600 |
place we found it at last time. */ |
place we found it at last time. */ |
| 5601 |
|
|
| 5602 |
if (p > req_byte_ptr) |
if (p > req_byte_ptr) |
| 5603 |
{ |
{ |
| 5604 |
if (req_byte_caseless) |
if (req_byte_caseless) |
| 5616 |
if (*p++ == req_byte) { p--; break; } |
if (*p++ == req_byte) { p--; break; } |
| 5617 |
} |
} |
| 5618 |
} |
} |
| 5619 |
|
|
| 5620 |
/* If we can't find the required character, break the matching loop, |
/* If we can't find the required character, break the matching loop, |
| 5621 |
forcing a match failure. */ |
forcing a match failure. */ |
| 5622 |
|
|
| 5623 |
if (p >= end_subject) |
if (p >= end_subject) |
| 5624 |
{ |
{ |
| 5625 |
rc = MATCH_NOMATCH; |
rc = MATCH_NOMATCH; |
| 5626 |
break; |
break; |
| 5627 |
} |
} |
| 5628 |
|
|
| 5629 |
/* If we have found the required character, save the point where we |
/* If we have found the required character, save the point where we |
| 5630 |
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 |
| 5631 |
the start hasn't passed this character yet. */ |
the start hasn't passed this character yet. */ |
| 5632 |
|
|
| 5633 |
req_byte_ptr = p; |
req_byte_ptr = p; |
| 5634 |
} |
} |
| 5635 |
} |
} |
| 5636 |
} |
} |
| 5637 |
|
|
| 5638 |
#ifdef DEBUG /* Sigh. Some compilers never learn. */ |
#ifdef DEBUG /* Sigh. Some compilers never learn. */ |
| 5639 |
printf(">>>> Match against: "); |
printf(">>>> Match against: "); |
| 5760 |
too many to fit into the vector. */ |
too many to fit into the vector. */ |
| 5761 |
|
|
| 5762 |
rc = md->offset_overflow? 0 : md->end_offset_top/2; |
rc = md->offset_overflow? 0 : md->end_offset_top/2; |
| 5763 |
|
|
| 5764 |
/* If there is space, set up the whole thing as substring 0. The value of |
/* If there is space, set up the whole thing as substring 0. The value of |
| 5765 |
md->start_match_ptr might be modified if \K was encountered on the success |
md->start_match_ptr might be modified if \K was encountered on the success |
| 5766 |
matching path. */ |
matching path. */ |