Browse Source

tiny-printf: Always print zeroes

At present this does not print zero values in numeric format (hex and
decimal). Add a special case for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Tom Rini <trini@konsulko.com>
scm-imx_v2016.03_4.1.15_2.0.0_ga
Simon Glass 5 years ago
parent
commit
74b1320ae5
1 changed files with 12 additions and 4 deletions
  1. +12
    -4
      lib/tiny-printf.c

+ 12
- 4
lib/tiny-printf.c View File

@ -82,13 +82,21 @@ int vprintf(const char *fmt, va_list va)
num = -(int)num;
out('-');
}
for (div = 1000000000; div; div /= 10)
div_out(&num, div);
if (!num) {
out_dgt(0);
} else {
for (div = 1000000000; div; div /= 10)
div_out(&num, div);
}
break;
case 'x':
num = va_arg(va, unsigned int);
for (div = 0x10000000; div; div /= 0x10)
div_out(&num, div);
if (!num) {
out_dgt(0);
} else {
for (div = 0x10000000; div; div /= 0x10)
div_out(&num, div);
}
break;
case 'c':
out((char)(va_arg(va, int)));


Loading…
Cancel
Save