From df732bb01b5703eb1a7b643b98606358e6911aa5 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Wed, 26 Nov 2014 21:17:16 +0200 Subject: [PATCH] pfenv_printf: Properly implement %p format specifier. Previously, it truncated pointer value to 32 bits on 64-bit systems. --- py/pfenv_printf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/py/pfenv_printf.c b/py/pfenv_printf.c index 003314e8f5..c0e826a5d2 100644 --- a/py/pfenv_printf.c +++ b/py/pfenv_printf.c @@ -146,13 +146,15 @@ int pfenv_vprintf(const pfenv_t *pfenv, const char *fmt, va_list args) { chrs += pfenv_print_int(pfenv, va_arg(args, int), 1, 10, 'a', flags, fill, width); break; case 'x': - case 'p': // ? chrs += pfenv_print_int(pfenv, va_arg(args, int), 0, 16, 'a', flags, fill, width); break; case 'X': - case 'P': // ? chrs += pfenv_print_int(pfenv, va_arg(args, int), 0, 16, 'A', flags, fill, width); break; + case 'p': + case 'P': // don't bother to handle upcase for 'P' + chrs += pfenv_print_int(pfenv, va_arg(args, mp_uint_t), 0, 16, 'a', flags, fill, width); + break; #if MICROPY_PY_BUILTINS_FLOAT case 'e': case 'E':