]> Savannah Git Hosting - gnulib.git/commitdiff
dfa: fix bug with ‘.’ and UTF-8 Hangul Syllables
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 14 May 2022 06:23:35 +0000 (23:23 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 14 May 2022 06:25:43 +0000 (23:25 -0700)
This fixes a bug introduced in 2019-12-18T05:41:27Z!eggert@cs.ucla.edu,
an earlier patch that fixed dfa.c to not match invalid UTF-8.
Unfortunately that patch had a couple of typos when dfa.c is
matching against the regular expression ‘.’ (dot).  One typo
caused dfa.c to incorrectly reject the valid UTF-8 sequences
(ED)(90-9F)(80-BF) corresponding to U+D400 through U+D7FF, which
are some Hangul Syllables and Hangul Jamo Extended-B.  The other
typo caused dfa.c to incorrectly reject the valid sequences
(F4)(88-8F)(80-BF)(80-BF) which correspond to U+108000 through
U+10FFFF (Supplemental Private Use Area plane B).
* lib/dfa.c (utf8_classes): Fix typos.
* tests/test-dfa-match.sh: Test the fix.

ChangeLog
lib/dfa.c
tests/test-dfa-match.sh

index 6ed8a507357232c7826d50b8d3689e97eac6858f..fe26d376186df7cfdfa8625afa5c45aab2ff070a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2022-05-13  Paul Eggert  <eggert@cs.ucla.edu>
+
+       dfa: fix bug with ‘.’ and UTF-8 Hangul Syllables
+       This fixes a bug introduced in 2019-12-18T05:41:27Z!eggert@cs.ucla.edu,
+       an earlier patch that fixed dfa.c to not match invalid UTF-8.
+       Unfortunately that patch had a couple of typos when dfa.c is
+       matching against the regular expression ‘.’ (dot).  One typo
+       caused dfa.c to incorrectly reject the valid UTF-8 sequences
+       (ED)(90-9F)(80-BF) corresponding to U+D400 through U+D7FF, which
+       are some Hangul Syllables and Hangul Jamo Extended-B.  The other
+       typo caused dfa.c to incorrectly reject the valid sequences
+       (F4)(88-8F)(80-BF)(80-BF) which correspond to U+108000 through
+       U+10FFFF (Supplemental Private Use Area plane B).
+       * lib/dfa.c (utf8_classes): Fix typos.
+       * tests/test-dfa-match.sh: Test the fix.
+
 2022-05-12  Paul Eggert  <eggert@cs.ucla.edu>
 
        manywarnings: update C warnings for GCC 12
index a27d096f735758496f535221169f7e7e618f8f1d..e88fabb442e6146d8534322362dd7f17bcf21d68 100644 (file)
--- a/lib/dfa.c
+++ b/lib/dfa.c
@@ -1704,7 +1704,7 @@ add_utf8_anychar (struct dfa *dfa)
     /* G. ed (just a token).  */
 
     /* H. 80-9f: 2nd byte of a "GHC" sequence.  */
-    CHARCLASS_INIT (0, 0, 0, 0, 0xffff, 0, 0, 0),
+    CHARCLASS_INIT (0, 0, 0, 0, 0xffffffff, 0, 0, 0),
 
     /* I. f0 (just a token).  */
 
@@ -1717,7 +1717,7 @@ add_utf8_anychar (struct dfa *dfa)
     /* L. f4 (just a token).  */
 
     /* M. 80-8f: 2nd byte of a "LMCC" sequence.  */
-    CHARCLASS_INIT (0, 0, 0, 0, 0xff, 0, 0, 0),
+    CHARCLASS_INIT (0, 0, 0, 0, 0xffff, 0, 0, 0),
   };
 
   /* Define the character classes that are needed below.  */
index b23851b8c05ed7a257c99013f08eab9fa34267be..4561584c4c4bfe30612e24f1bd163556aaf9db6f 100755 (executable)
@@ -42,4 +42,15 @@ in=$(printf "bb\nbb")
 $timeout_10 ${CHECKER} test-dfa-match-aux a "$in" 1 > out || fail=1
 compare /dev/null out || fail=1
 
+# If the platform supports U+00E9 LATIN SMALL LETTER E WITH ACUTE,
+# test U+D45C HANGUL SYLLABLE PYO.
+U_00E9=$(printf '\303\251\n')
+U_D45C=$(printf '\355\221\234\n')
+if testout=$(LC_ALL=en_US.UTF-8 $CHECKER test-dfa-match-aux '^.$' "$U_00E9") &&
+   test "$testout" = 2
+then
+  testout=$(LC_ALL=en_US.UTF-8 $CHECKER test-dfa-match-aux '^.$' "$U_D45C") &&
+  test "$testout" = 3 || fail=1
+fi
+
 Exit $fail