diff --git a/src/kprint/kvprintf.c b/src/kprint/kvprintf.c index d02557a..8622524 100644 --- a/src/kprint/kvprintf.c +++ b/src/kprint/kvprintf.c @@ -9,6 +9,8 @@ static int print_flag(char flag, va_list ap) { switch (flag) { + case '%': + return terminal_putchar('%'); case 'i': return terminal_writelong(va_arg(ap, int)); case 'd': @@ -25,21 +27,17 @@ int kvprintf(int level, const char *restrict format, va_list ap) { const char *start = format; const char *flag; - long padding; int ret = 0; + size_t len; while (*start != '\0') { - flag = strchr(start, '%'); - if (flag != NULL) { - padding = atoll(start + 1); - for (; isdigit(*flag); flag++); - ret += print_flag(*flag, ap); - start = flag + 1; - } - else { - terminal_writestring(start); - start += strlen(start); + if (*start == '%' && *(start + 1) != '\0') { + ret += print_flag(*(start + 1), ap); + start++; } + else + ret += terminal_putchar(*start); + start++; } return ret; } \ No newline at end of file