Mercurial > hg > octave-kai > gnulib-hg
changeset 17348:1fff19279ff9
regex: merge patches from libc
2013-02-26 Siddhesh Poyarekar <siddhesh@redhat.com>
* lib/regex_internal.h (__attribute__): Rename from __attribute.
All uses changed.
(bitset_not, bitset_merge, bitset_mask, re_string_char_size_at)
(re_string_wchar_at, re_string_elem_size_at):
Mark function as possibly unused.
2013-02-12 Andreas Schwab <schwab@suse.de> [BZ #11561]
* lib/regcomp.c (parse_bracket_exp) [_LIBC]: When looking up collating
elements compare against the byte sequence of it, not its name.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Mon, 25 Feb 2013 22:56:12 -0800 |
parents | cec099cbf54f |
children | abc852025ecf |
files | ChangeLog lib/regcomp.c lib/regex_internal.h |
diffstat | 3 files changed, 53 insertions(+), 58 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2013-02-25 Paul Eggert <eggert@cs.ucla.edu> + + regex: merge patches from libc + + 2013-02-26 Siddhesh Poyarekar <siddhesh@redhat.com> + * lib/regex_internal.h (__attribute__): Rename from __attribute. + All uses changed. + (bitset_not, bitset_merge, bitset_mask, re_string_char_size_at) + (re_string_wchar_at, re_string_elem_size_at): + Mark function as possibly unused. + + 2013-02-12 Andreas Schwab <schwab@suse.de> [BZ #11561] + * lib/regcomp.c (parse_bracket_exp) [_LIBC]: When looking up collating + elements compare against the byte sequence of it, not its name. + 2013-02-21 Paul Eggert <eggert@cs.ucla.edu> putenv: port better to native Windows @@ -249,7 +264,7 @@ 2013-01-29 Andreas Schwab <schwab@suse.de> - regex: fix buffer overrun in regexp matcher + regex: fix buffer overrun in regexp matcher [BZ #15078] * lib/regexec.c (extend_buffers): Add parameter min_len. (check_matching): Pass minimum needed length. (clean_state_log_if_needed): Likewise.
--- a/lib/regcomp.c +++ b/lib/regcomp.c @@ -2835,40 +2835,29 @@ /* Local function for parse_bracket_exp used in _LIBC environment. Seek the collating symbol entry corresponding to NAME. - Return the index of the symbol in the SYMB_TABLE. */ + Return the index of the symbol in the SYMB_TABLE, + or -1 if not found. */ auto inline int32_t __attribute ((always_inline)) - seek_collating_symbol_entry (name, name_len) - const unsigned char *name; - size_t name_len; + seek_collating_symbol_entry (const unsigned char *name, size_t name_len) { - int32_t hash = elem_hash ((const char *) name, name_len); - int32_t elem = hash % table_size; - if (symb_table[2 * elem] != 0) - { - int32_t second = hash % (table_size - 2) + 1; - - do - { - /* First compare the hashing value. */ - if (symb_table[2 * elem] == hash - /* Compare the length of the name. */ - && name_len == extra[symb_table[2 * elem + 1]] - /* Compare the name. */ - && memcmp (name, &extra[symb_table[2 * elem + 1] + 1], - name_len) == 0) - { - /* Yep, this is the entry. */ - break; - } - - /* Next entry. */ - elem += second; - } - while (symb_table[2 * elem] != 0); - } - return elem; + int32_t elem; + + for (elem = 0; elem < table_size; elem++) + if (symb_table[2 * elem] != 0) + { + int32_t idx = symb_table[2 * elem + 1]; + /* Skip the name of collating element name. */ + idx += 1 + extra[idx]; + if (/* Compare the length of the name. */ + name_len == extra[idx] + /* Compare the name. */ + && memcmp (name, &extra[idx + 1], name_len) == 0) + /* Yep, this is the entry. */ + return elem; + } + return -1; } /* Local function for parse_bracket_exp used in _LIBC environment. @@ -2877,8 +2866,7 @@ auto inline unsigned int __attribute ((always_inline)) - lookup_collation_sequence_value (br_elem) - bracket_elem_t *br_elem; + lookup_collation_sequence_value (bracket_elem_t *br_elem) { if (br_elem->type == SB_CHAR) { @@ -2906,7 +2894,7 @@ int32_t elem, idx; elem = seek_collating_symbol_entry (br_elem->opr.name, sym_name_len); - if (symb_table[2 * elem] != 0) + if (elem != -1) { /* We found the entry. */ idx = symb_table[2 * elem + 1]; @@ -2924,7 +2912,7 @@ /* Return the collation sequence value. */ return *(unsigned int *) (extra + idx); } - else if (symb_table[2 * elem] == 0 && sym_name_len == 1) + else if (sym_name_len == 1) { /* No valid character. Match it as a single byte character. */ @@ -2946,11 +2934,8 @@ auto inline reg_errcode_t __attribute ((always_inline)) - build_range_exp (sbcset, mbcset, range_alloc, start_elem, end_elem) - re_charset_t *mbcset; - Idx *range_alloc; - bitset_t sbcset; - bracket_elem_t *start_elem, *end_elem; + build_range_exp (bitset_t sbcset, re_charset_t *mbcset, int *range_alloc, + bracket_elem_t *start_elem, bracket_elem_t *end_elem) { unsigned int ch; uint32_t start_collseq; @@ -3030,25 +3015,22 @@ auto inline reg_errcode_t __attribute ((always_inline)) - build_collating_symbol (sbcset, mbcset, coll_sym_alloc, name) - re_charset_t *mbcset; - Idx *coll_sym_alloc; - bitset_t sbcset; - const unsigned char *name; + build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset, + Idx *coll_sym_alloc, const unsigned char *name) { int32_t elem, idx; size_t name_len = strlen ((const char *) name); if (nrules != 0) { elem = seek_collating_symbol_entry (name, name_len); - if (symb_table[2 * elem] != 0) + if (elem != -1) { /* We found the entry. */ idx = symb_table[2 * elem + 1]; /* Skip the name of collating element name. */ idx += 1 + extra[idx]; } - else if (symb_table[2 * elem] == 0 && name_len == 1) + else if (name_len == 1) { /* No valid character, treat it as a normal character. */
--- a/lib/regex_internal.h +++ b/lib/regex_internal.h @@ -107,10 +107,8 @@ # define attribute_hidden #endif /* not _LIBC */ -#if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) -# define __attribute(arg) __attribute__ (arg) -#else -# define __attribute(arg) +#if __GNUC__ < 3 + (__GNUC_MINOR__ < 1) +# define __attribute__(arg) #endif typedef __re_idx_t Idx; @@ -426,7 +424,7 @@ static void re_string_translate_buffer (re_string_t *pstr) internal_function; static unsigned int re_string_context_at (const re_string_t *input, Idx idx, int eflags) - internal_function __attribute ((pure)); + internal_function __attribute__ ((pure)); #endif #define re_string_peek_byte(pstr, offset) \ ((pstr)->mbs[(pstr)->cur_idx + offset]) @@ -774,7 +772,7 @@ memcpy (dest, src, sizeof (bitset_t)); } -static void +static void __attribute__ ((unused)) bitset_not (bitset_t set) { int bitset_i; @@ -786,7 +784,7 @@ & ~set[BITSET_WORDS - 1]); } -static void +static void __attribute__ ((unused)) bitset_merge (bitset_t dest, const bitset_t src) { int bitset_i; @@ -794,7 +792,7 @@ dest[bitset_i] |= src[bitset_i]; } -static void +static void __attribute__ ((unused)) bitset_mask (bitset_t dest, const bitset_t src) { int bitset_i; @@ -805,7 +803,7 @@ #ifdef RE_ENABLE_I18N /* Functions for re_string. */ static int -internal_function __attribute ((pure)) +internal_function __attribute__ ((pure, unused)) re_string_char_size_at (const re_string_t *pstr, Idx idx) { int byte_idx; @@ -818,7 +816,7 @@ } static wint_t -internal_function __attribute ((pure)) +internal_function __attribute__ ((pure, unused)) re_string_wchar_at (const re_string_t *pstr, Idx idx) { if (pstr->mb_cur_max == 1) @@ -828,7 +826,7 @@ # ifndef NOT_IN_libc static int -internal_function __attribute ((pure)) +internal_function __attribute__ ((pure, unused)) re_string_elem_size_at (const re_string_t *pstr, Idx idx) { # ifdef _LIBC