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-2006 University of Cambridge |
Copyright (c) 1997-2007 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 |
1246 |
else |
else |
1247 |
{ |
{ |
1248 |
code += _pcre_OP_lengths[c]; |
code += _pcre_OP_lengths[c]; |
1249 |
|
#ifdef SUPPORT_UTF8 |
1250 |
if (utf8) switch(c) |
if (utf8) switch(c) |
1251 |
{ |
{ |
1252 |
case OP_CHAR: |
case OP_CHAR: |
1267 |
if (code[-1] >= 0xc0) code += _pcre_utf8_table4[code[-1] & 0x3f]; |
if (code[-1] >= 0xc0) code += _pcre_utf8_table4[code[-1] & 0x3f]; |
1268 |
break; |
break; |
1269 |
} |
} |
1270 |
|
#endif |
1271 |
} |
} |
1272 |
} |
} |
1273 |
} |
} |
1311 |
else |
else |
1312 |
{ |
{ |
1313 |
code += _pcre_OP_lengths[c]; |
code += _pcre_OP_lengths[c]; |
1314 |
|
#ifdef SUPPORT_UTF8 |
1315 |
if (utf8) switch(c) |
if (utf8) switch(c) |
1316 |
{ |
{ |
1317 |
case OP_CHAR: |
case OP_CHAR: |
1332 |
if (code[-1] >= 0xc0) code += _pcre_utf8_table4[code[-1] & 0x3f]; |
if (code[-1] >= 0xc0) code += _pcre_utf8_table4[code[-1] & 0x3f]; |
1333 |
break; |
break; |
1334 |
} |
} |
1335 |
|
#endif |
1336 |
} |
} |
1337 |
} |
} |
1338 |
} |
} |
5043 |
with errorptr and erroroffset set |
with errorptr and erroroffset set |
5044 |
*/ |
*/ |
5045 |
|
|
5046 |
PCRE_DATA_SCOPE pcre * |
PCRE_EXP_DEFN pcre * |
5047 |
pcre_compile(const char *pattern, int options, const char **errorptr, |
pcre_compile(const char *pattern, int options, const char **errorptr, |
5048 |
int *erroroffset, const unsigned char *tables) |
int *erroroffset, const unsigned char *tables) |
5049 |
{ |
{ |
5051 |
} |
} |
5052 |
|
|
5053 |
|
|
5054 |
PCRE_DATA_SCOPE pcre * |
PCRE_EXP_DEFN pcre * |
5055 |
pcre_compile2(const char *pattern, int options, int *errorcodeptr, |
pcre_compile2(const char *pattern, int options, int *errorcodeptr, |
5056 |
const char **errorptr, int *erroroffset, const unsigned char *tables) |
const char **errorptr, int *erroroffset, const unsigned char *tables) |
5057 |
{ |
{ |
5100 |
if (erroroffset == NULL) |
if (erroroffset == NULL) |
5101 |
{ |
{ |
5102 |
errorcode = ERR16; |
errorcode = ERR16; |
5103 |
goto PCRE_EARLY_ERROR_RETURN; |
goto PCRE_EARLY_ERROR_RETURN2; |
5104 |
} |
} |
5105 |
|
|
5106 |
*erroroffset = 0; |
*erroroffset = 0; |
5113 |
(*erroroffset = _pcre_valid_utf8((uschar *)pattern, -1)) >= 0) |
(*erroroffset = _pcre_valid_utf8((uschar *)pattern, -1)) >= 0) |
5114 |
{ |
{ |
5115 |
errorcode = ERR44; |
errorcode = ERR44; |
5116 |
goto PCRE_UTF8_ERROR_RETURN; |
goto PCRE_EARLY_ERROR_RETURN2; |
5117 |
} |
} |
5118 |
#else |
#else |
5119 |
if ((options & PCRE_UTF8) != 0) |
if ((options & PCRE_UTF8) != 0) |
5138 |
cd->ctypes = tables + ctypes_offset; |
cd->ctypes = tables + ctypes_offset; |
5139 |
|
|
5140 |
/* Handle different types of newline. The three bits give seven cases. The |
/* Handle different types of newline. The three bits give seven cases. The |
5141 |
current code allows for fixed one- or two-byte sequences, plus "any". */ |
current code allows for fixed one- or two-byte sequences, plus "any" and |
5142 |
|
"anycrlf". */ |
5143 |
|
|
5144 |
switch (options & (PCRE_NEWLINE_CRLF | PCRE_NEWLINE_ANY)) |
switch (options & (PCRE_NEWLINE_CRLF | PCRE_NEWLINE_ANY)) |
5145 |
{ |
{ |
5149 |
case PCRE_NEWLINE_CR+ |
case PCRE_NEWLINE_CR+ |
5150 |
PCRE_NEWLINE_LF: newline = ('\r' << 8) | '\n'; break; |
PCRE_NEWLINE_LF: newline = ('\r' << 8) | '\n'; break; |
5151 |
case PCRE_NEWLINE_ANY: newline = -1; break; |
case PCRE_NEWLINE_ANY: newline = -1; break; |
5152 |
|
case PCRE_NEWLINE_ANYCRLF: newline = -2; break; |
5153 |
default: errorcode = ERR56; goto PCRE_EARLY_ERROR_RETURN; |
default: errorcode = ERR56; goto PCRE_EARLY_ERROR_RETURN; |
5154 |
} |
} |
5155 |
|
|
5156 |
if (newline < 0) |
if (newline == -2) |
5157 |
|
{ |
5158 |
|
cd->nltype = NLTYPE_ANYCRLF; |
5159 |
|
} |
5160 |
|
else if (newline < 0) |
5161 |
{ |
{ |
5162 |
cd->nltype = NLTYPE_ANY; |
cd->nltype = NLTYPE_ANY; |
5163 |
} |
} |
5331 |
(pcre_free)(re); |
(pcre_free)(re); |
5332 |
PCRE_EARLY_ERROR_RETURN: |
PCRE_EARLY_ERROR_RETURN: |
5333 |
*erroroffset = ptr - (const uschar *)pattern; |
*erroroffset = ptr - (const uschar *)pattern; |
5334 |
#ifdef SUPPORT_UTF8 |
PCRE_EARLY_ERROR_RETURN2: |
|
PCRE_UTF8_ERROR_RETURN: |
|
|
#endif |
|
5335 |
*errorptr = error_texts[errorcode]; |
*errorptr = error_texts[errorcode]; |
5336 |
if (errorcodeptr != NULL) *errorcodeptr = errorcode; |
if (errorcodeptr != NULL) *errorcodeptr = errorcode; |
5337 |
return NULL; |
return NULL; |
5421 |
else printf("Req char = \\x%02x%s\n", ch, caseless); |
else printf("Req char = \\x%02x%s\n", ch, caseless); |
5422 |
} |
} |
5423 |
|
|
5424 |
pcre_printint(re, stdout); |
pcre_printint(re, stdout, TRUE); |
5425 |
|
|
5426 |
/* This check is done here in the debugging case so that the code that |
/* This check is done here in the debugging case so that the code that |
5427 |
was compiled can be seen. */ |
was compiled can be seen. */ |