From b2bde490b4e24268309c5ca0021ef4a62fa01097 Mon Sep 17 00:00:00 2001 From: Alexey Frunze Date: Sun, 24 Jan 2016 18:38:58 -0800 Subject: [PATCH] Improve *printf() - support %i in addition to %d - print the sign when printing 0 with %+d --- src/libc/stdio/doprnt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libc/stdio/doprnt.c b/src/libc/stdio/doprnt.c index 7f54047..b1885bb 100644 --- a/src/libc/stdio/doprnt.c +++ b/src/libc/stdio/doprnt.c @@ -186,6 +186,7 @@ reswitch: switch (c = *fmt++) { break; case 'd': + case 'i': ul = lflag ? va_arg (ap, long) : va_arg (ap, int); if (! sign) sign = 1; base = 10; @@ -211,7 +212,7 @@ reswitch: switch (c = *fmt++) { sharpflag = (width == 0); goto nosign; - case 'n': + case 'n': /* TBD!!! fix this non-standard %n */ ul = lflag ? va_arg (ap, unsigned long) : sign ? (unsigned long) va_arg (ap, int) : va_arg (ap, unsigned int); @@ -294,7 +295,7 @@ cnt_unknown: if (ladjust) goto number; nosign: sign = 0; -number: if (sign && ((long) ul != 0L)) { +number: if (sign) { if ((long) ul < 0L) { neg = '-'; ul = -(long) ul;