|
|
|
@ -560,19 +560,13 @@ std::pair<std::map<boost::filesystem::path, Usages::Clang::PathSet>, Usages::Cla |
|
|
|
std::string line; |
|
|
|
std::string line; |
|
|
|
while(std::getline(stream, line)) { |
|
|
|
while(std::getline(stream, line)) { |
|
|
|
// Optimization: only run regex_match if line starts with # after spaces/tabs
|
|
|
|
// Optimization: only run regex_match if line starts with # after spaces/tabs
|
|
|
|
auto include_begin = line.cbegin(); |
|
|
|
size_t pos = 0; |
|
|
|
for(; include_begin != line.cend(); ++include_begin) { |
|
|
|
while(pos < line.size() && (line[pos] == ' ' || line[pos] == '\t')) |
|
|
|
if(*include_begin == ' ' || *include_begin == '\t') |
|
|
|
++pos; |
|
|
|
continue; |
|
|
|
if(pos >= line.size()) |
|
|
|
if(*include_begin == '#') |
|
|
|
continue; |
|
|
|
break; |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
include_begin = line.cend(); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
std::smatch sm; |
|
|
|
std::smatch sm; |
|
|
|
if(include_begin != line.cend() && std::regex_match(include_begin, line.cend(), sm, include_regex)) { |
|
|
|
if(line[pos] == '#' && std::regex_match(line.cbegin() + pos, line.cend(), sm, include_regex)) { |
|
|
|
boost::filesystem::path path(sm[1].str()); |
|
|
|
boost::filesystem::path path(sm[1].str()); |
|
|
|
boost::filesystem::path include_path; |
|
|
|
boost::filesystem::path include_path; |
|
|
|
// remove .. and .
|
|
|
|
// remove .. and .
|
|
|
|
@ -596,11 +590,10 @@ std::pair<std::map<boost::filesystem::path, Usages::Clang::PathSet>, Usages::Cla |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else if(check_spelling) { |
|
|
|
else if(check_spelling) { |
|
|
|
size_t pos = 0; |
|
|
|
|
|
|
|
while((pos = line.find(spelling, pos)) != std::string::npos) { |
|
|
|
while((pos = line.find(spelling, pos)) != std::string::npos) { |
|
|
|
if(!is_spelling_char(spelling[0]) || |
|
|
|
if(!is_spelling_char(spelling[0]) || |
|
|
|
((pos == 0 || !is_spelling_char(line[pos - 1])) && |
|
|
|
((pos == 0 || !is_spelling_char(line[pos - 1])) && |
|
|
|
(pos + spelling.size() >= line.size() - 1 || !is_spelling_char(line[pos + spelling.size()])))) { |
|
|
|
(pos + spelling.size() >= line.size() || !is_spelling_char(line[pos + spelling.size()])))) { |
|
|
|
paths_with_spelling.emplace(path); |
|
|
|
paths_with_spelling.emplace(path); |
|
|
|
check_spelling = false; |
|
|
|
check_spelling = false; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|