AK: Honor variable precision argument when formatting

printf didn't check whether the additional integer variable belongs to
the field width specifier or to the precision specifier, and always
applied it to the field width instead.

Implement the case distinction that we already use in literal width
and precision specifiers for the variable version as well so that
they are correctly attributed.
This commit is contained in:
Tim Schumacher 2021-05-30 18:06:10 +02:00 committed by Linus Groh
parent d5bf9182dd
commit 8c3e4ccd72
Notes: sideshowbarker 2024-07-18 17:09:09 +09:00

View file

@ -452,7 +452,13 @@ ALWAYS_INLINE int printf_internal(PutChFunc putch, char* buffer, const char*& fm
}
}
if (*p == '*') {
state.field_width = NextArgument<int>()(ap);
if (state.dot) {
state.has_fraction_length = true;
state.fraction_length = NextArgument<int>()(ap);
} else {
state.field_width = NextArgument<int>()(ap);
}
if (*(p + 1))
goto one_more;
}