diff options
author | Dave Brolley <brolley@redhat.com> | 2009-04-27 11:56:15 -0400 |
---|---|---|
committer | Dave Brolley <brolley@redhat.com> | 2009-04-27 11:56:15 -0400 |
commit | e84f20287ae21b31c3505dfd0a81176687ad1ec5 (patch) | |
tree | 956005556406fc93e4444ee0d425aafed8e241d0 /runtime/vsprintf.c | |
parent | fb6d28283bd7ea63364a008d32c53687a694642f (diff) | |
parent | 097e4a5b397b9e826453e01caa1f8169886128c5 (diff) | |
download | systemtap-steved-e84f20287ae21b31c3505dfd0a81176687ad1ec5.tar.gz systemtap-steved-e84f20287ae21b31c3505dfd0a81176687ad1ec5.tar.xz systemtap-steved-e84f20287ae21b31c3505dfd0a81176687ad1ec5.zip |
Merge branch 'master' of git://sources.redhat.com/git/systemtap
Conflicts:
configure
testsuite/configure
Diffstat (limited to 'runtime/vsprintf.c')
-rw-r--r-- | runtime/vsprintf.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/runtime/vsprintf.c b/runtime/vsprintf.c index 38ab0e2d..23810e75 100644 --- a/runtime/vsprintf.c +++ b/runtime/vsprintf.c @@ -361,18 +361,16 @@ static int _stp_vsnprintf(char *buf, size_t size, const char *fmt, va_list args) else len = 1; + if (*fmt_copy == 'M') + len = len * 2; /* hex dump print size */ + if (!(flags & STP_LEFT)) { while (len < field_width--) { num_bytes++; } } - if (*fmt_copy == 'M') { - num_bytes += number_size((unsigned long) *(uint64_t *) s, - 16, field_width, len, flags); - } - else { - num_bytes += len; - } + + num_bytes += len; while (len < field_width--) { num_bytes++; @@ -636,16 +634,25 @@ static int _stp_vsnprintf(char *buf, size_t size, const char *fmt, va_list args) len = 1; if (!(flags & STP_LEFT)) { - while (len < field_width--) { + int actlen = len; + if (*fmt == 'M') + actlen = len * 2; + while (actlen < field_width--) { if (str <= end) *str = ' '; ++str; } } - if (*fmt == 'M') { - str = number(str, str + len - 1 < end ? str + len - 1 : end, - (unsigned long) *(uint64_t *) s, - 16, field_width, len, flags); + if (*fmt == 'M') { /* stolen from kernel: trace_seq_putmem_hex() */ + const char _stp_hex_asc[] = "0123456789abcdef"; + int j; + for (i = 0, j = 0; i < len; i++) { + *str = _stp_hex_asc[((*s) & 0xf0) >> 4]; + str++; + *str = _stp_hex_asc[((*s) & 0x0f)]; + str++; s++; + } + len = len * 2; /* the actual length */ } else { for (i = 0; i < len; ++i) { |