>From a971cd4ff713a7d9b845adaf3ae2fd1bf1a7e458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Sat, 9 Mar 2019 20:40:34 -0800 Subject: [PATCH] tests: wc-nbsp: fix false failures on various systems * tests/misc/wc-nbsp.sh: Add gating checks for all characters, as there are disparate classifications on various systems: SunOS 5.10 treats \u202F, \u2060 as !iswprint() SunOS 5.10 treats \u00A0, \u2007 as iswspace() AIX 7.2, Darwin 17.4.0, NetBSD 7.1 treat \u2060 as !iswprint() --- tests/misc/wc-nbsp.sh | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/tests/misc/wc-nbsp.sh b/tests/misc/wc-nbsp.sh index aca971c..65cdc8a 100755 --- a/tests/misc/wc-nbsp.sh +++ b/tests/misc/wc-nbsp.sh @@ -22,29 +22,31 @@ print_ver_ wc printf # Before coreutils 8.31 nbsp was treated as part of a word, # rather than a word delimiter -export LC_ALL=en_US.ISO-8859-1 -if test "$(locale charmap 2>/dev/null)" = ISO-8859-1; then +check_word_sep() { + char="$1" # Use -L to determine whether NBSP is printable. # FreeBSD 11 and OS X treat NBSP as non printable ? - if test "$(env printf '=\xA0=' | wc -L)" = 3; then - test $(env printf '=\xA0=' | wc -w) = 2 || fail=1 - test $(env printf '=\xA0=' | POSIXLY_CORRECT=1 wc -w) = 1 || fail=1 + if test "$(env printf "=$char=" | wc -L)" = 3; then + test $(env printf "=$char=" | wc -w) = 2 || fail=1 fi +} + +export LC_ALL=en_US.ISO-8859-1 +if test "$(locale charmap 2>/dev/null)" = ISO-8859-1; then + check_word_sep '\xA0' fi + export LC_ALL=en_US.UTF-8 if test "$(locale charmap 2>/dev/null)" = UTF-8; then - if test "$(env printf '=\u00A0=' | wc -L)" = 3; then - test $(env printf '=\u00A0=' | wc -w) = 2 || fail=1 - test $(env printf '=\u2007=' | wc -w) = 2 || fail=1 - test $(env printf '=\u202F=' | wc -w) = 2 || fail=1 - test $(env printf '=\u2060=' | wc -w) = 2 || fail=1 - fi + check_word_sep '\u00A0' + check_word_sep '\u2007' + check_word_sep '\u202F' + check_word_sep '\u2060' fi + export LC_ALL=ru_RU.KOI8-R if test "$(locale charmap 2>/dev/null)" = KOI8-R; then - if test "$(env printf '=\x9A=' | wc -L)" = 3; then - test $(env printf '=\x9A=' | wc -w) = 2 || fail=1 - fi + check_word_sep '\x9A' fi Exit $fail -- 2.9.3