Commit c6467af8 authored by Houtan Bastani's avatar Houtan Bastani

Read options at top of .mod file as long as they exist on the first *non empty* line

In other words, allow newlines before these options
parent 2a9c4b23
Pipeline #1116 passed with stage
in 1 minute and 47 seconds
......@@ -74,19 +74,23 @@ vector<string>
parse_options_line(istream &modfile)
{
vector<string> options;
string first_line;
getline(modfile, first_line);
string first_nonempty_line;
regex pat{R"(^\s*//\s*--\+\s*options:([^\+]*)\+--)"};
smatch matches;
if (regex_search(first_line, matches, pat))
if (matches.size() > 1 && matches[1].matched)
while (getline(modfile, first_nonempty_line))
if (first_nonempty_line != "")
{
regex pat2{R"(([^,\s]+))"};
string s{matches[1]};
for (sregex_iterator p(s.begin(), s.end(), pat2);
p != sregex_iterator{}; ++p)
options.push_back((*p)[1]);
if (regex_search(first_nonempty_line, matches, pat))
if (matches.size() > 1 && matches[1].matched)
{
regex pat2{R"(([^,\s]+))"};
string s{matches[1]};
for (sregex_iterator p(s.begin(), s.end(), pat2);
p != sregex_iterator{}; ++p)
options.push_back((*p)[1]);
}
break;
}
modfile.seekg(0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment