From 6c7004423df033de1bf084e07956e7d5fbd95a25 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Fri, 21 Jul 2006 10:08:47 +0000 Subject: [PATCH] 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). --- lib/stdio/doprnt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 == ' '))))