summaryrefslogtreecommitdiffstats
path: root/runtime/vsprintf.c
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/vsprintf.c')
-rw-r--r--runtime/vsprintf.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/runtime/vsprintf.c b/runtime/vsprintf.c
index ba0bc85a..7abb5dc5 100644
--- a/runtime/vsprintf.c
+++ b/runtime/vsprintf.c
@@ -295,10 +295,26 @@ int _stp_vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
break;
case 'p':
+ len = 2*sizeof(void *) + 2;
if (field_width == -1) {
- field_width = 2*sizeof(void *);
+ field_width = len;
flags |= STP_ZEROPAD;
}
+ if (!(flags & STP_LEFT)) {
+ while (len < field_width--) {
+ if (str <= end)
+ *str = ' ';
+ ++str;
+ }
+ }
+ if (str <= end) {
+ *str++ = '0';
+ field_width--;
+ }
+ if (str <= end) {
+ *str++ = 'x';
+ field_width--;
+ }
str = number(str, end,
(unsigned long) va_arg(args, int64_t),
16, field_width, precision, flags);