summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Schumacher <timschumi@gmx.de>2021-12-07 14:47:01 +0100
committerBrian Gianforcaro <b.gianfo@gmail.com>2021-12-07 20:13:59 -0800
commit5c511de4cc001b66fac941c6f064f903e1005302 (patch)
treef7c1b5f31dd81dd7b86bbfbdcd38faa216c41d36
parentaad9d0aa51cd614b7ba9f738f0f647775551f0c3 (diff)
downloadserenity-5c511de4cc001b66fac941c6f064f903e1005302.zip
AK: Zero-pad automatically if formatting with precision
-rw-r--r--AK/PrintfImplementation.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/AK/PrintfImplementation.h b/AK/PrintfImplementation.h
index 408733d5d7..38b5fcf360 100644
--- a/AK/PrintfImplementation.h
+++ b/AK/PrintfImplementation.h
@@ -443,6 +443,7 @@ ALWAYS_INLINE int printf_internal(PutChFunc putch, char* buffer, const char*& fm
} else {
if (!state.has_fraction_length) {
state.has_fraction_length = true;
+ state.zero_pad = true;
state.fraction_length = 0;
}
state.fraction_length *= 10;
@@ -454,6 +455,7 @@ ALWAYS_INLINE int printf_internal(PutChFunc putch, char* buffer, const char*& fm
if (*p == '*') {
if (state.dot) {
state.has_fraction_length = true;
+ state.zero_pad = true;
state.fraction_length = NextArgument<int>()(ap);
} else {
state.field_width = NextArgument<int>()(ap);