aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/lib/stdio
diff options
context:
space:
mode:
authorMarvin Borner2020-05-29 23:47:29 +0200
committerMarvin Borner2020-05-29 23:47:29 +0200
commit45a5ecc72d8e700614a0751f0e7ec68199885b77 (patch)
tree7da3053bd5a2b5ced5a4605e18ab4e921f65bc70 /src/kernel/lib/stdio
parentdf7637951f705fb2e2192510ab276e2289fd6cec (diff)
Added more printf features
Diffstat (limited to 'src/kernel/lib/stdio')
-rw-r--r--src/kernel/lib/stdio/vsprintf.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/kernel/lib/stdio/vsprintf.c b/src/kernel/lib/stdio/vsprintf.c
index 6584ed1..61f4323 100644
--- a/src/kernel/lib/stdio/vsprintf.c
+++ b/src/kernel/lib/stdio/vsprintf.c
@@ -27,20 +27,30 @@ int vsprintf(char *str, const char *fmt, va_list args)
}
buf = *fmt;
+
+ // TODO: Improve this repetitive code
if (buf == 's') {
char *string = va_arg(args, char *);
append(str, string, i);
i = strlen(str);
} else if (buf == 'x') {
- itoa_base((u32)va_arg(args, int), format_buffer, 16);
+ itoa_base(va_arg(args, u32), format_buffer, 16, 0);
+ append(str, format_buffer, i);
+ i = strlen(str);
+ } else if (buf == 'd' || buf == 'i') {
+ itoa_base(va_arg(args, s32), format_buffer, 10, 1);
append(str, format_buffer, i);
i = strlen(str);
- } else if (buf == 'd') {
- itoa_base(va_arg(args, int), format_buffer, 10);
+ } else if (buf == 'u') {
+ itoa_base(va_arg(args, u32), format_buffer, 10, 0);
append(str, format_buffer, i);
i = strlen(str);
} else if (buf == 'o') {
- itoa_base(va_arg(args, int), format_buffer, 8);
+ itoa_base(va_arg(args, u32), format_buffer, 8, 0);
+ append(str, format_buffer, i);
+ i = strlen(str);
+ } else if (buf == 'b') {
+ itoa_base(va_arg(args, u32), format_buffer, 2, 0);
append(str, format_buffer, i);
i = strlen(str);
} else if (buf == 'c') {