]> git.draconx.ca Git - dxcommon.git/commitdiff
help: Fix NLS test on HP-UX 11.
authorNick Bowler <nbowler@draconx.ca>
Fri, 17 Nov 2023 05:28:11 +0000 (00:28 -0500)
committerNick Bowler <nbowler@draconx.ca>
Sat, 18 Nov 2023 21:39:55 +0000 (16:39 -0500)
This system has a "C.utf8" locale which appears disfunctional, all
other utf8 locales are OK.  So change the locale probe to avoid this
one if possible.

The HP-UX shell also seems to have some trouble with UTF-8 (especially
if the user set this C.utf8 locale where it just barfs on everything),
so rework the test to not involve the shell trying to decode strings.

snippet/test-nls.at
tests/functions.at

index 103cb5b715c06ac7e1cfe2f16bf5fa09b09ffeef..c713abb8dd065f5ec14b7a2e8b15d0a42fe59915 100644 (file)
@@ -39,7 +39,8 @@ test_find_locale_charmap '[[Uu][Tt][Ff]-*8]'])
 #   standard output.
 #
 #   By default, the user's own LC_CTYPE is preferred.  Otherwise, the first
-#   match in the output of "locale -a" is chosen.
+#   match in the output of "locale -a" is chosen, unless that starts with
+#   "C" in which case we prefer the next one.
 
 m4_defun_once([_TEST_NLS_SETUP], [m4_divert_push([HEADER-COPYRIGHT])
 # save user locale setting before m4sh clobbers it
@@ -59,19 +60,31 @@ test_find_locale_charmap () {
     $[1] = ""; sub(/^ "/, ""); sub(/"$/, ""); print
   }'`
 
-  LC_ALL=$save_LC_ALL
+  LC_ALL=$save_LC_ALL found_locale=
   if test_check_locale_charmap "$init_ctype" "$re"; then
-    AS_ECHO(["$init_ctype"])
-    return;
+    found_locale=$init_ctype
   fi
 
-  set x `locale -a | grep "$re"`; shift
-  for arg; do
-    if test_check_locale_charmap "$arg" "$re"; then
-      AS_ECHO(["$arg"])
-      return;
-    fi
-  done
+  case $found_locale in
+  C*|"")
+    set x `locale -a | grep "$re"`; shift
+    for arg; do
+      if test_check_locale_charmap "$arg" "$re"; then
+        found_locale=$arg;
+        case $found_locale in
+        C*) :;;
+        *) break ;;
+        esac
+      fi
+    done
+    ;;
+  esac
+
+  test ${found_locale+y} && {
+    AS_ECHO(["found matching locale $found_locale"]) >&AS_MESSAGE_LOG_FD
+    LC_ALL=$found_locale locale >&AS_MESSAGE_LOG_FD 2>&1
+    AS_ECHO(["$found_locale"])
+  }
 }
 m4_divert_pop([PREPARE_TESTS])
 ])
index fd1e10f5588460f36882c766285a5b56759011fa..e1d556b0a71d59e697f14c3701f23b9fb33faa0a 100644 (file)
@@ -116,14 +116,22 @@ AT_KEYWORDS([help nls])
 AT_SKIP_IF([test ! -x "$builddir/t/helpopt3"])
 TEST_UTF8_LOCALE([locale_utf8])
 
-AT_CHECK([m4_join([ ],
-  [LC_ALL=$locale_utf8 "$builddir/t/helpopt3"],
-  [--全角],
-  [--ハンカク],
-  )], [0],
-[[  --全角   8
-  --ハンカク       8
-]])
+# Avoid some deficient shell parsers barfing on UTF-8 sequences by
+# generating them this way using octal escapes.
+$AWK -f - >expout <<'EOF'
+BEGIN {
+  zenkaku = "--\345\205\250\350\247\222";
+  hankaku = "--\357\276\212\357\276\235\357\275\266\357\275\270"
+
+  print zenkaku, hankaku >"args"
+
+  print "  " zenkaku "\t" "8"
+  print "  " hankaku "\t" "8"
+}
+EOF
+
+AT_CHECK([LC_ALL=$locale_utf8 xargs "$builddir/t/helpopt3" <args],
+  [0], [expout])
 
 AT_CLEANUP