From 792c5a2882e226046cbc83b69b7d16ad20edb038 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 5 Feb 2024 07:42:01 -0600 Subject: [PATCH] Fix TEST_HOST for wc, adding "utf8locale" function. --- scripts/runtest.sh | 10 ++++++++++ tests/wc.test | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/runtest.sh b/scripts/runtest.sh index 8992c8f7..1289d4c6 100644 --- a/scripts/runtest.sh +++ b/scripts/runtest.sh @@ -165,6 +165,16 @@ testcmd() testing "${1:-$CMDNAME $2}" "\"$C\" $2" "$3" "$4" "$5" } +utf8locale() +{ + local i + + for i in $LC_ALL C.UTF-8 en_US.UTF-8 + do + [ "$(LC_ALL=$i locale charmap 2>/dev/null)" == UTF-8 ] && LC_ALL=$i && break + done +} + # Simple implementation of "expect" written in shell. # txpect NAME COMMAND [I/O/E/X/R[OE]string]... diff --git a/tests/wc.test b/tests/wc.test index 4ab03868..66cf48be 100755 --- a/tests/wc.test +++ b/tests/wc.test @@ -4,6 +4,8 @@ #testing "name" "command" "result" "infile" "stdin" +utf8locale + cat >file1 <> file1; d testing "-m" "wc -m file1" "8193 file1\n" "" "" testing "-m 2" 'cat "$FILES/utf8/test2.txt" | wc -m' "169\n" "" "" echo -n " " > file1 -testing "-mlw" "wc -mlw input" "1 2 11 input\n" "hello, 世界!\n" "" +NOSPACE=1 testing "-mlw" "wc -mlw input" "1 2 11 input\n" "hello, 世界!\n" "" rm file1 -- 2.39.2