From 1418c12261b4fa70643c32c02f90150236ee32cd Mon Sep 17 00:00:00 2001 From: Greg Hewgill Date: Sun, 13 Feb 2011 10:01:32 +1300 Subject: [PATCH] astyle formatting --- lib/settings.cpp | 100 +++++++++++++++++++++++++++++------------------ 1 file changed, 61 insertions(+), 39 deletions(-) diff --git a/lib/settings.cpp b/lib/settings.cpp index 88cb556ab..dbd4f37c7 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -123,47 +123,60 @@ bool Settings::Suppressions::FileMatcher::match(const std::string &pattern, cons const char *n = name.c_str(); std::stack > backtrack; - for (;;) { + for (;;) + { bool matching = true; - while (*p != '\0' && matching) { - switch (*p) { - case '*': - // Step forward until we match the next character after * - while (*n != '\0' && *n != p[1]) { - n++; - } - 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') { - n++; - } else { - matching = false; - } - break; - default: - // Non-wildcard characters match literally - if (*n == *p) { - n++; - } else { - matching = false; - } - break; + while (*p != '\0' && matching) + { + switch (*p) + { + case '*': + // Step forward until we match the next character after * + while (*n != '\0' && *n != p[1]) + { + n++; + } + 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') + { + n++; + } + else + { + matching = false; + } + break; + default: + // Non-wildcard characters match literally + if (*n == *p) + { + n++; + } + else + { + matching = false; + } + break; } p++; } // 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 lineset; std::map >::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 >::iterator g = _globs.begin(); g != _globs.end(); ++g) { - if (match(g->first, file)) { + for (std::map >::iterator g = _globs.begin(); g != _globs.end(); ++g) + { + if (match(g->first, file)) + { lineset.insert(g->second.begin(), g->second.end()); } }