Skip to content

Commit

Permalink
Split the lines
Browse files Browse the repository at this point in the history
  • Loading branch information
thegrb93 committed Jan 16, 2020
1 parent a1c588f commit 4da8961
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions source/whitelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ int parseWhitelist()
std::stringstream filereader;
filereader << input.rdbuf();
std::string filedata = filereader.str();
std::regex line_parser("[ \t]*([\\w\\.-]+)\\:(\\d+)(?:(?:[ \t]*\r?\n)+|[ \t]*$)");
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)
std::regex line_parser("(?:(?!\r?\n).)+");
std::regex entry_parser("^[ \\t]*([\\w\\.-]+)\\:(\\d+)[ \\t]*$");
for (std::sregex_iterator line = std::sregex_iterator(filedata.begin(), filedata.end(), line_parser), end = std::sregex_iterator(); line != end; ++line)
{
whitelist[match->operator[](1).str()].insert(match->operator[](2).str());
const std::string& linestr = line->operator[](0);
std::smatch match;
if(std::regex_match(linestr, match, entry_parser))
{
whitelist[match[1].str()].insert(match[2].str());
}
}
if (whitelist.empty())
{
Expand Down

0 comments on commit 4da8961

Please sign in to comment.