mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 17:58:09 +08:00
fix: skip first ws/newlines in toml literal
when ""_toml literal is used with C++11 raw-string literal, it normally starts with newline like the following. ```cpp const auto v = u8R"( [table] key = "value" )"_toml; ``` With this, the error message shows the first empty line that starts just after `u8R"(` and thus the error message shows nothing. To avoid this, skip the first empty lines and whitespaces in literal.
This commit is contained in:
@@ -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))
|
if(auto data = ::toml::detail::parse_toml_file(loc))
|
||||||
{
|
{
|
||||||
loc.reset(loc.begin()); // rollback to the top of the literal
|
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()),
|
return ::toml::value(std::move(data.unwrap()),
|
||||||
::toml::detail::region<std::vector<char>>(std::move(loc)));
|
::toml::detail::region<std::vector<char>>(std::move(loc)));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user