← Commit list

7105e4afd

Ron Yorston
Ron Yorston
2021-12-17
SUCCESS Duration: 153s

Subject

printf: allow 0 as a flag and allow multiple flags

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

coreutils/printf.c+1 -1
@@ -313,7 +313,7 @@ static char **print_formatted(char *f, char **argv, int *conv_err)
}
break;
}
- if (*f && strchr("-+ #", *f)) {
+ while (*f && strchr("-+ #0", *f)) {
++f;
++direc_length;
}
testsuite/printf.tests+10 -0
@@ -143,4 +143,14 @@ testing "printf aborts on %r" \
"printf: %r: invalid format\n""1\n" \
"" ""
+testing "printf treats leading 0 as flag" \
+ "${bb}printf '%0*d\n' 2 1 2>&1; echo \$?" \
+ "01\n""0\n" \
+ "" ""
+
+testing "printf handles multiple flags" \
+ "${bb}printf '%0 d\n' 2 2>&1; echo \$?" \
+ " 2\n""0\n" \
+ "" ""
+
exit $FAILCOUNT