From c6467af814fe74a8992cea7b8a96bd2956df9f33 Mon Sep 17 00:00:00 2001 From: Houtan Bastani <houtan@dynare.org> Date: Wed, 10 Apr 2019 14:49:33 +0200 Subject: [PATCH] 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 --- src/DynareMain.cc | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/DynareMain.cc b/src/DynareMain.cc index 99b593d6..88404669 100644 --- a/src/DynareMain.cc +++ b/src/DynareMain.cc @@ -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); -- GitLab