File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,17 @@ namespace
7575 {
7676 std::string return_value;
7777
78+ // Declare the regex we would like to match against each line of the
79+ // input file. Make sure we have a \r at the very end because the '.'
80+ // operator matches every printable character but not special ones
81+ // like \r. As a consequence, a line that ends in a Windows-style
82+ // \r would not match this regex even if it sets the correct parameter.
83+ //
84+ // We will deal with the presence of Windows line endings on Unix systems
85+ // in the places where we call this function, and so include the \r
86+ // in the second match group.
87+ const std::regex regex (" set[ \t ]+" + parameter_name + " [ \t ]*=[ \t ]*(.*\r ?)" );
88+
7889 std::istringstream x_file (parameters);
7990 while (x_file)
8091 {
@@ -91,7 +102,6 @@ namespace
91102 line.erase (line.size () - 1 , std::string::npos);
92103
93104 std::match_results<std::string::const_iterator> matches;
94- const std::regex regex (" set[ \t ]+" + parameter_name + " [ \t ]*=[ \t ]*(.*)" );
95105 if (std::regex_match (line, matches, regex))
96106 {
97107 // Since the line as a whole matched, the 'matches' variable needs to
You can’t perform that action at this time.
0 commit comments