From 5bdc0226271d9a112fa27950dc758db779421936 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Wed, 13 Feb 2019 13:51:08 +0900 Subject: [PATCH] fix: correctly serialize quoted keys --- toml/serializer.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/toml/serializer.hpp b/toml/serializer.hpp index a365200..d769e68 100644 --- a/toml/serializer.hpp +++ b/toml/serializer.hpp @@ -258,9 +258,10 @@ struct serializer std::string serialize_key(const toml::key& key) const { detail::location loc(key, key); - if(const auto unquoted = detail::lex_unquoted_key::invoke(loc)) + detail::lex_unquoted_key::invoke(loc); + if(loc.iter() == loc.end()) { - return key; // the key is unquoted-key + return key; // all the tokens are consumed. the key is unquoted-key. } std::string token("\""); token += this->escape_basic_string(key); @@ -382,7 +383,7 @@ struct serializer continue; } - const auto key_and_sep = serialize_key(kv.first) + " = "; + const auto key_and_sep = this->serialize_key(kv.first) + " = "; const auto residual_width = this->width_ - key_and_sep.size(); token += key_and_sep;