1203 |
Argument: |
Argument: |
1204 |
ptrptr points to the pattern position pointer |
ptrptr points to the pattern position pointer |
1205 |
negptr points to a boolean that is set TRUE for negation else FALSE |
negptr points to a boolean that is set TRUE for negation else FALSE |
1206 |
dptr points to an int that is set to the detailed property value |
ptypeptr points to an unsigned int that is set to the type value |
1207 |
|
pdataptr points to an unsigned int that is set to the detailed property value |
1208 |
errorcodeptr points to the error code variable |
errorcodeptr points to the error code variable |
1209 |
|
|
1210 |
Returns: type value from ucp_type_table, or -1 for an invalid type |
Returns: TRUE if the type value was found, or FALSE for an invalid type |
1211 |
*/ |
*/ |
1212 |
|
|
1213 |
static int |
static BOOL |
1214 |
get_ucp(const pcre_uchar **ptrptr, BOOL *negptr, int *dptr, int *errorcodeptr) |
get_ucp(const pcre_uchar **ptrptr, BOOL *negptr, unsigned int *ptypeptr, |
1215 |
|
unsigned int *pdataptr, int *errorcodeptr) |
1216 |
{ |
{ |
1217 |
pcre_uchar c; |
pcre_uchar c; |
1218 |
int i, bot, top; |
int i, bot, top; |
1267 |
r = STRCMP_UC_C8(name, PRIV(utt_names) + PRIV(utt)[i].name_offset); |
r = STRCMP_UC_C8(name, PRIV(utt_names) + PRIV(utt)[i].name_offset); |
1268 |
if (r == 0) |
if (r == 0) |
1269 |
{ |
{ |
1270 |
*dptr = PRIV(utt)[i].value; |
*ptypeptr = PRIV(utt)[i].type; |
1271 |
return PRIV(utt)[i].type; |
*pdataptr = PRIV(utt)[i].value; |
1272 |
|
return TRUE; |
1273 |
} |
} |
1274 |
if (r > 0) bot = i + 1; else top = i; |
if (r > 0) bot = i + 1; else top = i; |
1275 |
} |
} |
1276 |
|
|
1277 |
*errorcodeptr = ERR47; |
*errorcodeptr = ERR47; |
1278 |
*ptrptr = ptr; |
*ptrptr = ptr; |
1279 |
return -1; |
return FALSE; |
1280 |
|
|
1281 |
ERROR_RETURN: |
ERROR_RETURN: |
1282 |
*errorcodeptr = ERR46; |
*errorcodeptr = ERR46; |
1283 |
*ptrptr = ptr; |
*ptrptr = ptr; |
1284 |
return -1; |
return FALSE; |
1285 |
} |
} |
1286 |
#endif |
#endif |
1287 |
|
|
1914 |
|
|
1915 |
/* Check a class for variable quantification */ |
/* Check a class for variable quantification */ |
1916 |
|
|
|
#if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32 |
|
|
case OP_XCLASS: |
|
|
cc += GET(cc, 1) - PRIV(OP_lengths)[OP_CLASS]; |
|
|
/* Fall through */ |
|
|
#endif |
|
|
|
|
1917 |
case OP_CLASS: |
case OP_CLASS: |
1918 |
case OP_NCLASS: |
case OP_NCLASS: |
1919 |
|
#if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32 |
1920 |
|
case OP_XCLASS: |
1921 |
|
/* The original code caused an unsigned overflow in 64 bit systems, |
1922 |
|
so now we use a conditional statement. */ |
1923 |
|
if (op == OP_XCLASS) |
1924 |
|
cc += GET(cc, 1); |
1925 |
|
else |
1926 |
|
cc += PRIV(OP_lengths)[OP_CLASS]; |
1927 |
|
#else |
1928 |
cc += PRIV(OP_lengths)[OP_CLASS]; |
cc += PRIV(OP_lengths)[OP_CLASS]; |
1929 |
|
#endif |
1930 |
|
|
1931 |
switch (*cc) |
switch (*cc) |
1932 |
{ |
{ |
2922 |
pcre_uint32 *odptr) |
pcre_uint32 *odptr) |
2923 |
{ |
{ |
2924 |
pcre_uint32 c, othercase, next; |
pcre_uint32 c, othercase, next; |
2925 |
int co; |
unsigned int co; |
2926 |
|
|
2927 |
/* Find the first character that has an other case. If it has multiple other |
/* Find the first character that has an other case. If it has multiple other |
2928 |
cases, return its case offset value. */ |
cases, return its case offset value. */ |
2933 |
{ |
{ |
2934 |
*ocptr = c++; /* Character that has the set */ |
*ocptr = c++; /* Character that has the set */ |
2935 |
*cptr = c; /* Rest of input range */ |
*cptr = c; /* Rest of input range */ |
2936 |
return co; |
return (int)co; |
2937 |
} |
} |
2938 |
if ((othercase = UCD_OTHERCASE(c)) != c) break; |
if ((othercase = UCD_OTHERCASE(c)) != c) break; |
2939 |
} |
} |
2973 |
*/ |
*/ |
2974 |
|
|
2975 |
static BOOL |
static BOOL |
2976 |
check_char_prop(pcre_uint32 c, int ptype, int pdata, BOOL negated) |
check_char_prop(pcre_uint32 c, unsigned int ptype, unsigned int pdata, BOOL negated) |
2977 |
{ |
{ |
2978 |
#ifdef SUPPORT_UCP |
#ifdef SUPPORT_UCP |
2979 |
const pcre_uint32 *p; |
const pcre_uint32 *p; |
3159 |
#ifdef SUPPORT_UCP |
#ifdef SUPPORT_UCP |
3160 |
if (utf && c != NOTACHAR && (options & PCRE_CASELESS) != 0) |
if (utf && c != NOTACHAR && (options & PCRE_CASELESS) != 0) |
3161 |
{ |
{ |
3162 |
int ocs = UCD_CASESET(next); |
unsigned int ocs = UCD_CASESET(next); |
3163 |
if (ocs > 0) return check_char_prop(c, PT_CLIST, ocs, op_code >= OP_NOT); |
if (ocs > 0) return check_char_prop(c, PT_CLIST, ocs, op_code >= OP_NOT); |
3164 |
} |
} |
3165 |
#endif |
#endif |
3259 |
|
|
3260 |
#ifdef SUPPORT_UCP |
#ifdef SUPPORT_UCP |
3261 |
case OP_PROP: |
case OP_PROP: |
3262 |
return check_char_prop(next, (int)previous[0], (int)previous[1], FALSE); |
return check_char_prop(next, previous[0], previous[1], FALSE); |
3263 |
|
|
3264 |
case OP_NOTPROP: |
case OP_NOTPROP: |
3265 |
return check_char_prop(next, (int)previous[0], (int)previous[1], TRUE); |
return check_char_prop(next, previous[0], previous[1], TRUE); |
3266 |
#endif |
#endif |
3267 |
|
|
3268 |
default: |
default: |
3345 |
case ESC_p: |
case ESC_p: |
3346 |
case ESC_P: |
case ESC_P: |
3347 |
{ |
{ |
3348 |
int ptype, pdata, errorcodeptr; |
unsigned int ptype = 0, pdata = 0; |
3349 |
|
int errorcodeptr; |
3350 |
BOOL negated; |
BOOL negated; |
3351 |
|
|
3352 |
ptr--; /* Make ptr point at the p or P */ |
ptr--; /* Make ptr point at the p or P */ |
3353 |
ptype = get_ucp(&ptr, &negated, &pdata, &errorcodeptr); |
if (!get_ucp(&ptr, &negated, &ptype, &pdata, &errorcodeptr)) |
3354 |
if (ptype < 0) return FALSE; |
return FALSE; |
3355 |
ptr++; /* Point past the final curly ket */ |
ptr++; /* Point past the final curly ket */ |
3356 |
|
|
3357 |
/* If the property item is optional, we have to give up. (When generated |
/* If the property item is optional, we have to give up. (When generated |
3799 |
pcre_uint32 subreqchar, subfirstchar; |
pcre_uint32 subreqchar, subfirstchar; |
3800 |
pcre_int32 subreqcharflags, subfirstcharflags; |
pcre_int32 subreqcharflags, subfirstcharflags; |
3801 |
int terminator; |
int terminator; |
3802 |
int mclength; |
unsigned int mclength; |
3803 |
int tempbracount; |
unsigned int tempbracount; |
3804 |
pcre_uint32 ec; |
pcre_uint32 ec; |
3805 |
pcre_uchar mcbuffer[8]; |
pcre_uchar mcbuffer[8]; |
3806 |
|
|
4383 |
case ESC_P: |
case ESC_P: |
4384 |
{ |
{ |
4385 |
BOOL negated; |
BOOL negated; |
4386 |
int pdata; |
unsigned int ptype = 0, pdata = 0; |
4387 |
int ptype = get_ucp(&ptr, &negated, &pdata, errorcodeptr); |
if (!get_ucp(&ptr, &negated, &ptype, &pdata, errorcodeptr)) |
4388 |
if (ptype < 0) goto FAILED; |
goto FAILED; |
4389 |
*class_uchardata++ = ((escape == ESC_p) != negated)? |
*class_uchardata++ = ((escape == ESC_p) != negated)? |
4390 |
XCL_PROP : XCL_NOTPROP; |
XCL_PROP : XCL_NOTPROP; |
4391 |
*class_uchardata++ = ptype; |
*class_uchardata++ = ptype; |
5826 |
} |
} |
5827 |
namelen = (int)(ptr - name); |
namelen = (int)(ptr - name); |
5828 |
|
|
5829 |
if ((terminator > 0 && *ptr++ != terminator) || |
if ((terminator > 0 && *ptr++ != (pcre_uchar)terminator) || |
5830 |
*ptr++ != CHAR_RIGHT_PARENTHESIS) |
*ptr++ != CHAR_RIGHT_PARENTHESIS) |
5831 |
{ |
{ |
5832 |
ptr--; /* Error offset */ |
ptr--; /* Error offset */ |
6066 |
|
|
6067 |
if (lengthptr != NULL) |
if (lengthptr != NULL) |
6068 |
{ |
{ |
6069 |
if (*ptr != terminator) |
if (*ptr != (pcre_uchar)terminator) |
6070 |
{ |
{ |
6071 |
*errorcodeptr = ERR42; |
*errorcodeptr = ERR42; |
6072 |
goto FAILED; |
goto FAILED; |
6208 |
*errorcodeptr = ERR62; |
*errorcodeptr = ERR62; |
6209 |
goto FAILED; |
goto FAILED; |
6210 |
} |
} |
6211 |
if (*ptr != terminator) |
if (*ptr != (pcre_uchar)terminator) |
6212 |
{ |
{ |
6213 |
*errorcodeptr = ERR42; |
*errorcodeptr = ERR42; |
6214 |
goto FAILED; |
goto FAILED; |
6314 |
while(IS_DIGIT(*ptr)) |
while(IS_DIGIT(*ptr)) |
6315 |
recno = recno * 10 + *ptr++ - CHAR_0; |
recno = recno * 10 + *ptr++ - CHAR_0; |
6316 |
|
|
6317 |
if (*ptr != terminator) |
if (*ptr != (pcre_uchar)terminator) |
6318 |
{ |
{ |
6319 |
*errorcodeptr = ERR29; |
*errorcodeptr = ERR29; |
6320 |
goto FAILED; |
goto FAILED; |
6794 |
if (ptr[1] != CHAR_PLUS && ptr[1] != CHAR_MINUS) |
if (ptr[1] != CHAR_PLUS && ptr[1] != CHAR_MINUS) |
6795 |
{ |
{ |
6796 |
BOOL is_a_number = TRUE; |
BOOL is_a_number = TRUE; |
6797 |
for (p = ptr + 1; *p != 0 && *p != terminator; p++) |
for (p = ptr + 1; *p != 0 && *p != (pcre_uchar)terminator; p++) |
6798 |
{ |
{ |
6799 |
if (!MAX_255(*p)) { is_a_number = FALSE; break; } |
if (!MAX_255(*p)) { is_a_number = FALSE; break; } |
6800 |
if ((cd->ctypes[*p] & ctype_digit) == 0) is_a_number = FALSE; |
if ((cd->ctypes[*p] & ctype_digit) == 0) is_a_number = FALSE; |
6801 |
if ((cd->ctypes[*p] & ctype_word) == 0) break; |
if ((cd->ctypes[*p] & ctype_word) == 0) break; |
6802 |
} |
} |
6803 |
if (*p != terminator) |
if (*p != (pcre_uchar)terminator) |
6804 |
{ |
{ |
6805 |
*errorcodeptr = ERR57; |
*errorcodeptr = ERR57; |
6806 |
break; |
break; |
6818 |
|
|
6819 |
p = ptr + 2; |
p = ptr + 2; |
6820 |
while (IS_DIGIT(*p)) p++; |
while (IS_DIGIT(*p)) p++; |
6821 |
if (*p != terminator) |
if (*p != (pcre_uchar)terminator) |
6822 |
{ |
{ |
6823 |
*errorcodeptr = ERR57; |
*errorcodeptr = ERR57; |
6824 |
break; |
break; |
6882 |
else if (escape == ESC_P || escape == ESC_p) |
else if (escape == ESC_P || escape == ESC_p) |
6883 |
{ |
{ |
6884 |
BOOL negated; |
BOOL negated; |
6885 |
int pdata; |
unsigned int ptype = 0, pdata = 0; |
6886 |
int ptype = get_ucp(&ptr, &negated, &pdata, errorcodeptr); |
if (!get_ucp(&ptr, &negated, &ptype, &pdata, errorcodeptr)) |
6887 |
if (ptype < 0) goto FAILED; |
goto FAILED; |
6888 |
previous = code; |
previous = code; |
6889 |
*code++ = ((escape == ESC_p) != negated)? OP_PROP : OP_NOTPROP; |
*code++ = ((escape == ESC_p) != negated)? OP_PROP : OP_NOTPROP; |
6890 |
*code++ = ptype; |
*code++ = ptype; |
7111 |
pcre_uint32 branchfirstchar, branchreqchar; |
pcre_uint32 branchfirstchar, branchreqchar; |
7112 |
pcre_int32 branchfirstcharflags, branchreqcharflags; |
pcre_int32 branchfirstcharflags, branchreqcharflags; |
7113 |
int length; |
int length; |
7114 |
int orig_bracount; |
unsigned int orig_bracount; |
7115 |
int max_bracount; |
unsigned int max_bracount; |
7116 |
branch_chain bc; |
branch_chain bc; |
7117 |
|
|
7118 |
bc.outer = bcptr; |
bc.outer = bcptr; |
8129 |
if (code - codestart > length) errorcode = ERR23; |
if (code - codestart > length) errorcode = ERR23; |
8130 |
#endif |
#endif |
8131 |
|
|
8132 |
|
#ifdef SUPPORT_VALGRIND |
8133 |
|
/* If the estimated length exceeds the really used length, mark the extra |
8134 |
|
allocated memory as unadressable, so that any out-of-bound reads can be |
8135 |
|
detected. */ |
8136 |
|
VALGRIND_MAKE_MEM_NOACCESS(code, (length - (code - codestart)) * sizeof(pcre_uchar)); |
8137 |
|
#endif |
8138 |
|
|
8139 |
/* Fill in any forward references that are required. There may be repeated |
/* Fill in any forward references that are required. There may be repeated |
8140 |
references; optimize for them, as searching a large regex takes time. */ |
references; optimize for them, as searching a large regex takes time. */ |
8141 |
|
|