--- code/trunk/study.c 2007/02/24 21:38:45 25 +++ code/trunk/study.c 2007/02/24 21:39:42 53 @@ -9,7 +9,7 @@ Written by: Philip Hazel - Copyright (c) 1998 University of Cambridge + Copyright (c) 1997-2001 University of Cambridge ----------------------------------------------------------------------------- Permission is granted to anyone to use this software for any purpose on any @@ -25,6 +25,10 @@ 3. Altered versions must be plainly marked as such, and must not be misrepresented as being the original software. + +4. If PCRE is embedded in any software that is released under the GNU + General Purpose Licence (GPL), then the terms of that licence shall + supersede any condition above with which it is incompatible. ----------------------------------------------------------------------------- */ @@ -85,6 +89,14 @@ { register int c; +/* This next statement and the later reference to dummy are here in order to +trick the optimizer of the IBM C compiler for OS/2 into generating correct +code. Apparently IBM isn't going to fix the problem, and we would rather not +disable optimization (in this module it actually makes a big difference, and +the pcre module can use all the optimization it can get). */ + +volatile int dummy; + do { const uschar *tcode = code + 3; @@ -92,8 +104,6 @@ while (try_next) { - try_next = FALSE; - /* If a branch starts with a bracket or a positive lookahead assertion, recurse to set bits from within them. That's all for this branch. */ @@ -101,6 +111,7 @@ { if (!set_start_bits(tcode, start_bits, caseless, cd)) return FALSE; + try_next = FALSE; } else switch(*tcode) @@ -108,12 +119,17 @@ default: return FALSE; + /* Skip over extended extraction bracket number */ + + case OP_BRANUMBER: + tcode += 3; + break; + /* Skip over lookbehind and negative lookahead assertions */ case OP_ASSERT_NOT: case OP_ASSERTBACK: case OP_ASSERTBACK_NOT: - try_next = TRUE; do tcode += (tcode[1] << 8) + tcode[2]; while (*tcode == OP_ALT); tcode += 3; break; @@ -123,7 +139,6 @@ case OP_OPT: caseless = (tcode[1] & PCRE_CASELESS) != 0; tcode += 2; - try_next = TRUE; break; /* BRAZERO does the bracket, but carries on. */ @@ -132,9 +147,9 @@ case OP_BRAMINZERO: if (!set_start_bits(++tcode, start_bits, caseless, cd)) return FALSE; + dummy = 1; do tcode += (tcode[1] << 8) + tcode[2]; while (*tcode == OP_ALT); tcode += 3; - try_next = TRUE; break; /* Single-char * or ? sets the bit and tries the next item */ @@ -145,7 +160,6 @@ case OP_MINQUERY: set_bit(start_bits, tcode[1], caseless, cd); tcode += 2; - try_next = TRUE; break; /* Single-char upto sets the bit and tries the next */ @@ -154,7 +168,6 @@ case OP_MINUPTO: set_bit(start_bits, tcode[3], caseless, cd); tcode += 4; - try_next = TRUE; break; /* At least one single char sets the bit and stops */ @@ -168,6 +181,7 @@ case OP_PLUS: case OP_MINPLUS: set_bit(start_bits, tcode[1], caseless, cd); + try_next = FALSE; break; /* Single character type sets the bits and stops */ @@ -175,31 +189,37 @@ case OP_NOT_DIGIT: for (c = 0; c < 32; c++) start_bits[c] |= ~cd->cbits[c+cbit_digit]; + try_next = FALSE; break; case OP_DIGIT: for (c = 0; c < 32; c++) start_bits[c] |= cd->cbits[c+cbit_digit]; + try_next = FALSE; break; case OP_NOT_WHITESPACE: for (c = 0; c < 32; c++) start_bits[c] |= ~cd->cbits[c+cbit_space]; + try_next = FALSE; break; case OP_WHITESPACE: for (c = 0; c < 32; c++) start_bits[c] |= cd->cbits[c+cbit_space]; + try_next = FALSE; break; case OP_NOT_WORDCHAR: for (c = 0; c < 32; c++) - start_bits[c] |= ~(cd->cbits[c] | cd->cbits[c+cbit_word]); + start_bits[c] |= ~cd->cbits[c+cbit_word]; + try_next = FALSE; break; case OP_WORDCHAR: for (c = 0; c < 32; c++) - start_bits[c] |= (cd->cbits[c] | cd->cbits[c+cbit_word]); + start_bits[c] |= cd->cbits[c+cbit_word]; + try_next = FALSE; break; /* One or more character type fudges the pointer and restarts, knowing @@ -208,12 +228,10 @@ case OP_TYPEPLUS: case OP_TYPEMINPLUS: tcode++; - try_next = TRUE; break; case OP_TYPEEXACT: tcode += 3; - try_next = TRUE; break; /* Zero or more repeats of character types set the bits and then @@ -251,17 +269,16 @@ case OP_NOT_WORDCHAR: for (c = 0; c < 32; c++) - start_bits[c] |= ~(cd->cbits[c] | cd->cbits[c+cbit_word]); + start_bits[c] |= ~cd->cbits[c+cbit_word]; break; case OP_WORDCHAR: for (c = 0; c < 32; c++) - start_bits[c] |= (cd->cbits[c] | cd->cbits[c+cbit_word]); + start_bits[c] |= cd->cbits[c+cbit_word]; break; } tcode += 2; - try_next = TRUE; break; /* Character class: set the bits and either carry on or not, @@ -279,16 +296,16 @@ case OP_CRQUERY: case OP_CRMINQUERY: tcode++; - try_next = TRUE; break; case OP_CRRANGE: case OP_CRMINRANGE: - if (((tcode[1] << 8) + tcode[2]) == 0) - { - tcode += 5; - try_next = TRUE; - } + if (((tcode[1] << 8) + tcode[2]) == 0) tcode += 5; + else try_next = FALSE; + break; + + default: + try_next = FALSE; break; } }