aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coreutils/printf.c2
-rwxr-xr-xtestsuite/printf.tests10
2 files changed, 11 insertions, 1 deletions
diff --git a/coreutils/printf.c b/coreutils/printf.c
index dd94c8ade..2e672d15f 100644
--- a/coreutils/printf.c
+++ b/coreutils/printf.c
@@ -313,7 +313,7 @@ static char **print_formatted(char *f, char **argv, int *conv_err)
313 } 313 }
314 break; 314 break;
315 } 315 }
316 if (*f && strchr("-+ #", *f)) { 316 while (*f && strchr("-+ #0", *f)) {
317 ++f; 317 ++f;
318 ++direc_length; 318 ++direc_length;
319 } 319 }
diff --git a/testsuite/printf.tests b/testsuite/printf.tests
index 050edef71..728bbf4bf 100755
--- a/testsuite/printf.tests
+++ b/testsuite/printf.tests
@@ -143,4 +143,14 @@ testing "printf aborts on %r" \
143 "printf: %r: invalid format\n""1\n" \ 143 "printf: %r: invalid format\n""1\n" \
144 "" "" 144 "" ""
145 145
146testing "printf treats leading 0 as flag" \
147 "${bb}printf '%0*d\n' 2 1 2>&1; echo \$?" \
148 "01\n""0\n" \
149 "" ""
150
151testing "printf handles multiple flags" \
152 "${bb}printf '%0 d\n' 2 2>&1; echo \$?" \
153 " 2\n""0\n" \
154 "" ""
155
146exit $FAILCOUNT 156exit $FAILCOUNT