diff --git a/kernel/src/utils/string.c b/kernel/src/utils/string.c index 5ad49b0..34fe63a 100644 --- a/kernel/src/utils/string.c +++ b/kernel/src/utils/string.c @@ -50,10 +50,15 @@ uint64_t variadic_format_size(string_t string, va_list args) { buffer_in++; if (*buffer_in == '.') { buffer_in++; - while (*buffer_in > '0' && *buffer_in < '9') { - numeric_specifier *= 10; - numeric_specifier += *buffer_in - '0'; + if (*buffer_in == '*') { buffer_in++; + numeric_specifier = va_arg(args, uint64_t); + } else { + while (*buffer_in > '0' && *buffer_in < '9') { + numeric_specifier *= 10; + numeric_specifier += *buffer_in - '0'; + buffer_in++; + } } } @@ -67,8 +72,6 @@ uint64_t variadic_format_size(string_t string, va_list args) { uint64_t strlen = string_length(va_arg(args, string_t)); if (numeric_specifier > 0) { strlen = MIN(strlen, numeric_specifier); - } else { - strlen = numeric_specifier; } length += strlen; @@ -176,10 +179,15 @@ void variadic_format(string_t output, string_t string, va_list args) { buffer_in++; if (*buffer_in == '.') { buffer_in++; - while (*buffer_in > '0' && *buffer_in < '9') { - numeric_specifier *= 10; - numeric_specifier += *buffer_in - '0'; + if (*buffer_in == '*') { buffer_in++; + numeric_specifier = va_arg(args, uint64_t); + } else { + while (*buffer_in > '0' && *buffer_in < '9') { + numeric_specifier *= 10; + numeric_specifier += *buffer_in - '0'; + buffer_in++; + } } } @@ -196,8 +204,6 @@ void variadic_format(string_t output, string_t string, va_list args) { if (numeric_specifier > 0) { strlen = MIN(strlen, numeric_specifier); - } else { - strlen = numeric_specifier; } memory_copy((void*)str, buffer_out, strlen);