--- code/trunk/study.c 2007/02/24 21:39:21 43 +++ code/trunk/study.c 2007/02/24 21:39:42 53 @@ -9,7 +9,7 @@ Written by: Philip Hazel - Copyright (c) 1997-2000 University of Cambridge + Copyright (c) 1997-2001 University of Cambridge ----------------------------------------------------------------------------- Permission is granted to anyone to use this software for any purpose on any @@ -104,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. */ @@ -113,6 +111,7 @@ { if (!set_start_bits(tcode, start_bits, caseless, cd)) return FALSE; + try_next = FALSE; } else switch(*tcode) @@ -120,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; @@ -135,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. */ @@ -147,7 +150,6 @@ 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 */ @@ -158,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 */ @@ -167,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 */ @@ -181,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 */ @@ -188,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+cbit_word]; + try_next = FALSE; break; case OP_WORDCHAR: for (c = 0; c < 32; c++) start_bits[c] |= cd->cbits[c+cbit_word]; + try_next = FALSE; break; /* One or more character type fudges the pointer and restarts, knowing @@ -221,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 @@ -274,7 +279,6 @@ } tcode += 2; - try_next = TRUE; break; /* Character class: set the bits and either carry on or not, @@ -292,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; } }