feature (kernel): Implemented numeric_specifier feature for substrings in format strings
This commit is contained in:
parent
87ee378144
commit
b77e01a5d2
|
@ -64,7 +64,14 @@ uint64_t variadic_format_size(string_t string, va_list args) {
|
||||||
}
|
}
|
||||||
case 's': {
|
case 's': {
|
||||||
// string
|
// string
|
||||||
length += string_length(va_arg(args, string_t));
|
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;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'c': {
|
case 'c': {
|
||||||
|
@ -187,6 +194,12 @@ void variadic_format(string_t output, string_t string, va_list args) {
|
||||||
string_t str = va_arg(args, string_t);
|
string_t str = va_arg(args, string_t);
|
||||||
uint64_t strlen = string_length(str);
|
uint64_t strlen = string_length(str);
|
||||||
|
|
||||||
|
if (numeric_specifier > 0) {
|
||||||
|
strlen = MIN(strlen, numeric_specifier);
|
||||||
|
} else {
|
||||||
|
strlen = numeric_specifier;
|
||||||
|
}
|
||||||
|
|
||||||
memory_copy((void*)str, buffer_out, strlen);
|
memory_copy((void*)str, buffer_out, strlen);
|
||||||
buffer_out += strlen;
|
buffer_out += strlen;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue