Skip to content

Commit 4da8961

Browse files
committed
Split the lines
1 parent a1c588f commit 4da8961

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

source/whitelist.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,16 @@ int parseWhitelist()
2626
std::stringstream filereader;
2727
filereader << input.rdbuf();
2828
std::string filedata = filereader.str();
29-
std::regex line_parser("[ \t]*([\\w\\.-]+)\\:(\\d+)(?:(?:[ \t]*\r?\n)+|[ \t]*$)");
30-
for (std::regex_iterator<std::string::iterator> match = std::regex_iterator(filedata.begin(), filedata.end(), line_parser), end = std::regex_iterator<std::string::iterator>(); match != end; ++match)
29+
std::regex line_parser("(?:(?!\r?\n).)+");
30+
std::regex entry_parser("^[ \\t]*([\\w\\.-]+)\\:(\\d+)[ \\t]*$");
31+
for (std::sregex_iterator line = std::sregex_iterator(filedata.begin(), filedata.end(), line_parser), end = std::sregex_iterator(); line != end; ++line)
3132
{
32-
whitelist[match->operator[](1).str()].insert(match->operator[](2).str());
33+
const std::string& linestr = line->operator[](0);
34+
std::smatch match;
35+
if(std::regex_match(linestr, match, entry_parser))
36+
{
37+
whitelist[match[1].str()].insert(match[2].str());
38+
}
3339
}
3440
if (whitelist.empty())
3541
{

0 commit comments

Comments
 (0)