astyle formatting
This commit is contained in:
parent
421b32efb4
commit
1418c12261
|
@ -123,33 +123,44 @@ bool Settings::Suppressions::FileMatcher::match(const std::string &pattern, cons
|
|||
const char *n = name.c_str();
|
||||
std::stack<std::pair<const char *, const char *> > backtrack;
|
||||
|
||||
for (;;) {
|
||||
for (;;)
|
||||
{
|
||||
bool matching = true;
|
||||
while (*p != '\0' && matching) {
|
||||
switch (*p) {
|
||||
while (*p != '\0' && matching)
|
||||
{
|
||||
switch (*p)
|
||||
{
|
||||
case '*':
|
||||
// Step forward until we match the next character after *
|
||||
while (*n != '\0' && *n != p[1]) {
|
||||
while (*n != '\0' && *n != p[1])
|
||||
{
|
||||
n++;
|
||||
}
|
||||
if (*n != '\0') {
|
||||
if (*n != '\0')
|
||||
{
|
||||
// If this isn't the last possibility, save it for later
|
||||
backtrack.push(std::make_pair(p, n));
|
||||
}
|
||||
break;
|
||||
case '?':
|
||||
// Any character matches unless we're at the end of the name
|
||||
if (*n != '\0') {
|
||||
if (*n != '\0')
|
||||
{
|
||||
n++;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
matching = false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Non-wildcard characters match literally
|
||||
if (*n == *p) {
|
||||
if (*n == *p)
|
||||
{
|
||||
n++;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
matching = false;
|
||||
}
|
||||
break;
|
||||
|
@ -158,12 +169,14 @@ bool Settings::Suppressions::FileMatcher::match(const std::string &pattern, cons
|
|||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// If there are no other paths to tray, then fail
|
||||
if (backtrack.empty()) {
|
||||
if (backtrack.empty())
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (name.find_first_of("*?") != std::string::npos) {
|
||||
for (std::string::const_iterator i = name.begin(); i != name.end(); ++i) {
|
||||
if (*i == '*') {
|
||||
if (name.find_first_of("*?") != std::string::npos)
|
||||
{
|
||||
for (std::string::const_iterator i = name.begin(); i != name.end(); ++i)
|
||||
{
|
||||
if (*i == '*')
|
||||
{
|
||||
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.";
|
||||
}
|
||||
}
|
||||
}
|
||||
_globs[name].insert(line);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
_files[name].insert(line);
|
||||
}
|
||||
return "";
|
||||
|
@ -204,11 +223,14 @@ bool Settings::Suppressions::FileMatcher::isSuppressed(const std::string &file,
|
|||
std::set<unsigned int> lineset;
|
||||
|
||||
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());
|
||||
}
|
||||
for (std::map<std::string, std::set<unsigned int> >::iterator g = _globs.begin(); g != _globs.end(); ++g) {
|
||||
if (match(g->first, file)) {
|
||||
for (std::map<std::string, std::set<unsigned int> >::iterator g = _globs.begin(); g != _globs.end(); ++g)
|
||||
{
|
||||
if (match(g->first, file))
|
||||
{
|
||||
lineset.insert(g->second.begin(), g->second.end());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue