Subject: bug#73068: printf: please implement POSIX:2024 argument reordering

From: Pádraig Brady <[email-masked]>
Date: Thu, 12 Sep 2024 19:06:28 +0100

On 12/09/2024 18:06, Bruno Haible wrote:
> Pádraig Brady wrote:
>> I'll apply the attached sometime tomorrow.
> 
> Nice! Thank you.
> 
> There seems to be a typo in the unit test, though: It defines a shell
> function 'printf_checki_err' but the function it then invokes is
> 'printf_check_err'.

Hah, good catch.
That hid other errors in the test.
Fixed up with the attached.

thanks for the review,
Pádraig

diff --git a/tests/printf/printf-indexed.sh b/tests/printf/printf-indexed.sh
index 1c3a6c380..d0f799ab1 100755
--- a/tests/printf/printf-indexed.sh
+++ b/tests/printf/printf-indexed.sh
@@ -34,14 +34,14 @@ EOF
   compare exp out || fail=1
 }
 
-printf_checki_err() {
+printf_check_err() {
   cat <<EOF > exp || framework_failure_
 $1
 EOF
 
   shift
 
-  returns_1 $prog "$@" 2> out || fail=1
+  returns_ 1 $prog "$@" 2> out || fail=1
   compare exp out || fail=1
 }
 
@@ -85,9 +85,9 @@ printf_check_err 'printf: %-2$: invalid conversion specification' \
 
 # Ensure only base 10 numbers are accepted
 printf_check_err "printf: 'A': expected a numeric value" \
-                 '%0x2$s %1$s\n' A B
+                 '%0x2$s %2$s\n' A B
 # Verify int limits (avoiding comparisons with argc etc.)
-printf_check_err "printf: %${INT_OFLOW}$: invalid conversion specification" \
-                 "%${INT_OFLOW}$d\n" 1
+printf_check_err "printf: %${INT_OFLOW}\$: invalid conversion specification" \
+                 "%${INT_OFLOW}\$d\n" 1
 
 Exit $fail