From 79f867238a9b5c35805f6218aa0e04019eca1db2 Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Fri, 9 Aug 2019 23:24:53 +0300 Subject: 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. --- AK/PrintfImplementation.h | 5 +++++ 1 file changed, 5 insertions(+) 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 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)) -- cgit v1.2.3