summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/pcre/pcre_exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/pcre/pcre_exec.c')
-rw-r--r--src/3rdparty/pcre/pcre_exec.c1203
1 files changed, 646 insertions, 557 deletions
diff --git a/src/3rdparty/pcre/pcre_exec.c b/src/3rdparty/pcre/pcre_exec.c
index 2905808c83..c888468a25 100644
--- a/src/3rdparty/pcre/pcre_exec.c
+++ b/src/3rdparty/pcre/pcre_exec.c
@@ -37,7 +37,6 @@ POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
-
/* This module contains pcre_exec(), the externally visible function that does
pattern matching using an NFA algorithm, trying to mimic Perl as closely as
possible. There are also some static supporting functions. */
@@ -93,8 +92,6 @@ because the offset vector is always a multiple of 3 long. */
static const char rep_min[] = { 0, 0, 1, 1, 0, 0 };
static const char rep_max[] = { 0, 0, 0, 0, 1, 1 };
-
-
#ifdef PCRE_DEBUG
/*************************************************
* Debugging function to print chars *
@@ -115,10 +112,11 @@ Returns: nothing
static void
pchars(const pcre_uchar *p, int length, BOOL is_subject, match_data *md)
{
-unsigned int c;
+pcre_uint32 c;
+BOOL utf = md->utf;
if (is_subject && length > md->end_subject - p) length = md->end_subject - p;
while (length-- > 0)
- if (isprint(c = *(p++))) printf("%c", c); else printf("\\x%02x", c);
+ if (isprint(c = RAWUCHARINCTEST(p))) printf("%c", (char)c); else printf("\\x{%02x}", c);
}
#endif
@@ -140,7 +138,9 @@ Arguments:
md points to match data block
caseless TRUE if caseless
-Returns: < 0 if not matched, otherwise the number of subject bytes matched
+Returns: >= 0 the number of subject bytes matched
+ -1 no match
+ -2 partial match; always given if at end subject
*/
static int
@@ -149,6 +149,9 @@ match_ref(int offset, register PCRE_PUCHAR eptr, int length, match_data *md,
{
PCRE_PUCHAR eptr_start = eptr;
register PCRE_PUCHAR p = md->start_subject + md->offset_vector[offset];
+#ifdef SUPPORT_UTF
+BOOL utf = md->utf;
+#endif
#ifdef PCRE_DEBUG
if (eptr >= md->end_subject)
@@ -163,7 +166,8 @@ pchars(p, length, FALSE, md);
printf("\n");
#endif
-/* Always fail if reference not set (and not JavaScript compatible). */
+/* Always fail if reference not set (and not JavaScript compatible - in that
+case the length is passed as zero). */
if (length < 0) return -1;
@@ -175,24 +179,35 @@ if (caseless)
{
#ifdef SUPPORT_UTF
#ifdef SUPPORT_UCP
- if (md->utf)
+ if (utf)
{
/* Match characters up to the end of the reference. NOTE: the number of
- bytes matched may differ, because there are some characters whose upper and
- lower case versions code as different numbers of bytes. For example, U+023A
- (2 bytes in UTF-8) is the upper case version of U+2C65 (3 bytes in UTF-8);
- a sequence of 3 of the former uses 6 bytes, as does a sequence of two of
- the latter. It is important, therefore, to check the length along the
- reference, not along the subject (earlier code did this wrong). */
+ data units matched may differ, because in UTF-8 there are some characters
+ whose upper and lower case versions code have different numbers of bytes.
+ For example, U+023A (2 bytes in UTF-8) is the upper case version of U+2C65
+ (3 bytes in UTF-8); a sequence of 3 of the former uses 6 bytes, as does a
+ sequence of two of the latter. It is important, therefore, to check the
+ length along the reference, not along the subject (earlier code did this
+ wrong). */
PCRE_PUCHAR endptr = p + length;
while (p < endptr)
{
- int c, d;
- if (eptr >= md->end_subject) return -1;
+ pcre_uint32 c, d;
+ const ucd_record *ur;
+ if (eptr >= md->end_subject) return -2; /* Partial match */
GETCHARINC(c, eptr);
GETCHARINC(d, p);
- if (c != d && c != UCD_OTHERCASE(d)) return -1;
+ ur = GET_UCD(d);
+ if (c != d && c != d + ur->other_case)
+ {
+ const pcre_uint32 *pp = PRIV(ucd_caseless_sets) + ur->caseset;
+ for (;;)
+ {
+ if (c < *pp) return -1;
+ if (c == *pp++) break;
+ }
+ }
}
}
else
@@ -202,10 +217,13 @@ if (caseless)
/* The same code works when not in UTF-8 mode and in UTF-8 mode when there
is no UCP support. */
{
- if (eptr + length > md->end_subject) return -1;
while (length-- > 0)
{
- if (TABLE_GET(*p, md->lcc, *p) != TABLE_GET(*eptr, md->lcc, *eptr)) return -1;
+ pcre_uchar cc, cp;
+ if (eptr >= md->end_subject) return -2; /* Partial match */
+ cc = RAWUCHARTEST(eptr);
+ cp = RAWUCHARTEST(p);
+ if (TABLE_GET(cp, md->lcc, cp) != TABLE_GET(cc, md->lcc, cc)) return -1;
p++;
eptr++;
}
@@ -217,8 +235,11 @@ are in UTF-8 mode. */
else
{
- if (eptr + length > md->end_subject) return -1;
- while (length-- > 0) if (*p++ != *eptr++) return -1;
+ while (length-- > 0)
+ {
+ if (eptr >= md->end_subject) return -2; /* Partial match */
+ if (RAWUCHARINCTEST(p) != RAWUCHARINCTEST(eptr)) return -1;
+ }
}
return (int)(eptr - eptr_start);
@@ -273,7 +294,7 @@ enum { RM1=1, RM2, RM3, RM4, RM5, RM6, RM7, RM8, RM9, RM10,
RM31, RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40,
RM41, RM42, RM43, RM44, RM45, RM46, RM47, RM48, RM49, RM50,
RM51, RM52, RM53, RM54, RM55, RM56, RM57, RM58, RM59, RM60,
- RM61, RM62, RM63, RM64, RM65, RM66 };
+ RM61, RM62, RM63, RM64, RM65, RM66, RM67 };
/* These versions of the macros use the stack, as normal. There are debugging
versions and production versions. Note that the "rw" argument of RMATCH isn't
@@ -291,7 +312,7 @@ actually used in this definition. */
}
#define RRETURN(ra) \
{ \
- printf("match() returned %d from line %d ", ra, __LINE__); \
+ printf("match() returned %d from line %d\n", ra, __LINE__); \
return ra; \
}
#else
@@ -311,9 +332,15 @@ argument of match(), which never changes. */
#define RMATCH(ra,rb,rc,rd,re,rw)\
{\
- heapframe *newframe = (heapframe *)(PUBL(stack_malloc))(sizeof(heapframe));\
- if (newframe == NULL) RRETURN(PCRE_ERROR_NOMEMORY);\
- frame->Xwhere = rw; \
+ heapframe *newframe = frame->Xnextframe;\
+ if (newframe == NULL)\
+ {\
+ newframe = (heapframe *)(PUBL(stack_malloc))(sizeof(heapframe));\
+ if (newframe == NULL) RRETURN(PCRE_ERROR_NOMEMORY);\
+ newframe->Xnextframe = NULL;\
+ frame->Xnextframe = newframe;\
+ }\
+ frame->Xwhere = rw;\
newframe->Xeptr = ra;\
newframe->Xecode = rb;\
newframe->Xmstart = mstart;\
@@ -332,7 +359,6 @@ argument of match(), which never changes. */
{\
heapframe *oldframe = frame;\
frame = oldframe->Xprevframe;\
- if (oldframe != &frame_zero) (PUBL(stack_free))(oldframe);\
if (frame != NULL)\
{\
rrc = ra;\
@@ -346,6 +372,7 @@ argument of match(), which never changes. */
typedef struct heapframe {
struct heapframe *Xprevframe;
+ struct heapframe *Xnextframe;
/* Function arguments that may change */
@@ -376,7 +403,7 @@ typedef struct heapframe {
#ifdef SUPPORT_UCP
int Xprop_type;
- int Xprop_value;
+ unsigned int Xprop_value;
int Xprop_fail_result;
int Xoclength;
pcre_uchar Xocchars[6];
@@ -477,7 +504,7 @@ so they can be ordinary variables in all cases. Mark some of them with
register int rrc; /* Returns from recursive calls */
register int i; /* Used for loops not involving calls to RMATCH() */
-register unsigned int c; /* Character values not kept over RMATCH() calls */
+register pcre_uint32 c; /* Character values not kept over RMATCH() calls */
register BOOL utf; /* Local copy of UTF flag for speed */
BOOL minimize, possessive; /* Quantifier options */
@@ -492,9 +519,7 @@ the top-level on the stack rather than malloc-ing them all gives a performance
boost in many cases where there is not much "recursion". */
#ifdef NO_RECURSE
-heapframe frame_zero;
-heapframe *frame = &frame_zero;
-frame->Xprevframe = NULL; /* Marks the top level */
+heapframe *frame = (heapframe *)md->match_frames_base;
/* Copy in the original argument variables */
@@ -596,7 +621,7 @@ BOOL prev_is_word;
#ifdef SUPPORT_UCP
int prop_type;
-int prop_value;
+unsigned int prop_value;
int prop_fail_result;
int oclength;
pcre_uchar occhars[6];
@@ -607,9 +632,9 @@ int ctype;
int length;
int max;
int min;
-int number;
+unsigned int number;
int offset;
-int op;
+pcre_uchar op;
int save_capture_last;
int save_offset1, save_offset2, save_offset3;
int stacksave[REC_STACK_SAVE_MAX];
@@ -728,7 +753,7 @@ for (;;)
unaltered. */
else if (rrc == MATCH_SKIP_ARG &&
- STRCMP_UC_UC(ecode + 2, md->start_match_ptr) == 0)
+ STRCMP_UC_UC_TEST(ecode + 2, md->start_match_ptr) == 0)
{
md->start_match_ptr = eptr;
RRETURN(MATCH_SKIP);
@@ -897,7 +922,6 @@ for (;;)
}
else /* OP_KETRMAX */
{
- md->match_function_type = MATCH_CBEGROUP;
RMATCH(eptr, prev, offset_top, md, eptrb, RM66);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
ecode += 1 + LINK_SIZE;
@@ -1026,7 +1050,8 @@ for (;;)
for (;;)
{
- if (op >= OP_SBRA || op == OP_ONCE) md->match_function_type = MATCH_CBEGROUP;
+ if (op >= OP_SBRA || op == OP_ONCE)
+ md->match_function_type = MATCH_CBEGROUP;
/* If this is not a possibly empty group, and there are no (*THEN)s in
the pattern, and this is the final alternative, optimize as described
@@ -1253,10 +1278,12 @@ for (;;)
cb.version = 2; /* Version 1 of the callout block */
cb.callout_number = ecode[LINK_SIZE+2];
cb.offset_vector = md->offset_vector;
-#ifdef COMPILE_PCRE8
+#if defined COMPILE_PCRE8
cb.subject = (PCRE_SPTR)md->start_subject;
-#else
+#elif defined COMPILE_PCRE16
cb.subject = (PCRE_SPTR16)md->start_subject;
+#elif defined COMPILE_PCRE32
+ cb.subject = (PCRE_SPTR32)md->start_subject;
#endif
cb.subject_length = (int)(md->end_subject - md->start_subject);
cb.start_match = (int)(mstart - md->start_subject);
@@ -1286,7 +1313,7 @@ for (;;)
}
else
{
- int recno = GET2(ecode, LINK_SIZE + 2); /* Recursion group number*/
+ unsigned int recno = GET2(ecode, LINK_SIZE + 2); /* Recursion group number*/
condition = (recno == RREF_ANY || recno == md->recursive->group_num);
/* If the test is for recursion into a specific subpattern, and it is
@@ -1358,7 +1385,7 @@ for (;;)
if (!condition && condcode == OP_NCREF)
{
- int refno = offset >> 1;
+ unsigned int refno = offset >> 1;
pcre_uchar *slotA = md->name_table;
for (i = 0; i < md->name_count; i++)
@@ -1565,13 +1592,18 @@ for (;;)
mstart = md->start_match_ptr; /* In case \K reset it */
break;
}
+ md->mark = save_mark;
- /* PCRE does not allow THEN to escape beyond an assertion; it is treated
- as NOMATCH. */
+ /* A COMMIT failure must fail the entire assertion, without trying any
+ subsequent branches. */
+
+ if (rrc == MATCH_COMMIT) RRETURN(MATCH_NOMATCH);
+
+ /* PCRE does not allow THEN to escape beyond an assertion; it
+ is treated as NOMATCH. */
if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
ecode += GET(ecode, 1);
- md->mark = save_mark;
}
while (*ecode == OP_ALT);
@@ -1671,10 +1703,12 @@ for (;;)
cb.version = 2; /* Version 1 of the callout block */
cb.callout_number = ecode[1];
cb.offset_vector = md->offset_vector;
-#ifdef COMPILE_PCRE8
+#if defined COMPILE_PCRE8
cb.subject = (PCRE_SPTR)md->start_subject;
-#else
+#elif defined COMPILE_PCRE16
cb.subject = (PCRE_SPTR16)md->start_subject;
+#elif defined COMPILE_PCRE32
+ cb.subject = (PCRE_SPTR32)md->start_subject;
#endif
cb.subject_length = (int)(md->end_subject - md->start_subject);
cb.start_match = (int)(mstart - md->start_subject);
@@ -1711,7 +1745,7 @@ for (;;)
case OP_RECURSE:
{
recursion_info *ri;
- int recno;
+ unsigned int recno;
callpat = md->start_code + GET(ecode, 1);
recno = (callpat == md->start_code)? 0 :
@@ -1779,10 +1813,11 @@ for (;;)
goto RECURSION_MATCHED; /* Exit loop; end processing */
}
- /* PCRE does not allow THEN to escape beyond a recursion; it is treated
- as NOMATCH. */
+ /* PCRE does not allow THEN or COMMIT to escape beyond a recursion; it
+ is treated as NOMATCH. */
- else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)
+ else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN &&
+ rrc != MATCH_COMMIT)
{
DPRINTF(("Recursion gave error %d\n", rrc));
if (new_recursive.offset_save != stacksave)
@@ -1993,7 +2028,6 @@ for (;;)
}
if (*prev >= OP_SBRA) /* Could match an empty string */
{
- md->match_function_type = MATCH_CBEGROUP;
RMATCH(eptr, prev, offset_top, md, eptrb, RM50);
RRETURN(rrc);
}
@@ -2002,7 +2036,6 @@ for (;;)
}
else /* OP_KETRMAX */
{
- if (*prev >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
RMATCH(eptr, prev, offset_top, md, eptrb, RM13);
if (rrc == MATCH_ONCE && md->once_target == prev) rrc = MATCH_NOMATCH;
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
@@ -2059,7 +2092,21 @@ for (;;)
case OP_DOLLM:
if (eptr < md->end_subject)
- { if (!IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); }
+ {
+ if (!IS_NEWLINE(eptr))
+ {
+ if (md->partial != 0 &&
+ eptr + 1 >= md->end_subject &&
+ NLBLOCK->nltype == NLTYPE_FIXED &&
+ NLBLOCK->nllen == 2 &&
+ RAWUCHARTEST(eptr) == NLBLOCK->nl[0])
+ {
+ md->hitend = TRUE;
+ if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
+ }
+ RRETURN(MATCH_NOMATCH);
+ }
+ }
else
{
if (md->noteol) RRETURN(MATCH_NOMATCH);
@@ -2091,7 +2138,18 @@ for (;;)
ASSERT_NL_OR_EOS:
if (eptr < md->end_subject &&
(!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen))
+ {
+ if (md->partial != 0 &&
+ eptr + 1 >= md->end_subject &&
+ NLBLOCK->nltype == NLTYPE_FIXED &&
+ NLBLOCK->nllen == 2 &&
+ RAWUCHARTEST(eptr) == NLBLOCK->nl[0])
+ {
+ md->hitend = TRUE;
+ if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
+ }
RRETURN(MATCH_NOMATCH);
+ }
/* Either at end of string or \n before end. */
@@ -2219,12 +2277,25 @@ for (;;)
}
break;
- /* Match a single character type; inline for speed */
+ /* Match any single character type except newline; have to take care with
+ CRLF newlines and partial matching. */
case OP_ANY:
if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
+ if (md->partial != 0 &&
+ eptr + 1 >= md->end_subject &&
+ NLBLOCK->nltype == NLTYPE_FIXED &&
+ NLBLOCK->nllen == 2 &&
+ RAWUCHARTEST(eptr) == NLBLOCK->nl[0])
+ {
+ md->hitend = TRUE;
+ if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
+ }
+
/* Fall through */
+ /* Match any single character whatsoever. */
+
case OP_ALLANY:
if (eptr >= md->end_subject) /* DO NOT merge the eptr++ here; it must */
{ /* not be updated before SCHECK_PARTIAL. */
@@ -2364,18 +2435,24 @@ for (;;)
{
default: RRETURN(MATCH_NOMATCH);
- case 0x000d:
- if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
+ case CHAR_CR:
+ if (eptr >= md->end_subject)
+ {
+ SCHECK_PARTIAL();
+ }
+ else if (RAWUCHARTEST(eptr) == CHAR_LF) eptr++;
break;
- case 0x000a:
+ case CHAR_LF:
break;
- case 0x000b:
- case 0x000c:
- case 0x0085:
+ case CHAR_VT:
+ case CHAR_FF:
+ case CHAR_NEL:
+#ifndef EBCDIC
case 0x2028:
case 0x2029:
+#endif /* Not EBCDIC */
if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
break;
}
@@ -2391,27 +2468,8 @@ for (;;)
GETCHARINCTEST(c, eptr);
switch(c)
{
+ HSPACE_CASES: RRETURN(MATCH_NOMATCH); /* Byte and multibyte cases */
default: break;
- case 0x09: /* HT */
- case 0x20: /* SPACE */
- case 0xa0: /* NBSP */
- case 0x1680: /* OGHAM SPACE MARK */
- case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */
- case 0x2000: /* EN QUAD */
- case 0x2001: /* EM QUAD */
- case 0x2002: /* EN SPACE */
- case 0x2003: /* EM SPACE */
- case 0x2004: /* THREE-PER-EM SPACE */
- case 0x2005: /* FOUR-PER-EM SPACE */
- case 0x2006: /* SIX-PER-EM SPACE */
- case 0x2007: /* FIGURE SPACE */
- case 0x2008: /* PUNCTUATION SPACE */
- case 0x2009: /* THIN SPACE */
- case 0x200A: /* HAIR SPACE */
- case 0x202f: /* NARROW NO-BREAK SPACE */
- case 0x205f: /* MEDIUM MATHEMATICAL SPACE */
- case 0x3000: /* IDEOGRAPHIC SPACE */
- RRETURN(MATCH_NOMATCH);
}
ecode++;
break;
@@ -2425,27 +2483,8 @@ for (;;)
GETCHARINCTEST(c, eptr);
switch(c)
{
+ HSPACE_CASES: break; /* Byte and multibyte cases */
default: RRETURN(MATCH_NOMATCH);
- case 0x09: /* HT */
- case 0x20: /* SPACE */
- case 0xa0: /* NBSP */
- case 0x1680: /* OGHAM SPACE MARK */
- case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */
- case 0x2000: /* EN QUAD */
- case 0x2001: /* EM QUAD */
- case 0x2002: /* EN SPACE */
- case 0x2003: /* EM SPACE */
- case 0x2004: /* THREE-PER-EM SPACE */
- case 0x2005: /* FOUR-PER-EM SPACE */
- case 0x2006: /* SIX-PER-EM SPACE */
- case 0x2007: /* FIGURE SPACE */
- case 0x2008: /* PUNCTUATION SPACE */
- case 0x2009: /* THIN SPACE */
- case 0x200A: /* HAIR SPACE */
- case 0x202f: /* NARROW NO-BREAK SPACE */
- case 0x205f: /* MEDIUM MATHEMATICAL SPACE */
- case 0x3000: /* IDEOGRAPHIC SPACE */
- break;
}
ecode++;
break;
@@ -2459,15 +2498,8 @@ for (;;)
GETCHARINCTEST(c, eptr);
switch(c)
{
+ VSPACE_CASES: RRETURN(MATCH_NOMATCH);
default: break;
- case 0x0a: /* LF */
- case 0x0b: /* VT */
- case 0x0c: /* FF */
- case 0x0d: /* CR */
- case 0x85: /* NEL */
- case 0x2028: /* LINE SEPARATOR */
- case 0x2029: /* PARAGRAPH SEPARATOR */
- RRETURN(MATCH_NOMATCH);
}
ecode++;
break;
@@ -2481,15 +2513,8 @@ for (;;)
GETCHARINCTEST(c, eptr);
switch(c)
{
+ VSPACE_CASES: break;
default: RRETURN(MATCH_NOMATCH);
- case 0x0a: /* LF */
- case 0x0b: /* VT */
- case 0x0c: /* FF */
- case 0x0d: /* CR */
- case 0x85: /* NEL */
- case 0x2028: /* LINE SEPARATOR */
- case 0x2029: /* PARAGRAPH SEPARATOR */
- break;
}
ecode++;
break;
@@ -2507,6 +2532,7 @@ for (;;)
}
GETCHARINCTEST(c, eptr);
{
+ const pcre_uint32 *cp;
const ucd_record *prop = GET_UCD(c);
switch(ecode[1])
@@ -2567,6 +2593,17 @@ for (;;)
RRETURN(MATCH_NOMATCH);
break;
+ case PT_CLIST:
+ cp = PRIV(ucd_caseless_sets) + ecode[2];
+ for (;;)
+ {
+ if (c < *cp)
+ { if (op == OP_PROP) { RRETURN(MATCH_NOMATCH); } else break; }
+ if (c == *cp++)
+ { if (op == OP_PROP) break; else { RRETURN(MATCH_NOMATCH); } }
+ }
+ break;
+
/* This should never occur */
default:
@@ -2586,18 +2623,25 @@ for (;;)
SCHECK_PARTIAL();
RRETURN(MATCH_NOMATCH);
}
- GETCHARINCTEST(c, eptr);
- if (UCD_CATEGORY(c) == ucp_M) RRETURN(MATCH_NOMATCH);
- while (eptr < md->end_subject)
+ else
{
- int len = 1;
- if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
- if (UCD_CATEGORY(c) != ucp_M) break;
- eptr += len;
+ int lgb, rgb;
+ GETCHARINCTEST(c, eptr);
+ lgb = UCD_GRAPHBREAK(c);
+ while (eptr < md->end_subject)
+ {
+ int len = 1;
+ if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
+ rgb = UCD_GRAPHBREAK(c);
+ if ((PRIV(ucp_gbtable)[lgb] & (1 << rgb)) == 0) break;
+ lgb = rgb;
+ eptr += len;
+ }
}
+ CHECK_PARTIAL();
ecode++;
break;
-#endif
+#endif /* SUPPORT_UCP */
/* Match a back reference, possibly repeatedly. Look past the end of the
@@ -2660,6 +2704,7 @@ for (;;)
default: /* No repeat follows */
if ((length = match_ref(offset, eptr, length, md, caseless)) < 0)
{
+ if (length == -2) eptr = md->end_subject; /* Partial match */
CHECK_PARTIAL();
RRETURN(MATCH_NOMATCH);
}
@@ -2685,6 +2730,7 @@ for (;;)
int slength;
if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
{
+ if (slength == -2) eptr = md->end_subject; /* Partial match */
CHECK_PARTIAL();
RRETURN(MATCH_NOMATCH);
}
@@ -2708,6 +2754,7 @@ for (;;)
if (fi >= max) RRETURN(MATCH_NOMATCH);
if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
{
+ if (slength == -2) eptr = md->end_subject; /* Partial match */
CHECK_PARTIAL();
RRETURN(MATCH_NOMATCH);
}
@@ -2726,11 +2773,20 @@ for (;;)
int slength;
if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
{
- CHECK_PARTIAL();
+ /* Can't use CHECK_PARTIAL because we don't want to update eptr in
+ the soft partial matching case. */
+
+ if (slength == -2 && md->partial != 0 &&
+ md->end_subject > md->start_used_ptr)
+ {
+ md->hitend = TRUE;
+ if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
+ }
break;
}
eptr += slength;
}
+
while (eptr >= pp)
{
RMATCH(eptr, ecode, offset_top, md, eptrb, RM15);
@@ -3094,7 +3150,7 @@ for (;;)
CHECK_PARTIAL(); /* Not SCHECK_PARTIAL() */
RRETURN(MATCH_NOMATCH);
}
- while (length-- > 0) if (*ecode++ != *eptr++) RRETURN(MATCH_NOMATCH);
+ while (length-- > 0) if (*ecode++ != RAWUCHARINC(eptr)) RRETURN(MATCH_NOMATCH);
}
else
#endif
@@ -3134,8 +3190,8 @@ for (;;)
if (fc < 128)
{
- if (md->lcc[fc]
- != TABLE_GET(*eptr, md->lcc, *eptr)) RRETURN(MATCH_NOMATCH);
+ pcre_uchar cc = RAWUCHAR(eptr);
+ if (md->lcc[fc] != TABLE_GET(cc, md->lcc, cc)) RRETURN(MATCH_NOMATCH);
ecode++;
eptr++;
}
@@ -3146,7 +3202,7 @@ for (;;)
else
{
- unsigned int dc;
+ pcre_uint32 dc;
GETCHARINC(dc, eptr);
ecode += length;
@@ -3256,7 +3312,7 @@ for (;;)
if (length > 1)
{
#ifdef SUPPORT_UCP
- unsigned int othercase;
+ pcre_uint32 othercase;
if (op >= OP_STARI && /* Caseless */
(othercase = UCD_OTHERCASE(fc)) != fc)
oclength = PRIV(ord2utf)(othercase, occhars);
@@ -3360,7 +3416,7 @@ for (;;)
maximizing, find the maximum number of characters and work backwards. */
DPRINTF(("matching %c{%d,%d} against subject %.*s\n", fc, min, max,
- max, eptr));
+ max, (char *)eptr));
if (op >= OP_STARI) /* Caseless */
{
@@ -3383,12 +3439,15 @@ for (;;)
for (i = 1; i <= min; i++)
{
+ pcre_uchar cc;
+
if (eptr >= md->end_subject)
{
SCHECK_PARTIAL();
RRETURN(MATCH_NOMATCH);
}
- if (fc != *eptr && foc != *eptr) RRETURN(MATCH_NOMATCH);
+ cc = RAWUCHARTEST(eptr);
+ if (fc != cc && foc != cc) RRETURN(MATCH_NOMATCH);
eptr++;
}
if (min == max) continue;
@@ -3396,6 +3455,8 @@ for (;;)
{
for (fi = min;; fi++)
{
+ pcre_uchar cc;
+
RMATCH(eptr, ecode, offset_top, md, eptrb, RM24);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (fi >= max) RRETURN(MATCH_NOMATCH);
@@ -3404,7 +3465,8 @@ for (;;)
SCHECK_PARTIAL();
RRETURN(MATCH_NOMATCH);
}
- if (fc != *eptr && foc != *eptr) RRETURN(MATCH_NOMATCH);
+ cc = RAWUCHARTEST(eptr);
+ if (fc != cc && foc != cc) RRETURN(MATCH_NOMATCH);
eptr++;
}
/* Control never gets here */
@@ -3414,12 +3476,15 @@ for (;;)
pp = eptr;
for (i = min; i < max; i++)
{
+ pcre_uchar cc;
+
if (eptr >= md->end_subject)
{
SCHECK_PARTIAL();
break;
}
- if (fc != *eptr && foc != *eptr) break;
+ cc = RAWUCHARTEST(eptr);
+ if (fc != cc && foc != cc) break;
eptr++;
}
@@ -3447,7 +3512,7 @@ for (;;)
SCHECK_PARTIAL();
RRETURN(MATCH_NOMATCH);
}
- if (fc != *eptr++) RRETURN(MATCH_NOMATCH);
+ if (fc != RAWUCHARINCTEST(eptr)) RRETURN(MATCH_NOMATCH);
}
if (min == max) continue;
@@ -3464,7 +3529,7 @@ for (;;)
SCHECK_PARTIAL();
RRETURN(MATCH_NOMATCH);
}
- if (fc != *eptr++) RRETURN(MATCH_NOMATCH);
+ if (fc != RAWUCHARINCTEST(eptr)) RRETURN(MATCH_NOMATCH);
}
/* Control never gets here */
}
@@ -3478,7 +3543,7 @@ for (;;)
SCHECK_PARTIAL();
break;
}
- if (fc != *eptr) break;
+ if (fc != RAWUCHARTEST(eptr)) break;
eptr++;
}
if (possessive) continue;
@@ -3504,33 +3569,41 @@ for (;;)
SCHECK_PARTIAL();
RRETURN(MATCH_NOMATCH);
}
- ecode++;
- GETCHARINCTEST(c, eptr);
- if (op == OP_NOTI) /* The caseless case */
- {
- register unsigned int ch, och;
- ch = *ecode++;
-#ifdef COMPILE_PCRE8
- /* ch must be < 128 if UTF is enabled. */
- och = md->fcc[ch];
-#else
#ifdef SUPPORT_UTF
+ if (utf)
+ {
+ register pcre_uint32 ch, och;
+
+ ecode++;
+ GETCHARINC(ch, ecode);
+ GETCHARINC(c, eptr);
+
+ if (op == OP_NOT)
+ {
+ if (ch == c) RRETURN(MATCH_NOMATCH);
+ }
+ else
+ {
#ifdef SUPPORT_UCP
- if (utf && ch > 127)
- och = UCD_OTHERCASE(ch);
+ if (ch > 127)
+ och = UCD_OTHERCASE(ch);
#else
- if (utf && ch > 127)
- och = ch;
+ if (ch > 127)
+ och = ch;
#endif /* SUPPORT_UCP */
- else
-#endif /* SUPPORT_UTF */
- och = TABLE_GET(ch, md->fcc, ch);
-#endif /* COMPILE_PCRE8 */
- if (ch == c || och == c) RRETURN(MATCH_NOMATCH);
+ else
+ och = TABLE_GET(ch, md->fcc, ch);
+ if (ch == c || och == c) RRETURN(MATCH_NOMATCH);
+ }
}
- else /* Caseful */
+ else
+#endif
{
- if (*ecode++ == c) RRETURN(MATCH_NOMATCH);
+ register pcre_uint32 ch = ecode[1];
+ c = *eptr++;
+ if (ch == c || (op == OP_NOTI && TABLE_GET(ch, md->fcc, ch) == c))
+ RRETURN(MATCH_NOMATCH);
+ ecode += 2;
}
break;
@@ -3610,7 +3683,7 @@ for (;;)
/* Common code for all repeated single-byte matches. */
REPEATNOTCHAR:
- fc = *ecode++;
+ GETCHARINCTEST(fc, ecode);
/* The code is duplicated for the caseless and caseful cases, for speed,
since matching characters is likely to be quite common. First, ensure the
@@ -3621,14 +3694,10 @@ for (;;)
characters and work backwards. */
DPRINTF(("negative matching %c{%d,%d} against subject %.*s\n", fc, min, max,
- max, eptr));
+ max, (char *)eptr));
if (op >= OP_NOTSTARI) /* Caseless */
{
-#ifdef COMPILE_PCRE8
- /* fc must be < 128 if UTF is enabled. */
- foc = md->fcc[fc];
-#else
#ifdef SUPPORT_UTF
#ifdef SUPPORT_UCP
if (utf && fc > 127)
@@ -3640,12 +3709,11 @@ for (;;)
else
#endif /* SUPPORT_UTF */
foc = TABLE_GET(fc, md->fcc, fc);
-#endif /* COMPILE_PCRE8 */
#ifdef SUPPORT_UTF
if (utf)
{
- register unsigned int d;
+ register pcre_uint32 d;
for (i = 1; i <= min; i++)
{
if (eptr >= md->end_subject)
@@ -3654,7 +3722,7 @@ for (;;)
RRETURN(MATCH_NOMATCH);
}
GETCHARINC(d, eptr);
- if (fc == d || (unsigned int) foc == d) RRETURN(MATCH_NOMATCH);
+ if (fc == d || (unsigned int)foc == d) RRETURN(MATCH_NOMATCH);
}
}
else
@@ -3680,7 +3748,7 @@ for (;;)
#ifdef SUPPORT_UTF
if (utf)
{
- register unsigned int d;
+ register pcre_uint32 d;
for (fi = min;; fi++)
{
RMATCH(eptr, ecode, offset_top, md, eptrb, RM28);
@@ -3725,7 +3793,7 @@ for (;;)
#ifdef SUPPORT_UTF
if (utf)
{
- register unsigned int d;
+ register pcre_uint32 d;
for (i = min; i < max; i++)
{
int len = 1;
@@ -3782,7 +3850,7 @@ for (;;)
#ifdef SUPPORT_UTF
if (utf)
{
- register unsigned int d;
+ register pcre_uint32 d;
for (i = 1; i <= min; i++)
{
if (eptr >= md->end_subject)
@@ -3816,7 +3884,7 @@ for (;;)
#ifdef SUPPORT_UTF
if (utf)
{
- register unsigned int d;
+ register pcre_uint32 d;
for (fi = min;; fi++)
{
RMATCH(eptr, ecode, offset_top, md, eptrb, RM32);
@@ -3860,7 +3928,7 @@ for (;;)
#ifdef SUPPORT_UTF
if (utf)
{
- register unsigned int d;
+ register pcre_uint32 d;
for (i = min; i < max; i++)
{
int len = 1;
@@ -4136,6 +4204,27 @@ for (;;)
}
break;
+ case PT_CLIST:
+ for (i = 1; i <= min; i++)
+ {
+ const pcre_uint32 *cp;
+ if (eptr >= md->end_subject)
+ {
+ SCHECK_PARTIAL();
+ RRETURN(MATCH_NOMATCH);
+ }
+ GETCHARINCTEST(c, eptr);
+ cp = PRIV(ucd_caseless_sets) + prop_value;
+ for (;;)
+ {
+ if (c < *cp)
+ { if (prop_fail_result) break; else { RRETURN(MATCH_NOMATCH); } }
+ if (c == *cp++)
+ { if (prop_fail_result) { RRETURN(MATCH_NOMATCH); } else break; }
+ }
+ }
+ break;
+
/* This should not occur */
default:
@@ -4155,15 +4244,22 @@ for (;;)
SCHECK_PARTIAL();
RRETURN(MATCH_NOMATCH);
}
- GETCHARINCTEST(c, eptr);
- if (UCD_CATEGORY(c) == ucp_M) RRETURN(MATCH_NOMATCH);
- while (eptr < md->end_subject)
+ else
{
- int len = 1;
- if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
- if (UCD_CATEGORY(c) != ucp_M) break;
- eptr += len;
+ int lgb, rgb;
+ GETCHARINCTEST(c, eptr);
+ lgb = UCD_GRAPHBREAK(c);
+ while (eptr < md->end_subject)
+ {
+ int len = 1;
+ if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
+ rgb = UCD_GRAPHBREAK(c);
+ if ((PRIV(ucp_gbtable)[lgb] & (1 << rgb)) == 0) break;
+ lgb = rgb;
+ eptr += len;
+ }
}
+ CHECK_PARTIAL();
}
}
@@ -4184,6 +4280,15 @@ for (;;)
RRETURN(MATCH_NOMATCH);
}
if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
+ if (md->partial != 0 &&
+ eptr + 1 >= md->end_subject &&
+ NLBLOCK->nltype == NLTYPE_FIXED &&
+ NLBLOCK->nllen == 2 &&
+ RAWUCHAR(eptr) == NLBLOCK->nl[0])
+ {
+ md->hitend = TRUE;
+ if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
+ }
eptr++;
ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
}
@@ -4220,18 +4325,20 @@ for (;;)
{
default: RRETURN(MATCH_NOMATCH);
- case 0x000d:
- if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
+ case CHAR_CR:
+ if (eptr < md->end_subject && RAWUCHAR(eptr) == CHAR_LF) eptr++;
break;
- case 0x000a:
+ case CHAR_LF:
break;
- case 0x000b:
- case 0x000c:
- case 0x0085:
+ case CHAR_VT:
+ case CHAR_FF:
+ case CHAR_NEL:
+#ifndef EBCDIC
case 0x2028:
case 0x2029:
+#endif /* Not EBCDIC */
if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
break;
}
@@ -4249,27 +4356,8 @@ for (;;)
GETCHARINC(c, eptr);
switch(c)
{
+ HSPACE_CASES: RRETURN(MATCH_NOMATCH); /* Byte and multibyte cases */
default: break;
- case 0x09: /* HT */
- case 0x20: /* SPACE */
- case 0xa0: /* NBSP */
- case 0x1680: /* OGHAM SPACE MARK */
- case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */
- case 0x2000: /* EN QUAD */
- case 0x2001: /* EM QUAD */
- case 0x2002: /* EN SPACE */
- case 0x2003: /* EM SPACE */
- case 0x2004: /* THREE-PER-EM SPACE */
- case 0x2005: /* FOUR-PER-EM SPACE */
- case 0x2006: /* SIX-PER-EM SPACE */
- case 0x2007: /* FIGURE SPACE */
- case 0x2008: /* PUNCTUATION SPACE */
- case 0x2009: /* THIN SPACE */
- case 0x200A: /* HAIR SPACE */
- case 0x202f: /* NARROW NO-BREAK SPACE */
- case 0x205f: /* MEDIUM MATHEMATICAL SPACE */
- case 0x3000: /* IDEOGRAPHIC SPACE */
- RRETURN(MATCH_NOMATCH);
}
}
break;
@@ -4285,27 +4373,8 @@ for (;;)
GETCHARINC(c, eptr);
switch(c)
{
+ HSPACE_CASES: break; /* Byte and multibyte cases */
default: RRETURN(MATCH_NOMATCH);
- case 0x09: /* HT */
- case 0x20: /* SPACE */
- case 0xa0: /* NBSP */
- case 0x1680: /* OGHAM SPACE MARK */
- case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */
- case 0x2000: /* EN QUAD */
- case 0x2001: /* EM QUAD */
- case 0x2002: /* EN SPACE */
- case 0x2003: /* EM SPACE */
- case 0x2004: /* THREE-PER-EM SPACE */
- case 0x2005: /* FOUR-PER-EM SPACE */
- case 0x2006: /* SIX-PER-EM SPACE */
- case 0x2007: /* FIGURE SPACE */
- case 0x2008: /* PUNCTUATION SPACE */
- case 0x2009: /* THIN SPACE */
- case 0x200A: /* HAIR SPACE */
- case 0x202f: /* NARROW NO-BREAK SPACE */
- case 0x205f: /* MEDIUM MATHEMATICAL SPACE */
- case 0x3000: /* IDEOGRAPHIC SPACE */
- break;
}
}
break;
@@ -4321,15 +4390,8 @@ for (;;)
GETCHARINC(c, eptr);
switch(c)
{
+ VSPACE_CASES: RRETURN(MATCH_NOMATCH);
default: break;
- case 0x0a: /* LF */
- case 0x0b: /* VT */
- case 0x0c: /* FF */
- case 0x0d: /* CR */
- case 0x85: /* NEL */
- case 0x2028: /* LINE SEPARATOR */
- case 0x2029: /* PARAGRAPH SEPARATOR */
- RRETURN(MATCH_NOMATCH);
}
}
break;
@@ -4345,15 +4407,8 @@ for (;;)
GETCHARINC(c, eptr);
switch(c)
{
+ VSPACE_CASES: break;
default: RRETURN(MATCH_NOMATCH);
- case 0x0a: /* LF */
- case 0x0b: /* VT */
- case 0x0c: /* FF */
- case 0x0d: /* CR */
- case 0x85: /* NEL */
- case 0x2028: /* LINE SEPARATOR */
- case 0x2029: /* PARAGRAPH SEPARATOR */
- break;
}
}
break;
@@ -4375,12 +4430,15 @@ for (;;)
case OP_DIGIT:
for (i = 1; i <= min; i++)
{
+ pcre_uchar cc;
+
if (eptr >= md->end_subject)
{
SCHECK_PARTIAL();
RRETURN(MATCH_NOMATCH);
}
- if (*eptr >= 128 || (md->ctypes[*eptr] & ctype_digit) == 0)
+ cc = RAWUCHAR(eptr);
+ if (cc >= 128 || (md->ctypes[cc] & ctype_digit) == 0)
RRETURN(MATCH_NOMATCH);
eptr++;
/* No need to skip more bytes - we know it's a 1-byte character */
@@ -4390,12 +4448,15 @@ for (;;)
case OP_NOT_WHITESPACE:
for (i = 1; i <= min; i++)
{
+ pcre_uchar cc;
+
if (eptr >= md->end_subject)
{
SCHECK_PARTIAL();
RRETURN(MATCH_NOMATCH);
}
- if (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0)
+ cc = RAWUCHAR(eptr);
+ if (cc < 128 && (md->ctypes[cc] & ctype_space) != 0)
RRETURN(MATCH_NOMATCH);
eptr++;
ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
@@ -4405,12 +4466,15 @@ for (;;)
case OP_WHITESPACE:
for (i = 1; i <= min; i++)
{
+ pcre_uchar cc;
+
if (eptr >= md->end_subject)
{
SCHECK_PARTIAL();
RRETURN(MATCH_NOMATCH);
}
- if (*eptr >= 128 || (md->ctypes[*eptr] & ctype_space) == 0)
+ cc = RAWUCHAR(eptr);
+ if (cc >= 128 || (md->ctypes[cc] & ctype_space) == 0)
RRETURN(MATCH_NOMATCH);
eptr++;
/* No need to skip more bytes - we know it's a 1-byte character */
@@ -4420,12 +4484,15 @@ for (;;)
case OP_NOT_WORDCHAR:
for (i = 1; i <= min; i++)
{
+ pcre_uchar cc;
+
if (eptr >= md->end_subject)
{
SCHECK_PARTIAL();
RRETURN(MATCH_NOMATCH);
}
- if (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0)
+ cc = RAWUCHAR(eptr);
+ if (cc < 128 && (md->ctypes[cc] & ctype_word) != 0)
RRETURN(MATCH_NOMATCH);
eptr++;
ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
@@ -4435,12 +4502,15 @@ for (;;)
case OP_WORDCHAR:
for (i = 1; i <= min; i++)
{
+ pcre_uchar cc;
+
if (eptr >= md->end_subject)
{
SCHECK_PARTIAL();
RRETURN(MATCH_NOMATCH);
}
- if (*eptr >= 128 || (md->ctypes[*eptr] & ctype_word) == 0)
+ cc = RAWUCHAR(eptr);
+ if (cc >= 128 || (md->ctypes[cc] & ctype_word) == 0)
RRETURN(MATCH_NOMATCH);
eptr++;
/* No need to skip more bytes - we know it's a 1-byte character */
@@ -4468,6 +4538,15 @@ for (;;)
RRETURN(MATCH_NOMATCH);
}
if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
+ if (md->partial != 0 &&
+ eptr + 1 >= md->end_subject &&
+ NLBLOCK->nltype == NLTYPE_FIXED &&
+ NLBLOCK->nllen == 2 &&
+ *eptr == NLBLOCK->nl[0])
+ {
+ md->hitend = TRUE;
+ if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
+ }
eptr++;
}
break;
@@ -4502,17 +4581,17 @@ for (;;)
{
default: RRETURN(MATCH_NOMATCH);
- case 0x000d:
- if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
+ case CHAR_CR:
+ if (eptr < md->end_subject && *eptr == CHAR_LF) eptr++;
break;
- case 0x000a:
+ case CHAR_LF:
break;
- case 0x000b:
- case 0x000c:
- case 0x0085:
-#ifdef COMPILE_PCRE16
+ case CHAR_VT:
+ case CHAR_FF:
+ case CHAR_NEL:
+#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
case 0x2028:
case 0x2029:
#endif
@@ -4533,26 +4612,9 @@ for (;;)
switch(*eptr++)
{
default: break;
- case 0x09: /* HT */
- case 0x20: /* SPACE */
- case 0xa0: /* NBSP */
-#ifdef COMPILE_PCRE16
- case 0x1680: /* OGHAM SPACE MARK */
- case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */
- case 0x2000: /* EN QUAD */
- case 0x2001: /* EM QUAD */
- case 0x2002: /* EN SPACE */
- case 0x2003: /* EM SPACE */
- case 0x2004: /* THREE-PER-EM SPACE */
- case 0x2005: /* FOUR-PER-EM SPACE */
- case 0x2006: /* SIX-PER-EM SPACE */
- case 0x2007: /* FIGURE SPACE */
- case 0x2008: /* PUNCTUATION SPACE */
- case 0x2009: /* THIN SPACE */
- case 0x200A: /* HAIR SPACE */
- case 0x202f: /* NARROW NO-BREAK SPACE */
- case 0x205f: /* MEDIUM MATHEMATICAL SPACE */
- case 0x3000: /* IDEOGRAPHIC SPACE */
+ HSPACE_BYTE_CASES:
+#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
+ HSPACE_MULTIBYTE_CASES:
#endif
RRETURN(MATCH_NOMATCH);
}
@@ -4570,26 +4632,9 @@ for (;;)
switch(*eptr++)
{
default: RRETURN(MATCH_NOMATCH);
- case 0x09: /* HT */
- case 0x20: /* SPACE */
- case 0xa0: /* NBSP */
-#ifdef COMPILE_PCRE16
- case 0x1680: /* OGHAM SPACE MARK */
- case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */
- case 0x2000: /* EN QUAD */
- case 0x2001: /* EM QUAD */
- case 0x2002: /* EN SPACE */
- case 0x2003: /* EM SPACE */
- case 0x2004: /* THREE-PER-EM SPACE */
- case 0x2005: /* FOUR-PER-EM SPACE */
- case 0x2006: /* SIX-PER-EM SPACE */
- case 0x2007: /* FIGURE SPACE */
- case 0x2008: /* PUNCTUATION SPACE */
- case 0x2009: /* THIN SPACE */
- case 0x200A: /* HAIR SPACE */
- case 0x202f: /* NARROW NO-BREAK SPACE */
- case 0x205f: /* MEDIUM MATHEMATICAL SPACE */
- case 0x3000: /* IDEOGRAPHIC SPACE */
+ HSPACE_BYTE_CASES:
+#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
+ HSPACE_MULTIBYTE_CASES:
#endif
break;
}
@@ -4606,17 +4651,12 @@ for (;;)
}
switch(*eptr++)
{
- default: break;
- case 0x0a: /* LF */
- case 0x0b: /* VT */
- case 0x0c: /* FF */
- case 0x0d: /* CR */
- case 0x85: /* NEL */
-#ifdef COMPILE_PCRE16
- case 0x2028: /* LINE SEPARATOR */
- case 0x2029: /* PARAGRAPH SEPARATOR */
+ VSPACE_BYTE_CASES:
+#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
+ VSPACE_MULTIBYTE_CASES:
#endif
RRETURN(MATCH_NOMATCH);
+ default: break;
}
}
break;
@@ -4632,14 +4672,9 @@ for (;;)
switch(*eptr++)
{
default: RRETURN(MATCH_NOMATCH);
- case 0x0a: /* LF */
- case 0x0b: /* VT */
- case 0x0c: /* FF */
- case 0x0d: /* CR */
- case 0x85: /* NEL */
-#ifdef COMPILE_PCRE16
- case 0x2028: /* LINE SEPARATOR */
- case 0x2029: /* PARAGRAPH SEPARATOR */
+ VSPACE_BYTE_CASES:
+#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
+ VSPACE_MULTIBYTE_CASES:
#endif
break;
}
@@ -4917,8 +4952,31 @@ for (;;)
}
/* Control never gets here */
- /* This should never occur */
+ case PT_CLIST:
+ for (fi = min;; fi++)
+ {
+ const pcre_uint32 *cp;
+ RMATCH(eptr, ecode, offset_top, md, eptrb, RM67);
+ if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+ if (fi >= max) RRETURN(MATCH_NOMATCH);
+ if (eptr >= md->end_subject)
+ {
+ SCHECK_PARTIAL();
+ RRETURN(MATCH_NOMATCH);
+ }
+ GETCHARINCTEST(c, eptr);
+ cp = PRIV(ucd_caseless_sets) + prop_value;
+ for (;;)
+ {
+ if (c < *cp)
+ { if (prop_fail_result) break; else { RRETURN(MATCH_NOMATCH); } }
+ if (c == *cp++)
+ { if (prop_fail_result) { RRETURN(MATCH_NOMATCH); } else break; }
+ }
+ }
+ /* Control never gets here */
+ /* This should never occur */
default:
RRETURN(PCRE_ERROR_INTERNAL);
}
@@ -4939,15 +4997,22 @@ for (;;)
SCHECK_PARTIAL();
RRETURN(MATCH_NOMATCH);
}
- GETCHARINCTEST(c, eptr);
- if (UCD_CATEGORY(c) == ucp_M) RRETURN(MATCH_NOMATCH);
- while (eptr < md->end_subject)
+ else
{
- int len = 1;
- if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
- if (UCD_CATEGORY(c) != ucp_M) break;
- eptr += len;
+ int lgb, rgb;
+ GETCHARINCTEST(c, eptr);
+ lgb = UCD_GRAPHBREAK(c);
+ while (eptr < md->end_subject)
+ {
+ int len = 1;
+ if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
+ rgb = UCD_GRAPHBREAK(c);
+ if ((PRIV(ucp_gbtable)[lgb] & (1 << rgb)) == 0) break;
+ lgb = rgb;
+ eptr += len;
+ }
}
+ CHECK_PARTIAL();
}
}
else
@@ -4971,7 +5036,18 @@ for (;;)
GETCHARINC(c, eptr);
switch(ctype)
{
- case OP_ANY: /* This is the non-NL case */
+ case OP_ANY: /* This is the non-NL case */
+ if (md->partial != 0 && /* Take care with CRLF partial */
+ eptr >= md->end_subject &&
+ NLBLOCK->nltype == NLTYPE_FIXED &&
+ NLBLOCK->nllen == 2 &&
+ c == NLBLOCK->nl[0])
+ {
+ md->hitend = TRUE;
+ if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
+ }
+ break;
+
case OP_ALLANY:
case OP_ANYBYTE:
break;
@@ -4980,17 +5056,20 @@ for (;;)
switch(c)
{
default: RRETURN(MATCH_NOMATCH);
- case 0x000d:
- if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
+ case CHAR_CR:
+ if (eptr < md->end_subject && RAWUCHAR(eptr) == CHAR_LF) eptr++;
break;
- case 0x000a:
+
+ case CHAR_LF:
break;
- case 0x000b:
- case 0x000c:
- case 0x0085:
+ case CHAR_VT:
+ case CHAR_FF:
+ case CHAR_NEL:
+#ifndef EBCDIC
case 0x2028:
case 0x2029:
+#endif /* Not EBCDIC */
if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
break;
}
@@ -4999,84 +5078,32 @@ for (;;)
case OP_NOT_HSPACE:
switch(c)
{
+ HSPACE_CASES: RRETURN(MATCH_NOMATCH);
default: break;
- case 0x09: /* HT */
- case 0x20: /* SPACE */
- case 0xa0: /* NBSP */
- case 0x1680: /* OGHAM SPACE MARK */
- case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */
- case 0x2000: /* EN QUAD */
- case 0x2001: /* EM QUAD */
- case 0x2002: /* EN SPACE */
- case 0x2003: /* EM SPACE */
- case 0x2004: /* THREE-PER-EM SPACE */
- case 0x2005: /* FOUR-PER-EM SPACE */
- case 0x2006: /* SIX-PER-EM SPACE */
- case 0x2007: /* FIGURE SPACE */
- case 0x2008: /* PUNCTUATION SPACE */
- case 0x2009: /* THIN SPACE */
- case 0x200A: /* HAIR SPACE */
- case 0x202f: /* NARROW NO-BREAK SPACE */
- case 0x205f: /* MEDIUM MATHEMATICAL SPACE */
- case 0x3000: /* IDEOGRAPHIC SPACE */
- RRETURN(MATCH_NOMATCH);
}
break;
case OP_HSPACE:
switch(c)
{
+ HSPACE_CASES: break;
default: RRETURN(MATCH_NOMATCH);
- case 0x09: /* HT */
- case 0x20: /* SPACE */
- case 0xa0: /* NBSP */
- case 0x1680: /* OGHAM SPACE MARK */
- case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */
- case 0x2000: /* EN QUAD */
- case 0x2001: /* EM QUAD */
- case 0x2002: /* EN SPACE */
- case 0x2003: /* EM SPACE */
- case 0x2004: /* THREE-PER-EM SPACE */
- case 0x2005: /* FOUR-PER-EM SPACE */
- case 0x2006: /* SIX-PER-EM SPACE */
- case 0x2007: /* FIGURE SPACE */
- case 0x2008: /* PUNCTUATION SPACE */
- case 0x2009: /* THIN SPACE */
- case 0x200A: /* HAIR SPACE */
- case 0x202f: /* NARROW NO-BREAK SPACE */
- case 0x205f: /* MEDIUM MATHEMATICAL SPACE */
- case 0x3000: /* IDEOGRAPHIC SPACE */
- break;
}
break;
case OP_NOT_VSPACE:
switch(c)
{
+ VSPACE_CASES: RRETURN(MATCH_NOMATCH);
default: break;
- case 0x0a: /* LF */
- case 0x0b: /* VT */
- case 0x0c: /* FF */
- case 0x0d: /* CR */
- case 0x85: /* NEL */
- case 0x2028: /* LINE SEPARATOR */
- case 0x2029: /* PARAGRAPH SEPARATOR */
- RRETURN(MATCH_NOMATCH);
}
break;
case OP_VSPACE:
switch(c)
{
+ VSPACE_CASES: break;
default: RRETURN(MATCH_NOMATCH);
- case 0x0a: /* LF */
- case 0x0b: /* VT */
- case 0x0c: /* FF */
- case 0x0d: /* CR */
- case 0x85: /* NEL */
- case 0x2028: /* LINE SEPARATOR */
- case 0x2029: /* PARAGRAPH SEPARATOR */
- break;
}
break;
@@ -5134,7 +5161,18 @@ for (;;)
c = *eptr++;
switch(ctype)
{
- case OP_ANY: /* This is the non-NL case */
+ case OP_ANY: /* This is the non-NL case */
+ if (md->partial != 0 && /* Take care with CRLF partial */
+ eptr >= md->end_subject &&
+ NLBLOCK->nltype == NLTYPE_FIXED &&
+ NLBLOCK->nllen == 2 &&
+ c == NLBLOCK->nl[0])
+ {
+ md->hitend = TRUE;
+ if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
+ }
+ break;
+
case OP_ALLANY:
case OP_ANYBYTE:
break;
@@ -5143,17 +5181,17 @@ for (;;)
switch(c)
{
default: RRETURN(MATCH_NOMATCH);
- case 0x000d:
- if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
+ case CHAR_CR:
+ if (eptr < md->end_subject && *eptr == CHAR_LF) eptr++;
break;
- case 0x000a:
+ case CHAR_LF:
break;
- case 0x000b:
- case 0x000c:
- case 0x0085:
-#ifdef COMPILE_PCRE16
+ case CHAR_VT:
+ case CHAR_FF:
+ case CHAR_NEL:
+#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
case 0x2028:
case 0x2029:
#endif
@@ -5166,26 +5204,9 @@ for (;;)
switch(c)
{
default: break;
- case 0x09: /* HT */
- case 0x20: /* SPACE */
- case 0xa0: /* NBSP */
-#ifdef COMPILE_PCRE16
- case 0x1680: /* OGHAM SPACE MARK */
- case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */
- case 0x2000: /* EN QUAD */
- case 0x2001: /* EM QUAD */
- case 0x2002: /* EN SPACE */
- case 0x2003: /* EM SPACE */
- case 0x2004: /* THREE-PER-EM SPACE */
- case 0x2005: /* FOUR-PER-EM SPACE */
- case 0x2006: /* SIX-PER-EM SPACE */
- case 0x2007: /* FIGURE SPACE */
- case 0x2008: /* PUNCTUATION SPACE */
- case 0x2009: /* THIN SPACE */
- case 0x200A: /* HAIR SPACE */
- case 0x202f: /* NARROW NO-BREAK SPACE */
- case 0x205f: /* MEDIUM MATHEMATICAL SPACE */
- case 0x3000: /* IDEOGRAPHIC SPACE */
+ HSPACE_BYTE_CASES:
+#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
+ HSPACE_MULTIBYTE_CASES:
#endif
RRETURN(MATCH_NOMATCH);
}
@@ -5195,26 +5216,9 @@ for (;;)
switch(c)
{
default: RRETURN(MATCH_NOMATCH);
- case 0x09: /* HT */
- case 0x20: /* SPACE */
- case 0xa0: /* NBSP */
-#ifdef COMPILE_PCRE16
- case 0x1680: /* OGHAM SPACE MARK */
- case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */
- case 0x2000: /* EN QUAD */
- case 0x2001: /* EM QUAD */
- case 0x2002: /* EN SPACE */
- case 0x2003: /* EM SPACE */
- case 0x2004: /* THREE-PER-EM SPACE */
- case 0x2005: /* FOUR-PER-EM SPACE */
- case 0x2006: /* SIX-PER-EM SPACE */
- case 0x2007: /* FIGURE SPACE */
- case 0x2008: /* PUNCTUATION SPACE */
- case 0x2009: /* THIN SPACE */
- case 0x200A: /* HAIR SPACE */
- case 0x202f: /* NARROW NO-BREAK SPACE */
- case 0x205f: /* MEDIUM MATHEMATICAL SPACE */
- case 0x3000: /* IDEOGRAPHIC SPACE */
+ HSPACE_BYTE_CASES:
+#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
+ HSPACE_MULTIBYTE_CASES:
#endif
break;
}
@@ -5224,14 +5228,9 @@ for (;;)
switch(c)
{
default: break;
- case 0x0a: /* LF */
- case 0x0b: /* VT */
- case 0x0c: /* FF */
- case 0x0d: /* CR */
- case 0x85: /* NEL */
-#ifdef COMPILE_PCRE16
- case 0x2028: /* LINE SEPARATOR */
- case 0x2029: /* PARAGRAPH SEPARATOR */
+ VSPACE_BYTE_CASES:
+#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
+ VSPACE_MULTIBYTE_CASES:
#endif
RRETURN(MATCH_NOMATCH);
}
@@ -5241,14 +5240,9 @@ for (;;)
switch(c)
{
default: RRETURN(MATCH_NOMATCH);
- case 0x0a: /* LF */
- case 0x0b: /* VT */
- case 0x0c: /* FF */
- case 0x0d: /* CR */
- case 0x85: /* NEL */
-#ifdef COMPILE_PCRE16
- case 0x2028: /* LINE SEPARATOR */
- case 0x2029: /* PARAGRAPH SEPARATOR */
+ VSPACE_BYTE_CASES:
+#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
+ VSPACE_MULTIBYTE_CASES:
#endif
break;
}
@@ -5452,6 +5446,30 @@ for (;;)
}
break;
+ case PT_CLIST:
+ for (i = min; i < max; i++)
+ {
+ const pcre_uint32 *cp;
+ int len = 1;
+ if (eptr >= md->end_subject)
+ {
+ SCHECK_PARTIAL();
+ break;
+ }
+ GETCHARLENTEST(c, eptr, len);
+ cp = PRIV(ucd_caseless_sets) + prop_value;
+ for (;;)
+ {
+ if (c < *cp)
+ { if (prop_fail_result) break; else goto GOT_MAX; }
+ if (c == *cp++)
+ { if (prop_fail_result) goto GOT_MAX; else break; }
+ }
+ eptr += len;
+ }
+ GOT_MAX:
+ break;
+
default:
RRETURN(PCRE_ERROR_INTERNAL);
}
@@ -5475,22 +5493,27 @@ for (;;)
{
for (i = min; i < max; i++)
{
- int len = 1;
if (eptr >= md->end_subject)
{
SCHECK_PARTIAL();
break;
}
- if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
- if (UCD_CATEGORY(c) == ucp_M) break;
- eptr += len;
- while (eptr < md->end_subject)
+ else
{
- len = 1;
- if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
- if (UCD_CATEGORY(c) != ucp_M) break;
- eptr += len;
+ int lgb, rgb;
+ GETCHARINCTEST(c, eptr);
+ lgb = UCD_GRAPHBREAK(c);
+ while (eptr < md->end_subject)
+ {
+ int len = 1;
+ if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
+ rgb = UCD_GRAPHBREAK(c);
+ if ((PRIV(ucp_gbtable)[lgb] & (1 << rgb)) == 0) break;
+ lgb = rgb;
+ eptr += len;
+ }
}
+ CHECK_PARTIAL();
}
/* eptr is now past the end of the maximum run */
@@ -5534,6 +5557,15 @@ for (;;)
break;
}
if (IS_NEWLINE(eptr)) break;
+ if (md->partial != 0 && /* Take care with CRLF partial */
+ eptr + 1 >= md->end_subject &&
+ NLBLOCK->nltype == NLTYPE_FIXED &&
+ NLBLOCK->nllen == 2 &&
+ RAWUCHAR(eptr) == NLBLOCK->nl[0])
+ {
+ md->hitend = TRUE;
+ if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
+ }
eptr++;
ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
}
@@ -5551,6 +5583,15 @@ for (;;)
break;
}
if (IS_NEWLINE(eptr)) break;
+ if (md->partial != 0 && /* Take care with CRLF partial */
+ eptr + 1 >= md->end_subject &&
+ NLBLOCK->nltype == NLTYPE_FIXED &&
+ NLBLOCK->nllen == 2 &&
+ RAWUCHAR(eptr) == NLBLOCK->nl[0])
+ {
+ md->hitend = TRUE;
+ if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
+ }
eptr++;
ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
}
@@ -5600,17 +5641,20 @@ for (;;)
break;
}
GETCHARLEN(c, eptr, len);
- if (c == 0x000d)
+ if (c == CHAR_CR)
{
if (++eptr >= md->end_subject) break;
- if (*eptr == 0x000a) eptr++;
+ if (RAWUCHAR(eptr) == CHAR_LF) eptr++;
}
else
{
- if (c != 0x000a &&
+ if (c != CHAR_LF &&
(md->bsr_anycrlf ||
- (c != 0x000b && c != 0x000c &&
- c != 0x0085 && c != 0x2028 && c != 0x2029)))
+ (c != CHAR_VT && c != CHAR_FF && c != CHAR_NEL
+#ifndef EBCDIC
+ && c != 0x2028 && c != 0x2029
+#endif /* Not EBCDIC */
+ )))
break;
eptr += len;
}
@@ -5631,28 +5675,8 @@ for (;;)
GETCHARLEN(c, eptr, len);
switch(c)
{
+ HSPACE_CASES: gotspace = TRUE; break;
default: gotspace = FALSE; break;
- case 0x09: /* HT */
- case 0x20: /* SPACE */
- case 0xa0: /* NBSP */
- case 0x1680: /* OGHAM SPACE MARK */
- case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */
- case 0x2000: /* EN QUAD */
- case 0x2001: /* EM QUAD */
- case 0x2002: /* EN SPACE */
- case 0x2003: /* EM SPACE */
- case 0x2004: /* THREE-PER-EM SPACE */
- case 0x2005: /* FOUR-PER-EM SPACE */
- case 0x2006: /* SIX-PER-EM SPACE */
- case 0x2007: /* FIGURE SPACE */
- case 0x2008: /* PUNCTUATION SPACE */
- case 0x2009: /* THIN SPACE */
- case 0x200A: /* HAIR SPACE */
- case 0x202f: /* NARROW NO-BREAK SPACE */
- case 0x205f: /* MEDIUM MATHEMATICAL SPACE */
- case 0x3000: /* IDEOGRAPHIC SPACE */
- gotspace = TRUE;
- break;
}
if (gotspace == (ctype == OP_NOT_HSPACE)) break;
eptr += len;
@@ -5673,16 +5697,8 @@ for (;;)
GETCHARLEN(c, eptr, len);
switch(c)
{
+ VSPACE_CASES: gotspace = TRUE; break;
default: gotspace = FALSE; break;
- case 0x0a: /* LF */
- case 0x0b: /* VT */
- case 0x0c: /* FF */
- case 0x0d: /* CR */
- case 0x85: /* NEL */
- case 0x2028: /* LINE SEPARATOR */
- case 0x2029: /* PARAGRAPH SEPARATOR */
- gotspace = TRUE;
- break;
}
if (gotspace == (ctype == OP_NOT_VSPACE)) break;
eptr += len;
@@ -5796,8 +5812,8 @@ for (;;)
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (eptr-- == pp) break; /* Stop if tried at original pos */
BACKCHAR(eptr);
- if (ctype == OP_ANYNL && eptr > pp && *eptr == '\n' &&
- eptr[-1] == '\r') eptr--;
+ if (ctype == OP_ANYNL && eptr > pp && RAWUCHAR(eptr) == CHAR_NL &&
+ RAWUCHAR(eptr - 1) == CHAR_CR) eptr--;
}
}
else
@@ -5815,6 +5831,15 @@ for (;;)
break;
}
if (IS_NEWLINE(eptr)) break;
+ if (md->partial != 0 && /* Take care with CRLF partial */
+ eptr + 1 >= md->end_subject &&
+ NLBLOCK->nltype == NLTYPE_FIXED &&
+ NLBLOCK->nllen == 2 &&
+ *eptr == NLBLOCK->nl[0])
+ {
+ md->hitend = TRUE;
+ if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
+ }
eptr++;
}
break;
@@ -5839,19 +5864,19 @@ for (;;)
break;
}
c = *eptr;
- if (c == 0x000d)
+ if (c == CHAR_CR)
{
if (++eptr >= md->end_subject) break;
- if (*eptr == 0x000a) eptr++;
+ if (*eptr == CHAR_LF) eptr++;
}
else
{
- if (c != 0x000a && (md->bsr_anycrlf ||
- (c != 0x000b && c != 0x000c && c != 0x0085
-#ifdef COMPILE_PCRE16
- && c != 0x2028 && c != 0x2029
+ if (c != CHAR_LF && (md->bsr_anycrlf ||
+ (c != CHAR_VT && c != CHAR_FF && c != CHAR_NEL
+#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
+ && c != 0x2028 && c != 0x2029
#endif
- ))) break;
+ ))) break;
eptr++;
}
}
@@ -5865,15 +5890,17 @@ for (;;)
SCHECK_PARTIAL();
break;
}
- c = *eptr;
- if (c == 0x09 || c == 0x20 || c == 0xa0
-#ifdef COMPILE_PCRE16
- || c == 0x1680 || c == 0x180e || (c >= 0x2000 && c <= 0x200A)
- || c == 0x202f || c == 0x205f || c == 0x3000
+ switch(*eptr)
+ {
+ default: eptr++; break;
+ HSPACE_BYTE_CASES:
+#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
+ HSPACE_MULTIBYTE_CASES:
#endif
- ) break;
- eptr++;
+ goto ENDLOOP00;
+ }
}
+ ENDLOOP00:
break;
case OP_HSPACE:
@@ -5884,15 +5911,17 @@ for (;;)
SCHECK_PARTIAL();
break;
}
- c = *eptr;
- if (c != 0x09 && c != 0x20 && c != 0xa0
-#ifdef COMPILE_PCRE16
- && c != 0x1680 && c != 0x180e && (c < 0x2000 || c > 0x200A)
- && c != 0x202f && c != 0x205f && c != 0x3000
+ switch(*eptr)
+ {
+ default: goto ENDLOOP01;
+ HSPACE_BYTE_CASES:
+#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
+ HSPACE_MULTIBYTE_CASES:
#endif
- ) break;
- eptr++;
+ eptr++; break;
+ }
}
+ ENDLOOP01:
break;
case OP_NOT_VSPACE:
@@ -5903,14 +5932,17 @@ for (;;)
SCHECK_PARTIAL();
break;
}
- c = *eptr;
- if (c == 0x0a || c == 0x0b || c == 0x0c || c == 0x0d || c == 0x85
-#ifdef COMPILE_PCRE16
- || c == 0x2028 || c == 0x2029
+ switch(*eptr)
+ {
+ default: eptr++; break;
+ VSPACE_BYTE_CASES:
+#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
+ VSPACE_MULTIBYTE_CASES:
#endif
- ) break;
- eptr++;
+ goto ENDLOOP02;
+ }
}
+ ENDLOOP02:
break;
case OP_VSPACE:
@@ -5921,14 +5953,17 @@ for (;;)
SCHECK_PARTIAL();
break;
}
- c = *eptr;
- if (c != 0x0a && c != 0x0b && c != 0x0c && c != 0x0d && c != 0x85
-#ifdef COMPILE_PCRE16
- && c != 0x2028 && c != 0x2029
+ switch(*eptr)
+ {
+ default: goto ENDLOOP03;
+ VSPACE_BYTE_CASES:
+#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
+ VSPACE_MULTIBYTE_CASES:
#endif
- ) break;
- eptr++;
+ eptr++; break;
+ }
}
+ ENDLOOP03:
break;
case OP_NOT_DIGIT:
@@ -6025,8 +6060,8 @@ for (;;)
RMATCH(eptr, ecode, offset_top, md, eptrb, RM47);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
eptr--;
- if (ctype == OP_ANYNL && eptr > pp && *eptr == '\n' &&
- eptr[-1] == '\r') eptr--;
+ if (ctype == OP_ANYNL && eptr > pp && *eptr == CHAR_LF &&
+ eptr[-1] == CHAR_CR) eptr--;
}
}
@@ -6076,14 +6111,11 @@ switch (frame->Xwhere)
LBL(32) LBL(34) LBL(42) LBL(46)
#ifdef SUPPORT_UCP
LBL(36) LBL(37) LBL(38) LBL(39) LBL(40) LBL(41) LBL(44) LBL(45)
- LBL(59) LBL(60) LBL(61) LBL(62)
+ LBL(59) LBL(60) LBL(61) LBL(62) LBL(67)
#endif /* SUPPORT_UCP */
#endif /* SUPPORT_UTF */
default:
DPRINTF(("jump error in pcre match: label %d non-existent\n", frame->Xwhere));
-
-printf("+++jump error in pcre match: label %d non-existent\n", frame->Xwhere);
-
return PCRE_ERROR_INTERNAL;
}
#undef LBL
@@ -6145,6 +6177,31 @@ Undefine all the macros that were defined above to handle this. */
***************************************************************************/
+#ifdef NO_RECURSE
+/*************************************************
+* Release allocated heap frames *
+*************************************************/
+
+/* This function releases all the allocated frames. The base frame is on the
+machine stack, and so must not be freed.
+
+Argument: the address of the base frame
+Returns: nothing
+*/
+
+static void
+release_match_heapframes (heapframe *frame_base)
+{
+heapframe *nextframe = frame_base->Xnextframe;
+while (nextframe != NULL)
+ {
+ heapframe *oldframe = nextframe;
+ nextframe = nextframe->Xnextframe;
+ (PUBL(stack_free))(oldframe);
+ }
+}
+#endif
+
/*************************************************
* Execute a Regular Expression *
@@ -6170,16 +6227,21 @@ Returns: > 0 => success; value is the number of elements filled in
< -1 => some kind of unexpected problem
*/
-#ifdef COMPILE_PCRE8
+#if defined COMPILE_PCRE8
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre_exec(const pcre *argument_re, const pcre_extra *extra_data,
PCRE_SPTR subject, int length, int start_offset, int options, int *offsets,
int offsetcount)
-#else
+#elif defined COMPILE_PCRE16
PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
pcre16_exec(const pcre16 *argument_re, const pcre16_extra *extra_data,
PCRE_SPTR16 subject, int length, int start_offset, int options, int *offsets,
int offsetcount)
+#elif defined COMPILE_PCRE32
+PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
+pcre32_exec(const pcre32 *argument_re, const pcre32_extra *extra_data,
+ PCRE_SPTR32 subject, int length, int start_offset, int options, int *offsets,
+ int offsetcount)
#endif
{
int rc, ocount, arg_offset_max;
@@ -6207,13 +6269,22 @@ PCRE_PUCHAR req_char_ptr = start_match - 1;
const pcre_study_data *study;
const REAL_PCRE *re = (const REAL_PCRE *)argument_re;
+#ifdef NO_RECURSE
+heapframe frame_zero;
+frame_zero.Xprevframe = NULL; /* Marks the top level */
+frame_zero.Xnextframe = NULL; /* None are allocated yet */
+md->match_frames_base = &frame_zero;
+#endif
+
/* Check for the special magic call that measures the size of the stack used
-per recursive call of match(). */
+per recursive call of match(). Without the funny casting for sizeof, a Windows
+compiler gave this error: "unary minus operator applied to unsigned type,
+result still unsigned". Hopefully the cast fixes that. */
if (re == NULL && extra_data == NULL && subject == NULL && length == -999 &&
start_offset == -999)
#ifdef NO_RECURSE
- return -sizeof(heapframe);
+ return -((int)sizeof(heapframe));
#else
return match(NULL, NULL, NULL, 0, NULL, NULL, 0);
#endif
@@ -6224,6 +6295,7 @@ if ((options & ~PUBLIC_EXEC_OPTIONS) != 0) return PCRE_ERROR_BADOPTION;
if (re == NULL || subject == NULL || (offsets == NULL && offsetcount > 0))
return PCRE_ERROR_NULL;
if (offsetcount < 0) return PCRE_ERROR_BADCOUNT;
+if (length < 0) return PCRE_ERROR_BADLENGTH;
if (start_offset < 0 || start_offset > length) return PCRE_ERROR_BADOFFSET;
/* Check that the first field in the block is the magic number. If it is not,
@@ -6261,39 +6333,45 @@ if (utf && (options & PCRE_NO_UTF8_CHECK) == 0)
offsets[0] = erroroffset;
offsets[1] = errorcode;
}
-#ifdef COMPILE_PCRE16
- return (errorcode <= PCRE_UTF16_ERR1 && md->partial > 1)?
- PCRE_ERROR_SHORTUTF16 : PCRE_ERROR_BADUTF16;
-#else
+#if defined COMPILE_PCRE8
return (errorcode <= PCRE_UTF8_ERR5 && md->partial > 1)?
PCRE_ERROR_SHORTUTF8 : PCRE_ERROR_BADUTF8;
+#elif defined COMPILE_PCRE16
+ return (errorcode <= PCRE_UTF16_ERR1 && md->partial > 1)?
+ PCRE_ERROR_SHORTUTF16 : PCRE_ERROR_BADUTF16;
+#elif defined COMPILE_PCRE32
+ return PCRE_ERROR_BADUTF32;
#endif
}
-
+#if defined COMPILE_PCRE8 || defined COMPILE_PCRE16
/* Check that a start_offset points to the start of a UTF character. */
if (start_offset > 0 && start_offset < length &&
NOT_FIRSTCHAR(((PCRE_PUCHAR)subject)[start_offset]))
return PCRE_ERROR_BADUTF8_OFFSET;
+#endif
}
#endif
/* If the pattern was successfully studied with JIT support, run the JIT
executable instead of the rest of this function. Most options must be set at
compile time for the JIT code to be usable. Fallback to the normal code path if
-an unsupported flag is set. In particular, JIT does not support partial
-matching. */
+an unsupported flag is set. */
#ifdef SUPPORT_JIT
if (extra_data != NULL
- && (extra_data->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0
+ && (extra_data->flags & (PCRE_EXTRA_EXECUTABLE_JIT |
+ PCRE_EXTRA_TABLES)) == PCRE_EXTRA_EXECUTABLE_JIT
&& extra_data->executable_jit != NULL
- && (extra_data->flags & PCRE_EXTRA_TABLES) == 0
- && (options & ~(PCRE_NO_UTF8_CHECK | PCRE_NOTBOL | PCRE_NOTEOL |
- PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART)) == 0)
- return PRIV(jit_exec)(re, extra_data->executable_jit,
- (const pcre_uchar *)subject, length, start_offset, options,
- ((extra_data->flags & PCRE_EXTRA_MATCH_LIMIT) == 0)
- ? MATCH_LIMIT : extra_data->match_limit, offsets, offsetcount);
+ && (options & ~PUBLIC_JIT_EXEC_OPTIONS) == 0)
+ {
+ rc = PRIV(jit_exec)(extra_data, (const pcre_uchar *)subject, length,
+ start_offset, options, offsets, offsetcount);
+
+ /* PCRE_ERROR_NULL means that the selected normal or partial matching
+ mode is not compiled. In this case we simply fallback to interpreter. */
+
+ if (rc != PCRE_ERROR_JIT_BADOPTION) return rc;
+ }
#endif
/* Carry on with non-JIT matching. This information is for finding all the
@@ -6576,12 +6654,14 @@ for(;;)
if (has_first_char)
{
+ pcre_uchar smc;
+
if (first_char != first_char2)
while (start_match < end_subject &&
- *start_match != first_char && *start_match != first_char2)
+ (smc = RAWUCHARTEST(start_match)) != first_char && smc != first_char2)
start_match++;
else
- while (start_match < end_subject && *start_match != first_char)
+ while (start_match < end_subject && RAWUCHARTEST(start_match) != first_char)
start_match++;
}
@@ -6613,7 +6693,7 @@ for(;;)
if (start_match[-1] == CHAR_CR &&
(md->nltype == NLTYPE_ANY || md->nltype == NLTYPE_ANYCRLF) &&
start_match < end_subject &&
- *start_match == CHAR_NL)
+ RAWUCHARTEST(start_match) == CHAR_NL)
start_match++;
}
}
@@ -6624,7 +6704,7 @@ for(;;)
{
while (start_match < end_subject)
{
- register unsigned int c = *start_match;
+ register pcre_uint32 c = RAWUCHARTEST(start_match);
#ifndef COMPILE_PCRE8
if (c > 255) c = 255;
#endif
@@ -6692,7 +6772,7 @@ for(;;)
{
while (p < end_subject)
{
- register int pp = *p++;
+ register pcre_uint32 pp = RAWUCHARINCTEST(p);
if (pp == req_char || pp == req_char2) { p--; break; }
}
}
@@ -6700,7 +6780,7 @@ for(;;)
{
while (p < end_subject)
{
- if (*p++ == req_char) { p--; break; }
+ if (RAWUCHARINCTEST(p) == req_char) { p--; break; }
}
}
@@ -6887,7 +6967,7 @@ if (rc == MATCH_MATCH || rc == MATCH_ACCEPT)
{
register int *iptr, *iend;
int resetcount = 2 + re->top_bracket * 2;
- if (resetcount > offsetcount) resetcount = ocount;
+ if (resetcount > offsetcount) resetcount = offsetcount;
iptr = offsets + md->end_offset_top;
iend = offsets + resetcount;
while (iptr < iend) *iptr++ = -1;
@@ -6908,6 +6988,9 @@ if (rc == MATCH_MATCH || rc == MATCH_ACCEPT)
if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)
*(extra_data->mark) = (pcre_uchar *)md->mark;
DPRINTF((">>>> returning %d\n", rc));
+#ifdef NO_RECURSE
+ release_match_heapframes(&frame_zero);
+#endif
return rc;
}
@@ -6925,6 +7008,9 @@ if (using_temporary_offsets)
if (rc != MATCH_NOMATCH && rc != PCRE_ERROR_PARTIAL)
{
DPRINTF((">>>> error: returning %d\n", rc));
+#ifdef NO_RECURSE
+ release_match_heapframes(&frame_zero);
+#endif
return rc;
}
@@ -6954,6 +7040,9 @@ else
if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)
*(extra_data->mark) = (pcre_uchar *)md->nomatch_mark;
+#ifdef NO_RECURSE
+ release_match_heapframes(&frame_zero);
+#endif
return rc;
}