summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-25 00:57:32 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-25 01:01:11 +0300
commitde51686bb14bca0432fbf046786604518aed85a3 (patch)
tree9699c21e82c9f48a81c369425d2b334e2339449d
parent2a9777006e034ba0fa1260355d282c434b0c3978 (diff)
downloadmplint-de51686bb14bca0432fbf046786604518aed85a3.tar.gz
mplint-de51686bb14bca0432fbf046786604518aed85a3.tar.bz2
mplint-de51686bb14bca0432fbf046786604518aed85a3.tar.xz
mplint-de51686bb14bca0432fbf046786604518aed85a3.zip
Add exceptions into debug and license rules.
-rw-r--r--src/rules/debug.cpp2
-rw-r--r--src/rules/license.cpp5
-rw-r--r--src/stringutils.cpp11
-rw-r--r--src/stringutils.h2
-rw-r--r--src/template.hpp2
5 files changed, 20 insertions, 2 deletions
diff --git a/src/rules/debug.cpp b/src/rules/debug.cpp
index e2279bf..7c16990 100644
--- a/src/rules/debug.cpp
+++ b/src/rules/debug.cpp
@@ -45,6 +45,8 @@ registerRuleExt(debugCpp, "004", "(.+)[.]cpp")
startRule(debugCpp)
{
+ if (isMatch(file, "(.*)[/]debug[/]([^/]*)[.](cpp|h)"))
+ terminateRule();
}
endRule(debugCpp)
diff --git a/src/rules/license.cpp b/src/rules/license.cpp
index d70a051..06eda18 100644
--- a/src/rules/license.cpp
+++ b/src/rules/license.cpp
@@ -24,6 +24,11 @@ registerRuleExt(license, "005", "(.+)[.](h|cpp)")
startRule(license)
{
+ if (isMatch(file, "(.*)[/]((debug|sdl2gfx)[/]([^/]*)|mumblemanager"
+ "|SDLMain|utils/physfsrwops|utils/base64)[.](cpp|h)"))
+ {
+ terminateRule();
+ }
}
endRule(license)
diff --git a/src/stringutils.cpp b/src/stringutils.cpp
index f580266..05e6a01 100644
--- a/src/stringutils.cpp
+++ b/src/stringutils.cpp
@@ -24,11 +24,12 @@
#include <string>
#include <algorithm>
+#include <cctype>
#include <cstdarg>
#include <cstdio>
-#include <cctype>
-#include <list>
#include <ctime>
+#include <list>
+#include <regex>
std::string &trim(std::string &str)
{
@@ -694,3 +695,9 @@ void secureChatCommand(std::string &str)
if (str[0] == '/' || str[0] == '@' || str[0] == '#')
str = "_" + str;
}
+
+bool isMatch(const std::string &str, const std::string &exp)
+{
+ std::regex regExp(exp);
+ return std::regex_match(str, regExp);
+}
diff --git a/src/stringutils.h b/src/stringutils.h
index 8943317..f7218c0 100644
--- a/src/stringutils.h
+++ b/src/stringutils.h
@@ -234,4 +234,6 @@ bool isDigit(const std::string &str);
void secureChatCommand(std::string &str);
+bool isMatch(const std::string &str, const std::string &exp);
+
#endif // STRINGUTILS_H
diff --git a/src/template.hpp b/src/template.hpp
index 3acfb86..25c7b88 100644
--- a/src/template.hpp
+++ b/src/template.hpp
@@ -21,6 +21,8 @@
#include "rulebase.h"
#include "stringutils.h"
+#include <regex>
+
#include "localconsts.h"
#define registerRule(rule) \