]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: wc-nbsp: fix false failures on various systems
authorPádraig Brady <P@draigBrady.com>
Sun, 10 Mar 2019 04:40:34 +0000 (20:40 -0800)
committerPádraig Brady <P@draigBrady.com>
Sun, 10 Mar 2019 04:59:21 +0000 (20:59 -0800)
* 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

index aca971cd8790e9bf3840e595dae94e2a01b129f1..65cdc8a3138828f403010e87f6e97b244bcd7621 100755 (executable)
@@ -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