tests: More character encoding issues on command line.
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 2 Aug 2020 21:26:31 +0000 (21:26 +0000)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 2 Aug 2020 22:48:27 +0000 (22:48 +0000)
Unix-like systems don't have a command-line encoding, so we can pass
whatever bytes we want.  mingw uses some particular encoding for
command line arguments, so this screws up trying to pass UTF-8 in.  This
commit side-steps the problem by passing only ASCII characters on the
command line and making the test program decode the bytes.

This fixes several test failures under mingw.

tests/language/lexer/command-name-test.c
tests/language/lexer/command-name.at

index d63b8a20abca85ca303292a627bb9a4634a5234a..59a00f1ea44c8b795b3c0adff8b93c7fc1309a5b 100644 (file)
@@ -118,6 +118,17 @@ parse_options (int argc, char **argv)
 
     }
 
 
     }
 
+  for (int i = optind; i < argc; i++)
+    {
+      /* Replace ++ by nonbreaking space in UTF-8. */
+      for (char *p = argv[i]; *p != '\0'; p++)
+        if (p[0] == '+' && p[1] == '+')
+          {
+            p[0] = 0xc2;
+            p[1] = 0xa0;
+          }
+    }
+
   for (breakpoint = optind; ; breakpoint++)
     if (breakpoint >= argc)
       error (1, 0, "missing ',' on command line; use --help for help");
   for (breakpoint = optind; ; breakpoint++)
     if (breakpoint >= argc)
       error (1, 0, "missing ',' on command line; use --help for help");
index 50da596d94e598981ad17f68e075cde2e9422dfd..395aa05cc5210b81157e21b7f5d760ee22e6e474 100644 (file)
@@ -18,7 +18,7 @@ AT_BANNER([command name matching])
 \f
 AT_SETUP([single words])
 AT_KEYWORDS([command name matching])
 \f
 AT_SETUP([single words])
 AT_KEYWORDS([command name matching])
-AT_CHECK([command-name-test DESCRIPTIVES , DESCRIPTIVESX DESCRIPTIVES descr Des DEX DE '' 'DESCRIPTIVES MORE' 'DESCRIPTIVES@<00A0>@MORE'],
+AT_CHECK([command-name-test DESCRIPTIVES , DESCRIPTIVESX DESCRIPTIVES descr Des DEX DE '' 'DESCRIPTIVES MORE' 'DESCRIPTIVES++MORE'],
   [0], [dnl
 string="DESCRIPTIVESX":
        command="DESCRIPTIVES" match=no
   [0], [dnl
 string="DESCRIPTIVESX":
        command="DESCRIPTIVES" match=no
@@ -60,7 +60,7 @@ AT_CLEANUP
 \f
 AT_SETUP([two words without prefix match])
 AT_KEYWORDS([command name matching])
 \f
 AT_SETUP([two words without prefix match])
 AT_KEYWORDS([command name matching])
-AT_CHECK([command-name-test 'DO IF' 'DO REPEAT' , 'DO@<00A0>@IF' 'DO REPEAT' 'DO REP' 'DO OTHER' 'D IF' 'DO I' DO],
+AT_CHECK([command-name-test 'DO IF' 'DO REPEAT' , 'DO++IF' 'DO REPEAT' 'DO REP' 'DO OTHER' 'D IF' 'DO I' DO],
   [0], [dnl
 string="DO@<00A0>@IF":
        command="DO IF" match=yes exact=yes missing_words=0
   [0], [dnl
 string="DO@<00A0>@IF":
        command="DO IF" match=yes exact=yes missing_words=0
@@ -153,7 +153,7 @@ AT_CLEANUP
 
 AT_SETUP([ambiguous two-word names])
 AT_KEYWORDS([command name matching])
 
 AT_SETUP([ambiguous two-word names])
 AT_KEYWORDS([command name matching])
-AT_CHECK([command-name-test VARCOMP VARSTOCASES 'VARIABLE ATTRIBUTE' , VAR VARC VARS VARI 'VAR@<00A0>@ATT'],
+AT_CHECK([command-name-test VARCOMP VARSTOCASES 'VARIABLE ATTRIBUTE' , VAR VARC VARS VARI 'VAR++ATT'],
   [0], [dnl
 string="VAR":
        command="VARCOMP" match=yes exact=no missing_words=0
   [0], [dnl
 string="VAR":
        command="VARCOMP" match=yes exact=no missing_words=0
@@ -225,7 +225,7 @@ AT_CLEANUP
 \f
 AT_SETUP([off by more than one word])
 AT_KEYWORDS([command name matching])
 \f
 AT_SETUP([off by more than one word])
 AT_KEYWORDS([command name matching])
-AT_CHECK([command-name-test 'a@<00A0>@b c' , a 'a b' 'a b c' 'a@<00A0>@b c d' 'a b c@<00A0>@d e'],
+AT_CHECK([command-name-test 'a++b c' , a 'a b' 'a b c' 'a++b c d' 'a b c++d e'],
   [0], [dnl
 string="a":
        command="a@<00A0>@b c" match=yes exact=yes missing_words=2
   [0], [dnl
 string="a":
        command="a@<00A0>@b c" match=yes exact=yes missing_words=2