aboutsummaryrefslogtreecommitdiff
path: root/coreutils/printf.c
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2018-10-19 15:25:41 +0200
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2018-10-19 15:27:42 +0200
commit3db4e7f84cf795de8559ea0d96eaa491999ccf24 (patch)
tree0260c160e82214f81dc2aeaef7764e4bb0c632ef /coreutils/printf.c
parent7effa31cd4b5c76d20f63882002eb023f05aaa46 (diff)
downloadbusybox-w32-3db4e7f84cf795de8559ea0d96eaa491999ccf24.tar.gz
busybox-w32-3db4e7f84cf795de8559ea0d96eaa491999ccf24.tar.bz2
busybox-w32-3db4e7f84cf795de8559ea0d96eaa491999ccf24.zip
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/printf.c')
-rw-r--r--coreutils/printf.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/coreutils/printf.c b/coreutils/printf.c
index a666ff7ac..b2429c5cf 100644
--- a/coreutils/printf.c
+++ b/coreutils/printf.c
@@ -191,6 +191,7 @@ static void print_direc(char *format, unsigned fmt_length,
191 if (have_width - 1 == have_prec) 191 if (have_width - 1 == have_prec)
192 have_width = NULL; 192 have_width = NULL;
193 193
194 /* multiconvert sets errno = 0, but %s needs it cleared */
194 errno = 0; 195 errno = 0;
195 196
196 switch (format[fmt_length - 1]) { 197 switch (format[fmt_length - 1]) {
@@ -199,7 +200,7 @@ static void print_direc(char *format, unsigned fmt_length,
199 break; 200 break;
200 case 'd': 201 case 'd':
201 case 'i': 202 case 'i':
202 llv = my_xstrtoll(argument); 203 llv = my_xstrtoll(skip_whitespace(argument));
203 print_long: 204 print_long:
204 if (!have_width) { 205 if (!have_width) {
205 if (!have_prec) 206 if (!have_prec)
@@ -217,7 +218,7 @@ static void print_direc(char *format, unsigned fmt_length,
217 case 'u': 218 case 'u':
218 case 'x': 219 case 'x':
219 case 'X': 220 case 'X':
220 llv = my_xstrtoull(argument); 221 llv = my_xstrtoull(skip_whitespace(argument));
221 /* cheat: unsigned long and long have same width, so... */ 222 /* cheat: unsigned long and long have same width, so... */
222 goto print_long; 223 goto print_long;
223 case 's': 224 case 's':