diff options
-rw-r--r-- | coreutils/printf.c | 2 | ||||
-rwxr-xr-x | testsuite/printf.tests | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/coreutils/printf.c b/coreutils/printf.c index dd94c8a..2e672d1 100644 --- a/coreutils/printf.c +++ b/coreutils/printf.c @@ -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; } diff --git a/testsuite/printf.tests b/testsuite/printf.tests index 050edef..728bbf4 100755 --- a/testsuite/printf.tests +++ b/testsuite/printf.tests @@ -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 |