summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@gmail.com>2019-08-09 23:24:53 +0300
committerAndreas Kling <awesomekling@gmail.com>2019-08-10 08:46:22 +0200
commit79f867238a9b5c35805f6218aa0e04019eca1db2 (patch)
treefef54cf702bd32166d31c163824a867fb244c554
parentcfe8fdd5aaf1937563278ac6a30d57593df24c7c (diff)
downloadserenity-79f867238a9b5c35805f6218aa0e04019eca1db2.zip
printf: Support dynamic fill widths
The printf formatting mini-language actually allows you to pass a '*' character in place of the fill width specification, in which case it eats one of the passed in arguments and uses it as width, so implement that.
-rw-r--r--AK/PrintfImplementation.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/AK/PrintfImplementation.h b/AK/PrintfImplementation.h
index 2899fb04ab..40f127694a 100644
--- a/AK/PrintfImplementation.h
+++ b/AK/PrintfImplementation.h
@@ -222,6 +222,11 @@ template<typename PutChFunc>
if (*(p + 1))
goto one_more;
}
+ if (*p == '*') {
+ fieldWidth = va_arg(ap, int);
+ if (*(p + 1))
+ goto one_more;
+ }
if (*p == 'l') {
++long_qualifiers;
if (*(p + 1))