fix: allow empty table in the middle of a file

This commit is contained in:
ToruNiina
2019-03-01 22:53:16 +09:00
parent 0c9806e99f
commit 536b23dc84

View File

@@ -1370,7 +1370,7 @@ result<table, std::string> parse_ml_table(location<Container>& loc)
const auto first = loc.iter(); const auto first = loc.iter();
if(first == loc.end()) if(first == loc.end())
{ {
return err(std::string("toml::parse_ml_table: input is empty")); return ok(toml::table{});
} }
// XXX at lest one newline is needed. // XXX at lest one newline is needed.
@@ -1453,7 +1453,7 @@ result<table, std::string> parse_toml_file(location<Container>& loc)
} }
table data; table data;
/* root object is also table, but without [tablename] */ // root object is also a table, but without [tablename]
if(auto tab = parse_ml_table(loc)) if(auto tab = parse_ml_table(loc))
{ {
data = std::move(tab.unwrap()); data = std::move(tab.unwrap());