From ecffca672656d6e4a2d39314237289f5740e8562 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 7 Sep 2022 17:33:31 -0700 Subject: [PATCH] Don't parse '}' as fill --- include/fmt/core.h | 1 + test/format-test.cc | 1 + 2 files changed, 2 insertions(+) diff --git a/include/fmt/core.h b/include/fmt/core.h index 42835c0ecfed..ed36a3f845ae 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -2395,6 +2395,7 @@ FMT_CONSTEXPR auto parse_align(const Char* begin, const Char* end, auto c = *begin; if (c == '{') return handler.on_error("invalid fill character '{'"), begin; + if (c == '}') return begin; handler.on_fill(basic_string_view(begin, to_unsigned(p - begin))); begin = p + 1; } else diff --git a/test/format-test.cc b/test/format-test.cc index 862a3cb3c0d4..15c3f9f21536 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -1205,6 +1205,7 @@ constexpr auto uint128_max = ~static_cast<__uint128_t>(0); TEST(format_test, format_dec) { EXPECT_EQ("0", fmt::format("{0}", 0)); EXPECT_EQ("42", fmt::format("{0}", 42)); + EXPECT_EQ("42>", fmt::format("{:}>", 42)); EXPECT_EQ("42", fmt::format("{0:d}", 42)); EXPECT_EQ("42", fmt::format("{0}", 42u)); EXPECT_EQ("-42", fmt::format("{0}", -42));