From de51686bb14bca0432fbf046786604518aed85a3 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 25 May 2014 00:57:32 +0300 Subject: Add exceptions into debug and license rules. --- src/rules/debug.cpp | 2 ++ src/rules/license.cpp | 5 +++++ src/stringutils.cpp | 11 +++++++++-- src/stringutils.h | 2 ++ src/template.hpp | 2 ++ 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 #include +#include #include #include -#include -#include #include +#include +#include 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 + #include "localconsts.h" #define registerRule(rule) \ -- cgit v1.2.3-60-g2f50