From: Ben Pfaff <blp@cs.stanford.edu>
Date: Sun, 2 Aug 2020 21:26:31 +0000 (+0000)
Subject: tests: More character encoding issues on command line.
X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd1c414d08fcfa3ff569a9d29611e6db041a6afb;p=pspp

tests: More character encoding issues on command line.

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.
---

diff --git a/tests/language/lexer/command-name-test.c b/tests/language/lexer/command-name-test.c
index d63b8a20ab..59a00f1ea4 100644
--- a/tests/language/lexer/command-name-test.c
+++ b/tests/language/lexer/command-name-test.c
@@ -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");
diff --git a/tests/language/lexer/command-name.at b/tests/language/lexer/command-name.at
index 50da596d94..395aa05cc5 100644
--- a/tests/language/lexer/command-name.at
+++ b/tests/language/lexer/command-name.at
@@ -18,7 +18,7 @@ AT_BANNER([command name matching])
 
 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
@@ -60,7 +60,7 @@ AT_CLEANUP
 
 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
@@ -153,7 +153,7 @@ AT_CLEANUP
 
 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
@@ -225,7 +225,7 @@ AT_CLEANUP
 
 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