X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fregex.c;h=51106c05109b4519fb43c4aa064ab02c143d98b9;hb=49d9742daf6fc7cf638b621ab6066fb1f72cfccc;hp=32c15191158f444a71e62b2970528cb853e5c3b1;hpb=5e576318cdb5628381e4082c3f4a29c1e97f27a8;p=gnulib.git diff --git a/lib/regex.c b/lib/regex.c index 32c151911..51106c051 100644 --- a/lib/regex.c +++ b/lib/regex.c @@ -4,7 +4,7 @@ internationalization features.) Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, - 2002, 2003, 2004 Free Software Foundation, Inc. + 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -583,7 +583,10 @@ typedef enum # undef INSIDE_RECURSION # endif #endif -#include "unlocked-io.h" + +#if USE_UNLOCKED_IO +# include "unlocked-io.h" +#endif #ifdef INSIDE_RECURSION /* Common operations on the compiled pattern. */ @@ -2076,7 +2079,8 @@ static reg_errcode_t byte_compile_range (unsigned int range_start, bufp->allocated <<= 1; \ if (bufp->allocated > MAX_BUF_SIZE) \ bufp->allocated = MAX_BUF_SIZE; \ - bufp->buffer = REALLOC (COMPILED_BUFFER_VAR, bufp->allocated); \ + bufp->buffer \ + = (UCHAR_T *) REALLOC (COMPILED_BUFFER_VAR, bufp->allocated); \ if (COMPILED_BUFFER_VAR == NULL) \ return REG_ESPACE; \ /* If the buffer moved, move all the pointers into it. */ \ @@ -6007,19 +6011,22 @@ byte_re_match_2_internal (struct re_pattern_buffer *bufp, longest match, try backtracking. */ if (d != end_match_2) { - /* 1 if this match ends in the same string (string1 or string2) - as the best previous match. */ - boolean same_str_p = (FIRST_STRING_P (match_end) - == MATCHING_IN_FIRST_STRING); /* 1 if this match is the best seen so far. */ boolean best_match_p; - /* AIX compiler got confused when this was combined - with the previous declaration. */ - if (same_str_p) - best_match_p = d > match_end; - else - best_match_p = !MATCHING_IN_FIRST_STRING; + { + /* 1 if this match ends in the same string (string1 or string2) + as the best previous match. */ + boolean same_str_p = (FIRST_STRING_P (match_end) + == MATCHING_IN_FIRST_STRING); + + /* AIX compiler got confused when this was combined + with the previous declaration. */ + if (same_str_p) + best_match_p = d > match_end; + else + best_match_p = !MATCHING_IN_FIRST_STRING; + } DEBUG_PRINT1 ("backtracking.\n"); @@ -6274,9 +6281,9 @@ byte_re_match_2_internal (struct re_pattern_buffer *bufp, uint32_t nrules; # endif /* _LIBC */ #endif /* WCHAR */ - boolean not = (re_opcode_t) *(p - 1) == charset_not; + boolean negate = (re_opcode_t) *(p - 1) == charset_not; - DEBUG_PRINT2 ("EXECUTING charset%s.\n", not ? "_not" : ""); + DEBUG_PRINT2 ("EXECUTING charset%s.\n", negate ? "_not" : ""); PREFETCH (); c = TRANSLATE (*d); /* The character to match. */ #ifdef WCHAR @@ -6609,20 +6616,20 @@ byte_re_match_2_internal (struct re_pattern_buffer *bufp, if (c == *workp) goto char_set_matched; - not = !not; + negate = !negate; char_set_matched: - if (not) goto fail; + if (negate) goto fail; #else /* Cast to `unsigned' instead of `unsigned char' in case the bit list is a full 32 bytes long. */ if (c < (unsigned) (*p * BYTEWIDTH) && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) - not = !not; + negate = !negate; p += 1 + *p; - if (!not) goto fail; + if (!negate) goto fail; #undef WORK_BUFFER_SIZE #endif /* WCHAR */ SET_REGS_MATCHED (); @@ -7122,15 +7129,15 @@ byte_re_match_2_internal (struct re_pattern_buffer *bufp, else if ((re_opcode_t) p1[3] == charset || (re_opcode_t) p1[3] == charset_not) { - int not = (re_opcode_t) p1[3] == charset_not; + int negate = (re_opcode_t) p1[3] == charset_not; if (c < (unsigned) (p1[4] * BYTEWIDTH) && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) - not = !not; + negate = !negate; - /* `not' is equal to 1 if c would match, which means + /* `negate' is equal to 1 if c would match, which means that we can't change to pop_failure_jump. */ - if (!not) + if (!negate) { p[-3] = (unsigned char) pop_failure_jump; DEBUG_PRINT1 (" No match => pop_failure_jump.\n"); @@ -7906,7 +7913,7 @@ re_comp (const char *s) if (!s) { if (!re_comp_buf.buffer) - return gettext ("No previous regular expression"); + return (char *) gettext ("No previous regular expression"); return 0; } @@ -8011,14 +8018,15 @@ regcomp (regex_t *preg, const char *pattern, int cflags) preg->used = 0; /* Try to allocate space for the fastmap. */ - preg->fastmap = malloc (1 << BYTEWIDTH); + preg->fastmap = (char *) malloc (1 << BYTEWIDTH); if (cflags & REG_ICASE) { unsigned i; - preg->translate = malloc (CHAR_SET_SIZE - * sizeof (*(RE_TRANSLATE_TYPE)0)); + preg->translate = + (RE_TRANSLATE_TYPE) + malloc (CHAR_SET_SIZE * sizeof (*(RE_TRANSLATE_TYPE)0)); if (preg->translate == NULL) return (int) REG_ESPACE;