| 573 |
int clen, dlen; |
int clen, dlen; |
| 574 |
unsigned int c, d; |
unsigned int c, d; |
| 575 |
int forced_fail = 0; |
int forced_fail = 0; |
| 576 |
BOOL partial_newline = FALSE; |
BOOL partial_newline = FALSE; |
| 577 |
BOOL could_continue = reset_could_continue; |
BOOL could_continue = reset_could_continue; |
| 578 |
reset_could_continue = FALSE; |
reset_could_continue = FALSE; |
| 579 |
|
|
| 580 |
/* Make the new state list into the active state list and empty the |
/* Make the new state list into the active state list and empty the |
| 581 |
new state list. */ |
new state list. */ |
| 582 |
|
|
| 645 |
|
|
| 646 |
/* A negative offset is a special case meaning "hold off going to this |
/* A negative offset is a special case meaning "hold off going to this |
| 647 |
(negated) state until the number of characters in the data field have |
(negated) state until the number of characters in the data field have |
| 648 |
been skipped". If the could_continue flag was passed over from a previous |
been skipped". If the could_continue flag was passed over from a previous |
| 649 |
state, arrange for it to passed on. */ |
state, arrange for it to passed on. */ |
| 650 |
|
|
| 651 |
if (state_offset < 0) |
if (state_offset < 0) |
| 695 |
permitted. |
permitted. |
| 696 |
|
|
| 697 |
We also use this mechanism for opcodes such as OP_TYPEPLUS that take an |
We also use this mechanism for opcodes such as OP_TYPEPLUS that take an |
| 698 |
argument that is not a data character - but is always one byte long because |
argument that is not a data character - but is always one byte long because |
| 699 |
the values are small. We have to take special action to deal with \P, \p, |
the values are small. We have to take special action to deal with \P, \p, |
| 700 |
\H, \h, \V, \v and \X in this case. To keep the other cases fast, convert |
\H, \h, \V, \v and \X in this case. To keep the other cases fast, convert |
| 701 |
these ones to new opcodes. */ |
these ones to new opcodes. */ |
| 894 |
/*-----------------------------------------------------------------*/ |
/*-----------------------------------------------------------------*/ |
| 895 |
case OP_ANY: |
case OP_ANY: |
| 896 |
if (clen > 0 && !IS_NEWLINE(ptr)) |
if (clen > 0 && !IS_NEWLINE(ptr)) |
| 897 |
{ |
{ |
| 898 |
if (ptr + 1 >= md->end_subject && |
if (ptr + 1 >= md->end_subject && |
| 899 |
(md->moptions & (PCRE_PARTIAL_HARD)) != 0 && |
(md->moptions & (PCRE_PARTIAL_HARD)) != 0 && |
| 900 |
NLBLOCK->nltype == NLTYPE_FIXED && |
NLBLOCK->nltype == NLTYPE_FIXED && |
| 901 |
NLBLOCK->nllen == 2 && |
NLBLOCK->nllen == 2 && |
| 902 |
c == NLBLOCK->nl[0]) |
c == NLBLOCK->nl[0]) |
| 903 |
{ |
{ |
| 904 |
could_continue = partial_newline = TRUE; |
could_continue = partial_newline = TRUE; |
| 905 |
} |
} |
| 906 |
else |
else |
| 907 |
{ |
{ |
| 908 |
ADD_NEW(state_offset + 1, 0); |
ADD_NEW(state_offset + 1, 0); |
| 909 |
} |
} |
| 910 |
} |
} |
| 911 |
break; |
break; |
| 912 |
|
|
| 938 |
else if (ptr + 1 >= md->end_subject && |
else if (ptr + 1 >= md->end_subject && |
| 939 |
(md->moptions & (PCRE_PARTIAL_HARD|PCRE_PARTIAL_SOFT)) != 0 && |
(md->moptions & (PCRE_PARTIAL_HARD|PCRE_PARTIAL_SOFT)) != 0 && |
| 940 |
NLBLOCK->nltype == NLTYPE_FIXED && |
NLBLOCK->nltype == NLTYPE_FIXED && |
| 941 |
NLBLOCK->nllen == 2 && |
NLBLOCK->nllen == 2 && |
| 942 |
c == NLBLOCK->nl[0]) |
c == NLBLOCK->nl[0]) |
| 943 |
{ |
{ |
| 944 |
if ((md->moptions & PCRE_PARTIAL_HARD) != 0) |
if ((md->moptions & PCRE_PARTIAL_HARD) != 0) |
| 945 |
{ |
{ |
| 946 |
reset_could_continue = TRUE; |
reset_could_continue = TRUE; |
| 947 |
ADD_NEW_DATA(-(state_offset + 1), 0, 1); |
ADD_NEW_DATA(-(state_offset + 1), 0, 1); |
| 948 |
} |
} |
| 949 |
else could_continue = partial_newline = TRUE; |
else could_continue = partial_newline = TRUE; |
| 950 |
} |
} |
| 951 |
} |
} |
| 952 |
break; |
break; |
| 953 |
|
|
| 963 |
else if (ptr + 1 >= md->end_subject && |
else if (ptr + 1 >= md->end_subject && |
| 964 |
(md->moptions & (PCRE_PARTIAL_HARD|PCRE_PARTIAL_SOFT)) != 0 && |
(md->moptions & (PCRE_PARTIAL_HARD|PCRE_PARTIAL_SOFT)) != 0 && |
| 965 |
NLBLOCK->nltype == NLTYPE_FIXED && |
NLBLOCK->nltype == NLTYPE_FIXED && |
| 966 |
NLBLOCK->nllen == 2 && |
NLBLOCK->nllen == 2 && |
| 967 |
c == NLBLOCK->nl[0]) |
c == NLBLOCK->nl[0]) |
| 968 |
{ |
{ |
| 969 |
if ((md->moptions & PCRE_PARTIAL_HARD) != 0) |
if ((md->moptions & PCRE_PARTIAL_HARD) != 0) |
| 970 |
{ |
{ |
| 971 |
reset_could_continue = TRUE; |
reset_could_continue = TRUE; |
| 972 |
ADD_NEW_DATA(-(state_offset + 1), 0, 1); |
ADD_NEW_DATA(-(state_offset + 1), 0, 1); |
| 973 |
} |
} |
| 974 |
else could_continue = partial_newline = TRUE; |
else could_continue = partial_newline = TRUE; |
| 975 |
} |
} |
| 976 |
} |
} |
| 977 |
else if (IS_NEWLINE(ptr)) |
else if (IS_NEWLINE(ptr)) |
| 978 |
{ ADD_ACTIVE(state_offset + 1, 0); } |
{ ADD_ACTIVE(state_offset + 1, 0); } |
| 1138 |
if (d == OP_ANY && ptr + 1 >= md->end_subject && |
if (d == OP_ANY && ptr + 1 >= md->end_subject && |
| 1139 |
(md->moptions & (PCRE_PARTIAL_HARD)) != 0 && |
(md->moptions & (PCRE_PARTIAL_HARD)) != 0 && |
| 1140 |
NLBLOCK->nltype == NLTYPE_FIXED && |
NLBLOCK->nltype == NLTYPE_FIXED && |
| 1141 |
NLBLOCK->nllen == 2 && |
NLBLOCK->nllen == 2 && |
| 1142 |
c == NLBLOCK->nl[0]) |
c == NLBLOCK->nl[0]) |
| 1143 |
{ |
{ |
| 1144 |
could_continue = partial_newline = TRUE; |
could_continue = partial_newline = TRUE; |
| 1145 |
} |
} |
| 1146 |
else if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) || |
else if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) || |
| 1147 |
(c < 256 && |
(c < 256 && |
| 1148 |
(d != OP_ANY || !IS_NEWLINE(ptr)) && |
(d != OP_ANY || !IS_NEWLINE(ptr)) && |
| 1169 |
if (d == OP_ANY && ptr + 1 >= md->end_subject && |
if (d == OP_ANY && ptr + 1 >= md->end_subject && |
| 1170 |
(md->moptions & (PCRE_PARTIAL_HARD)) != 0 && |
(md->moptions & (PCRE_PARTIAL_HARD)) != 0 && |
| 1171 |
NLBLOCK->nltype == NLTYPE_FIXED && |
NLBLOCK->nltype == NLTYPE_FIXED && |
| 1172 |
NLBLOCK->nllen == 2 && |
NLBLOCK->nllen == 2 && |
| 1173 |
c == NLBLOCK->nl[0]) |
c == NLBLOCK->nl[0]) |
| 1174 |
{ |
{ |
| 1175 |
could_continue = partial_newline = TRUE; |
could_continue = partial_newline = TRUE; |
| 1176 |
} |
} |
| 1177 |
else if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) || |
else if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) || |
| 1178 |
(c < 256 && |
(c < 256 && |
| 1179 |
(d != OP_ANY || !IS_NEWLINE(ptr)) && |
(d != OP_ANY || !IS_NEWLINE(ptr)) && |
| 1199 |
if (d == OP_ANY && ptr + 1 >= md->end_subject && |
if (d == OP_ANY && ptr + 1 >= md->end_subject && |
| 1200 |
(md->moptions & (PCRE_PARTIAL_HARD)) != 0 && |
(md->moptions & (PCRE_PARTIAL_HARD)) != 0 && |
| 1201 |
NLBLOCK->nltype == NLTYPE_FIXED && |
NLBLOCK->nltype == NLTYPE_FIXED && |
| 1202 |
NLBLOCK->nllen == 2 && |
NLBLOCK->nllen == 2 && |
| 1203 |
c == NLBLOCK->nl[0]) |
c == NLBLOCK->nl[0]) |
| 1204 |
{ |
{ |
| 1205 |
could_continue = partial_newline = TRUE; |
could_continue = partial_newline = TRUE; |
| 1206 |
} |
} |
| 1207 |
else if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) || |
else if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) || |
| 1208 |
(c < 256 && |
(c < 256 && |
| 1209 |
(d != OP_ANY || !IS_NEWLINE(ptr)) && |
(d != OP_ANY || !IS_NEWLINE(ptr)) && |
| 1227 |
if (d == OP_ANY && ptr + 1 >= md->end_subject && |
if (d == OP_ANY && ptr + 1 >= md->end_subject && |
| 1228 |
(md->moptions & (PCRE_PARTIAL_HARD)) != 0 && |
(md->moptions & (PCRE_PARTIAL_HARD)) != 0 && |
| 1229 |
NLBLOCK->nltype == NLTYPE_FIXED && |
NLBLOCK->nltype == NLTYPE_FIXED && |
| 1230 |
NLBLOCK->nllen == 2 && |
NLBLOCK->nllen == 2 && |
| 1231 |
c == NLBLOCK->nl[0]) |
c == NLBLOCK->nl[0]) |
| 1232 |
{ |
{ |
| 1233 |
could_continue = partial_newline = TRUE; |
could_continue = partial_newline = TRUE; |
| 1234 |
} |
} |
| 1235 |
else if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) || |
else if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) || |
| 1236 |
(c < 256 && |
(c < 256 && |
| 1237 |
(d != OP_ANY || !IS_NEWLINE(ptr)) && |
(d != OP_ANY || !IS_NEWLINE(ptr)) && |
| 1256 |
if (d == OP_ANY && ptr + 1 >= md->end_subject && |
if (d == OP_ANY && ptr + 1 >= md->end_subject && |
| 1257 |
(md->moptions & (PCRE_PARTIAL_HARD)) != 0 && |
(md->moptions & (PCRE_PARTIAL_HARD)) != 0 && |
| 1258 |
NLBLOCK->nltype == NLTYPE_FIXED && |
NLBLOCK->nltype == NLTYPE_FIXED && |
| 1259 |
NLBLOCK->nllen == 2 && |
NLBLOCK->nllen == 2 && |
| 1260 |
c == NLBLOCK->nl[0]) |
c == NLBLOCK->nl[0]) |
| 1261 |
{ |
{ |
| 1262 |
could_continue = partial_newline = TRUE; |
could_continue = partial_newline = TRUE; |
| 1263 |
} |
} |
| 1264 |
else if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) || |
else if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) || |
| 1265 |
(c < 256 && |
(c < 256 && |
| 1266 |
(d != OP_ANY || !IS_NEWLINE(ptr)) && |
(d != OP_ANY || !IS_NEWLINE(ptr)) && |
| 1909 |
ncount++; |
ncount++; |
| 1910 |
nptr += ndlen; |
nptr += ndlen; |
| 1911 |
} |
} |
| 1912 |
if (nptr >= end_subject && (md->moptions & PCRE_PARTIAL_HARD) != 0) |
if (nptr >= end_subject && (md->moptions & PCRE_PARTIAL_HARD) != 0) |
| 1913 |
reset_could_continue = TRUE; |
reset_could_continue = TRUE; |
| 1914 |
if (++count >= GET2(code, 1)) |
if (++count >= GET2(code, 1)) |
| 1915 |
{ ADD_NEW_DATA(-(state_offset + 2 + IMM2_SIZE), 0, ncount); } |
{ ADD_NEW_DATA(-(state_offset + 2 + IMM2_SIZE), 0, ncount); } |
| 1916 |
else |
else |
| 2124 |
ncount++; |
ncount++; |
| 2125 |
nptr += nclen; |
nptr += nclen; |
| 2126 |
} |
} |
| 2127 |
if (nptr >= end_subject && (md->moptions & PCRE_PARTIAL_HARD) != 0) |
if (nptr >= end_subject && (md->moptions & PCRE_PARTIAL_HARD) != 0) |
| 2128 |
reset_could_continue = TRUE; |
reset_could_continue = TRUE; |
| 2129 |
ADD_NEW_DATA(-(state_offset + 1), 0, ncount); |
ADD_NEW_DATA(-(state_offset + 1), 0, ncount); |
| 2130 |
} |
} |
| 2131 |
break; |
break; |
| 2151 |
break; |
break; |
| 2152 |
|
|
| 2153 |
case 0x000d: |
case 0x000d: |
| 2154 |
if (ptr + 1 >= end_subject) |
if (ptr + 1 >= end_subject) |
| 2155 |
{ |
{ |
| 2156 |
ADD_NEW(state_offset + 1, 0); |
ADD_NEW(state_offset + 1, 0); |
| 2157 |
if ((md->moptions & PCRE_PARTIAL_HARD) != 0) |
if ((md->moptions & PCRE_PARTIAL_HARD) != 0) |
| 2158 |
reset_could_continue = TRUE; |
reset_could_continue = TRUE; |
| 2159 |
} |
} |
| 2160 |
else if (ptr[1] == 0x0a) |
else if (ptr[1] == 0x0a) |
| 2161 |
{ |
{ |
| 2162 |
ADD_NEW_DATA(-(state_offset + 1), 0, 1); |
ADD_NEW_DATA(-(state_offset + 1), 0, 1); |
| 2163 |
} |
} |
| 2164 |
else |
else |
| 2165 |
{ |
{ |
| 2166 |
ADD_NEW(state_offset + 1, 0); |
ADD_NEW(state_offset + 1, 0); |
| 2167 |
} |
} |
| 2168 |
break; |
break; |
| 2169 |
} |
} |
| 2170 |
break; |
break; |
| 2277 |
|
|
| 2278 |
case OP_NOTI: |
case OP_NOTI: |
| 2279 |
if (clen > 0) |
if (clen > 0) |
| 2280 |
{ |
{ |
| 2281 |
unsigned int otherd; |
unsigned int otherd; |
| 2282 |
#ifdef SUPPORT_UTF |
#ifdef SUPPORT_UTF |
| 2283 |
if (utf && d >= 128) |
if (utf && d >= 128) |
| 2291 |
otherd = TABLE_GET(d, fcc, d); |
otherd = TABLE_GET(d, fcc, d); |
| 2292 |
if (c != d && c != otherd) |
if (c != d && c != otherd) |
| 2293 |
{ ADD_NEW(state_offset + dlen + 1, 0); } |
{ ADD_NEW(state_offset + dlen + 1, 0); } |
| 2294 |
} |
} |
| 2295 |
break; |
break; |
| 2296 |
|
|
| 2297 |
/*-----------------------------------------------------------------*/ |
/*-----------------------------------------------------------------*/ |
| 3047 |
|
|
| 3048 |
The "could_continue" variable is true if a state could have continued but |
The "could_continue" variable is true if a state could have continued but |
| 3049 |
for the fact that the end of the subject was reached. */ |
for the fact that the end of the subject was reached. */ |
| 3050 |
|
|
| 3051 |
if (new_count <= 0) |
if (new_count <= 0) |
| 3052 |
{ |
{ |
| 3053 |
if (rlevel == 1 && /* Top level, and */ |
if (rlevel == 1 && /* Top level, and */ |
| 3064 |
( /* or ... */ |
( /* or ... */ |
| 3065 |
ptr >= end_subject && /* End of subject and */ |
ptr >= end_subject && /* End of subject and */ |
| 3066 |
ptr > md->start_used_ptr) /* Inspected non-empty string */ |
ptr > md->start_used_ptr) /* Inspected non-empty string */ |
| 3067 |
) |
) |
| 3068 |
) |
) |
| 3069 |
{ |
{ |
| 3070 |
if (offsetcount >= 2) |
if (offsetcount >= 2) |
| 3071 |
{ |
{ |
| 3172 |
PCRE_ERROR_BADENDIANNESS:PCRE_ERROR_BADMAGIC; |
PCRE_ERROR_BADENDIANNESS:PCRE_ERROR_BADMAGIC; |
| 3173 |
if ((re->flags & PCRE_MODE) == 0) return PCRE_ERROR_BADMODE; |
if ((re->flags & PCRE_MODE) == 0) return PCRE_ERROR_BADMODE; |
| 3174 |
|
|
| 3175 |
/* If restarting after a partial match, do some sanity checks on the contents |
/* If restarting after a partial match, do some sanity checks on the contents |
| 3176 |
of the workspace. */ |
of the workspace. */ |
| 3177 |
|
|
| 3178 |
if ((options & PCRE_DFA_RESTART) != 0) |
if ((options & PCRE_DFA_RESTART) != 0) |
| 3179 |
{ |
{ |
| 3180 |
if ((workspace[0] & (-2)) != 0 || workspace[1] < 1 || |
if ((workspace[0] & (-2)) != 0 || workspace[1] < 1 || |
| 3181 |
workspace[1] > (wscount - 2)/INTS_PER_STATEBLOCK) |
workspace[1] > (wscount - 2)/INTS_PER_STATEBLOCK) |
| 3182 |
return PCRE_ERROR_DFA_BADRESTART; |
return PCRE_ERROR_DFA_BADRESTART; |
| 3183 |
} |
} |
| 3184 |
|
|
| 3185 |
/* Set up study, callout, and table data */ |
/* Set up study, callout, and table data */ |
| 3186 |
|
|