mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-19 11:14:41 +00:00
Fix sign handling in 'L'
This commit is contained in:
parent
23b976a615
commit
8c88abde64
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user