1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 10:37:45 +00:00

AK+Format: Support all format specifiers for strings.

The following is now possible:

    outf("{:.4}", "abcdef"); // abcd
    outf("{:*<8}", "abcdef"); // abcdef**
This commit is contained in:
asynts 2020-09-29 13:55:58 +02:00 committed by Andreas Kling
parent c0d9daadb0
commit 71b7ef0992
3 changed files with 58 additions and 9 deletions

View file

@ -141,7 +141,7 @@ inline size_t convert_unsigned_to_string(
};
const auto used_by_field = used_by_significant_digits + used_by_prefix;
const auto used_by_padding = static_cast<size_t>(max<ssize_t>(0, static_cast<ssize_t>(width) - static_cast<ssize_t>(used_by_field)));
const auto used_by_padding = width < used_by_field ? 0 : width - used_by_field;
if (align == Align::Left) {
const auto used_by_right_padding = used_by_padding;