svn path=/trunk/; revision=6938
This commit is contained in:
Matthias Clasen
2008-05-27 04:17:54 +00:00
parent c9db84f9f2
commit adae23350a
11 changed files with 501 additions and 297 deletions

View File

@@ -84,11 +84,11 @@ centralize the loading of these characters. In the case of Type * etc, the
small value. ***NOTE*** If the start of this table is modified, the two tables
that follow must also be modified. */
static uschar coptable[] = {
static const uschar coptable[] = {
0, /* End */
0, 0, 0, 0, 0, /* \A, \G, \K, \B, \b */
0, 0, 0, 0, 0, 0, /* \D, \d, \S, \s, \W, \w */
0, 0, /* Any, Anybyte */
0, 0, 0, /* Any, AllAny, Anybyte */
0, 0, 0, /* NOTPROP, PROP, EXTUNI */
0, 0, 0, 0, 0, /* \R, \H, \h, \V, \v */
0, 0, 0, 0, 0, /* \Z, \z, Opt, ^, $ */
@@ -132,26 +132,26 @@ static uschar coptable[] = {
0, /* DEF */
0, 0, /* BRAZERO, BRAMINZERO */
0, 0, 0, 0, /* PRUNE, SKIP, THEN, COMMIT */
0, 0 /* FAIL, ACCEPT */
0, 0, 0 /* FAIL, ACCEPT, SKIPZERO */
};
/* These 2 tables allow for compact code for testing for \D, \d, \S, \s, \W,
and \w */
static uschar toptable1[] = {
static const uschar toptable1[] = {
0, 0, 0, 0, 0, 0,
ctype_digit, ctype_digit,
ctype_space, ctype_space,
ctype_word, ctype_word,
0 /* OP_ANY */
0, 0 /* OP_ANY, OP_ALLANY */
};
static uschar toptable2[] = {
static const uschar toptable2[] = {
0, 0, 0, 0, 0, 0,
ctype_digit, 0,
ctype_space, 0,
ctype_word, 0,
1 /* OP_ANY */
1, 1 /* OP_ANY, OP_ALLANY */
};
@@ -223,8 +223,8 @@ Arguments:
rlevel function call recursion level
recursing regex recursive call level
Returns: > 0 =>
= 0 =>
Returns: > 0 => number of match offset pairs placed in offsets
= 0 => offsets overflowed; longest matches are present
-1 => failed to match
< -1 => some kind of unexpected problem
@@ -693,6 +693,13 @@ for (;;)
ADD_ACTIVE(code - start_code + 1 + LINK_SIZE, 0);
break;
/*-----------------------------------------------------------------*/
case OP_SKIPZERO:
code += 1 + GET(code, 2);
while (*code == OP_ALT) code += GET(code, 1);
ADD_ACTIVE(code - start_code + 1 + LINK_SIZE, 0);
break;
/*-----------------------------------------------------------------*/
case OP_CIRC:
if ((ptr == start_subject && (md->moptions & PCRE_NOTBOL) == 0) ||
@@ -732,7 +739,13 @@ for (;;)
/*-----------------------------------------------------------------*/
case OP_ANY:
if (clen > 0 && ((ims & PCRE_DOTALL) != 0 || !IS_NEWLINE(ptr)))
if (clen > 0 && !IS_NEWLINE(ptr))
{ ADD_NEW(state_offset + 1, 0); }
break;
/*-----------------------------------------------------------------*/
case OP_ALLANY:
if (clen > 0)
{ ADD_NEW(state_offset + 1, 0); }
break;
@@ -852,8 +865,8 @@ for (;;)
/* ========================================================================== */
/* These opcodes likewise inspect the subject character, but have an
argument that is not a data character. It is one of these opcodes:
OP_ANY, OP_DIGIT, OP_NOT_DIGIT, OP_WHITESPACE, OP_NOT_SPACE, OP_WORDCHAR,
OP_NOT_WORDCHAR. The value is loaded into d. */
OP_ANY, OP_ALLANY, OP_DIGIT, OP_NOT_DIGIT, OP_WHITESPACE, OP_NOT_SPACE,
OP_WORDCHAR, OP_NOT_WORDCHAR. The value is loaded into d. */
case OP_TYPEPLUS:
case OP_TYPEMINPLUS:
@@ -864,10 +877,7 @@ for (;;)
{
if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||
(c < 256 &&
(d != OP_ANY ||
(ims & PCRE_DOTALL) != 0 ||
!IS_NEWLINE(ptr)
) &&
(d != OP_ANY || !IS_NEWLINE(ptr)) &&
((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))
{
if (count > 0 && codevalue == OP_TYPEPOSPLUS)
@@ -890,10 +900,7 @@ for (;;)
{
if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||
(c < 256 &&
(d != OP_ANY ||
(ims & PCRE_DOTALL) != 0 ||
!IS_NEWLINE(ptr)
) &&
(d != OP_ANY || !IS_NEWLINE(ptr)) &&
((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))
{
if (codevalue == OP_TYPEPOSQUERY)
@@ -915,10 +922,7 @@ for (;;)
{
if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||
(c < 256 &&
(d != OP_ANY ||
(ims & PCRE_DOTALL) != 0 ||
!IS_NEWLINE(ptr)
) &&
(d != OP_ANY || !IS_NEWLINE(ptr)) &&
((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))
{
if (codevalue == OP_TYPEPOSSTAR)
@@ -938,10 +942,7 @@ for (;;)
{
if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||
(c < 256 &&
(d != OP_ANY ||
(ims & PCRE_DOTALL) != 0 ||
!IS_NEWLINE(ptr)
) &&
(d != OP_ANY || !IS_NEWLINE(ptr)) &&
((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))
{
if (++count >= GET2(code, 1))
@@ -962,10 +963,7 @@ for (;;)
{
if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) ||
(c < 256 &&
(d != OP_ANY ||
(ims & PCRE_DOTALL) != 0 ||
!IS_NEWLINE(ptr)
) &&
(d != OP_ANY || !IS_NEWLINE(ptr)) &&
((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0))
{
if (codevalue == OP_TYPEPOSUPTO)
@@ -2162,7 +2160,12 @@ for (;;)
/* ========================================================================== */
/* These are the opcodes for fancy brackets of various kinds. We have
to use recursion in order to handle them. */
to use recursion in order to handle them. The "always failing" assersion
(?!) is optimised when compiling to OP_FAIL, so we have to support that,
though the other "backtracking verbs" are not supported. */
case OP_FAIL:
break;
case OP_ASSERT:
case OP_ASSERT_NOT: