summaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer2018-10-19 15:25:41 +0200
committerBernhard Reutner-Fischer2018-10-19 15:27:42 +0200
commit3db4e7f84cf795de8559ea0d96eaa491999ccf24 (patch)
tree0260c160e82214f81dc2aeaef7764e4bb0c632ef /coreutils
parent7effa31cd4b5c76d20f63882002eb023f05aaa46 (diff)
downloadbusybox-3db4e7f84cf795de8559ea0d96eaa491999ccf24.zip
busybox-3db4e7f84cf795de8559ea0d96eaa491999ccf24.tar.gz
printf: fix printing +-prefixed numbers
Thanks to Cristian Ionescu-Idbohrn for noticing. Also fix "%d" ' 42' to skip leading whitespace. function old new delta print_direc 435 454 +19 bb_strtoll 99 103 +4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 23/0) Total: 23 bytes Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/printf.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/coreutils/printf.c b/coreutils/printf.c
index a666ff7..b2429c5 100644
--- a/coreutils/printf.c
+++ b/coreutils/printf.c
@@ -191,6 +191,7 @@ static void print_direc(char *format, unsigned fmt_length,
if (have_width - 1 == have_prec)
have_width = NULL;
+ /* multiconvert sets errno = 0, but %s needs it cleared */
errno = 0;
switch (format[fmt_length - 1]) {
@@ -199,7 +200,7 @@ static void print_direc(char *format, unsigned fmt_length,
break;
case 'd':
case 'i':
- llv = my_xstrtoll(argument);
+ llv = my_xstrtoll(skip_whitespace(argument));
print_long:
if (!have_width) {
if (!have_prec)
@@ -217,7 +218,7 @@ static void print_direc(char *format, unsigned fmt_length,
case 'u':
case 'x':
case 'X':
- llv = my_xstrtoull(argument);
+ llv = my_xstrtoull(skip_whitespace(argument));
/* cheat: unsigned long and long have same width, so... */
goto print_long;
case 's':