9 |
|
|
10 |
Written by: Philip Hazel <ph10@cam.ac.uk> |
Written by: Philip Hazel <ph10@cam.ac.uk> |
11 |
|
|
12 |
Copyright (c) 1998 University of Cambridge |
Copyright (c) 1997-2001 University of Cambridge |
13 |
|
|
14 |
----------------------------------------------------------------------------- |
----------------------------------------------------------------------------- |
15 |
Permission is granted to anyone to use this software for any purpose on any |
Permission is granted to anyone to use this software for any purpose on any |
25 |
|
|
26 |
3. Altered versions must be plainly marked as such, and must not be |
3. Altered versions must be plainly marked as such, and must not be |
27 |
misrepresented as being the original software. |
misrepresented as being the original software. |
28 |
|
|
29 |
|
4. If PCRE is embedded in any software that is released under the GNU |
30 |
|
General Purpose Licence (GPL), then the terms of that licence shall |
31 |
|
supersede any condition above with which it is incompatible. |
32 |
----------------------------------------------------------------------------- |
----------------------------------------------------------------------------- |
33 |
*/ |
*/ |
34 |
|
|
89 |
{ |
{ |
90 |
register int c; |
register int c; |
91 |
|
|
92 |
|
/* This next statement and the later reference to dummy are here in order to |
93 |
|
trick the optimizer of the IBM C compiler for OS/2 into generating correct |
94 |
|
code. Apparently IBM isn't going to fix the problem, and we would rather not |
95 |
|
disable optimization (in this module it actually makes a big difference, and |
96 |
|
the pcre module can use all the optimization it can get). */ |
97 |
|
|
98 |
|
volatile int dummy; |
99 |
|
|
100 |
do |
do |
101 |
{ |
{ |
102 |
const uschar *tcode = code + 3; |
const uschar *tcode = code + 3; |
104 |
|
|
105 |
while (try_next) |
while (try_next) |
106 |
{ |
{ |
|
try_next = FALSE; |
|
|
|
|
107 |
/* If a branch starts with a bracket or a positive lookahead assertion, |
/* If a branch starts with a bracket or a positive lookahead assertion, |
108 |
recurse to set bits from within them. That's all for this branch. */ |
recurse to set bits from within them. That's all for this branch. */ |
109 |
|
|
111 |
{ |
{ |
112 |
if (!set_start_bits(tcode, start_bits, caseless, cd)) |
if (!set_start_bits(tcode, start_bits, caseless, cd)) |
113 |
return FALSE; |
return FALSE; |
114 |
|
try_next = FALSE; |
115 |
} |
} |
116 |
|
|
117 |
else switch(*tcode) |
else switch(*tcode) |
119 |
default: |
default: |
120 |
return FALSE; |
return FALSE; |
121 |
|
|
122 |
|
/* Skip over extended extraction bracket number */ |
123 |
|
|
124 |
|
case OP_BRANUMBER: |
125 |
|
tcode += 3; |
126 |
|
break; |
127 |
|
|
128 |
/* Skip over lookbehind and negative lookahead assertions */ |
/* Skip over lookbehind and negative lookahead assertions */ |
129 |
|
|
130 |
case OP_ASSERT_NOT: |
case OP_ASSERT_NOT: |
131 |
case OP_ASSERTBACK: |
case OP_ASSERTBACK: |
132 |
case OP_ASSERTBACK_NOT: |
case OP_ASSERTBACK_NOT: |
|
try_next = TRUE; |
|
133 |
do tcode += (tcode[1] << 8) + tcode[2]; while (*tcode == OP_ALT); |
do tcode += (tcode[1] << 8) + tcode[2]; while (*tcode == OP_ALT); |
134 |
tcode += 3; |
tcode += 3; |
135 |
break; |
break; |
139 |
case OP_OPT: |
case OP_OPT: |
140 |
caseless = (tcode[1] & PCRE_CASELESS) != 0; |
caseless = (tcode[1] & PCRE_CASELESS) != 0; |
141 |
tcode += 2; |
tcode += 2; |
|
try_next = TRUE; |
|
142 |
break; |
break; |
143 |
|
|
144 |
/* BRAZERO does the bracket, but carries on. */ |
/* BRAZERO does the bracket, but carries on. */ |
147 |
case OP_BRAMINZERO: |
case OP_BRAMINZERO: |
148 |
if (!set_start_bits(++tcode, start_bits, caseless, cd)) |
if (!set_start_bits(++tcode, start_bits, caseless, cd)) |
149 |
return FALSE; |
return FALSE; |
150 |
|
dummy = 1; |
151 |
do tcode += (tcode[1] << 8) + tcode[2]; while (*tcode == OP_ALT); |
do tcode += (tcode[1] << 8) + tcode[2]; while (*tcode == OP_ALT); |
152 |
tcode += 3; |
tcode += 3; |
|
try_next = TRUE; |
|
153 |
break; |
break; |
154 |
|
|
155 |
/* Single-char * or ? sets the bit and tries the next item */ |
/* Single-char * or ? sets the bit and tries the next item */ |
160 |
case OP_MINQUERY: |
case OP_MINQUERY: |
161 |
set_bit(start_bits, tcode[1], caseless, cd); |
set_bit(start_bits, tcode[1], caseless, cd); |
162 |
tcode += 2; |
tcode += 2; |
|
try_next = TRUE; |
|
163 |
break; |
break; |
164 |
|
|
165 |
/* Single-char upto sets the bit and tries the next */ |
/* Single-char upto sets the bit and tries the next */ |
168 |
case OP_MINUPTO: |
case OP_MINUPTO: |
169 |
set_bit(start_bits, tcode[3], caseless, cd); |
set_bit(start_bits, tcode[3], caseless, cd); |
170 |
tcode += 4; |
tcode += 4; |
|
try_next = TRUE; |
|
171 |
break; |
break; |
172 |
|
|
173 |
/* At least one single char sets the bit and stops */ |
/* At least one single char sets the bit and stops */ |
181 |
case OP_PLUS: |
case OP_PLUS: |
182 |
case OP_MINPLUS: |
case OP_MINPLUS: |
183 |
set_bit(start_bits, tcode[1], caseless, cd); |
set_bit(start_bits, tcode[1], caseless, cd); |
184 |
|
try_next = FALSE; |
185 |
break; |
break; |
186 |
|
|
187 |
/* Single character type sets the bits and stops */ |
/* Single character type sets the bits and stops */ |
189 |
case OP_NOT_DIGIT: |
case OP_NOT_DIGIT: |
190 |
for (c = 0; c < 32; c++) |
for (c = 0; c < 32; c++) |
191 |
start_bits[c] |= ~cd->cbits[c+cbit_digit]; |
start_bits[c] |= ~cd->cbits[c+cbit_digit]; |
192 |
|
try_next = FALSE; |
193 |
break; |
break; |
194 |
|
|
195 |
case OP_DIGIT: |
case OP_DIGIT: |
196 |
for (c = 0; c < 32; c++) |
for (c = 0; c < 32; c++) |
197 |
start_bits[c] |= cd->cbits[c+cbit_digit]; |
start_bits[c] |= cd->cbits[c+cbit_digit]; |
198 |
|
try_next = FALSE; |
199 |
break; |
break; |
200 |
|
|
201 |
case OP_NOT_WHITESPACE: |
case OP_NOT_WHITESPACE: |
202 |
for (c = 0; c < 32; c++) |
for (c = 0; c < 32; c++) |
203 |
start_bits[c] |= ~cd->cbits[c+cbit_space]; |
start_bits[c] |= ~cd->cbits[c+cbit_space]; |
204 |
|
try_next = FALSE; |
205 |
break; |
break; |
206 |
|
|
207 |
case OP_WHITESPACE: |
case OP_WHITESPACE: |
208 |
for (c = 0; c < 32; c++) |
for (c = 0; c < 32; c++) |
209 |
start_bits[c] |= cd->cbits[c+cbit_space]; |
start_bits[c] |= cd->cbits[c+cbit_space]; |
210 |
|
try_next = FALSE; |
211 |
break; |
break; |
212 |
|
|
213 |
case OP_NOT_WORDCHAR: |
case OP_NOT_WORDCHAR: |
214 |
for (c = 0; c < 32; c++) |
for (c = 0; c < 32; c++) |
215 |
start_bits[c] |= ~(cd->cbits[c] | cd->cbits[c+cbit_word]); |
start_bits[c] |= ~cd->cbits[c+cbit_word]; |
216 |
|
try_next = FALSE; |
217 |
break; |
break; |
218 |
|
|
219 |
case OP_WORDCHAR: |
case OP_WORDCHAR: |
220 |
for (c = 0; c < 32; c++) |
for (c = 0; c < 32; c++) |
221 |
start_bits[c] |= (cd->cbits[c] | cd->cbits[c+cbit_word]); |
start_bits[c] |= cd->cbits[c+cbit_word]; |
222 |
|
try_next = FALSE; |
223 |
break; |
break; |
224 |
|
|
225 |
/* One or more character type fudges the pointer and restarts, knowing |
/* One or more character type fudges the pointer and restarts, knowing |
228 |
case OP_TYPEPLUS: |
case OP_TYPEPLUS: |
229 |
case OP_TYPEMINPLUS: |
case OP_TYPEMINPLUS: |
230 |
tcode++; |
tcode++; |
|
try_next = TRUE; |
|
231 |
break; |
break; |
232 |
|
|
233 |
case OP_TYPEEXACT: |
case OP_TYPEEXACT: |
234 |
tcode += 3; |
tcode += 3; |
|
try_next = TRUE; |
|
235 |
break; |
break; |
236 |
|
|
237 |
/* Zero or more repeats of character types set the bits and then |
/* Zero or more repeats of character types set the bits and then |
269 |
|
|
270 |
case OP_NOT_WORDCHAR: |
case OP_NOT_WORDCHAR: |
271 |
for (c = 0; c < 32; c++) |
for (c = 0; c < 32; c++) |
272 |
start_bits[c] |= ~(cd->cbits[c] | cd->cbits[c+cbit_word]); |
start_bits[c] |= ~cd->cbits[c+cbit_word]; |
273 |
break; |
break; |
274 |
|
|
275 |
case OP_WORDCHAR: |
case OP_WORDCHAR: |
276 |
for (c = 0; c < 32; c++) |
for (c = 0; c < 32; c++) |
277 |
start_bits[c] |= (cd->cbits[c] | cd->cbits[c+cbit_word]); |
start_bits[c] |= cd->cbits[c+cbit_word]; |
278 |
break; |
break; |
279 |
} |
} |
280 |
|
|
281 |
tcode += 2; |
tcode += 2; |
|
try_next = TRUE; |
|
282 |
break; |
break; |
283 |
|
|
284 |
/* Character class: set the bits and either carry on or not, |
/* Character class: set the bits and either carry on or not, |
296 |
case OP_CRQUERY: |
case OP_CRQUERY: |
297 |
case OP_CRMINQUERY: |
case OP_CRMINQUERY: |
298 |
tcode++; |
tcode++; |
|
try_next = TRUE; |
|
299 |
break; |
break; |
300 |
|
|
301 |
case OP_CRRANGE: |
case OP_CRRANGE: |
302 |
case OP_CRMINRANGE: |
case OP_CRMINRANGE: |
303 |
if (((tcode[1] << 8) + tcode[2]) == 0) |
if (((tcode[1] << 8) + tcode[2]) == 0) tcode += 5; |
304 |
{ |
else try_next = FALSE; |
305 |
tcode += 5; |
break; |
306 |
try_next = TRUE; |
|
307 |
} |
default: |
308 |
|
try_next = FALSE; |
309 |
break; |
break; |
310 |
} |
} |
311 |
} |
} |