bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/4] dfa: do not use strcoll to match multibyte characters in ran


From: Paolo Bonzini
Subject: [PATCH 2/4] dfa: do not use strcoll to match multibyte characters in ranges
Date: Fri, 27 Apr 2012 14:24:55 +0200

From: Aharon Robbins <address@hidden>

This does not affect the behavior of grep, which always defers
to glibc or gnulib when matching ranges.
* src/dfa.c (match_mb_charset): Compare wc directly to the range
endpoints.
---
 src/dfa.c |   10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/src/dfa.c b/src/dfa.c
index b7b8e02..39ca604 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -2967,7 +2967,6 @@ match_mb_charset (struct dfa *d, state_num s, position 
pos, size_t idx)
                                    with which this operator match.  */
   int op_len;                   /* Length of the operator.  */
   char buffer[128];
-  wchar_t wcbuf[6];
 
   /* Pointer to the structure to which we are currently referring.  */
   struct mb_char_classes *work_mbc;
@@ -3040,16 +3039,11 @@ match_mb_charset (struct dfa *d, state_num s, position 
pos, size_t idx)
         }
     }
 
-  wcbuf[0] = wc;
-  wcbuf[1] = wcbuf[3] = wcbuf[5] = '\0';
-
   /* match with a range?  */
   for (i = 0; i < work_mbc->nranges; i++)
     {
-      wcbuf[2] = work_mbc->range_sts[i];
-      wcbuf[4] = work_mbc->range_ends[i];
-
-      if (wcscoll (wcbuf, wcbuf + 2) >= 0 && wcscoll (wcbuf + 4, wcbuf) >= 0)
+      if (work_mbc->range_sts[i] <= wc &&
+          wc <= work_mbc->range_ends[i])
         goto charset_matched;
     }
 
-- 
1.7.9.3





reply via email to

[Prev in Thread] Current Thread [Next in Thread]