Commit 8c88abde authored by Victor Zverovich's avatar Victor Zverovich

Fix sign handling in 'L'

parent 23b976a6
......@@ -1552,6 +1552,7 @@ template <typename OutputIt, typename Char, typename UInt> struct int_writer {
char digits[40];
format_decimal(digits, abs_value, num_digits);
basic_memory_buffer<Char> buffer;
size += prefix_size;
buffer.resize(size);
basic_string_view<Char> s(&sep, sep_size);
// Index of a decimal digit with the least significant digit having index 0.
......@@ -1571,6 +1572,7 @@ template <typename OutputIt, typename Char, typename UInt> struct int_writer {
std::uninitialized_copy(s.data(), s.data() + s.size(),
make_checked(p, s.size()));
}
if (prefix_size != 0) p[-1] = static_cast<Char>('-');
write(out, basic_string_view<Char>(buffer.data(), buffer.size()), specs);
}
......
......@@ -49,6 +49,7 @@ TEST(LocaleTest, Format) {
std::locale loc(std::locale(), new numpunct<char>());
EXPECT_EQ("1234567", fmt::format(std::locale(), "{:n}", 1234567));
EXPECT_EQ("1~234~567", fmt::format(loc, "{:n}", 1234567));
EXPECT_EQ("-1~234~567", fmt::format(loc, "{:n}", -1234567));
fmt::format_arg_store<fmt::format_context, int> as{1234567};
EXPECT_EQ("1~234~567", fmt::vformat(loc, "{:n}", fmt::format_args(as)));
std::string s;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment