Mercurial > hg > octave-lyh > gnulib-hg
changeset 13014:6240e99d3e0c
regcomp.c: make non-_LIBC implementation of build_range_exp consistent
The _LIBC implementation of build_range_exp correctly honors the
RE_NO_EMPTY_RANGES flag when checking for reversed range endpoints.
However, the non-_LIBC implementation would ignore that syntax-bit
flag and return REG_ERANGE unconditionally.
This change makes it honor that flag.
* lib/regcomp.c (build_range_exp) [!_LIBC]: Add a parameter: "syntax".
Make two pointer parameters "const".
Use "syntax" bits in order to honor RE_NO_EMPTY_RANGES.
(parse_bracket_exp): Update caller.
author | Jim Meyering <meyering@redhat.com> |
---|---|
date | Fri, 19 Mar 2010 21:26:36 +0100 |
parents | 91cd971b278e |
children | cf6badcbf27b |
files | ChangeLog lib/regcomp.c |
diffstat | 2 files changed, 26 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2010-03-19 Jim Meyering <meyering@redhat.com> + regcomp.c: make non-_LIBC implementation of build_range_exp consistent + The _LIBC implementation of build_range_exp correctly honors the + RE_NO_EMPTY_RANGES flag when checking for reversed range endpoints. + However, the non-_LIBC implementation would ignore that syntax-bit + flag and return REG_ERANGE unconditionally. + This change makes it honor that flag. + * lib/regcomp.c (build_range_exp) [!_LIBC]: Add a parameter: "syntax". + Make two pointer parameters "const". + Use "syntax" bits in order to honor RE_NO_EMPTY_RANGES. + (parse_bracket_exp): Update caller. + regex.m4: correct the reversed range endpoint ([b-a]) test * m4/regex.m4: When requiring that [b-a] evoke failure, use RE_NO_EMPTY_RANGES. This makes this entire configure-time
--- a/lib/regcomp.c +++ b/lib/regcomp.c @@ -2622,11 +2622,17 @@ static reg_errcode_t internal_function # ifdef RE_ENABLE_I18N -build_range_exp (bitset_t sbcset, re_charset_t *mbcset, Idx *range_alloc, - bracket_elem_t *start_elem, bracket_elem_t *end_elem) +build_range_exp (const reg_syntax_t syntax, + bitset_t sbcset, + re_charset_t *mbcset, + Idx *range_alloc, + const bracket_elem_t *start_elem, + const bracket_elem_t *end_elem) # else /* not RE_ENABLE_I18N */ -build_range_exp (bitset_t sbcset, bracket_elem_t *start_elem, - bracket_elem_t *end_elem) +build_range_exp (const reg_syntax_t syntax, + bitset_t sbcset, + const bracket_elem_t *start_elem, + const bracket_elem_t *end_elem) # endif /* not RE_ENABLE_I18N */ { unsigned int start_ch, end_ch; @@ -2665,7 +2671,9 @@ return REG_ECOLLATE; cmp_buf[0] = start_wc; cmp_buf[4] = end_wc; - if (wcscoll (cmp_buf, cmp_buf + 4) > 0) + + if (BE ((syntax & RE_NO_EMPTY_RANGES) + && wcscoll (cmp_buf, cmp_buf + 4) > 0, 0)) return REG_ERANGE; /* Got valid collation sequence values, add them as a new entry. @@ -3168,11 +3176,11 @@ &start_elem, &end_elem); #else # ifdef RE_ENABLE_I18N - *err = build_range_exp (sbcset, + *err = build_range_exp (syntax, sbcset, dfa->mb_cur_max > 1 ? mbcset : NULL, &range_alloc, &start_elem, &end_elem); # else - *err = build_range_exp (sbcset, &start_elem, &end_elem); + *err = build_range_exp (syntax, sbcset, &start_elem, &end_elem); # endif #endif /* RE_ENABLE_I18N */ if (BE (*err != REG_NOERROR, 0))