From 0604c6de0186c21724546ece7fd19cf73617f8af Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@fb.com>
Date: Sun, 9 Nov 2014 09:26:30 -0800
Subject: [PATCH 1/2] tests: avoid hex_printf_ portability problems

* tests/init.cfg (hex_printf_): Spell out a-f and A-F, for
non-C locales, ensure that the input to sed is newline-terminated,
and quote the final octal format string.
Suggestions from Paul Eggert.
---
 tests/init.cfg | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tests/init.cfg b/tests/init.cfg
index e7a2389..8c71008 100644
--- a/tests/init.cfg
+++ b/tests/init.cfg
@@ -159,8 +159,10 @@ or use the shortcut target of the toplevel Makefile,
 # sequence of four-byte strings \xHH where each H is a hexadecimal byte.
 hex_printf_()
 {
-  printf $(printf '\\%o' \
-    $(printf %s "$1"|sed 's,\\x\([0-9a-fA-F][0-9a-fA-F]\), 0x\1,g'))
+  local octal_fmt=$(printf '\\%o' \
+    $(printf '%s\n' "$1" \
+      | sed 's,\\x\([0-9abcdefABCDEF][0-9abcdefABCDEF]\), 0x\1,g'))
+  printf "$octal_fmt"
 }

 # Wrap tr so that it always runs in the C locale.
-- 
2.1.2

