]> Savannah Git Hosting - gnulib.git/commitdiff
dfa: do not match middle of multibyte character
authorNorihiro Tanaka <noritnk@kcn.ne.jp>
Mon, 28 Nov 2016 13:26:07 +0000 (22:26 +0900)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 28 Nov 2016 16:38:26 +0000 (08:38 -0800)
* lib/dfa.c (transit_state): If it fails in matching a single byte
character in a state including a period expression in a non-UTF8
multibyte locale, skip the trailing bytes.
(dfa_supported): Revert previous change.

ChangeLog
lib/dfa.c

index fec4fb953cb0b4043e59f0fa42c5f6b5e8f43c0d..fd062aee7d566515e71df9c012ee3e94208980f4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2016-11-27  Norihiro Tanaka <noritnk@kcn.ne.jp>
+
+        dfa: avoid match middle in multibyte character
+        * lib/dfa.c (transit_state): If fails in matching single byte characters
+        on a state including period expression in non-UTF8 multibyte locales,
+        skip trailing bytes.
+        (dfa_supported): Revert previous change.
+
 2016-11-27  Jim Meyering  <meyering@fb.com>
 
        dfa: avoid false match in non-UTF8 multibyte locales
index f0ed139d3d3434ce1782ac514b5e881287e7f545..673ef95d4c509053804c3404f74bb92aee50c54c 100644 (file)
--- a/lib/dfa.c
+++ b/lib/dfa.c
@@ -2913,7 +2913,7 @@ transit_state (struct dfa *d, state_num s, unsigned char const **pp,
   /* Calculate the state which can be reached from the state 's' by
      consuming 'mbclen' single bytes from the buffer.  */
   s1 = s;
-  for (i = 0; i < mbclen && 0 <= s; i++)
+  for (i = 0; i < mbclen && (i == 0 || d->min_trcount <= s); i++)
     s = transit_state_singlebyte (d, s, pp);
   *pp += mbclen - i;
 
@@ -3272,12 +3272,6 @@ free_mbdata (struct dfa *d)
 static bool _GL_ATTRIBUTE_PURE
 dfa_supported (struct dfa const *d)
 {
-  /* Declare any non-UTF8 multibyte locale "not supported."  Otherwise, a
-     regexp like ".*7" would mistakenly match \uC9, e.g., via this command:
-     (export LC_ALL=zh_CN.gb18030; printf '\uC9\n' | grep '.*7')  */
-  if (d->localeinfo.multibyte && !d->localeinfo.using_utf8)
-    return false;
-
   size_t i;
   for (i = 0; i < d->tindex; i++)
     {