feature (kernel): Implemented variable numeric_specifiers

This commit is contained in:
antifallobst 2023-02-23 11:34:01 +01:00
parent 547f74758e
commit 49a48c70ca
1 changed files with 16 additions and 10 deletions

View File

@ -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);