summaryrefslogtreecommitdiffstats
path: root/runtime/vsprintf.c
diff options
context:
space:
mode:
authorhunt <hunt>2006-05-25 18:49:17 +0000
committerhunt <hunt>2006-05-25 18:49:17 +0000
commit53b5476c54e5157fc3c5e48784038b317cf497d9 (patch)
tree4da836610e6ede7ed6fa9ac053a1c2ffc2929aee /runtime/vsprintf.c
parent037c3a7751a1687ff11da746b895d951e2a062c6 (diff)
downloadsystemtap-steved-53b5476c54e5157fc3c5e48784038b317cf497d9.tar.gz
systemtap-steved-53b5476c54e5157fc3c5e48784038b317cf497d9.tar.xz
systemtap-steved-53b5476c54e5157fc3c5e48784038b317cf497d9.zip
2006-05-25 Martin Hunt <hunt@redhat.com>
* vsprintf.c (_stp_vsnprintf): Change %p to work like libc and automatically insert "0x" before the pointer.
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);