mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-29 09:31:06 +00:00
Fix the error when formatting a float with a filled buffer on MSVC.
This commit is contained in:
parent
cb316b13b1
commit
33baa8f382
@ -320,6 +320,15 @@ void fmt::BasicWriter<Char>::FormatDouble(
|
|||||||
Char fill = static_cast<Char>(spec.fill());
|
Char fill = static_cast<Char>(spec.fill());
|
||||||
for (;;) {
|
for (;;) {
|
||||||
std::size_t size = buffer_.capacity() - offset;
|
std::size_t size = buffer_.capacity() - offset;
|
||||||
|
#if _MSC_VER
|
||||||
|
// MSVC's vsnprintf_s doesn't work with zero size, so reserve
|
||||||
|
// space for at least one extra character to make the size non-zero.
|
||||||
|
// Note that the buffer's capacity will increase by more than 1.
|
||||||
|
if (size == 0) {
|
||||||
|
buffer_.reserve(offset + 1);
|
||||||
|
size = buffer_.capacity() - offset;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
Char *start = &buffer_[offset];
|
Char *start = &buffer_[offset];
|
||||||
int n = internal::CharTraits<Char>::FormatFloat(
|
int n = internal::CharTraits<Char>::FormatFloat(
|
||||||
start, size, format, width_for_sprintf, precision, value);
|
start, size, format, width_for_sprintf, precision, value);
|
||||||
|
Loading…
Reference in New Issue
Block a user