mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 17:28:12 +08:00
fix: remove extraneous null character after float
the bug was introduced by snprintf
This commit is contained in:
@@ -36,7 +36,7 @@ struct serializer
|
|||||||
std::vector<char> buf(bsz + 1, '\0'); // +1 for null character(\0)
|
std::vector<char> buf(bsz + 1, '\0'); // +1 for null character(\0)
|
||||||
std::snprintf(buf.data(), buf.size(), fmt, this->float_prec_, f);
|
std::snprintf(buf.data(), buf.size(), fmt, this->float_prec_, f);
|
||||||
|
|
||||||
std::string token(buf.begin(), buf.end());
|
std::string token(buf.begin(), std::prev(buf.end()));
|
||||||
if(token.back() == '.') // 1. => 1.0
|
if(token.back() == '.') // 1. => 1.0
|
||||||
{
|
{
|
||||||
token += '0';
|
token += '0';
|
||||||
|
Reference in New Issue
Block a user