From 51037ae517bcc9a8a275eb7ff07c708d803a9173 Mon Sep 17 00:00:00 2001 From: cem Date: Wed, 1 Jun 2016 16:11:09 +0000 Subject: libthr: _thread_vprintf: Enhance support for %p, %#x No functional change. No ABI change. Reviewed by: kib Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D6672 --- lib/libthr/thread/thr_printf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib/libthr/thread/thr_printf.c') diff --git a/lib/libthr/thread/thr_printf.c b/lib/libthr/thread/thr_printf.c index 8e9a151..d38ee18 100644 --- a/lib/libthr/thread/thr_printf.c +++ b/lib/libthr/thread/thr_printf.c @@ -68,15 +68,19 @@ _thread_vprintf(int fd, const char *fmt, va_list ap) unsigned long r, u; int c; long d; - int islong; + int islong, isalt; while ((c = *fmt++)) { + isalt = 0; islong = 0; if (c == '%') { next: c = *fmt++; if (c == '\0') return; switch (c) { + case '#': + isalt = 1; + goto next; case 'c': pchar(fd, va_arg(ap, int)); continue; @@ -87,10 +91,13 @@ next: c = *fmt++; islong = 1; goto next; case 'p': + pstr(fd, "0x"); islong = 1; case 'd': case 'u': case 'x': + if (c == 'x' && isalt) + pstr(fd, "0x"); r = ((c == 'u') || (c == 'd')) ? 10 : 16; if (c == 'd') { if (islong) -- cgit v1.1