fix: kprintf support first argument
This commit is contained in:
parent
2cbe9c9492
commit
27ec2f24c2
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user