Skip to content

Commit

Permalink
Don't parse '}' as fill
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Sep 8, 2022
1 parent 3176e0f commit ecffca6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Char>(begin, to_unsigned(p - begin)));
begin = p + 1;
} else
Expand Down
1 change: 1 addition & 0 deletions test/format-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit ecffca6

Please sign in to comment.