diff --git a/pcre/ChangeLog b/pcre/ChangeLog index 7d837b9..a31a84d 100644 --- a/pcre/ChangeLog +++ b/pcre/ChangeLog @@ -1,3 +1,13 @@ +2004-10-29 Paolo Bonzini + + * regstudy.c (set_start_bits, set_boyer_moore): Do several + cleanups, including removing unused variables/labels, and + turning while loops to do/whiles if it can be done safely. + * regcomp.c: Do not use register. + * regperl.c: Do not use register. + * regposix.c: Do not use register. Simplify code to not + test for unused opcodes (OP_COND, OP_ASSERT, etc.). + 2004-10-29 Paolo Bonzini * regstudy.c (prune_bracket): Distinguish correctly the diff --git a/pcre/regcomp.c b/pcre/regcomp.c index 07c99fb..cf7c025 100644 --- a/pcre/regcomp.c +++ b/pcre/regcomp.c @@ -247,8 +247,8 @@ find_fixedlength (code, options) { int length = -1; - register int branchlength = 0; - register uschar *cc = code + 3; + int branchlength = 0; + uschar *cc = code + 3; /* Scan along the opcodes for this branch. If we get to the end of the branch, check the length against that of the other branches. */ @@ -256,7 +256,7 @@ find_fixedlength (code, options) for (;;) { int d; - register int op = *cc; + int op = *cc; if (op >= OP_BRA) op = OP_BRA; @@ -453,7 +453,7 @@ check_posix_name (ptr, len) const uschar *ptr; int len; { - register int yield = 0; + int yield = 0; while (posix_name_lengths[yield] != 0) { if (len == posix_name_lengths[yield] && @@ -733,14 +733,14 @@ first_significant_code (code, options, optbit, optstop) static BOOL is_anchored (code, options) - register const uschar *code; + const uschar *code; int *options; { do { const uschar *scode = first_significant_code (code + 3, options, PCRE_MULTILINE, FALSE); - register int op = *scode; + int op = *scode; if (op >= OP_BRA || op == OP_ASSERT || op == OP_ONCE || op == OP_COND) { if (!is_anchored (scode, options)) @@ -783,7 +783,7 @@ is_startline (code) do { const uschar *scode = first_significant_code (code + 3, NULL, 0, FALSE); - register int op = *scode; + int op = *scode; if (op >= OP_BRA || op == OP_ASSERT || op == OP_ONCE || op == OP_COND) { if (!is_startline (scode)) @@ -990,13 +990,13 @@ find_firstchar (code, options) const uschar *code; int *options; { - register int c = -1; + int c = -1; do { int d; const uschar *scode = first_significant_code (code + 3, options, PCRE_CASELESS, TRUE); - register int op = *scode; + int op = *scode; if (op >= OP_BRA) op = OP_BRA; diff --git a/pcre/regexec.c b/pcre/regexec.c index f170016..3831482 100644 --- a/pcre/regexec.c +++ b/pcre/regexec.c @@ -136,7 +136,7 @@ pchars (p, length, is_subject, md) static BOOL match_ref (offset, eptr, length, md, ims) int offset; - register const uschar *eptr; + const uschar *eptr; int length; match_data *md; unsigned long int ims; @@ -206,8 +206,8 @@ match_ref (offset, eptr, length, md, ims) static BOOL match (eptr, ecode, offset_top, md, ims, eptrb, flags) - register const uschar *eptr; - register const uschar *ecode; + const uschar *eptr; + const uschar *ecode; int offset_top; match_data *md; unsigned long int ims; @@ -235,8 +235,8 @@ match (eptr, ecode, offset_top, md, ims, eptrb, flags) { int op = (int) *ecode; int min, max, ctype; - register int i; - register int c; + int i; + int c; int kind = 0; /* Opening capturing bracket. If there is space in the offset vector, save @@ -934,9 +934,7 @@ match (eptr, ecode, offset_top, md, ims, eptrb, flags) if (length == 0) continue; - /* First, ensure the minimum number of matches are present. We get back - the length of the reference string explicitly rather than passing the - address of eptr, so that eptr can be a register variable. */ + /* First, ensure the minimum number of matches are present. */ for (i = 1; i <= min; i++) { @@ -1121,10 +1119,10 @@ match (eptr, ecode, offset_top, md, ims, eptrb, flags) case OP_CHARS: { - register int length = ecode[1]; + int length = ecode[1]; ecode += 2; -#ifdef DEBUG /* Sigh. Some compilers never learn. */ +#ifdef DEBUG if (eptr >= md->end_subject) printf ("matching subject against pattern "); else @@ -1853,8 +1851,8 @@ pcre_exec (re, extra, subject, length, start_offset, options, offsets, offsetcou initialize them to avoid reading uninitialized locations. */ if (match_block.offset_vector != NULL) { - register int *iptr = match_block.offset_vector + ocount; - register int *iend = iptr - resetcount / 2 + 1; + int *iptr = match_block.offset_vector + ocount; + int *iend = iptr - resetcount / 2 + 1; while (--iptr >= iend) *iptr = -1; } @@ -1878,8 +1876,8 @@ pcre_exec (re, extra, subject, length, start_offset, options, offsets, offsetcou do { int rc; - register int *iptr = match_block.offset_vector; - register int *iend = iptr + resetcount; + int *iptr = match_block.offset_vector; + int *iend = iptr + resetcount; #ifdef DEBUG int skipped_chars = 0; #endif @@ -1954,7 +1952,7 @@ pcre_exec (re, extra, subject, length, start_offset, options, offsets, offsetcou { while (start_match < end_subject) { - register int c = *start_match; + int c = *start_match; if ((start_bits[c / 8] & (1 << (c & 7))) == 0) #ifdef DEBUG skipped_chars++, @@ -1987,7 +1985,7 @@ pcre_exec (re, extra, subject, length, start_offset, options, offsets, offsetcou if (req_char >= 0) { - register const uschar *p = start_match + ((first_char >= 0) ? 1 : 0); + const uschar *p = start_match + ((first_char >= 0) ? 1 : 0); /* We don't need to repeat the search if we haven't yet reached the place we found it at last time. */ @@ -2014,7 +2012,7 @@ pcre_exec (re, extra, subject, length, start_offset, options, offsets, offsetcou { while (p < end_subject) { - register int pp = *p++; + int pp = *p++; if (pp == req_char || pp == req_char2) { p--; diff --git a/pcre/regperl.c b/pcre/regperl.c index dfad38c..3353482 100644 --- a/pcre/regperl.c +++ b/pcre/regperl.c @@ -313,9 +313,9 @@ compile_branch_perl (options, brackets, codeptr, ptrptr, errorptr, optchanged, r int prevreqchar; int condcount = 0; int subcountlits = 0; - register int c; - register uschar *code = *codeptr; - uschar *tempcode; + int c; + uschar *start; + uschar *code = *codeptr; const uschar *ptr = *ptrptr; const uschar *tempptr; uschar *previous = NULL; @@ -438,7 +438,7 @@ compile_branch_perl (options, brackets, codeptr, ptrptr, errorptr, optchanged, r { BOOL local_negate = FALSE; int posix_class, i; - register const uschar *cbits = cd->cbits; + const uschar *cbits = cd->cbits; if (ptr[1] != ':') { @@ -504,7 +504,7 @@ compile_branch_perl (options, brackets, codeptr, ptrptr, errorptr, optchanged, r c = '\b'; else if (c < 0) { - register const uschar *cbits = cd->cbits; + const uschar *cbits = cd->cbits; class_charcount = 10; switch (-c) { @@ -891,7 +891,7 @@ compile_branch_perl (options, brackets, codeptr, ptrptr, errorptr, optchanged, r else if ((int) *previous >= OP_BRA || (int) *previous == OP_ONCE || (int) *previous == OP_COND) { - register int i; + int i; int ketoffset = 0; int len = code - previous; uschar *bralink = NULL; @@ -904,7 +904,7 @@ compile_branch_perl (options, brackets, codeptr, ptrptr, errorptr, optchanged, r if (repeat_max == -1) { - register uschar *ket = previous; + uschar *ket = previous; do ket += (ket[1] << 8) + ket[2]; while (*ket != OP_KET); @@ -1257,21 +1257,19 @@ compile_branch_perl (options, brackets, codeptr, ptrptr, errorptr, optchanged, r bravalue = OP_BRA + *brackets; } - /* Process nested bracketed re. Assertions may not be repeated, but other - kinds can be. We copy code into a non-register variable in order to be able - to pass its address because some compilers complain otherwise. Pass in a - new setting for the ims options if they have changed. */ + /* Process nested bracketed re. Assertions may not be repeated, but other kinds + can be. Pass in a new setting for the ims options if they have changed. */ previous = (bravalue >= OP_ONCE) ? code : NULL; *code = bravalue; - tempcode = code; + start = code; if (!compile_regex ( options | PCRE_INGROUP, /* Set for all nested groups */ ((options & PCRE_IMS) != (newoptions & PCRE_IMS)) ? newoptions & PCRE_IMS : -1, /* Pass ims options if changed */ brackets, /* Capturing bracket count */ - &tempcode, /* Where to put code (updated) */ + &code, /* Where to put code (updated) */ &ptr, /* Input pointer (updated) */ errorptr, /* Where to put an error message */ (bravalue == OP_ASSERTBACK || @@ -1284,7 +1282,7 @@ compile_branch_perl (options, brackets, codeptr, ptrptr, errorptr, optchanged, r goto FAILED; /* At the end of compiling, code is still pointing to the start of the - group, while tempcode has been updated to point past the end of the group + group, while code has been updated to point past the end of the group and any option resetting that may follow it. The pattern pointer (ptr) is on the bracket. */ @@ -1293,7 +1291,7 @@ compile_branch_perl (options, brackets, codeptr, ptrptr, errorptr, optchanged, r else if (bravalue == OP_COND) { - uschar *tc = code; + uschar *tc = start; condcount = 0; do @@ -1328,10 +1326,6 @@ compile_branch_perl (options, brackets, codeptr, ptrptr, errorptr, optchanged, r *countlits += subcountlits; } - /* Now update the main code pointer to the end of the group. */ - - code = tempcode; - /* Error if hit end of pattern */ if (ptr > cd->end || *ptr != ')') diff --git a/pcre/regposix.c b/pcre/regposix.c index cc7d901..d58c70d 100644 --- a/pcre/regposix.c +++ b/pcre/regposix.c @@ -280,9 +280,8 @@ compile_branch_posix (options, brackets, codeptr, ptrptr, errorptr, optchanged, int condcount = 0; int subcountlits = 0; BOOL first = TRUE; - register int c; - register uschar *code = *codeptr; - uschar *tempcode; + int c; + uschar *code = *codeptr; const uschar *ptr = *ptrptr; const uschar *tempptr; uschar *previous = NULL; @@ -517,10 +516,9 @@ compile_branch_posix (options, brackets, codeptr, ptrptr, errorptr, optchanged, /* If previous was a bracket group, we may have to replicate it in certain cases. */ - else if ((int) *previous >= OP_BRA || (int) *previous == OP_ONCE || - (int) *previous == OP_COND) + else if ((int) *previous >= OP_BRA) { - register int i; + int i; int ketoffset = 0; int len = code - previous; @@ -532,7 +530,7 @@ compile_branch_posix (options, brackets, codeptr, ptrptr, errorptr, optchanged, if (repeat_max == -1) { - register uschar *ket = previous; + uschar *ket = previous; do ket += (ket[1] << 8) + ket[2]; while (*ket != OP_KET); @@ -754,7 +752,7 @@ compile_branch_posix (options, brackets, codeptr, ptrptr, errorptr, optchanged, check_posix_syntax (ptr, &tempptr, cd)) { int posix_class, i; - register const uschar *cbits = cd->cbits; + const uschar *cbits = cd->cbits; if (ptr[1] != ':') { @@ -958,25 +956,22 @@ compile_branch_posix (options, brackets, codeptr, ptrptr, errorptr, optchanged, else bravalue = OP_BRA + *brackets; - /* Process nested bracketed re. Assertions may not be repeated, but other - kinds can be. We copy code into a non-register variable in order to be able - to pass its address because some compilers complain otherwise. Pass in a - new setting for the ims options if they have changed. */ + /* Process nested bracketed re. Assertions may not be repeated, but other kinds + can be. Pass in a new setting for the ims options if they have changed. */ previous = code; *code = bravalue; - tempcode = code; if (!compile_regex (options | PCRE_INGROUP, /* Set for all nested groups */ ((options & PCRE_IMS) != (newoptions & PCRE_IMS)) ? newoptions & PCRE_IMS : -1, /* Pass ims options if changed */ brackets, /* Capturing bracket count */ - &tempcode, /* Where to put code (updated) */ + &code, /* Where to put code (updated) */ &ptr, /* Input pointer (updated) */ errorptr, /* Where to put an error message */ FALSE, /* Whether this is a lookbehind assertion */ - skipbytes, /* Skip over OP_COND/OP_BRANUMBER */ + skipbytes, /* Skip over OP_BRANUMBER */ &subreqchar, /* For possible last char */ &subcountlits, /* For literal count */ cd, /* Tables block */ @@ -984,32 +979,10 @@ compile_branch_posix (options, brackets, codeptr, ptrptr, errorptr, optchanged, goto FAILED; /* At the end of compiling, code is still pointing to the start of the - group, while tempcode has been updated to point past the end of the group + group, while code has been updated to point past the end of the group and any option resetting that may follow it. The pattern pointer (ptr) is on the bracket. */ - /* If this is a conditional bracket, check that there are no more than - two branches in the group. */ - - else if (bravalue == OP_COND) - { - uschar *tc = code; - condcount = 0; - - do - { - condcount++; - tc += (tc[1] << 8) | tc[2]; - } - while (*tc != OP_KET); - - if (condcount > 2) - { - *errorptr = pcre_estrings[27]; - goto FAILED; - } - } - /* Handle updating of the required character. If the subpattern didn't set one, leave it as it was. Otherwise, update it for normal brackets of all kinds, forward assertions, and conditions with two branches. Don't @@ -1018,21 +991,13 @@ compile_branch_posix (options, brackets, codeptr, ptrptr, errorptr, optchanged, the definition of prevreqchar and subcountlits outside the main loop so that they can be accessed for the back off. */ - if (subreqchar > 0 && - (bravalue >= OP_BRA || bravalue == OP_ONCE - || bravalue == OP_ASSERT || (bravalue == OP_COND - && condcount == 2))) + if (subreqchar > 0 && bravalue >= OP_BRA) { prevreqchar = *reqchar; *reqchar = subreqchar; - if (bravalue != OP_ASSERT) - *countlits += subcountlits; + *countlits += subcountlits; } - /* Now update the main code pointer to the end of the group. */ - - code = tempcode; - /* Error if hit end of pattern */ if (ptr > cd->end || *ptr != ')') diff --git a/pcre/regstudy.c b/pcre/regstudy.c index 1ba2118..eb95f08 100644 --- a/pcre/regstudy.c +++ b/pcre/regstudy.c @@ -192,29 +192,31 @@ set_boyer_moore (code, bmtable, length, caseless, cd) { const uschar *tcode = code + 3; BOOL try_next = TRUE; - int old_length; /* If the branch has more than one alternative, it's too complicated, so exit. */ if (code[(code[1] << 8) + code[2]] == OP_ALT) return length; - while (try_next && length < 255) + do { - register int c = *tcode; - old_length = length; + int i; - NEXT_OPCODE: - - switch (c) + switch (*tcode) { + default: + /* If a branch starts with a bracket, recurse to set the string + from within them. That's all for this branch. */ + if ((int) *tcode >= OP_BRA) + length = set_boyer_moore (tcode, bmtable, length, caseless, cd); + return length; + /* Skip over extended extraction bracket number */ case OP_BRANUMBER: tcode += 3; break; - /* Skip over lookbehind assertions */ case OP_ASSERTBACK: @@ -262,13 +264,15 @@ set_boyer_moore (code, bmtable, length, caseless, cd) case OP_EXACT: length += (tcode[1] << 8) + tcode[2]; + if (length > 255) + length = 255; set_bmtable (bmtable, tcode[3], length, caseless, cd); tcode += 4; break; case OP_CHARS: { - register int nchars = tcode[1]; + int nchars = tcode[1]; if (nchars > 255 - length) nchars = 255 - length; @@ -284,9 +288,9 @@ set_boyer_moore (code, bmtable, length, caseless, cd) tcode++; REPEATTYPENOT: length++; - for (c = 0; c < 255; c++) - if (!*tcode || !(cd->ctypes[c] & (1 << *tcode))) - set_bmtable (bmtable, c, length, caseless, cd); + for (i = 0; i < 255; i++) + if (!*tcode || !(cd->ctypes[i] & (1 << *tcode))) + set_bmtable (bmtable, i, length, caseless, cd); break; @@ -294,9 +298,9 @@ set_boyer_moore (code, bmtable, length, caseless, cd) tcode++; REPEATTYPE: length++; - for (c = 0; c < 255; c++) - if (cd->ctypes[c] & (*tcode ? 1 << *tcode : 0)) - set_bmtable (bmtable, c, length, caseless, cd); + for (i = 0; i < 255; i++) + if (cd->ctypes[i] & (*tcode ? 1 << *tcode : 0)) + set_bmtable (bmtable, i, length, caseless, cd); break; @@ -371,7 +375,7 @@ set_boyer_moore (code, bmtable, length, caseless, cd) case OP_CL_MINQUERY: case OP_CL_ONCEQUERY: { - register const uschar *classptr = tcode + 1; + const uschar *classptr = tcode + 1; tcode++; switch (tcode[-1]) { @@ -405,30 +409,18 @@ set_boyer_moore (code, bmtable, length, caseless, cd) default: length++; - for (c = 0; c < 255; c++) - if (classptr[c >> 3] & (1 << (c & 7))) - set_bmtable (bmtable, c, length, caseless, cd); + for (i = 0; i < 255; i++) + if (classptr[i >> 3] & (1 << (i & 7))) + set_bmtable (bmtable, i, length, caseless, cd); break; } tcode += 32; break; /* End of class handling */ } - - default: - /* Undo the effect of a OP_TYPE... opcode */ - length = old_length; - - /* If a branch starts with a bracket, recurse to set the string - from within them. That's all for this branch. */ - - if ((int) *tcode >= OP_BRA) - length = set_boyer_moore (tcode, bmtable, - length, caseless, cd); - try_next = FALSE; - break; } /* End of switch */ } /* End of try_next loop */ + while (try_next && length < 255); return length; } @@ -460,7 +452,7 @@ set_start_bits (code, start_bits, caseless, cd) BOOL caseless; compile_data *cd; { - register int c; + int i; /* 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 @@ -475,7 +467,7 @@ set_start_bits (code, start_bits, caseless, cd) const uschar *tcode = code + 3; BOOL try_next = TRUE; - while (try_next) + do { /* 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. */ @@ -484,212 +476,215 @@ set_start_bits (code, start_bits, caseless, cd) { if (!set_start_bits (tcode, start_bits, caseless, cd)) return FALSE; - try_next = FALSE; + break; } - else - switch (*tcode) - { - default: + switch (*tcode) + { + default: + if ((int) *tcode >= OP_BRA || *tcode == OP_ASSERT) + abort (); + else return FALSE; - /* Skip over extended extraction bracket number */ + /* 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: - do - tcode += (tcode[1] << 8) + tcode[2]; - while (*tcode == OP_ALT); - tcode += 3; - break; + case OP_BRANUMBER: + tcode += 3; + break; + /* Skip over lookbehind and negative lookahead assertions */ + + case OP_ASSERT_NOT: + case OP_ASSERTBACK: + case OP_ASSERTBACK_NOT: + do + tcode += (tcode[1] << 8) + tcode[2]; + while (*tcode == OP_ALT); + tcode += 3; + break; + /* Skip over an option setting, changing the caseless flag */ + + case OP_OPT: + caseless = (tcode[1] & PCRE_CASELESS) != 0; + tcode += 2; + break; + + /* BRAZERO does the bracket, but carries on. */ + + case OP_BRAZERO: + 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; + break; + + /* Single-char * or ? sets the bit and tries the next item */ + + case OP_MAXSTAR: + case OP_MINSTAR: + case OP_ONCESTAR: + case OP_MAXQUERY: + case OP_MINQUERY: + case OP_ONCEQUERY: + set_bit (start_bits, tcode[1], caseless, cd); + tcode += 2; + break; - case OP_OPT: - caseless = (tcode[1] & PCRE_CASELESS) != 0; - tcode += 2; - break; - - /* BRAZERO does the bracket, but carries on. */ - - case OP_BRAZERO: - case OP_BRAMINZERO: - if (!set_start_bits (++tcode, start_bits, caseless, cd)) + /* Single-char upto sets the bit and tries the next */ + + case OP_MAXUPTO: + case OP_MINUPTO: + case OP_ONCEUPTO: + set_bit (start_bits, tcode[3], caseless, cd); + tcode += 4; + break; + + /* At least one single char sets the bit and stops */ + + case OP_EXACT: /* Fall through */ + tcode++; + + case OP_CHARS: /* Fall through */ + tcode++; + + case OP_MAXPLUS: + case OP_MINPLUS: + case OP_ONCEPLUS: + set_bit (start_bits, tcode[1], caseless, cd); + try_next = FALSE; + break; + + /* Single character type sets the bits and stops */ + + case OP_TYPENOT: + tcode++; + try_next = FALSE; + REPEATTYPENOT: + if (!*tcode) + return FALSE; + + for (i = 0; i < 32; i++) + start_bits[i] |= ~cd->cbits[i + *tcode * 32]; + break; + + case OP_TYPE: + tcode++; + try_next = FALSE; + REPEATTYPE: + if (!*tcode) return FALSE; - dummy = 1; - do - tcode += (tcode[1] << 8) + tcode[2]; - while (*tcode == OP_ALT); - tcode += 3; - break; - - /* Single-char * or ? sets the bit and tries the next item */ - - case OP_MAXSTAR: - case OP_MINSTAR: - case OP_ONCESTAR: - case OP_MAXQUERY: - case OP_MINQUERY: - case OP_ONCEQUERY: - set_bit (start_bits, tcode[1], caseless, cd); + + for (i = 0; i < 32; i++) + start_bits[i] |= cd->cbits[i + *tcode * 32]; + break; + + /* One or more character type fudges the pointer and restarts. */ + + case OP_TYPEEXACT: tcode += 2; - break; - - /* Single-char upto sets the bit and tries the next */ - - case OP_MAXUPTO: - case OP_MINUPTO: - case OP_ONCEUPTO: - set_bit (start_bits, tcode[3], caseless, cd); - tcode += 4; - break; - - /* At least one single char sets the bit and stops */ - - case OP_EXACT: /* Fall through */ + + case OP_TYPE_MAXPLUS: + case OP_TYPE_MINPLUS: + case OP_TYPE_ONCEPLUS: + tcode++; + try_next = FALSE; + goto REPEATTYPE; + + /* Zero or more repeats of character types set the bits and then + try again. */ + + case OP_TYPE_MAXUPTO: + case OP_TYPE_MINUPTO: + case OP_TYPE_ONCEUPTO: + tcode += 2; /* Fall through */ + + case OP_TYPE_MAXSTAR: + case OP_TYPE_MINSTAR: + case OP_TYPE_ONCESTAR: + case OP_TYPE_MAXQUERY: + case OP_TYPE_MINQUERY: + case OP_TYPE_ONCEQUERY: + tcode++; + goto REPEATTYPE; + break; + + /* One or more character type fudges the pointer and restarts. */ + + case OP_TYPENOTEXACT: + tcode += 2; /* Fall through */ + + case OP_TYPENOT_MAXPLUS: + case OP_TYPENOT_MINPLUS: + case OP_TYPENOT_ONCEPLUS: + try_next = FALSE; + goto REPEATTYPENOT; + + case OP_TYPENOT_MAXUPTO: + case OP_TYPENOT_MINUPTO: + case OP_TYPENOT_ONCEUPTO: + tcode += 2; /* Fall through */ + + case OP_TYPENOT_MAXSTAR: + case OP_TYPENOT_MINSTAR: + case OP_TYPENOT_ONCESTAR: + case OP_TYPENOT_MAXQUERY: + case OP_TYPENOT_MINQUERY: + case OP_TYPENOT_ONCEQUERY: + tcode++; + goto REPEATTYPENOT; + + /* Character class: set the bits and either carry on or not, + according to the repeat count. */ + + case OP_CLASS: + case OP_CL_MAXSTAR: + case OP_CL_MINSTAR: + case OP_CL_ONCESTAR: + case OP_CL_MAXPLUS: + case OP_CL_MINPLUS: + case OP_CL_ONCEPLUS: + case OP_CL_MAXQUERY: + case OP_CL_MINQUERY: + case OP_CL_ONCEQUERY: + case OP_CL_MAXRANGE: + case OP_CL_MINRANGE: + case OP_CL_ONCERANGE: + { tcode++; + for (i = 0; i < 32; i++) + start_bits[i] |= tcode[i]; + tcode += 32; + switch (tcode[-33]) + { + case OP_CL_MAXSTAR: + case OP_CL_MINSTAR: + case OP_CL_ONCESTAR: + case OP_CL_MAXQUERY: + case OP_CL_MINQUERY: + case OP_CL_ONCEQUERY: + break; + + case OP_CL_MAXRANGE: + case OP_CL_MINRANGE: + case OP_CL_ONCERANGE: + if (((tcode[1] << 8) + tcode[2]) == 0) + tcode += 4; + else + try_next = FALSE; + break; + } + } + break; /* End of class handling */ - case OP_CHARS: /* Fall through */ - tcode++; - - case OP_MAXPLUS: - case OP_MINPLUS: - case OP_ONCEPLUS: - set_bit (start_bits, tcode[1], caseless, cd); - try_next = FALSE; - break; - - /* Single character type sets the bits and stops */ - - case OP_TYPENOT: - tcode++; - try_next = FALSE; - REPEATTYPENOT: - if (!*tcode) - return FALSE; - - for (c = 0; c < 32; c++) - start_bits[c] |= ~cd->cbits[c + *tcode * 32]; - break; - - case OP_TYPE: - tcode++; - try_next = FALSE; - REPEATTYPE: - if (!*tcode) - return FALSE; - - for (c = 0; c < 32; c++) - start_bits[c] |= cd->cbits[c + *tcode * 32]; - break; - - /* One or more character type fudges the pointer and restarts. */ - - case OP_TYPEEXACT: - tcode += 2; - - case OP_TYPE_MAXPLUS: - case OP_TYPE_MINPLUS: - case OP_TYPE_ONCEPLUS: - tcode++; - try_next = FALSE; - goto REPEATTYPE; - - /* Zero or more repeats of character types set the bits and then - try again. */ - - case OP_TYPE_MAXUPTO: - case OP_TYPE_MINUPTO: - case OP_TYPE_ONCEUPTO: - tcode += 2; /* Fall through */ - - case OP_TYPE_MAXSTAR: - case OP_TYPE_MINSTAR: - case OP_TYPE_ONCESTAR: - case OP_TYPE_MAXQUERY: - case OP_TYPE_MINQUERY: - case OP_TYPE_ONCEQUERY: - tcode++; - goto REPEATTYPE; - break; - - /* One or more character type fudges the pointer and restarts. */ - - case OP_TYPENOTEXACT: - tcode += 2; /* Fall through */ - - case OP_TYPENOT_MAXPLUS: - case OP_TYPENOT_MINPLUS: - case OP_TYPENOT_ONCEPLUS: - try_next = FALSE; - goto REPEATTYPENOT; - - case OP_TYPENOT_MAXUPTO: - case OP_TYPENOT_MINUPTO: - case OP_TYPENOT_ONCEUPTO: - tcode += 2; /* Fall through */ - - case OP_TYPENOT_MAXSTAR: - case OP_TYPENOT_MINSTAR: - case OP_TYPENOT_ONCESTAR: - case OP_TYPENOT_MAXQUERY: - case OP_TYPENOT_MINQUERY: - case OP_TYPENOT_ONCEQUERY: - tcode++; - goto REPEATTYPENOT; - - /* Character class: set the bits and either carry on or not, - according to the repeat count. */ - - case OP_CLASS: - case OP_CL_MAXSTAR: - case OP_CL_MINSTAR: - case OP_CL_ONCESTAR: - case OP_CL_MAXPLUS: - case OP_CL_MINPLUS: - case OP_CL_ONCEPLUS: - case OP_CL_MAXQUERY: - case OP_CL_MINQUERY: - case OP_CL_ONCEQUERY: - case OP_CL_MAXRANGE: - case OP_CL_MINRANGE: - case OP_CL_ONCERANGE: - { - tcode++; - for (c = 0; c < 32; c++) - start_bits[c] |= tcode[c]; - tcode += 32; - switch (tcode[-33]) - { - case OP_CL_MAXSTAR: - case OP_CL_MINSTAR: - case OP_CL_ONCESTAR: - case OP_CL_MAXQUERY: - case OP_CL_MINQUERY: - case OP_CL_ONCEQUERY: - break; - - case OP_CL_MAXRANGE: - case OP_CL_MINRANGE: - case OP_CL_ONCERANGE: - if (((tcode[1] << 8) + tcode[2]) == 0) - tcode += 4; - else - try_next = FALSE; - break; - } - } - break; /* End of class handling */ - - } /* End of switch */ + } /* End of switch */ } /* End of try_next loop */ + while (try_next); code += (code[1] << 8) + code[2]; /* Advance to next branch */ }