On Wed, Oct 23, 2013 at 12:44 AM, Paul Eggert <[email protected]> wrote:
>>   http://meyering.net/grep/grep-2.14.51-7a35.tar.xz
>
> That snapshot fails "make check" on Ubuntu 13.10 x86-64.
> However, when I generate a tarball from the same git source,
> "make check" works for me.
>
> I think I tracked this down to a discrepancy in the tools used
> to build this snapshot.  But it's getting late so I hope someone
> else can check this.
>
> The snapshot fails because the three tests multibyte-white-space,
> pcre-utf8, surrogate-pair all fail.  And they fail because
> "printf '\x40'" prints "\x40" rather than "@".
> And this happens because the tests are run with
> /bin/sh, not /bin/bash; on Ubuntu /bin/sh is Dash
> and Dash mishandles printf with '\x...'.  And this
> happens because './configure' decides to make SHELL
> /bin/sh rather than /bin/bash.  And I think *this*
> happens because 'configure' was built with Autoconf
> 2.69.112-f181 rather than Autoconf 2.69 (this is
> the Autoconf 2.69 shipped with Fedora 19).  The
> respective 'configure' scripts are pretty hairy,
> though, and I can't easily see why the meyering.net
> snapshot went awry.

Thanks for tracking that down.
I've adjusted the tests not to rely on printf-\xHH.  Here's the patch
I expect to push.
I want to write a replacement printf function (set up via init.sh and
that transforms \xHH to \OOO in the format string), but that will have
to wait until after the release.
From a181ed9a6778c313dda49b7d7921e4d700bb1d52 Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email protected]>
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"'" }' </dev/null
+}
+
 for i in $utf8_space_characters; do
-  printf "$i\n" | grep -q '^\s$' \
+  hex_printf "$i\n" | grep -q '^\s$' \
       || { warn_ "$i FAILED to match \\s"; fail=1; }
-  printf "$i\n" | grep -q '\S'
+  hex_printf "$i\n" | grep -q '\S'
   test $? = 1 \
       || { warn_ "$i vs. \\S FAILED"; fail=1; }
 done
diff --git a/tests/surrogate-pair b/tests/surrogate-pair
index a589819..2d7d3bd 100755
--- a/tests/surrogate-pair
+++ b/tests/surrogate-pair
@@ -23,7 +23,7 @@ require_compiled_in_MB_support

 fail=0

-printf '\xf0\x90\x90\x85\n' > 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

Reply via email to