| 124 |
-ESC_H, 0, |
-ESC_H, 0, |
| 125 |
0, -ESC_K, |
0, -ESC_K, |
| 126 |
0, 0, |
0, 0, |
| 127 |
0, 0, |
-ESC_N, 0, |
| 128 |
-ESC_P, -ESC_Q, |
-ESC_P, -ESC_Q, |
| 129 |
-ESC_R, -ESC_S, |
-ESC_R, -ESC_S, |
| 130 |
0, 0, |
0, 0, |
| 171 |
/* B8 */ 0, 0, 0, 0, 0, ']', '=', '-', |
/* B8 */ 0, 0, 0, 0, 0, ']', '=', '-', |
| 172 |
/* C0 */ '{',-ESC_A, -ESC_B, -ESC_C, -ESC_D,-ESC_E, 0, -ESC_G, |
/* C0 */ '{',-ESC_A, -ESC_B, -ESC_C, -ESC_D,-ESC_E, 0, -ESC_G, |
| 173 |
/* C8 */-ESC_H, 0, 0, 0, 0, 0, 0, 0, |
/* C8 */-ESC_H, 0, 0, 0, 0, 0, 0, 0, |
| 174 |
/* D0 */ '}', 0, -ESC_K, 0, 0, 0, 0, -ESC_P, |
/* D0 */ '}', 0, -ESC_K, 0, 0,-ESC_N, 0, -ESC_P, |
| 175 |
/* D8 */-ESC_Q,-ESC_R, 0, 0, 0, 0, 0, 0, |
/* D8 */-ESC_Q,-ESC_R, 0, 0, 0, 0, 0, 0, |
| 176 |
/* E0 */ '\\', 0, -ESC_S, 0, 0,-ESC_V, -ESC_W, -ESC_X, |
/* E0 */ '\\', 0, -ESC_S, 0, 0,-ESC_V, -ESC_W, -ESC_X, |
| 177 |
/* E8 */ 0,-ESC_Z, 0, 0, 0, 0, 0, 0, |
/* E8 */ 0,-ESC_Z, 0, 0, 0, 0, 0, 0, |
| 188 |
platforms. */ |
platforms. */ |
| 189 |
|
|
| 190 |
typedef struct verbitem { |
typedef struct verbitem { |
| 191 |
int len; |
int len; /* Length of verb name */ |
| 192 |
int op; |
int op; /* Op when no arg, or -1 if arg mandatory */ |
| 193 |
|
int op_arg; /* Op when arg present, or -1 if not allowed */ |
| 194 |
} verbitem; |
} verbitem; |
| 195 |
|
|
| 196 |
static const char verbnames[] = |
static const char verbnames[] = |
| 197 |
|
"\0" /* Empty name is a shorthand for MARK */ |
| 198 |
|
STRING_MARK0 |
| 199 |
STRING_ACCEPT0 |
STRING_ACCEPT0 |
| 200 |
STRING_COMMIT0 |
STRING_COMMIT0 |
| 201 |
STRING_F0 |
STRING_F0 |
| 205 |
STRING_THEN; |
STRING_THEN; |
| 206 |
|
|
| 207 |
static const verbitem verbs[] = { |
static const verbitem verbs[] = { |
| 208 |
{ 6, OP_ACCEPT }, |
{ 0, -1, OP_MARK }, |
| 209 |
{ 6, OP_COMMIT }, |
{ 4, -1, OP_MARK }, |
| 210 |
{ 1, OP_FAIL }, |
{ 6, OP_ACCEPT, -1 }, |
| 211 |
{ 4, OP_FAIL }, |
{ 6, OP_COMMIT, -1 }, |
| 212 |
{ 5, OP_PRUNE }, |
{ 1, OP_FAIL, -1 }, |
| 213 |
{ 4, OP_SKIP }, |
{ 4, OP_FAIL, -1 }, |
| 214 |
{ 4, OP_THEN } |
{ 5, OP_PRUNE, OP_PRUNE_ARG }, |
| 215 |
|
{ 4, OP_SKIP, OP_SKIP_ARG }, |
| 216 |
|
{ 4, OP_THEN, OP_THEN_ARG } |
| 217 |
}; |
}; |
| 218 |
|
|
| 219 |
static const int verbcount = sizeof(verbs)/sizeof(verbitem); |
static const int verbcount = sizeof(verbs)/sizeof(verbitem); |
| 261 |
cbit_xdigit,-1, 0 /* xdigit */ |
cbit_xdigit,-1, 0 /* xdigit */ |
| 262 |
}; |
}; |
| 263 |
|
|
| 264 |
|
/* Table of substitutes for \d etc when PCRE_UCP is set. The POSIX class |
| 265 |
|
substitutes must be in the order of the names, defined above, and there are |
| 266 |
|
both positive and negative cases. NULL means no substitute. */ |
| 267 |
|
|
| 268 |
|
#ifdef SUPPORT_UCP |
| 269 |
|
static const uschar *substitutes[] = { |
| 270 |
|
(uschar *)"\\P{Nd}", /* \D */ |
| 271 |
|
(uschar *)"\\p{Nd}", /* \d */ |
| 272 |
|
(uschar *)"\\P{Xsp}", /* \S */ /* NOTE: Xsp is Perl space */ |
| 273 |
|
(uschar *)"\\p{Xsp}", /* \s */ |
| 274 |
|
(uschar *)"\\P{Xwd}", /* \W */ |
| 275 |
|
(uschar *)"\\p{Xwd}" /* \w */ |
| 276 |
|
}; |
| 277 |
|
|
| 278 |
|
static const uschar *posix_substitutes[] = { |
| 279 |
|
(uschar *)"\\p{L}", /* alpha */ |
| 280 |
|
(uschar *)"\\p{Ll}", /* lower */ |
| 281 |
|
(uschar *)"\\p{Lu}", /* upper */ |
| 282 |
|
(uschar *)"\\p{Xan}", /* alnum */ |
| 283 |
|
NULL, /* ascii */ |
| 284 |
|
(uschar *)"\\h", /* blank */ |
| 285 |
|
NULL, /* cntrl */ |
| 286 |
|
(uschar *)"\\p{Nd}", /* digit */ |
| 287 |
|
NULL, /* graph */ |
| 288 |
|
NULL, /* print */ |
| 289 |
|
NULL, /* punct */ |
| 290 |
|
(uschar *)"\\p{Xps}", /* space */ /* NOTE: Xps is POSIX space */ |
| 291 |
|
(uschar *)"\\p{Xwd}", /* word */ |
| 292 |
|
NULL, /* xdigit */ |
| 293 |
|
/* Negated cases */ |
| 294 |
|
(uschar *)"\\P{L}", /* ^alpha */ |
| 295 |
|
(uschar *)"\\P{Ll}", /* ^lower */ |
| 296 |
|
(uschar *)"\\P{Lu}", /* ^upper */ |
| 297 |
|
(uschar *)"\\P{Xan}", /* ^alnum */ |
| 298 |
|
NULL, /* ^ascii */ |
| 299 |
|
(uschar *)"\\H", /* ^blank */ |
| 300 |
|
NULL, /* ^cntrl */ |
| 301 |
|
(uschar *)"\\P{Nd}", /* ^digit */ |
| 302 |
|
NULL, /* ^graph */ |
| 303 |
|
NULL, /* ^print */ |
| 304 |
|
NULL, /* ^punct */ |
| 305 |
|
(uschar *)"\\P{Xps}", /* ^space */ /* NOTE: Xps is POSIX space */ |
| 306 |
|
(uschar *)"\\P{Xwd}", /* ^word */ |
| 307 |
|
NULL /* ^xdigit */ |
| 308 |
|
}; |
| 309 |
|
#define POSIX_SUBSIZE (sizeof(posix_substitutes)/sizeof(uschar *)) |
| 310 |
|
#endif |
| 311 |
|
|
| 312 |
#define STRING(a) # a |
#define STRING(a) # a |
| 313 |
#define XSTRING(s) STRING(s) |
#define XSTRING(s) STRING(s) |
| 371 |
/* 35 */ |
/* 35 */ |
| 372 |
"invalid condition (?(0)\0" |
"invalid condition (?(0)\0" |
| 373 |
"\\C not allowed in lookbehind assertion\0" |
"\\C not allowed in lookbehind assertion\0" |
| 374 |
"PCRE does not support \\L, \\l, \\N, \\U, or \\u\0" |
"PCRE does not support \\L, \\l, \\N{name}, \\U, or \\u\0" |
| 375 |
"number after (?C is > 255\0" |
"number after (?C is > 255\0" |
| 376 |
"closing ) for (?C expected\0" |
"closing ) for (?C expected\0" |
| 377 |
/* 40 */ |
/* 40 */ |
| 397 |
"inconsistent NEWLINE options\0" |
"inconsistent NEWLINE options\0" |
| 398 |
"\\g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number\0" |
"\\g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number\0" |
| 399 |
"a numbered reference must not be zero\0" |
"a numbered reference must not be zero\0" |
| 400 |
"(*VERB) with an argument is not supported\0" |
"an argument is not allowed for (*ACCEPT), (*FAIL), or (*COMMIT)\0" |
| 401 |
/* 60 */ |
/* 60 */ |
| 402 |
"(*VERB) not recognized\0" |
"(*VERB) not recognized\0" |
| 403 |
"number is too big\0" |
"number is too big\0" |
| 405 |
"digit expected after (?+\0" |
"digit expected after (?+\0" |
| 406 |
"] is an invalid data character in JavaScript compatibility mode\0" |
"] is an invalid data character in JavaScript compatibility mode\0" |
| 407 |
/* 65 */ |
/* 65 */ |
| 408 |
"different names for subpatterns of the same number are not allowed\0"; |
"different names for subpatterns of the same number are not allowed\0" |
| 409 |
|
"(*MARK) must have an argument\0" |
| 410 |
|
"this version of PCRE is not compiled with PCRE_UCP support\0" |
| 411 |
|
; |
| 412 |
|
|
| 413 |
/* Table to identify digits and hex digits. This is used when compiling |
/* Table to identify digits and hex digits. This is used when compiling |
| 414 |
patterns. Note that the tables in chartables are dependent on the locale, and |
patterns. Note that the tables in chartables are dependent on the locale, and |
| 641 |
|
|
| 642 |
case CHAR_l: |
case CHAR_l: |
| 643 |
case CHAR_L: |
case CHAR_L: |
|
case CHAR_N: |
|
| 644 |
case CHAR_u: |
case CHAR_u: |
| 645 |
case CHAR_U: |
case CHAR_U: |
| 646 |
*errorcodeptr = ERR37; |
*errorcodeptr = ERR37; |
| 878 |
} |
} |
| 879 |
} |
} |
| 880 |
|
|
| 881 |
|
/* Perl supports \N{name} for character names, as well as plain \N for "not |
| 882 |
|
newline". PCRE does not support \N{name}. */ |
| 883 |
|
|
| 884 |
|
if (c == -ESC_N && ptr[1] == CHAR_LEFT_CURLY_BRACKET) |
| 885 |
|
*errorcodeptr = ERR37; |
| 886 |
|
|
| 887 |
|
/* If PCRE_UCP is set, we change the values for \d etc. */ |
| 888 |
|
|
| 889 |
|
if ((options & PCRE_UCP) != 0 && c <= -ESC_D && c >= -ESC_w) |
| 890 |
|
c -= (ESC_DU - ESC_D); |
| 891 |
|
|
| 892 |
|
/* Set the pointer to the final character before returning. */ |
| 893 |
|
|
| 894 |
*ptrptr = ptr; |
*ptrptr = ptr; |
| 895 |
return c; |
return c; |
| 896 |
} |
} |
| 1682 |
|
|
| 1683 |
/* Otherwise, we can get the item's length from the table, except that for |
/* Otherwise, we can get the item's length from the table, except that for |
| 1684 |
repeated character types, we have to test for \p and \P, which have an extra |
repeated character types, we have to test for \p and \P, which have an extra |
| 1685 |
two bytes of parameters. */ |
two bytes of parameters, and for MARK/PRUNE/SKIP/THEN with an argument, we |
| 1686 |
|
must add in its length. */ |
| 1687 |
|
|
| 1688 |
else |
else |
| 1689 |
{ |
{ |
| 1707 |
case OP_TYPEPOSUPTO: |
case OP_TYPEPOSUPTO: |
| 1708 |
if (code[3] == OP_PROP || code[3] == OP_NOTPROP) code += 2; |
if (code[3] == OP_PROP || code[3] == OP_NOTPROP) code += 2; |
| 1709 |
break; |
break; |
| 1710 |
|
|
| 1711 |
|
case OP_MARK: |
| 1712 |
|
case OP_PRUNE_ARG: |
| 1713 |
|
case OP_SKIP_ARG: |
| 1714 |
|
case OP_THEN_ARG: |
| 1715 |
|
code += code[1]; |
| 1716 |
|
break; |
| 1717 |
} |
} |
| 1718 |
|
|
| 1719 |
/* Add in the fixed length from the table */ |
/* Add in the fixed length from the table */ |
| 1785 |
|
|
| 1786 |
/* Otherwise, we can get the item's length from the table, except that for |
/* Otherwise, we can get the item's length from the table, except that for |
| 1787 |
repeated character types, we have to test for \p and \P, which have an extra |
repeated character types, we have to test for \p and \P, which have an extra |
| 1788 |
two bytes of parameters. */ |
two bytes of parameters, and for MARK/PRUNE/SKIP/THEN with an argument, we |
| 1789 |
|
must add in its length. */ |
| 1790 |
|
|
| 1791 |
else |
else |
| 1792 |
{ |
{ |
| 1810 |
case OP_TYPEEXACT: |
case OP_TYPEEXACT: |
| 1811 |
if (code[3] == OP_PROP || code[3] == OP_NOTPROP) code += 2; |
if (code[3] == OP_PROP || code[3] == OP_NOTPROP) code += 2; |
| 1812 |
break; |
break; |
| 1813 |
|
|
| 1814 |
|
case OP_MARK: |
| 1815 |
|
case OP_PRUNE_ARG: |
| 1816 |
|
case OP_SKIP_ARG: |
| 1817 |
|
case OP_THEN_ARG: |
| 1818 |
|
code += code[1]; |
| 1819 |
|
break; |
| 1820 |
} |
} |
| 1821 |
|
|
| 1822 |
/* Add in the fixed length from the table */ |
/* Add in the fixed length from the table */ |
| 2086 |
break; |
break; |
| 2087 |
#endif |
#endif |
| 2088 |
|
|
| 2089 |
|
/* MARK, and PRUNE/SKIP/THEN with an argument must skip over the argument |
| 2090 |
|
string. */ |
| 2091 |
|
|
| 2092 |
|
case OP_MARK: |
| 2093 |
|
case OP_PRUNE_ARG: |
| 2094 |
|
case OP_SKIP_ARG: |
| 2095 |
|
case OP_THEN_ARG: |
| 2096 |
|
code += code[1]; |
| 2097 |
|
break; |
| 2098 |
|
|
| 2099 |
/* None of the remaining opcodes are required to match a character. */ |
/* None of the remaining opcodes are required to match a character. */ |
| 2100 |
|
|
| 2101 |
default: |
default: |
| 2316 |
{ |
{ |
| 2317 |
*code++ = OP_CALLOUT; |
*code++ = OP_CALLOUT; |
| 2318 |
*code++ = 255; |
*code++ = 255; |
| 2319 |
PUT(code, 0, ptr - cd->start_pattern); /* Pattern offset */ |
PUT(code, 0, (int)(ptr - cd->start_pattern)); /* Pattern offset */ |
| 2320 |
PUT(code, LINK_SIZE, 0); /* Default length */ |
PUT(code, LINK_SIZE, 0); /* Default length */ |
| 2321 |
return code + 2*LINK_SIZE; |
return code + 2*LINK_SIZE; |
| 2322 |
} |
} |
| 2323 |
|
|
| 2342 |
static void |
static void |
| 2343 |
complete_callout(uschar *previous_callout, const uschar *ptr, compile_data *cd) |
complete_callout(uschar *previous_callout, const uschar *ptr, compile_data *cd) |
| 2344 |
{ |
{ |
| 2345 |
int length = ptr - cd->start_pattern - GET(previous_callout, 2); |
int length = (int)(ptr - cd->start_pattern - GET(previous_callout, 2)); |
| 2346 |
PUT(previous_callout, 2 + LINK_SIZE, length); |
PUT(previous_callout, 2 + LINK_SIZE, length); |
| 2347 |
} |
} |
| 2348 |
|
|
| 2544 |
else |
else |
| 2545 |
#endif /* SUPPORT_UTF8 */ |
#endif /* SUPPORT_UTF8 */ |
| 2546 |
return (item == cd->fcc[next]); /* Non-UTF-8 mode */ |
return (item == cd->fcc[next]); /* Non-UTF-8 mode */ |
| 2547 |
|
|
| 2548 |
|
/* Note that OP_DIGIT etc. are generated only when PCRE_UCP is *not* set. |
| 2549 |
|
When it is set, \d etc. are converted into OP_(NOT_)PROP codes. */ |
| 2550 |
|
|
| 2551 |
case OP_DIGIT: |
case OP_DIGIT: |
| 2552 |
return next > 127 || (cd->ctypes[next] & ctype_digit) == 0; |
return next > 127 || (cd->ctypes[next] & ctype_digit) == 0; |
| 2589 |
case 0x202f: |
case 0x202f: |
| 2590 |
case 0x205f: |
case 0x205f: |
| 2591 |
case 0x3000: |
case 0x3000: |
| 2592 |
return op_code != OP_HSPACE; |
return op_code == OP_NOT_HSPACE; |
| 2593 |
default: |
default: |
| 2594 |
return op_code == OP_HSPACE; |
return op_code != OP_NOT_HSPACE; |
| 2595 |
} |
} |
| 2596 |
|
|
| 2597 |
|
case OP_ANYNL: |
| 2598 |
case OP_VSPACE: |
case OP_VSPACE: |
| 2599 |
case OP_NOT_VSPACE: |
case OP_NOT_VSPACE: |
| 2600 |
switch(next) |
switch(next) |
| 2606 |
case 0x85: |
case 0x85: |
| 2607 |
case 0x2028: |
case 0x2028: |
| 2608 |
case 0x2029: |
case 0x2029: |
| 2609 |
return op_code != OP_VSPACE; |
return op_code == OP_NOT_VSPACE; |
| 2610 |
default: |
default: |
| 2611 |
return op_code == OP_VSPACE; |
return op_code != OP_NOT_VSPACE; |
| 2612 |
} |
} |
| 2613 |
|
|
| 2614 |
default: |
default: |
| 2616 |
} |
} |
| 2617 |
|
|
| 2618 |
|
|
| 2619 |
/* Handle the case when the next item is \d, \s, etc. */ |
/* Handle the case when the next item is \d, \s, etc. Note that when PCRE_UCP |
| 2620 |
|
is set, \d turns into ESC_du rather than ESC_d, etc., so ESC_d etc. are |
| 2621 |
|
generated only when PCRE_UCP is *not* set, that is, when only ASCII |
| 2622 |
|
characteristics are recognized. */ |
| 2623 |
|
|
| 2624 |
switch(op_code) |
switch(op_code) |
| 2625 |
{ |
{ |
| 2698 |
|
|
| 2699 |
case OP_DIGIT: |
case OP_DIGIT: |
| 2700 |
return next == -ESC_D || next == -ESC_s || next == -ESC_W || |
return next == -ESC_D || next == -ESC_s || next == -ESC_W || |
| 2701 |
next == -ESC_h || next == -ESC_v; |
next == -ESC_h || next == -ESC_v || next == -ESC_R; |
| 2702 |
|
|
| 2703 |
case OP_NOT_DIGIT: |
case OP_NOT_DIGIT: |
| 2704 |
return next == -ESC_d; |
return next == -ESC_d; |
| 2705 |
|
|
| 2706 |
case OP_WHITESPACE: |
case OP_WHITESPACE: |
| 2707 |
return next == -ESC_S || next == -ESC_d || next == -ESC_w; |
return next == -ESC_S || next == -ESC_d || next == -ESC_w || next == -ESC_R; |
| 2708 |
|
|
| 2709 |
case OP_NOT_WHITESPACE: |
case OP_NOT_WHITESPACE: |
| 2710 |
return next == -ESC_s || next == -ESC_h || next == -ESC_v; |
return next == -ESC_s || next == -ESC_h || next == -ESC_v; |
| 2711 |
|
|
| 2712 |
case OP_HSPACE: |
case OP_HSPACE: |
| 2713 |
return next == -ESC_S || next == -ESC_H || next == -ESC_d || next == -ESC_w; |
return next == -ESC_S || next == -ESC_H || next == -ESC_d || |
| 2714 |
|
next == -ESC_w || next == -ESC_v || next == -ESC_R; |
| 2715 |
|
|
| 2716 |
case OP_NOT_HSPACE: |
case OP_NOT_HSPACE: |
| 2717 |
return next == -ESC_h; |
return next == -ESC_h; |
| 2718 |
|
|
| 2719 |
/* Can't have \S in here because VT matches \S (Perl anomaly) */ |
/* Can't have \S in here because VT matches \S (Perl anomaly) */ |
| 2720 |
|
case OP_ANYNL: |
| 2721 |
case OP_VSPACE: |
case OP_VSPACE: |
| 2722 |
return next == -ESC_V || next == -ESC_d || next == -ESC_w; |
return next == -ESC_V || next == -ESC_d || next == -ESC_w; |
| 2723 |
|
|
| 2724 |
case OP_NOT_VSPACE: |
case OP_NOT_VSPACE: |
| 2725 |
return next == -ESC_v; |
return next == -ESC_v || next == -ESC_R; |
| 2726 |
|
|
| 2727 |
case OP_WORDCHAR: |
case OP_WORDCHAR: |
| 2728 |
return next == -ESC_W || next == -ESC_s || next == -ESC_h || next == -ESC_v; |
return next == -ESC_W || next == -ESC_s || next == -ESC_h || |
| 2729 |
|
next == -ESC_v || next == -ESC_R; |
| 2730 |
|
|
| 2731 |
case OP_NOT_WORDCHAR: |
case OP_NOT_WORDCHAR: |
| 2732 |
return next == -ESC_w || next == -ESC_d; |
return next == -ESC_w || next == -ESC_d; |
| 2790 |
BOOL groupsetfirstbyte = FALSE; |
BOOL groupsetfirstbyte = FALSE; |
| 2791 |
const uschar *ptr = *ptrptr; |
const uschar *ptr = *ptrptr; |
| 2792 |
const uschar *tempptr; |
const uschar *tempptr; |
| 2793 |
|
const uschar *nestptr = NULL; |
| 2794 |
uschar *previous = NULL; |
uschar *previous = NULL; |
| 2795 |
uschar *previous_callout = NULL; |
uschar *previous_callout = NULL; |
| 2796 |
uschar *save_hwm = NULL; |
uschar *save_hwm = NULL; |
| 2861 |
|
|
| 2862 |
c = *ptr; |
c = *ptr; |
| 2863 |
|
|
| 2864 |
|
/* If we are at the end of a nested substitution, revert to the outer level |
| 2865 |
|
string. Nesting only happens one level deep. */ |
| 2866 |
|
|
| 2867 |
|
if (c == 0 && nestptr != NULL) |
| 2868 |
|
{ |
| 2869 |
|
ptr = nestptr; |
| 2870 |
|
nestptr = NULL; |
| 2871 |
|
c = *ptr; |
| 2872 |
|
} |
| 2873 |
|
|
| 2874 |
/* If we are in the pre-compile phase, accumulate the length used for the |
/* If we are in the pre-compile phase, accumulate the length used for the |
| 2875 |
previous cycle of this loop. */ |
previous cycle of this loop. */ |
| 2876 |
|
|
| 2901 |
goto FAILED; |
goto FAILED; |
| 2902 |
} |
} |
| 2903 |
|
|
| 2904 |
*lengthptr += code - last_code; |
*lengthptr += (int)(code - last_code); |
| 2905 |
DPRINTF(("length=%d added %d c=%c\n", *lengthptr, code - last_code, c)); |
DPRINTF(("length=%d added %d c=%c\n", *lengthptr, code - last_code, c)); |
| 2906 |
|
|
| 2907 |
/* If "previous" is set and it is not at the start of the work space, move |
/* If "previous" is set and it is not at the start of the work space, move |
| 3019 |
*errorcodeptr = ERR20; |
*errorcodeptr = ERR20; |
| 3020 |
goto FAILED; |
goto FAILED; |
| 3021 |
} |
} |
| 3022 |
*lengthptr += code - last_code; /* To include callout length */ |
*lengthptr += (int)(code - last_code); /* To include callout length */ |
| 3023 |
DPRINTF((">> end branch\n")); |
DPRINTF((">> end branch\n")); |
| 3024 |
} |
} |
| 3025 |
return TRUE; |
return TRUE; |
| 3168 |
{ /* Braces are required because the */ |
{ /* Braces are required because the */ |
| 3169 |
GETCHARLEN(c, ptr, ptr); /* macro generates multiple statements */ |
GETCHARLEN(c, ptr, ptr); /* macro generates multiple statements */ |
| 3170 |
} |
} |
| 3171 |
|
|
| 3172 |
/* In the pre-compile phase, accumulate the length of any UTF-8 extra |
/* In the pre-compile phase, accumulate the length of any UTF-8 extra |
| 3173 |
data and reset the pointer. This is so that very large classes that |
data and reset the pointer. This is so that very large classes that |
| 3174 |
contain a zillion UTF-8 characters no longer overwrite the work space |
contain a zillion UTF-8 characters no longer overwrite the work space |
| 3224 |
ptr++; |
ptr++; |
| 3225 |
} |
} |
| 3226 |
|
|
| 3227 |
posix_class = check_posix_name(ptr, tempptr - ptr); |
posix_class = check_posix_name(ptr, (int)(tempptr - ptr)); |
| 3228 |
if (posix_class < 0) |
if (posix_class < 0) |
| 3229 |
{ |
{ |
| 3230 |
*errorcodeptr = ERR30; |
*errorcodeptr = ERR30; |
| 3237 |
|
|
| 3238 |
if ((options & PCRE_CASELESS) != 0 && posix_class <= 2) |
if ((options & PCRE_CASELESS) != 0 && posix_class <= 2) |
| 3239 |
posix_class = 0; |
posix_class = 0; |
| 3240 |
|
|
| 3241 |
/* We build the bit map for the POSIX class in a chunk of local store |
/* When PCRE_UCP is set, some of the POSIX classes are converted to |
| 3242 |
because we may be adding and subtracting from it, and we don't want to |
different escape sequences that use Unicode properties. */ |
| 3243 |
subtract bits that may be in the main map already. At the end we or the |
|
| 3244 |
result into the bit map that is being built. */ |
#ifdef SUPPORT_UCP |
| 3245 |
|
if ((options & PCRE_UCP) != 0) |
| 3246 |
|
{ |
| 3247 |
|
int pc = posix_class + ((local_negate)? POSIX_SUBSIZE/2 : 0); |
| 3248 |
|
if (posix_substitutes[pc] != NULL) |
| 3249 |
|
{ |
| 3250 |
|
nestptr = tempptr + 1; |
| 3251 |
|
ptr = posix_substitutes[pc] - 1; |
| 3252 |
|
continue; |
| 3253 |
|
} |
| 3254 |
|
} |
| 3255 |
|
#endif |
| 3256 |
|
/* In the non-UCP case, we build the bit map for the POSIX class in a |
| 3257 |
|
chunk of local store because we may be adding and subtracting from it, |
| 3258 |
|
and we don't want to subtract bits that may be in the main map already. |
| 3259 |
|
At the end we or the result into the bit map that is being built. */ |
| 3260 |
|
|
| 3261 |
posix_class *= 3; |
posix_class *= 3; |
| 3262 |
|
|
| 3300 |
|
|
| 3301 |
/* Backslash may introduce a single character, or it may introduce one |
/* Backslash may introduce a single character, or it may introduce one |
| 3302 |
of the specials, which just set a flag. The sequence \b is a special |
of the specials, which just set a flag. The sequence \b is a special |
| 3303 |
case. Inside a class (and only there) it is treated as backspace. |
case. Inside a class (and only there) it is treated as backspace. We |
| 3304 |
Elsewhere it marks a word boundary. Other escapes have preset maps ready |
assume that other escapes have more than one character in them, so set |
| 3305 |
to 'or' into the one we are building. We assume they have more than one |
class_charcount bigger than one. Unrecognized escapes fall through and |
| 3306 |
character in them, so set class_charcount bigger than one. */ |
are either treated as literal characters (by default), or are faulted if |
| 3307 |
|
PCRE_EXTRA is set. */ |
| 3308 |
|
|
| 3309 |
if (c == CHAR_BACKSLASH) |
if (c == CHAR_BACKSLASH) |
| 3310 |
{ |
{ |
| 3311 |
c = check_escape(&ptr, errorcodeptr, cd->bracount, options, TRUE); |
c = check_escape(&ptr, errorcodeptr, cd->bracount, options, TRUE); |
| 3312 |
if (*errorcodeptr != 0) goto FAILED; |
if (*errorcodeptr != 0) goto FAILED; |
| 3313 |
|
|
| 3314 |
if (-c == ESC_b) c = CHAR_BS; /* \b is backspace in a class */ |
if (-c == ESC_b) c = CHAR_BS; /* \b is backspace in a class */ |
|
else if (-c == ESC_X) c = CHAR_X; /* \X is literal X in a class */ |
|
|
else if (-c == ESC_R) c = CHAR_R; /* \R is literal R in a class */ |
|
| 3315 |
else if (-c == ESC_Q) /* Handle start of quoted string */ |
else if (-c == ESC_Q) /* Handle start of quoted string */ |
| 3316 |
{ |
{ |
| 3317 |
if (ptr[1] == CHAR_BACKSLASH && ptr[2] == CHAR_E) |
if (ptr[1] == CHAR_BACKSLASH && ptr[2] == CHAR_E) |
| 3328 |
register const uschar *cbits = cd->cbits; |
register const uschar *cbits = cd->cbits; |
| 3329 |
class_charcount += 2; /* Greater than 1 is what matters */ |
class_charcount += 2; /* Greater than 1 is what matters */ |
| 3330 |
|
|
| 3331 |
/* Save time by not doing this in the pre-compile phase. */ |
switch (-c) |
|
|
|
|
if (lengthptr == NULL) switch (-c) |
|
| 3332 |
{ |
{ |
| 3333 |
|
#ifdef SUPPORT_UCP |
| 3334 |
|
case ESC_du: /* These are the values given for \d etc */ |
| 3335 |
|
case ESC_DU: /* when PCRE_UCP is set. We replace the */ |
| 3336 |
|
case ESC_wu: /* escape sequence with an appropriate \p */ |
| 3337 |
|
case ESC_WU: /* or \P to test Unicode properties instead */ |
| 3338 |
|
case ESC_su: /* of the default ASCII testing. */ |
| 3339 |
|
case ESC_SU: |
| 3340 |
|
nestptr = ptr; |
| 3341 |
|
ptr = substitutes[-c - ESC_DU] - 1; /* Just before substitute */ |
| 3342 |
|
class_charcount -= 2; /* Undo! */ |
| 3343 |
|
continue; |
| 3344 |
|
#endif |
| 3345 |
case ESC_d: |
case ESC_d: |
| 3346 |
for (c = 0; c < 32; c++) classbits[c] |= cbits[c+cbit_digit]; |
for (c = 0; c < 32; c++) classbits[c] |= cbits[c+cbit_digit]; |
| 3347 |
continue; |
continue; |
| 3371 |
classbits[1] |= 0x08; /* Perl 5.004 onwards omits VT from \s */ |
classbits[1] |= 0x08; /* Perl 5.004 onwards omits VT from \s */ |
| 3372 |
continue; |
continue; |
| 3373 |
|
|
| 3374 |
default: /* Not recognized; fall through */ |
case ESC_h: |
|
break; /* Need "default" setting to stop compiler warning. */ |
|
|
} |
|
|
|
|
|
/* In the pre-compile phase, just do the recognition. */ |
|
|
|
|
|
else if (c == -ESC_d || c == -ESC_D || c == -ESC_w || |
|
|
c == -ESC_W || c == -ESC_s || c == -ESC_S) continue; |
|
|
|
|
|
/* We need to deal with \H, \h, \V, and \v in both phases because |
|
|
they use extra memory. */ |
|
|
|
|
|
if (-c == ESC_h) |
|
|
{ |
|
| 3375 |
SETBIT(classbits, 0x09); /* VT */ |
SETBIT(classbits, 0x09); /* VT */ |
| 3376 |
SETBIT(classbits, 0x20); /* SPACE */ |
SETBIT(classbits, 0x20); /* SPACE */ |
| 3377 |
SETBIT(classbits, 0xa0); /* NSBP */ |
SETBIT(classbits, 0xa0); /* NSBP */ |
| 3395 |
} |
} |
| 3396 |
#endif |
#endif |
| 3397 |
continue; |
continue; |
|
} |
|
| 3398 |
|
|
| 3399 |
if (-c == ESC_H) |
case ESC_H: |
|
{ |
|
| 3400 |
for (c = 0; c < 32; c++) |
for (c = 0; c < 32; c++) |
| 3401 |
{ |
{ |
| 3402 |
int x = 0xff; |
int x = 0xff; |
| 3438 |
} |
} |
| 3439 |
#endif |
#endif |
| 3440 |
continue; |
continue; |
|
} |
|
| 3441 |
|
|
| 3442 |
if (-c == ESC_v) |
case ESC_v: |
|
{ |
|
| 3443 |
SETBIT(classbits, 0x0a); /* LF */ |
SETBIT(classbits, 0x0a); /* LF */ |
| 3444 |
SETBIT(classbits, 0x0b); /* VT */ |
SETBIT(classbits, 0x0b); /* VT */ |
| 3445 |
SETBIT(classbits, 0x0c); /* FF */ |
SETBIT(classbits, 0x0c); /* FF */ |
| 3455 |
} |
} |
| 3456 |
#endif |
#endif |
| 3457 |
continue; |
continue; |
|
} |
|
| 3458 |
|
|
| 3459 |
if (-c == ESC_V) |
case ESC_V: |
|
{ |
|
| 3460 |
for (c = 0; c < 32; c++) |
for (c = 0; c < 32; c++) |
| 3461 |
{ |
{ |
| 3462 |
int x = 0xff; |
int x = 0xff; |
| 3486 |
} |
} |
| 3487 |
#endif |
#endif |
| 3488 |
continue; |
continue; |
|
} |
|
|
|
|
|
/* We need to deal with \P and \p in both phases. */ |
|
| 3489 |
|
|
| 3490 |
#ifdef SUPPORT_UCP |
#ifdef SUPPORT_UCP |
| 3491 |
if (-c == ESC_p || -c == ESC_P) |
case ESC_p: |
| 3492 |
{ |
case ESC_P: |
| 3493 |
BOOL negated; |
{ |
| 3494 |
int pdata; |
BOOL negated; |
| 3495 |
int ptype = get_ucp(&ptr, &negated, &pdata, errorcodeptr); |
int pdata; |
| 3496 |
if (ptype < 0) goto FAILED; |
int ptype = get_ucp(&ptr, &negated, &pdata, errorcodeptr); |
| 3497 |
class_utf8 = TRUE; |
if (ptype < 0) goto FAILED; |
| 3498 |
*class_utf8data++ = ((-c == ESC_p) != negated)? |
class_utf8 = TRUE; |
| 3499 |
XCL_PROP : XCL_NOTPROP; |
*class_utf8data++ = ((-c == ESC_p) != negated)? |
| 3500 |
*class_utf8data++ = ptype; |
XCL_PROP : XCL_NOTPROP; |
| 3501 |
*class_utf8data++ = pdata; |
*class_utf8data++ = ptype; |
| 3502 |
class_charcount -= 2; /* Not a < 256 character */ |
*class_utf8data++ = pdata; |
| 3503 |
continue; |
class_charcount -= 2; /* Not a < 256 character */ |
| 3504 |
} |
continue; |
| 3505 |
|
} |
| 3506 |
#endif |
#endif |
| 3507 |
/* Unrecognized escapes are faulted if PCRE is running in its |
/* Unrecognized escapes are faulted if PCRE is running in its |
| 3508 |
strict mode. By default, for compatibility with Perl, they are |
strict mode. By default, for compatibility with Perl, they are |
| 3509 |
treated as literals. */ |
treated as literals. */ |
| 3510 |
|
|
| 3511 |
if ((options & PCRE_EXTRA) != 0) |
default: |
| 3512 |
{ |
if ((options & PCRE_EXTRA) != 0) |
| 3513 |
*errorcodeptr = ERR7; |
{ |
| 3514 |
goto FAILED; |
*errorcodeptr = ERR7; |
| 3515 |
|
goto FAILED; |
| 3516 |
|
} |
| 3517 |
|
class_charcount -= 2; /* Undo the default count from above */ |
| 3518 |
|
c = *ptr; /* Get the final character and fall through */ |
| 3519 |
|
break; |
| 3520 |
} |
} |
|
|
|
|
class_charcount -= 2; /* Undo the default count from above */ |
|
|
c = *ptr; /* Get the final character and fall through */ |
|
| 3521 |
} |
} |
| 3522 |
|
|
| 3523 |
/* Fall through if we have a single character (c >= 0). This may be |
/* Fall through if we have a single character (c >= 0). This may be |
| 3587 |
d = check_escape(&ptr, errorcodeptr, cd->bracount, options, TRUE); |
d = check_escape(&ptr, errorcodeptr, cd->bracount, options, TRUE); |
| 3588 |
if (*errorcodeptr != 0) goto FAILED; |
if (*errorcodeptr != 0) goto FAILED; |
| 3589 |
|
|
| 3590 |
/* \b is backspace; \X is literal X; \R is literal R; any other |
/* \b is backspace; any other special means the '-' was literal */ |
|
special means the '-' was literal */ |
|
| 3591 |
|
|
| 3592 |
if (d < 0) |
if (d < 0) |
| 3593 |
{ |
{ |
| 3594 |
if (d == -ESC_b) d = CHAR_BS; |
if (d == -ESC_b) d = CHAR_BS; else |
|
else if (d == -ESC_X) d = CHAR_X; |
|
|
else if (d == -ESC_R) d = CHAR_R; else |
|
| 3595 |
{ |
{ |
| 3596 |
ptr = oldptr; |
ptr = oldptr; |
| 3597 |
goto LONE_SINGLE_CHARACTER; /* A few lines below */ |
goto LONE_SINGLE_CHARACTER; /* A few lines below */ |
| 3757 |
} |
} |
| 3758 |
} |
} |
| 3759 |
|
|
| 3760 |
/* Loop until ']' reached. This "while" is the end of the "do" above. */ |
/* Loop until ']' reached. This "while" is the end of the "do" far above. |
| 3761 |
|
If we are at the end of an internal nested string, revert to the outer |
| 3762 |
|
string. */ |
| 3763 |
|
|
| 3764 |
|
while (((c = *(++ptr)) != 0 || |
| 3765 |
|
(nestptr != NULL && |
| 3766 |
|
(ptr = nestptr, nestptr = NULL, c = *(++ptr)) != 0)) && |
| 3767 |
|
(c != CHAR_RIGHT_SQUARE_BRACKET || inescq)); |
| 3768 |
|
|
| 3769 |
while ((c = *(++ptr)) != 0 && (c != CHAR_RIGHT_SQUARE_BRACKET || inescq)); |
/* Check for missing terminating ']' */ |
| 3770 |
|
|
| 3771 |
if (c == 0) /* Missing terminating ']' */ |
if (c == 0) |
| 3772 |
{ |
{ |
| 3773 |
*errorcodeptr = ERR6; |
*errorcodeptr = ERR6; |
| 3774 |
goto FAILED; |
goto FAILED; |
| 3775 |
} |
} |
| 3776 |
|
|
|
|
|
|
/* This code has been disabled because it would mean that \s counts as |
|
|
an explicit \r or \n reference, and that's not really what is wanted. Now |
|
|
we set the flag only if there is a literal "\r" or "\n" in the class. */ |
|
|
|
|
|
#if 0 |
|
|
/* Remember whether \r or \n are in this class */ |
|
|
|
|
|
if (negate_class) |
|
|
{ |
|
|
if ((classbits[1] & 0x24) != 0x24) cd->external_flags |= PCRE_HASCRORLF; |
|
|
} |
|
|
else |
|
|
{ |
|
|
if ((classbits[1] & 0x24) != 0) cd->external_flags |= PCRE_HASCRORLF; |
|
|
} |
|
|
#endif |
|
|
|
|
|
|
|
| 3777 |
/* If class_charcount is 1, we saw precisely one character whose value is |
/* If class_charcount is 1, we saw precisely one character whose value is |
| 3778 |
less than 256. As long as there were no characters >= 128 and there was no |
less than 256. As long as there were no characters >= 128 and there was no |
| 3779 |
use of \p or \P, in other words, no use of any XCLASS features, we can |
use of \p or \P, in other words, no use of any XCLASS features, we can |
| 3790 |
can cause firstbyte to be set. Otherwise, there can be no first char if |
can cause firstbyte to be set. Otherwise, there can be no first char if |
| 3791 |
this item is first, whatever repeat count may follow. In the case of |
this item is first, whatever repeat count may follow. In the case of |
| 3792 |
reqbyte, save the previous value for reinstating. */ |
reqbyte, save the previous value for reinstating. */ |
| 3793 |
|
|
| 3794 |
#ifdef SUPPORT_UTF8 |
#ifdef SUPPORT_UTF8 |
| 3795 |
if (class_charcount == 1 && !class_utf8 && |
if (class_charcount == 1 && !class_utf8 && |
| 3796 |
(!utf8 || !negate_class || class_lastchar < 128)) |
(!utf8 || !negate_class || class_lastchar < 128)) |
| 3837 |
|
|
| 3838 |
/* If there are characters with values > 255, we have to compile an |
/* If there are characters with values > 255, we have to compile an |
| 3839 |
extended class, with its own opcode, unless there was a negated special |
extended class, with its own opcode, unless there was a negated special |
| 3840 |
such as \S in the class, because in that case all characters > 255 are in |
such as \S in the class, and PCRE_UCP is not set, because in that case all |
| 3841 |
the class, so any that were explicitly given as well can be ignored. If |
characters > 255 are in the class, so any that were explicitly given as |
| 3842 |
(when there are explicit characters > 255 that must be listed) there are no |
well can be ignored. If (when there are explicit characters > 255 that must |
| 3843 |
characters < 256, we can omit the bitmap in the actual compiled code. */ |
be listed) there are no characters < 256, we can omit the bitmap in the |
| 3844 |
|
actual compiled code. */ |
| 3845 |
|
|
| 3846 |
#ifdef SUPPORT_UTF8 |
#ifdef SUPPORT_UTF8 |
| 3847 |
if (class_utf8 && !should_flip_negation) |
if (class_utf8 && (!should_flip_negation || (options & PCRE_UCP) != 0)) |
| 3848 |
{ |
{ |
| 3849 |
*class_utf8data++ = XCL_END; /* Marks the end of extra data */ |
*class_utf8data++ = XCL_END; /* Marks the end of extra data */ |
| 3850 |
*code++ = OP_XCLASS; |
*code++ = OP_XCLASS; |
| 3870 |
} |
} |
| 3871 |
#endif |
#endif |
| 3872 |
|
|
| 3873 |
/* If there are no characters > 255, set the opcode to OP_CLASS or |
/* If there are no characters > 255, or they are all to be included or |
| 3874 |
OP_NCLASS, depending on whether the whole class was negated and whether |
excluded, set the opcode to OP_CLASS or OP_NCLASS, depending on whether the |
| 3875 |
there were negative specials such as \S in the class. Then copy the 32-byte |
whole class was negated and whether there were negative specials such as \S |
| 3876 |
map into the code vector, negating it if necessary. */ |
(non-UCP) in the class. Then copy the 32-byte map into the code vector, |
| 3877 |
|
negating it if necessary. */ |
| 3878 |
|
|
| 3879 |
*code++ = (negate_class == should_flip_negation) ? OP_CLASS : OP_NCLASS; |
*code++ = (negate_class == should_flip_negation) ? OP_CLASS : OP_NCLASS; |
| 3880 |
if (negate_class) |
if (negate_class) |
| 4254 |
{ |
{ |
| 4255 |
register int i; |
register int i; |
| 4256 |
int ketoffset = 0; |
int ketoffset = 0; |
| 4257 |
int len = code - previous; |
int len = (int)(code - previous); |
| 4258 |
uschar *bralink = NULL; |
uschar *bralink = NULL; |
| 4259 |
|
|
| 4260 |
/* Repeating a DEFINE group is pointless */ |
/* Repeating a DEFINE group is pointless */ |
| 4275 |
{ |
{ |
| 4276 |
register uschar *ket = previous; |
register uschar *ket = previous; |
| 4277 |
do ket += GET(ket, 1); while (*ket != OP_KET); |
do ket += GET(ket, 1); while (*ket != OP_KET); |
| 4278 |
ketoffset = code - ket; |
ketoffset = (int)(code - ket); |
| 4279 |
} |
} |
| 4280 |
|
|
| 4281 |
/* The case of a zero minimum is special because of the need to stick |
/* The case of a zero minimum is special because of the need to stick |
| 4343 |
/* We chain together the bracket offset fields that have to be |
/* We chain together the bracket offset fields that have to be |
| 4344 |
filled in later when the ends of the brackets are reached. */ |
filled in later when the ends of the brackets are reached. */ |
| 4345 |
|
|
| 4346 |
offset = (bralink == NULL)? 0 : previous - bralink; |
offset = (bralink == NULL)? 0 : (int)(previous - bralink); |
| 4347 |
bralink = previous; |
bralink = previous; |
| 4348 |
PUTINC(previous, 0, offset); |
PUTINC(previous, 0, offset); |
| 4349 |
} |
} |
| 4452 |
{ |
{ |
| 4453 |
int offset; |
int offset; |
| 4454 |
*code++ = OP_BRA; |
*code++ = OP_BRA; |
| 4455 |
offset = (bralink == NULL)? 0 : code - bralink; |
offset = (bralink == NULL)? 0 : (int)(code - bralink); |
| 4456 |
bralink = code; |
bralink = code; |
| 4457 |
PUTINC(code, 0, offset); |
PUTINC(code, 0, offset); |
| 4458 |
} |
} |
| 4473 |
while (bralink != NULL) |
while (bralink != NULL) |
| 4474 |
{ |
{ |
| 4475 |
int oldlinkoffset; |
int oldlinkoffset; |
| 4476 |
int offset = code - bralink + 1; |
int offset = (int)(code - bralink + 1); |
| 4477 |
uschar *bra = code - offset; |
uschar *bra = code - offset; |
| 4478 |
oldlinkoffset = GET(bra, 1); |
oldlinkoffset = GET(bra, 1); |
| 4479 |
bralink = (oldlinkoffset == 0)? NULL : bralink - oldlinkoffset; |
bralink = (oldlinkoffset == 0)? NULL : bralink - oldlinkoffset; |
| 4561 |
#endif |
#endif |
| 4562 |
} |
} |
| 4563 |
|
|
| 4564 |
len = code - tempcode; |
len = (int)(code - tempcode); |
| 4565 |
if (len > 0) switch (*tempcode) |
if (len > 0) switch (*tempcode) |
| 4566 |
{ |
{ |
| 4567 |
case OP_STAR: *tempcode = OP_POSSTAR; break; |
case OP_STAR: *tempcode = OP_POSSTAR; break; |
| 4620 |
|
|
| 4621 |
/* First deal with various "verbs" that can be introduced by '*'. */ |
/* First deal with various "verbs" that can be introduced by '*'. */ |
| 4622 |
|
|
| 4623 |
if (*(++ptr) == CHAR_ASTERISK && (cd->ctypes[ptr[1]] & ctype_letter) != 0) |
if (*(++ptr) == CHAR_ASTERISK && |
| 4624 |
|
((cd->ctypes[ptr[1]] & ctype_letter) != 0 || ptr[1] == ':')) |
| 4625 |
{ |
{ |
| 4626 |
int i, namelen; |
int i, namelen; |
| 4627 |
|
int arglen = 0; |
| 4628 |
const char *vn = verbnames; |
const char *vn = verbnames; |
| 4629 |
const uschar *name = ++ptr; |
const uschar *name = ptr + 1; |
| 4630 |
|
const uschar *arg = NULL; |
| 4631 |
previous = NULL; |
previous = NULL; |
| 4632 |
while ((cd->ctypes[*++ptr] & ctype_letter) != 0) {}; |
while ((cd->ctypes[*++ptr] & ctype_letter) != 0) {}; |
| 4633 |
|
namelen = (int)(ptr - name); |
| 4634 |
|
|
| 4635 |
if (*ptr == CHAR_COLON) |
if (*ptr == CHAR_COLON) |
| 4636 |
{ |
{ |
| 4637 |
*errorcodeptr = ERR59; /* Not supported */ |
arg = ++ptr; |
| 4638 |
goto FAILED; |
while ((cd->ctypes[*ptr] & (ctype_letter|ctype_digit)) != 0 |
| 4639 |
|
|| *ptr == '_') ptr++; |
| 4640 |
|
arglen = ptr - arg; |
| 4641 |
} |
} |
| 4642 |
|
|
| 4643 |
if (*ptr != CHAR_RIGHT_PARENTHESIS) |
if (*ptr != CHAR_RIGHT_PARENTHESIS) |
| 4644 |
{ |
{ |
| 4645 |
*errorcodeptr = ERR60; |
*errorcodeptr = ERR60; |
| 4646 |
goto FAILED; |
goto FAILED; |
| 4647 |
} |
} |
| 4648 |
namelen = ptr - name; |
|
| 4649 |
|
/* Scan the table of verb names */ |
| 4650 |
|
|
| 4651 |
for (i = 0; i < verbcount; i++) |
for (i = 0; i < verbcount; i++) |
| 4652 |
{ |
{ |
| 4653 |
if (namelen == verbs[i].len && |
if (namelen == verbs[i].len && |
| 4665 |
PUT2INC(code, 0, oc->number); |
PUT2INC(code, 0, oc->number); |
| 4666 |
} |
} |
| 4667 |
} |
} |
| 4668 |
*code++ = verbs[i].op; |
|
| 4669 |
break; |
/* Handle the cases with/without an argument */ |
| 4670 |
|
|
| 4671 |
|
if (arglen == 0) |
| 4672 |
|
{ |
| 4673 |
|
if (verbs[i].op < 0) /* Argument is mandatory */ |
| 4674 |
|
{ |
| 4675 |
|
*errorcodeptr = ERR66; |
| 4676 |
|
goto FAILED; |
| 4677 |
|
} |
| 4678 |
|
*code++ = verbs[i].op; |
| 4679 |
|
} |
| 4680 |
|
|
| 4681 |
|
else |
| 4682 |
|
{ |
| 4683 |
|
if (verbs[i].op_arg < 0) /* Argument is forbidden */ |
| 4684 |
|
{ |
| 4685 |
|
*errorcodeptr = ERR59; |
| 4686 |
|
goto FAILED; |
| 4687 |
|
} |
| 4688 |
|
*code++ = verbs[i].op_arg; |
| 4689 |
|
*code++ = arglen; |
| 4690 |
|
memcpy(code, arg, arglen); |
| 4691 |
|
code += arglen; |
| 4692 |
|
*code++ = 0; |
| 4693 |
|
} |
| 4694 |
|
|
| 4695 |
|
break; /* Found verb, exit loop */ |
| 4696 |
} |
} |
| 4697 |
|
|
| 4698 |
vn += verbs[i].len + 1; |
vn += verbs[i].len + 1; |
| 4699 |
} |
} |
| 4700 |
if (i < verbcount) continue; |
|
| 4701 |
*errorcodeptr = ERR60; |
if (i < verbcount) continue; /* Successfully handled a verb */ |
| 4702 |
|
*errorcodeptr = ERR60; /* Verb not recognized */ |
| 4703 |
goto FAILED; |
goto FAILED; |
| 4704 |
} |
} |
| 4705 |
|
|
| 4818 |
recno * 10 + *ptr - CHAR_0 : -1; |
recno * 10 + *ptr - CHAR_0 : -1; |
| 4819 |
ptr++; |
ptr++; |
| 4820 |
} |
} |
| 4821 |
namelen = ptr - name; |
namelen = (int)(ptr - name); |
| 4822 |
|
|
| 4823 |
if ((terminator > 0 && *ptr++ != terminator) || |
if ((terminator > 0 && *ptr++ != terminator) || |
| 4824 |
*ptr++ != CHAR_RIGHT_PARENTHESIS) |
*ptr++ != CHAR_RIGHT_PARENTHESIS) |
| 5014 |
goto FAILED; |
goto FAILED; |
| 5015 |
} |
} |
| 5016 |
*code++ = n; |
*code++ = n; |
| 5017 |
PUT(code, 0, ptr - cd->start_pattern + 1); /* Pattern offset */ |
PUT(code, 0, (int)(ptr - cd->start_pattern + 1)); /* Pattern offset */ |
| 5018 |
PUT(code, LINK_SIZE, 0); /* Default length */ |
PUT(code, LINK_SIZE, 0); /* Default length */ |
| 5019 |
code += 2 * LINK_SIZE; |
code += 2 * LINK_SIZE; |
| 5020 |
} |
} |
| 5021 |
previous = NULL; |
previous = NULL; |
| 5048 |
name = ++ptr; |
name = ++ptr; |
| 5049 |
|
|
| 5050 |
while ((cd->ctypes[*ptr] & ctype_word) != 0) ptr++; |
while ((cd->ctypes[*ptr] & ctype_word) != 0) ptr++; |
| 5051 |
namelen = ptr - name; |
namelen = (int)(ptr - name); |
| 5052 |
|
|
| 5053 |
/* In the pre-compile phase, just do a syntax check. */ |
/* In the pre-compile phase, just do a syntax check. */ |
| 5054 |
|
|
| 5178 |
NAMED_REF_OR_RECURSE: |
NAMED_REF_OR_RECURSE: |
| 5179 |
name = ++ptr; |
name = ++ptr; |
| 5180 |
while ((cd->ctypes[*ptr] & ctype_word) != 0) ptr++; |
while ((cd->ctypes[*ptr] & ctype_word) != 0) ptr++; |
| 5181 |
namelen = ptr - name; |
namelen = (int)(ptr - name); |
| 5182 |
|
|
| 5183 |
/* In the pre-compile phase, do a syntax check and set a dummy |
/* In the pre-compile phase, do a syntax check and set a dummy |
| 5184 |
reference number. */ |
reference number. */ |
| 5347 |
of the group. */ |
of the group. */ |
| 5348 |
|
|
| 5349 |
called = cd->start_code + recno; |
called = cd->start_code + recno; |
| 5350 |
PUTINC(cd->hwm, 0, code + 2 + LINK_SIZE - cd->start_code); |
PUTINC(cd->hwm, 0, (int)(code + 2 + LINK_SIZE - cd->start_code)); |
| 5351 |
} |
} |
| 5352 |
|
|
| 5353 |
/* If not a forward reference, and the subpattern is still open, |
/* If not a forward reference, and the subpattern is still open, |
| 5371 |
code += 1 + LINK_SIZE; |
code += 1 + LINK_SIZE; |
| 5372 |
|
|
| 5373 |
*code = OP_RECURSE; |
*code = OP_RECURSE; |
| 5374 |
PUT(code, 1, called - cd->start_code); |
PUT(code, 1, (int)(called - cd->start_code)); |
| 5375 |
code += 1 + LINK_SIZE; |
code += 1 + LINK_SIZE; |
| 5376 |
|
|
| 5377 |
*code = OP_KET; |
*code = OP_KET; |
| 5482 |
} /* End of switch for character following (? */ |
} /* End of switch for character following (? */ |
| 5483 |
} /* End of (? handling */ |
} /* End of (? handling */ |
| 5484 |
|
|
| 5485 |
/* Opening parenthesis not followed by '?'. If PCRE_NO_AUTO_CAPTURE is set, |
/* Opening parenthesis not followed by '*' or '?'. If PCRE_NO_AUTO_CAPTURE |
| 5486 |
all unadorned brackets become non-capturing and behave like (?:...) |
is set, all unadorned brackets become non-capturing and behave like (?:...) |
| 5487 |
brackets. */ |
brackets. */ |
| 5488 |
|
|
| 5489 |
else if ((options & PCRE_NO_AUTO_CAPTURE) != 0) |
else if ((options & PCRE_NO_AUTO_CAPTURE) != 0) |
| 5675 |
|
|
| 5676 |
/* ===================================================================*/ |
/* ===================================================================*/ |
| 5677 |
/* Handle metasequences introduced by \. For ones like \d, the ESC_ values |
/* Handle metasequences introduced by \. For ones like \d, the ESC_ values |
| 5678 |
are arranged to be the negation of the corresponding OP_values. For the |
are arranged to be the negation of the corresponding OP_values in the |
| 5679 |
back references, the values are ESC_REF plus the reference number. Only |
default case when PCRE_UCP is not set. For the back references, the values |
| 5680 |
back references and those types that consume a character may be repeated. |
are ESC_REF plus the reference number. Only back references and those types |
| 5681 |
We can test for values between ESC_b and ESC_Z for the latter; this may |
that consume a character may be repeated. We can test for values between |
| 5682 |
have to change if any new ones are ever created. */ |
ESC_b and ESC_Z for the latter; this may have to change if any new ones are |
| 5683 |
|
ever created. */ |
| 5684 |
|
|
| 5685 |
case CHAR_BACKSLASH: |
case CHAR_BACKSLASH: |
| 5686 |
tempptr = ptr; |
tempptr = ptr; |
| 5840 |
#endif |
#endif |
| 5841 |
|
|
| 5842 |
/* For the rest (including \X when Unicode properties are supported), we |
/* For the rest (including \X when Unicode properties are supported), we |
| 5843 |
can obtain the OP value by negating the escape value. */ |
can obtain the OP value by negating the escape value in the default |
| 5844 |
|
situation when PCRE_UCP is not set. When it *is* set, we substitute |
| 5845 |
|
Unicode property tests. */ |
| 5846 |
|
|
| 5847 |
else |
else |
| 5848 |
{ |
{ |
| 5849 |
previous = (-c > ESC_b && -c < ESC_Z)? code : NULL; |
#ifdef SUPPORT_UCP |
| 5850 |
*code++ = -c; |
if (-c >= ESC_DU && -c <= ESC_wu) |
| 5851 |
|
{ |
| 5852 |
|
nestptr = ptr + 1; /* Where to resume */ |
| 5853 |
|
ptr = substitutes[-c - ESC_DU] - 1; /* Just before substitute */ |
| 5854 |
|
} |
| 5855 |
|
else |
| 5856 |
|
#endif |
| 5857 |
|
{ |
| 5858 |
|
previous = (-c > ESC_b && -c < ESC_Z)? code : NULL; |
| 5859 |
|
*code++ = -c; |
| 5860 |
|
} |
| 5861 |
} |
} |
| 5862 |
continue; |
continue; |
| 5863 |
} |
} |
| 6189 |
{ |
{ |
| 6190 |
if (lengthptr == NULL) |
if (lengthptr == NULL) |
| 6191 |
{ |
{ |
| 6192 |
int branch_length = code - last_branch; |
int branch_length = (int)(code - last_branch); |
| 6193 |
do |
do |
| 6194 |
{ |
{ |
| 6195 |
int prev_length = GET(last_branch, 1); |
int prev_length = GET(last_branch, 1); |
| 6203 |
/* Fill in the ket */ |
/* Fill in the ket */ |
| 6204 |
|
|
| 6205 |
*code = OP_KET; |
*code = OP_KET; |
| 6206 |
PUT(code, 1, code - start_bracket); |
PUT(code, 1, (int)(code - start_bracket)); |
| 6207 |
code += 1 + LINK_SIZE; |
code += 1 + LINK_SIZE; |
| 6208 |
|
|
| 6209 |
/* If it was a capturing subpattern, check to see if it contained any |
/* If it was a capturing subpattern, check to see if it contained any |
| 6218 |
code - start_bracket); |
code - start_bracket); |
| 6219 |
*start_bracket = OP_ONCE; |
*start_bracket = OP_ONCE; |
| 6220 |
code += 1 + LINK_SIZE; |
code += 1 + LINK_SIZE; |
| 6221 |
PUT(start_bracket, 1, code - start_bracket); |
PUT(start_bracket, 1, (int)(code - start_bracket)); |
| 6222 |
*code = OP_KET; |
*code = OP_KET; |
| 6223 |
PUT(code, 1, code - start_bracket); |
PUT(code, 1, (int)(code - start_bracket)); |
| 6224 |
code += 1 + LINK_SIZE; |
code += 1 + LINK_SIZE; |
| 6225 |
length += 2 + 2*LINK_SIZE; |
length += 2 + 2*LINK_SIZE; |
| 6226 |
} |
} |
| 6275 |
else |
else |
| 6276 |
{ |
{ |
| 6277 |
*code = OP_ALT; |
*code = OP_ALT; |
| 6278 |
PUT(code, 1, code - last_branch); |
PUT(code, 1, (int)(code - last_branch)); |
| 6279 |
bc.current_branch = last_branch = code; |
bc.current_branch = last_branch = code; |
| 6280 |
code += 1 + LINK_SIZE; |
code += 1 + LINK_SIZE; |
| 6281 |
} |
} |
| 6594 |
int firstbyte, reqbyte, newline; |
int firstbyte, reqbyte, newline; |
| 6595 |
int errorcode = 0; |
int errorcode = 0; |
| 6596 |
int skipatstart = 0; |
int skipatstart = 0; |
| 6597 |
BOOL utf8 = (options & PCRE_UTF8) != 0; |
BOOL utf8; |
| 6598 |
size_t size; |
size_t size; |
| 6599 |
uschar *code; |
uschar *code; |
| 6600 |
const uschar *codestart; |
const uschar *codestart; |
| 6664 |
|
|
| 6665 |
if (strncmp((char *)(ptr+skipatstart+2), STRING_UTF8_RIGHTPAR, 5) == 0) |
if (strncmp((char *)(ptr+skipatstart+2), STRING_UTF8_RIGHTPAR, 5) == 0) |
| 6666 |
{ skipatstart += 7; options |= PCRE_UTF8; continue; } |
{ skipatstart += 7; options |= PCRE_UTF8; continue; } |
| 6667 |
|
else if (strncmp((char *)(ptr+skipatstart+2), STRING_UCP_RIGHTPAR, 4) == 0) |
| 6668 |
|
{ skipatstart += 6; options |= PCRE_UCP; continue; } |
| 6669 |
|
|
| 6670 |
if (strncmp((char *)(ptr+skipatstart+2), STRING_CR_RIGHTPAR, 3) == 0) |
if (strncmp((char *)(ptr+skipatstart+2), STRING_CR_RIGHTPAR, 3) == 0) |
| 6671 |
{ skipatstart += 5; newnl = PCRE_NEWLINE_CR; } |
{ skipatstart += 5; newnl = PCRE_NEWLINE_CR; } |
| 6689 |
options = (options & ~(PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) | newbsr; |
options = (options & ~(PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) | newbsr; |
| 6690 |
else break; |
else break; |
| 6691 |
} |
} |
| 6692 |
|
|
| 6693 |
|
utf8 = (options & PCRE_UTF8) != 0; |
| 6694 |
|
|
| 6695 |
/* Can't support UTF8 unless PCRE has been compiled to include the code. */ |
/* Can't support UTF8 unless PCRE has been compiled to include the code. */ |
| 6696 |
|
|
| 6709 |
} |
} |
| 6710 |
#endif |
#endif |
| 6711 |
|
|
| 6712 |
|
/* Can't support UCP unless PCRE has been compiled to include the code. */ |
| 6713 |
|
|
| 6714 |
|
#ifndef SUPPORT_UCP |
| 6715 |
|
if ((options & PCRE_UCP) != 0) |
| 6716 |
|
{ |
| 6717 |
|
errorcode = ERR67; |
| 6718 |
|
goto PCRE_EARLY_ERROR_RETURN; |
| 6719 |
|
} |
| 6720 |
|
#endif |
| 6721 |
|
|
| 6722 |
/* Check validity of \R options. */ |
/* Check validity of \R options. */ |
| 6723 |
|
|
| 6724 |
switch (options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) |
switch (options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) |
| 6847 |
pointers. */ |
pointers. */ |
| 6848 |
|
|
| 6849 |
re->magic_number = MAGIC_NUMBER; |
re->magic_number = MAGIC_NUMBER; |
| 6850 |
re->size = size; |
re->size = (int)size; |
| 6851 |
re->options = cd->external_options; |
re->options = cd->external_options; |
| 6852 |
re->flags = cd->external_flags; |
re->flags = cd->external_flags; |
| 6853 |
re->dummy1 = 0; |
re->dummy1 = 0; |
| 6918 |
recno = GET(codestart, offset); |
recno = GET(codestart, offset); |
| 6919 |
groupptr = _pcre_find_bracket(codestart, utf8, recno); |
groupptr = _pcre_find_bracket(codestart, utf8, recno); |
| 6920 |
if (groupptr == NULL) errorcode = ERR53; |
if (groupptr == NULL) errorcode = ERR53; |
| 6921 |
else PUT(((uschar *)codestart), offset, groupptr - codestart); |
else PUT(((uschar *)codestart), offset, (int)(groupptr - codestart)); |
| 6922 |
} |
} |
| 6923 |
|
|
| 6924 |
/* Give an error if there's back reference to a non-existent capturing |
/* Give an error if there's back reference to a non-existent capturing |
| 6973 |
{ |
{ |
| 6974 |
(pcre_free)(re); |
(pcre_free)(re); |
| 6975 |
PCRE_EARLY_ERROR_RETURN: |
PCRE_EARLY_ERROR_RETURN: |
| 6976 |
*erroroffset = ptr - (const uschar *)pattern; |
*erroroffset = (int)(ptr - (const uschar *)pattern); |
| 6977 |
PCRE_EARLY_ERROR_RETURN2: |
PCRE_EARLY_ERROR_RETURN2: |
| 6978 |
*errorptr = find_error_text(errorcode); |
*errorptr = find_error_text(errorcode); |
| 6979 |
if (errorcodeptr != NULL) *errorcodeptr = errorcode; |
if (errorcodeptr != NULL) *errorcodeptr = errorcode; |