diff options
author | Elliott Baron <elliott@localhost.localdomain> | 2008-12-19 17:00:51 -0500 |
---|---|---|
committer | Elliott Baron <elliott@localhost.localdomain> | 2008-12-19 17:00:51 -0500 |
commit | 51d997112e435da6fc84713ef09908b3b8659798 (patch) | |
tree | 80db6ddb4d303aa515b28f7fc00594022565fa5a /runtime/vsprintf.c | |
parent | a46143af464b24e75e784a3ebaebf86bc52a44ed (diff) | |
download | systemtap-steved-51d997112e435da6fc84713ef09908b3b8659798.tar.gz systemtap-steved-51d997112e435da6fc84713ef09908b3b8659798.tar.xz systemtap-steved-51d997112e435da6fc84713ef09908b3b8659798.zip |
Better implementation for %M
Diffstat (limited to 'runtime/vsprintf.c')
-rw-r--r-- | runtime/vsprintf.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/runtime/vsprintf.c b/runtime/vsprintf.c index fbd90a83..60852872 100644 --- a/runtime/vsprintf.c +++ b/runtime/vsprintf.c @@ -283,7 +283,7 @@ int _stp_vsnprintf(char *buf, size_t size, const char *fmt, va_list args) continue; case 's': - case 'M': + case 'M': case 'm': s = va_arg(args, char *); if ((unsigned long)s < PAGE_SIZE) @@ -303,15 +303,23 @@ int _stp_vsnprintf(char *buf, size_t size, const char *fmt, va_list args) ++str; } } - for (i = 0; i < len; ++i) { - if (str <= end) { - if (*fmt == 'M') - str = number(str, str + 2, (uint64_t)(unsigned char) *s, 16, 2, 2, STP_SPACE); - else - *str = *s; - } - ++str; ++s; + if (*fmt == 'M') { + str = number(str, str + len - 1 < end ? str + len - 1 : end, + (unsigned long) *(uint64_t *) s, + 16, field_width, len, flags); + } + else { + for (i = 0; i < len; ++i) { + if (str <= end) { + //if (*fmt == 'M') + //str = number(str, str + 2, (uint64_t)(unsigned char) *s, 16, 2, 2, STP_SPACE); + //else + *str = *s; + } + ++str; ++s; + } } + while (len < field_width--) { if (str <= end) *str = ' '; @@ -323,7 +331,6 @@ int _stp_vsnprintf(char *buf, size_t size, const char *fmt, va_list args) ++str; } continue; - case 'X': flags |= STP_LARGE; case 'x': |