diff options
author | Ian Moffett <ian@osmora.org> | 2025-06-13 19:06:00 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-06-13 19:13:22 -0400 |
commit | d99afb18e808820e9a83dce863dbb0ca2deabff5 (patch) | |
tree | 474d74a41903ecb2181b19820730ef30188c99ac /lib/libc/src/stdio | |
parent | 6d267c90fcf3afad4216d859b1fe24740e0ec6cb (diff) |
usr: libc: Support padding of hex digits
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'lib/libc/src/stdio')
-rw-r--r-- | lib/libc/src/stdio/vsnprintf.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/libc/src/stdio/vsnprintf.c b/lib/libc/src/stdio/vsnprintf.c index 0e29600..24b2df6 100644 --- a/lib/libc/src/stdio/vsnprintf.c +++ b/lib/libc/src/stdio/vsnprintf.c @@ -123,6 +123,12 @@ vsnprintf(char *s, size_t size, const char *fmt, va_list ap) num = __va_arg(ap, uint64_t); itoa(num, num_buf, 16); tmp_len = strlen(num_buf); + if (pad_width > 0) { + num_len = strlen(num_buf); + for (size_t i = num_len; i < pad_width; ++i) + printc(s, size, &off, '0'); + pad_width = 0; + } printstr(s, size, &off, num_buf + 2); break; case 's': |