Merge branch 'master' into string-view

This commit is contained in:
ToruNiina
2019-04-23 23:32:08 +09:00
4 changed files with 19 additions and 7 deletions

View File

@@ -73,6 +73,9 @@ inline ::toml::value operator""_toml(const char* str, std::size_t len)
if(auto data = ::toml::detail::parse_toml_file(loc))
{
loc.reset(loc.begin()); // rollback to the top of the literal
// skip needless characters for error message
skip_line::invoke(loc); // skip the first several needless lines
skip_ws::invoke(loc); // skip the first several needless whitespaces
return ::toml::value(std::move(data.unwrap()),
::toml::detail::region<std::vector<char>>(std::move(loc)));
}

View File

@@ -1406,10 +1406,16 @@ parse_inline_table(location<Container>& loc)
return ok(std::make_pair(
retval, region<Container>(loc, first, loc.iter())));
}
else if(*loc.iter() == '#' || *loc.iter() == '\r' || *loc.iter() == '\n')
{
throw syntax_error(format_underline("[error] "
"toml::parse_inline_table: missing curly brace `}`",
{{std::addressof(loc), "should be `}`"}}));
}
else
{
throw syntax_error(format_underline("[error] "
"toml:::parse_inline_table: missing table separator `,` ",
"toml::parse_inline_table: missing table separator `,` ",
{{std::addressof(loc), "should be `,`"}}));
}
}

View File

@@ -343,7 +343,8 @@ inline std::string format_underline(const std::string& message,
{
// invalid
// ~~~~~~~
retval << make_string(reg->size(), '~');
const auto underline_len = std::min(reg->size(), reg->line().size());
retval << make_string(underline_len, '~');
}
retval << ' ';