From a181ed9a6778c313dda49b7d7921e4d700bb1d52 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 23 Oct 2013 13:48:57 -0700 Subject: [PATCH] tests: port to bourne shells whose printf doesn't grok hex Use octal escapes, not hex, in printf(1) format strings, and in one case, use $AWK's printf so we can continue to use the table of hex values. * tests/char-class-multibyte: Use printf octal escapes, not hex, for portability to shells like dash and Solaris 10's /bin/sh. * tests/backslash-s-vs-invalid-multitype: Likewise. * tests/surrogate-pair: Likewise. * tests/unibyte-bracket-expr: Count in decimal and convert to octal. * tests/multibyte-white-space (hex_printf): New function. Use it in place of printf so we can retain the table of hex digits without hitting the limitation of some bourne shells. Reported by Paul Eggert in http://bugs.gnu.org/15690#11 --- tests/backslash-s-vs-invalid-multitype | 2 +- tests/char-class-multibyte | 2 +- tests/multibyte-white-space | 12 ++++++++++-- tests/surrogate-pair | 2 +- tests/unibyte-bracket-expr | 19 +++++++++++-------- 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/tests/backslash-s-vs-invalid-multitype b/tests/backslash-s-vs-invalid-multitype index 4f1a71d..9aff5a1 100755 --- a/tests/backslash-s-vs-invalid-multitype +++ b/tests/backslash-s-vs-invalid-multitype @@ -14,7 +14,7 @@ require_en_utf8_locale_ LC_ALL=en_US.UTF-8 export LC_ALL -printf '\x82\n' > in || framework_failure_ +printf '\202\n' > in || framework_failure_ fail=0 grep '^\S$' in > out-S && fail=1 diff --git a/tests/char-class-multibyte b/tests/char-class-multibyte index fae7511..459d10c 100755 --- a/tests/char-class-multibyte +++ b/tests/char-class-multibyte @@ -24,7 +24,7 @@ done for LOC in en_US.UTF-8 $LOCALE_FR_UTF8; do out=out3-$LOC - printf '\xc3\n' | LC_ALL=$LOC grep '[é]' > $out + printf '\303\n' | LC_ALL=$LOC grep '[é]' > $out test $? = 1 || fail=1 done diff --git a/tests/multibyte-white-space b/tests/multibyte-white-space index 07ed085..16205fa 100755 --- a/tests/multibyte-white-space +++ b/tests/multibyte-white-space @@ -57,10 +57,18 @@ EOF fail=0 +# Like printf with a single argument. +# The difference is that while some printf implementations fail to +# handle \xHH escapes, no awk implementation has that problem. +hex_printf() +{ + ${AWK-awk} 'BEGIN { printf "'"$1"'" }' in || framework_failure_ +printf '\360\220\220\205\n' > in || framework_failure_ LC_ALL=en_US.UTF-8 export LC_ALL diff --git a/tests/unibyte-bracket-expr b/tests/unibyte-bracket-expr index 126a445..17a431d 100755 --- a/tests/unibyte-bracket-expr +++ b/tests/unibyte-bracket-expr @@ -27,14 +27,17 @@ export LC_ALL fail=0 -for i in 8 9 a b c d e f; do - for j in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do - in=in-$i$j - b=$(printf "\\x$i$j") - echo "$b" > $in || framework_failure_ - grep "[$b]" $in > out || fail=1 - compare out $in || fail=1 - done +i=128 +while :; do + in=in-$i + octal=$(printf '%03o' $i) + b=$(printf "\\$octal") + echo "$b" > $in || framework_failure_ + grep "[$b]" $in > out || fail=1 + compare out $in || fail=1 + + test $i = 255 && break + i=$(expr $i + 1) done Exit $fail -- 1.8.4.1.559.gdb9bdfb