From 82e8c1e68b26a27e58c01d422c9b31b6ea50c828 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Sun, 21 Apr 2019 16:31:24 +0900 Subject: [PATCH] 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. --- toml/literal.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/toml/literal.hpp b/toml/literal.hpp index d7194ed..0e61cc9 100644 --- a/toml/literal.hpp +++ b/toml/literal.hpp @@ -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::move(loc))); }