[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Rational Range Interpretation patches, 3/3
From: |
Aharon Robbins |
Subject: |
Rational Range Interpretation patches, 3/3 |
Date: |
Mon, 16 Jan 2012 22:26:03 +0200 |
User-agent: |
Heirloom mailx 12.4 7/29/08 |
>From 8b8d37d4e4bfae93920d17f7f1c81b8db26fcefd Mon Sep 17 00:00:00 2001
From: Arnold D. Robbins <address@hidden>
Date: Mon, 16 Jan 2012 22:17:58 +0200
Subject: [PATCH] Implement Rational Range Interpretation.
* regcomp.c (build_range_exp): Compare the wide characters
directly instead of using wcscoll.
* regexec.c (check_node_accept_bytes): Ditto.
---
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 3398adb..bf7f9f8 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -2654,7 +2654,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]
@@ -2668,11 +2667,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.
@@ -2713,10 +2708,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 aa8e524..81066c1 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -3985,18 +3985,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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Rational Range Interpretation patches, 3/3,
Aharon Robbins <=