summaryrefslogtreecommitdiffstats
path: root/runtime/vsprintf.c
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/vsprintf.c')
-rw-r--r--runtime/vsprintf.c27
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':