mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 17:58:09 +08:00
chore: merge branch 'master' into travis-ci
This commit is contained in:
@@ -1058,7 +1058,7 @@ bool is_valid_forward_table_definition(const value& fwd,
|
|||||||
{
|
{
|
||||||
// table keys always contains all the nodes from the root.
|
// table keys always contains all the nodes from the root.
|
||||||
const auto& tks = tabkeys.unwrap().first;
|
const auto& tks = tabkeys.unwrap().first;
|
||||||
if(std::distance(key_first, key_last) == tks.size() &&
|
if(std::size_t(std::distance(key_first, key_last)) == tks.size() &&
|
||||||
std::equal(tks.begin(), tks.end(), key_first))
|
std::equal(tks.begin(), tks.end(), key_first))
|
||||||
{
|
{
|
||||||
// the keys are equivalent. it is not allowed.
|
// the keys are equivalent. it is not allowed.
|
||||||
@@ -1079,7 +1079,7 @@ bool is_valid_forward_table_definition(const value& fwd,
|
|||||||
// a dotted key starts from the node representing a table in which the
|
// a dotted key starts from the node representing a table in which the
|
||||||
// dotted key belongs to.
|
// dotted key belongs to.
|
||||||
const auto& dks = dotkeys.unwrap().first;
|
const auto& dks = dotkeys.unwrap().first;
|
||||||
if(std::distance(key_curr, key_last) == dks.size() &&
|
if(std::size_t(std::distance(key_curr, key_last)) == dks.size() &&
|
||||||
std::equal(dks.begin(), dks.end(), key_curr))
|
std::equal(dks.begin(), dks.end(), key_curr))
|
||||||
{
|
{
|
||||||
// the keys are equivalent. it is not allowed.
|
// the keys are equivalent. it is not allowed.
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
#include "value.hpp"
|
#include "value.hpp"
|
||||||
#include "lexer.hpp"
|
#include "lexer.hpp"
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
namespace toml
|
namespace toml
|
||||||
{
|
{
|
||||||
@@ -30,13 +31,12 @@ struct serializer
|
|||||||
}
|
}
|
||||||
std::string operator()(const toml::floating f) const
|
std::string operator()(const toml::floating f) const
|
||||||
{
|
{
|
||||||
std::string token = [=] {
|
const auto fmt = "%.*g";
|
||||||
// every float value needs decimal point (or exponent).
|
const auto bsz = std::snprintf(nullptr, 0, fmt, this->float_prec_, f);
|
||||||
std::ostringstream oss;
|
std::vector<char> buf(bsz + 1, '\0'); // +1 for null character(\0)
|
||||||
oss << std::setprecision(float_prec_) << std::showpoint << f;
|
std::snprintf(buf.data(), buf.size(), fmt, this->float_prec_, f);
|
||||||
return oss.str();
|
|
||||||
}();
|
|
||||||
|
|
||||||
|
std::string token(buf.begin(), 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