From 0f83ee60398d9d27c5f39fe29d43a94b5f011e72 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Wed, 12 Dec 2018 19:12:23 +0900 Subject: [PATCH] change temporaly loc from token to copy of loc location constructed from token string does not has correct line number information. to show an informative error message about UTF-8 and escape sequences, parse_(ml_)basic_string requires those information that can only be given from root location. --- toml/parser.hpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/toml/parser.hpp b/toml/parser.hpp index d630967..2cd4e85 100644 --- a/toml/parser.hpp +++ b/toml/parser.hpp @@ -341,9 +341,11 @@ parse_ml_basic_string(location& loc) const auto first = loc.iter(); if(const auto token = lex_ml_basic_string::invoke(loc)) { - location inner_loc(loc.name(), token.unwrap().str()); + auto inner_loc = loc; + inner_loc.iter() = first; + std::string retval; - retval.reserve(inner_loc.source()->size()); + retval.reserve(token.unwrap().size()); auto delim = lex_ml_basic_string_delim::invoke(inner_loc); if(!delim) @@ -396,7 +398,8 @@ parse_basic_string(location& loc) const auto first = loc.iter(); if(const auto token = lex_basic_string::invoke(loc)) { - location inner_loc(loc.name(), token.unwrap().str()); + auto inner_loc = loc; + inner_loc.iter() = first; auto quot = lex_quotation_mark::invoke(inner_loc); if(!quot) @@ -406,7 +409,7 @@ parse_basic_string(location& loc) } std::string retval; - retval.reserve(inner_loc.source()->size()); + retval.reserve(token.unwrap().size()); quot = err("tmp"); while(!quot)