astyle formatting
This commit is contained in:
parent
421b32efb4
commit
1418c12261
100
lib/settings.cpp
100
lib/settings.cpp
|
@ -123,47 +123,60 @@ bool Settings::Suppressions::FileMatcher::match(const std::string &pattern, cons
|
||||||
const char *n = name.c_str();
|
const char *n = name.c_str();
|
||||||
std::stack<std::pair<const char *, const char *> > backtrack;
|
std::stack<std::pair<const char *, const char *> > backtrack;
|
||||||
|
|
||||||
for (;;) {
|
for (;;)
|
||||||
|
{
|
||||||
bool matching = true;
|
bool matching = true;
|
||||||
while (*p != '\0' && matching) {
|
while (*p != '\0' && matching)
|
||||||
switch (*p) {
|
{
|
||||||
case '*':
|
switch (*p)
|
||||||
// Step forward until we match the next character after *
|
{
|
||||||
while (*n != '\0' && *n != p[1]) {
|
case '*':
|
||||||
n++;
|
// Step forward until we match the next character after *
|
||||||
}
|
while (*n != '\0' && *n != p[1])
|
||||||
if (*n != '\0') {
|
{
|
||||||
// If this isn't the last possibility, save it for later
|
n++;
|
||||||
backtrack.push(std::make_pair(p, n));
|
}
|
||||||
}
|
if (*n != '\0')
|
||||||
break;
|
{
|
||||||
case '?':
|
// If this isn't the last possibility, save it for later
|
||||||
// Any character matches unless we're at the end of the name
|
backtrack.push(std::make_pair(p, n));
|
||||||
if (*n != '\0') {
|
}
|
||||||
n++;
|
break;
|
||||||
} else {
|
case '?':
|
||||||
matching = false;
|
// Any character matches unless we're at the end of the name
|
||||||
}
|
if (*n != '\0')
|
||||||
break;
|
{
|
||||||
default:
|
n++;
|
||||||
// Non-wildcard characters match literally
|
}
|
||||||
if (*n == *p) {
|
else
|
||||||
n++;
|
{
|
||||||
} else {
|
matching = false;
|
||||||
matching = false;
|
}
|
||||||
}
|
break;
|
||||||
break;
|
default:
|
||||||
|
// Non-wildcard characters match literally
|
||||||
|
if (*n == *p)
|
||||||
|
{
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
matching = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we haven't failed matching and we've reached the end of the name, then success
|
// If we haven't failed matching and we've reached the end of the name, then success
|
||||||
if (matching && *n == '\0') {
|
if (matching && *n == '\0')
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there are no other paths to tray, then fail
|
// If there are no other paths to tray, then fail
|
||||||
if (backtrack.empty()) {
|
if (backtrack.empty())
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,17 +192,23 @@ bool Settings::Suppressions::FileMatcher::match(const std::string &pattern, cons
|
||||||
|
|
||||||
std::string Settings::Suppressions::FileMatcher::addFile(const std::string &name, unsigned int line)
|
std::string Settings::Suppressions::FileMatcher::addFile(const std::string &name, unsigned int line)
|
||||||
{
|
{
|
||||||
if (name.find_first_of("*?") != std::string::npos) {
|
if (name.find_first_of("*?") != std::string::npos)
|
||||||
for (std::string::const_iterator i = name.begin(); i != name.end(); ++i) {
|
{
|
||||||
if (*i == '*') {
|
for (std::string::const_iterator i = name.begin(); i != name.end(); ++i)
|
||||||
|
{
|
||||||
|
if (*i == '*')
|
||||||
|
{
|
||||||
std::string::const_iterator j = i + 1;
|
std::string::const_iterator j = i + 1;
|
||||||
if (j != name.end() && (*j == '*' || *j == '?')) {
|
if (j != name.end() && (*j == '*' || *j == '?'))
|
||||||
|
{
|
||||||
return "Failed to add suppression. Syntax error in glob.";
|
return "Failed to add suppression. Syntax error in glob.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_globs[name].insert(line);
|
_globs[name].insert(line);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
_files[name].insert(line);
|
_files[name].insert(line);
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
@ -204,11 +223,14 @@ bool Settings::Suppressions::FileMatcher::isSuppressed(const std::string &file,
|
||||||
std::set<unsigned int> lineset;
|
std::set<unsigned int> lineset;
|
||||||
|
|
||||||
std::map<std::string, std::set<unsigned int> >::const_iterator f = _files.find(file);
|
std::map<std::string, std::set<unsigned int> >::const_iterator f = _files.find(file);
|
||||||
if (f != _files.end()) {
|
if (f != _files.end())
|
||||||
|
{
|
||||||
lineset.insert(f->second.begin(), f->second.end());
|
lineset.insert(f->second.begin(), f->second.end());
|
||||||
}
|
}
|
||||||
for (std::map<std::string, std::set<unsigned int> >::iterator g = _globs.begin(); g != _globs.end(); ++g) {
|
for (std::map<std::string, std::set<unsigned int> >::iterator g = _globs.begin(); g != _globs.end(); ++g)
|
||||||
if (match(g->first, file)) {
|
{
|
||||||
|
if (match(g->first, file))
|
||||||
|
{
|
||||||
lineset.insert(g->second.begin(), g->second.end());
|
lineset.insert(g->second.begin(), g->second.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue