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
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;
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.
&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))