fix: remove extraneous null character after float

the bug was introduced by snprintf
This commit is contained in:
ToruNiina
2019-03-15 19:30:36 +09:00
parent 9eb4008d6d
commit 9b8db6a225

View File

@@ -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';