From: Ben Gras Date: Fri, 21 Jul 2006 10:08:47 +0000 (+0000) Subject: Fix for %#02x bug (shouldn't print 0x, but junk was printed) found by X-Git-Tag: v3.1.3~241 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/mult.png?a=commitdiff_plain;h=6c7004423df033de1bf084e07956e7d5fbd95a25;p=minix.git Fix for %#02x bug (shouldn't print 0x, but junk was printed) found by Joren l'Ami. Also fixes %p when arg is 0 (printed 0 instead of 0x0). --- diff --git a/lib/stdio/doprnt.c b/lib/stdio/doprnt.c index 309505958..a0248b688 100755 --- a/lib/stdio/doprnt.c +++ b/lib/stdio/doprnt.c @@ -80,7 +80,7 @@ o_print(va_list *ap, int flags, char *s, char c, int precision, int is_signed) unsigned_val = signed_val; } if ((flags & FL_ALT) && (c == 'o')) *s++ = '0'; - if (!unsigned_val) { + if (!unsigned_val && c != 'p') { if (!precision) return s; } else if (((flags & FL_ALT) && (c == 'x' || c == 'X')) @@ -268,7 +268,7 @@ _doprnt(register const char *fmt, va_list ap, FILE *stream) */ between_fill = 0; if ((flags & FL_ZEROFILL) - && (((c == 'x' || c == 'X') && (flags & FL_ALT)) + && (((c == 'x' || c == 'X') && (flags & FL_ALT) && j > 1) || (c == 'p') || ((flags & FL_SIGNEDCONV) && ( *s1 == '+' || *s1 == '-' || *s1 == ' '))))