Il 27/04/2012 11:07, Aharon Robbins ha scritto: > From 5c7665f2ced46d2e830958bce1bf46469995d3de Mon Sep 17 00:00:00 2001 > From: Arnold D. Robbins <arn...@skeeve.com> > Date: Fri, 27 Apr 2012 12:04:22 +0300 > Subject: [PATCH] Implement Rational Range Interpretation in Gnulib. > > --- > lib/regcomp.c | 13 +++---------- > lib/regexec.c | 12 ++---------- > 2 files changed, 5 insertions(+), 20 deletions(-) > > diff --git a/lib/regcomp.c b/lib/regcomp.c > index b51a9a6..7748535 100644 > --- a/lib/regcomp.c > +++ b/lib/regcomp.c > @@ -2702,7 +2702,6 @@ build_range_exp (const reg_syntax_t syntax, > wchar_t wc; > wint_t start_wc; > wint_t end_wc; > - wchar_t cmp_buf[6] = {L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'}; > > start_ch = ((start_elem->type == SB_CHAR) ? start_elem->opr.ch > : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0] > @@ -2716,11 +2715,7 @@ build_range_exp (const reg_syntax_t syntax, > ? __btowc (end_ch) : end_elem->opr.wch); > if (start_wc == WEOF || end_wc == WEOF) > return REG_ECOLLATE; > - cmp_buf[0] = start_wc; > - cmp_buf[4] = end_wc; > - > - if (BE ((syntax & RE_NO_EMPTY_RANGES) > - && wcscoll (cmp_buf, cmp_buf + 4) > 0, 0)) > + else if ((syntax & RE_NO_EMPTY_RANGES) && start_wc > end_wc) > return REG_ERANGE; > > /* Got valid collation sequence values, add them as a new entry. > @@ -2761,10 +2756,8 @@ build_range_exp (const reg_syntax_t syntax, > /* Build the table for single byte characters. */ > for (wc = 0; wc < SBC_MAX; ++wc) > { > - cmp_buf[2] = wc; > - if (wcscoll (cmp_buf, cmp_buf + 2) <= 0 > - && wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0) > - bitset_set (sbcset, wc); > + if (start_wc <= wc && wc <= end_wc) > + bitset_set (sbcset, wc); > } > } > # else /* not RE_ENABLE_I18N */ > diff --git a/lib/regexec.c b/lib/regexec.c > index 92efb44..5a6a0dc 100644 > --- a/lib/regexec.c > +++ b/lib/regexec.c > @@ -3986,18 +3986,10 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx > node_idx, > # endif /* _LIBC */ > { > /* match with range expression? */ > -#if __GNUC__ >= 2 && ! (__STDC_VERSION__ < 199901L && defined > __STRICT_ANSI__) > - wchar_t cmp_buf[] = {L'\0', L'\0', wc, L'\0', L'\0', L'\0'}; > -#else > - wchar_t cmp_buf[] = {L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'}; > - cmp_buf[2] = wc; > -#endif > for (i = 0; i < cset->nranges; ++i) > { > - cmp_buf[0] = cset->range_starts[i]; > - cmp_buf[4] = cset->range_ends[i]; > - if (wcscoll (cmp_buf, cmp_buf + 2) <= 0 > - && wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0) > + if (cset->range_starts[i] <= wc > + && wc <= cset->range_ends[i]) > { > match_len = char_len; > goto check_node_accept_bytes_match; > -- 1.7.1
These look good. Paolo