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-2007 University of Cambridge |
Copyright (c) 1997-2008 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 |
84 |
small value. ***NOTE*** If the start of this table is modified, the two tables |
small value. ***NOTE*** If the start of this table is modified, the two tables |
85 |
that follow must also be modified. */ |
that follow must also be modified. */ |
86 |
|
|
87 |
static uschar coptable[] = { |
static const uschar coptable[] = { |
88 |
0, /* End */ |
0, /* End */ |
89 |
0, 0, 0, 0, 0, /* \A, \G, \K, \B, \b */ |
0, 0, 0, 0, 0, /* \A, \G, \K, \B, \b */ |
90 |
0, 0, 0, 0, 0, 0, /* \D, \d, \S, \s, \W, \w */ |
0, 0, 0, 0, 0, 0, /* \D, \d, \S, \s, \W, \w */ |
91 |
0, 0, /* Any, Anybyte */ |
0, 0, 0, /* Any, AllAny, Anybyte */ |
92 |
0, 0, 0, /* NOTPROP, PROP, EXTUNI */ |
0, 0, 0, /* NOTPROP, PROP, EXTUNI */ |
93 |
0, 0, 0, 0, 0, /* \R, \H, \h, \V, \v */ |
0, 0, 0, 0, 0, /* \R, \H, \h, \V, \v */ |
94 |
0, 0, 0, 0, 0, /* \Z, \z, Opt, ^, $ */ |
0, 0, 0, 0, 0, /* \Z, \z, Opt, ^, $ */ |
132 |
0, /* DEF */ |
0, /* DEF */ |
133 |
0, 0, /* BRAZERO, BRAMINZERO */ |
0, 0, /* BRAZERO, BRAMINZERO */ |
134 |
0, 0, 0, 0, /* PRUNE, SKIP, THEN, COMMIT */ |
0, 0, 0, 0, /* PRUNE, SKIP, THEN, COMMIT */ |
135 |
0, 0 /* FAIL, ACCEPT */ |
0, 0, 0 /* FAIL, ACCEPT, SKIPZERO */ |
136 |
}; |
}; |
137 |
|
|
138 |
/* These 2 tables allow for compact code for testing for \D, \d, \S, \s, \W, |
/* These 2 tables allow for compact code for testing for \D, \d, \S, \s, \W, |
139 |
and \w */ |
and \w */ |
140 |
|
|
141 |
static uschar toptable1[] = { |
static const uschar toptable1[] = { |
142 |
0, 0, 0, 0, 0, 0, |
0, 0, 0, 0, 0, 0, |
143 |
ctype_digit, ctype_digit, |
ctype_digit, ctype_digit, |
144 |
ctype_space, ctype_space, |
ctype_space, ctype_space, |
145 |
ctype_word, ctype_word, |
ctype_word, ctype_word, |
146 |
0 /* OP_ANY */ |
0, 0 /* OP_ANY, OP_ALLANY */ |
147 |
}; |
}; |
148 |
|
|
149 |
static uschar toptable2[] = { |
static const uschar toptable2[] = { |
150 |
0, 0, 0, 0, 0, 0, |
0, 0, 0, 0, 0, 0, |
151 |
ctype_digit, 0, |
ctype_digit, 0, |
152 |
ctype_space, 0, |
ctype_space, 0, |
153 |
ctype_word, 0, |
ctype_word, 0, |
154 |
1 /* OP_ANY */ |
1, 1 /* OP_ANY, OP_ALLANY */ |
155 |
}; |
}; |
156 |
|
|
157 |
|
|
223 |
rlevel function call recursion level |
rlevel function call recursion level |
224 |
recursing regex recursive call level |
recursing regex recursive call level |
225 |
|
|
226 |
Returns: > 0 => |
Returns: > 0 => number of match offset pairs placed in offsets |
227 |
= 0 => |
= 0 => offsets overflowed; longest matches are present |
228 |
-1 => failed to match |
-1 => failed to match |
229 |
< -1 => some kind of unexpected problem |
< -1 => some kind of unexpected problem |
230 |
|
|
694 |
break; |
break; |
695 |
|
|
696 |
/*-----------------------------------------------------------------*/ |
/*-----------------------------------------------------------------*/ |
697 |
|
case OP_SKIPZERO: |
698 |
|
code += 1 + GET(code, 2); |
699 |
|
while (*code == OP_ALT) code += GET(code, 1); |
700 |
|
ADD_ACTIVE(code - start_code + 1 + LINK_SIZE, 0); |
701 |
|
break; |
702 |
|
|
703 |
|
/*-----------------------------------------------------------------*/ |
704 |
case OP_CIRC: |
case OP_CIRC: |
705 |
if ((ptr == start_subject && (md->moptions & PCRE_NOTBOL) == 0) || |
if ((ptr == start_subject && (md->moptions & PCRE_NOTBOL) == 0) || |
706 |
((ims & PCRE_MULTILINE) != 0 && |
((ims & PCRE_MULTILINE) != 0 && |
744 |
break; |
break; |
745 |
|
|
746 |
/*-----------------------------------------------------------------*/ |
/*-----------------------------------------------------------------*/ |
747 |
|
case OP_ALLANY: |
748 |
|
if (clen > 0) |
749 |
|
{ ADD_NEW(state_offset + 1, 0); } |
750 |
|
break; |
751 |
|
|
752 |
|
/*-----------------------------------------------------------------*/ |
753 |
case OP_EODN: |
case OP_EODN: |
754 |
if (clen == 0 || (IS_NEWLINE(ptr) && ptr == end_subject - md->nllen)) |
if (clen == 0 || (IS_NEWLINE(ptr) && ptr == end_subject - md->nllen)) |
755 |
{ ADD_ACTIVE(state_offset + 1, 0); } |
{ ADD_ACTIVE(state_offset + 1, 0); } |
865 |
/* ========================================================================== */ |
/* ========================================================================== */ |
866 |
/* These opcodes likewise inspect the subject character, but have an |
/* These opcodes likewise inspect the subject character, but have an |
867 |
argument that is not a data character. It is one of these opcodes: |
argument that is not a data character. It is one of these opcodes: |
868 |
OP_ANY, OP_DIGIT, OP_NOT_DIGIT, OP_WHITESPACE, OP_NOT_SPACE, OP_WORDCHAR, |
OP_ANY, OP_ALLANY, OP_DIGIT, OP_NOT_DIGIT, OP_WHITESPACE, OP_NOT_SPACE, |
869 |
OP_NOT_WORDCHAR. The value is loaded into d. */ |
OP_WORDCHAR, OP_NOT_WORDCHAR. The value is loaded into d. */ |
870 |
|
|
871 |
case OP_TYPEPLUS: |
case OP_TYPEPLUS: |
872 |
case OP_TYPEMINPLUS: |
case OP_TYPEMINPLUS: |
2175 |
|
|
2176 |
/* ========================================================================== */ |
/* ========================================================================== */ |
2177 |
/* These are the opcodes for fancy brackets of various kinds. We have |
/* These are the opcodes for fancy brackets of various kinds. We have |
2178 |
to use recursion in order to handle them. */ |
to use recursion in order to handle them. The "always failing" assersion |
2179 |
|
(?!) is optimised when compiling to OP_FAIL, so we have to support that, |
2180 |
|
though the other "backtracking verbs" are not supported. */ |
2181 |
|
|
2182 |
|
case OP_FAIL: |
2183 |
|
break; |
2184 |
|
|
2185 |
case OP_ASSERT: |
case OP_ASSERT: |
2186 |
case OP_ASSERT_NOT: |
case OP_ASSERT_NOT: |
2622 |
md->moptions |= re->options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE); |
md->moptions |= re->options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE); |
2623 |
#ifdef BSR_ANYCRLF |
#ifdef BSR_ANYCRLF |
2624 |
else md->moptions |= PCRE_BSR_ANYCRLF; |
else md->moptions |= PCRE_BSR_ANYCRLF; |
2625 |
#endif |
#endif |
2626 |
} |
} |
2627 |
|
|
2628 |
/* Handle different types of newline. The three bits give eight cases. If |
/* Handle different types of newline. The three bits give eight cases. If |
2629 |
nothing is set at run time, whatever was used at compile time applies. */ |
nothing is set at run time, whatever was used at compile time applies. */ |