1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:57:35 +00:00

AK: Zero-pad automatically if formatting with precision

This commit is contained in:
Tim Schumacher 2021-12-07 14:47:01 +01:00 committed by Brian Gianforcaro
parent aad9d0aa51
commit 5c511de4cc

View file

@ -443,6 +443,7 @@ ALWAYS_INLINE int printf_internal(PutChFunc putch, char* buffer, const char*& fm
} else { } else {
if (!state.has_fraction_length) { if (!state.has_fraction_length) {
state.has_fraction_length = true; state.has_fraction_length = true;
state.zero_pad = true;
state.fraction_length = 0; state.fraction_length = 0;
} }
state.fraction_length *= 10; state.fraction_length *= 10;
@ -454,6 +455,7 @@ ALWAYS_INLINE int printf_internal(PutChFunc putch, char* buffer, const char*& fm
if (*p == '*') { if (*p == '*') {
if (state.dot) { if (state.dot) {
state.has_fraction_length = true; state.has_fraction_length = true;
state.zero_pad = true;
state.fraction_length = NextArgument<int>()(ap); state.fraction_length = NextArgument<int>()(ap);
} else { } else {
state.field_width = NextArgument<int>()(ap); state.field_width = NextArgument<int>()(ap);