diff options
Diffstat (limited to 'src/rules')
-rw-r--r-- | src/rules/baseclass.cpp | 7 | ||||
-rw-r--r-- | src/rules/brackets.cpp | 2 | ||||
-rw-r--r-- | src/rules/constructor.cpp | 2 | ||||
-rw-r--r-- | src/rules/constructorbrackets.cpp | 5 | ||||
-rw-r--r-- | src/rules/copyconstructor.cpp | 17 | ||||
-rw-r--r-- | src/rules/debug.cpp | 4 | ||||
-rw-r--r-- | src/rules/dump.cpp | 4 | ||||
-rw-r--r-- | src/rules/final.cpp | 6 | ||||
-rw-r--r-- | src/rules/formatting.cpp | 4 | ||||
-rw-r--r-- | src/rules/include.cpp | 3 | ||||
-rw-r--r-- | src/rules/license.cpp | 6 | ||||
-rw-r--r-- | src/rules/packet.cpp | 3 | ||||
-rw-r--r-- | src/rules/po.cpp | 3 | ||||
-rw-r--r-- | src/rules/translation.cpp | 2 | ||||
-rw-r--r-- | src/rules/virtual.cpp | 4 | ||||
-rw-r--r-- | src/rules/xml.cpp | 3 |
16 files changed, 33 insertions, 42 deletions
diff --git a/src/rules/baseclass.cpp b/src/rules/baseclass.cpp index c6c06bf..edb339e 100644 --- a/src/rules/baseclass.cpp +++ b/src/rules/baseclass.cpp @@ -20,7 +20,7 @@ #include "template.hpp" -registerRuleExt(baseclass, "006", "(.+)[.](cpp|h)") +registerRuleExt(baseclass, "006", R"( \.(cpp|h)$ )") startRule(baseclass) { @@ -32,11 +32,8 @@ endRule(baseclass) parseLineRule(baseclass) { - std::smatch m; if (data.find("friend ") == std::string::npos && - isMatch(data, "(.*)(class|struct) (([a-zA-Z_0123456789]+)|" - "([a-zA-Z_0123456789 ]+)([a-zA-Z_0123456789]+))[:](.*)", - m)) + isMatch(data, R"( (class|struct) \s+? [\w\s]+? [^\s] : )")) { print("Wrong align after class name and before ':'."); } diff --git a/src/rules/brackets.cpp b/src/rules/brackets.cpp index a323249..2bb025f 100644 --- a/src/rules/brackets.cpp +++ b/src/rules/brackets.cpp @@ -20,7 +20,7 @@ #include "template.hpp" -registerRuleExt(brackets, "015", "(.+)[.](cpp|h)") +registerRuleExt(brackets, "015", R"( \.(cpp|h)$ )") startRule(brackets) { diff --git a/src/rules/constructor.cpp b/src/rules/constructor.cpp index e1795cb..c8bc8ef 100644 --- a/src/rules/constructor.cpp +++ b/src/rules/constructor.cpp @@ -20,7 +20,7 @@ #include "template.hpp" -registerRuleExt(constructor, "006", "(.+)[.](cpp|h)") +registerRuleExt(constructor, "006", R"( \.(cpp|h)$ )") bool foundConstructor(false); int align = 0; diff --git a/src/rules/constructorbrackets.cpp b/src/rules/constructorbrackets.cpp index 73dd9f3..17ae235 100644 --- a/src/rules/constructorbrackets.cpp +++ b/src/rules/constructorbrackets.cpp @@ -20,7 +20,7 @@ #include "template.hpp" -registerRuleExt(constructorBrackets, "017", "(.+)[.](cpp|h)") +registerRuleExt(constructorBrackets, "017", R"( \.(cpp|h)$ )") startRule(constructorBrackets) { @@ -34,8 +34,7 @@ parseLineRule(constructorBrackets) { if (data.find("new ") != std::string::npos) { - std::smatch m; - if (isMatch(data, "(.+)[ ]new[ ]([a-zA-Z_0123456789]+)[(][)](.+)", m)) + if (isMatch(data, R"( \b new \s+? \w+? \s*? \( \s*? \) )")) { print("Remove () after new CLASS()."); } diff --git a/src/rules/copyconstructor.cpp b/src/rules/copyconstructor.cpp index 3aeeccb..e96234e 100644 --- a/src/rules/copyconstructor.cpp +++ b/src/rules/copyconstructor.cpp @@ -20,7 +20,7 @@ #include "template.hpp" -registerRuleExt(copyConstructor, "016", "(.+)[.](cpp|h)") +registerRuleExt(copyConstructor, "016", R"( \.(cpp|h)$ )") namespace { @@ -51,20 +51,17 @@ endRule(copyConstructor) parseLineRule(copyConstructor) { - std::smatch m; - if (isMatch(data, "(.*)(class|struct) ([a-zA-Z_0123456789]+)" - " (|not)final(.*)", - m)) + jp::VecNum m; + if (isMatch(data, R"( (class|struct) \s+? (\w+?) \s+? (not)?final )", m)) { - const std::string str = m.str(3); + const std::string str = m[0][2]; mClasses.insert(str); mLines[str] = line; } - else if (isMatch(data, "([ ]*)(A_DELETE_COPY|A_DEFAULT_COPY)[(]" - "([a-zA-Z_0123456789]+)[)](.*)", - m)) + else if (isMatch(data, R"( ^ \s*? (A_DELETE_COPY|A_DEFAULT_COPY) )" + R"( \s*? \( \s*? (\w+?) \s*? \) )", m)) { - const std::string str = m.str(3); + const std::string str = m[0][2]; if (mClasses.find(str) != mClasses.end()) { mClasses.erase(str); diff --git a/src/rules/debug.cpp b/src/rules/debug.cpp index 82e16fe..f2cbb96 100644 --- a/src/rules/debug.cpp +++ b/src/rules/debug.cpp @@ -20,7 +20,7 @@ #include "template.hpp" -registerRuleExt(debugH, "003", "(.+)[.]h") +registerRuleExt(debugH, "003", R"( \.h$ )") startRule(debugH) { @@ -47,7 +47,7 @@ registerRuleExt(debugCpp, "004", "(.+)[.]cpp") startRule(debugCpp) { - if (isMatch(file, "(.*)[/]debug[/]([^/]*)[.](cpp|h)")) + if (isMatch(file, R"( /debug/ .*? \.(cpp|h) $ )")) terminateRule(); foundDebug = false; } diff --git a/src/rules/dump.cpp b/src/rules/dump.cpp index a01aefe..0e909ac 100644 --- a/src/rules/dump.cpp +++ b/src/rules/dump.cpp @@ -21,7 +21,7 @@ #include "template.hpp" /* -registerRuleExt(dumpCpp, "001", "(.+)[.]cpp") +registerRuleExt(dumpCpp, "001", R"( \.cpp$ )") startRule(dumpCpp) { @@ -39,7 +39,7 @@ parseLineRule(dumpCpp) } -registerRuleExt(dumpH, "002", "(.+)[.]h") +registerRuleExt(dumpH, "002", R"( \.h$ )") startRule(dumpH) { diff --git a/src/rules/final.cpp b/src/rules/final.cpp index bc2acb7..a968c54 100644 --- a/src/rules/final.cpp +++ b/src/rules/final.cpp @@ -20,7 +20,7 @@ #include "template.hpp" -registerRuleExt(finalCheck, "007", "(.+)[.](cpp|h)") +registerRuleExt(finalCheck, "007", R"( \.(cpp|h)$ )") startRule(finalCheck) { @@ -38,8 +38,8 @@ endRule(finalCheck) parseLineRule(finalCheck) { - if (isMatch(data, "([ ]*)(static |)(class|struct) ([a-zA-Z_0123456789]+)" - "($|( [:])([^;]+)(.*))")) + if (isMatch(data, R"( ^ \s*? (static \s+?)? (class|struct) )" + R"( \s+? \w+? \s*? ($ | :) )")) { print("Need add final or notfinal into class declaration"); } diff --git a/src/rules/formatting.cpp b/src/rules/formatting.cpp index 1a49848..175be96 100644 --- a/src/rules/formatting.cpp +++ b/src/rules/formatting.cpp @@ -20,7 +20,9 @@ #include "template.hpp" -registerRuleExt(formatting, "011", "(.+)[.](cpp|h)") +#include <stack> + +registerRuleExt(formatting, "011", R"( \.(cpp|h)$ )") namespace { diff --git a/src/rules/include.cpp b/src/rules/include.cpp index 347bf58..c6e4246 100644 --- a/src/rules/include.cpp +++ b/src/rules/include.cpp @@ -20,7 +20,7 @@ #include "template.hpp" -registerRuleExt(include, "008", "(.+)[.](cpp|h)") +registerRuleExt(include, "008", R"( \.(cpp|h)$ )") startRule(include) { @@ -61,4 +61,3 @@ parseLineRule(include) } } } - diff --git a/src/rules/license.cpp b/src/rules/license.cpp index 0778831..9bd8fd9 100644 --- a/src/rules/license.cpp +++ b/src/rules/license.cpp @@ -25,12 +25,12 @@ bool foundManaPlus(false); bool checkText(false); bool foundLicenseNumber(false); -registerRuleExt(license, "005", "(.+)[.](h|cpp|cc|inc)") +registerRuleExt(license, "005", R"( \.(h|cpp|cc|inc)$ )") startRule(license) { - if (isMatch(file, "(.*)[/]((debug|sdl2gfx)[/]([^/]*)|mumblemanager" - "|SDLMain|utils/physfsrwops|utils/base64)[.](cpp|h)")) + if (isMatch(file, R"( / ( (debug|sdl2gfx)/.*? | mumblemanager | )" + R"( SDLMain | utils/physfsrwops | utils/base64 ) \.(cpp|h) $ )")) { terminateRule(); } diff --git a/src/rules/packet.cpp b/src/rules/packet.cpp index 003f28b..68362c2 100644 --- a/src/rules/packet.cpp +++ b/src/rules/packet.cpp @@ -20,7 +20,7 @@ #include "template.hpp" -registerRuleExt(packet, "012", "(.+)[.](cpp)") +registerRuleExt(packet, "012", R"( \.cpp$ )") startRule(packet) { @@ -35,4 +35,3 @@ parseLineRule(packet) if (data.find("createOutPacket(SMSG") != std::string::npos) print("Wrong output packet creation. Must be 'createOutPacket(CMSG...'"); } - diff --git a/src/rules/po.cpp b/src/rules/po.cpp index ab40041..98d0698 100644 --- a/src/rules/po.cpp +++ b/src/rules/po.cpp @@ -20,7 +20,7 @@ #include "template.hpp" -registerRuleExt(po, "010", "(.+)[.](po)") +registerRuleExt(po, "010", R"( \.po$ )") bool readId(false); bool readStr(false); @@ -244,4 +244,3 @@ parseLineRule(po) msgStr = std::string(); } } - diff --git a/src/rules/translation.cpp b/src/rules/translation.cpp index e8a2fdd..c951483 100644 --- a/src/rules/translation.cpp +++ b/src/rules/translation.cpp @@ -20,7 +20,7 @@ #include "template.hpp" -registerRuleExt(Translation, "014", "(.+)[.](cpp|h|hpp|cc|inc)") +registerRuleExt(Translation, "014", R"( \.(cpp|h|hpp|cc|inc)$ )") startRule(Translation) { diff --git a/src/rules/virtual.cpp b/src/rules/virtual.cpp index a52a369..4772d44 100644 --- a/src/rules/virtual.cpp +++ b/src/rules/virtual.cpp @@ -20,7 +20,7 @@ #include "template.hpp" -registerRuleExt(virtualCheck, "013", "(.+)[.](cpp|h)") +registerRuleExt(virtualCheck, "013", R"( \.(cpp|h)$ )") startRule(virtualCheck) { @@ -32,7 +32,7 @@ endRule(virtualCheck) parseLineRule(virtualCheck) { - if (isMatch(data, "(.+)virtual[ ](.+)[ ](override|final)(.*)") && + if (isMatch(data, R"( virtual \s+? .+? \s+? (override|final) )") && data.find("finalize") == std::string::npos) { print("Keywords virtual is useless if used with override or final"); diff --git a/src/rules/xml.cpp b/src/rules/xml.cpp index 1736a4f..d7bae95 100644 --- a/src/rules/xml.cpp +++ b/src/rules/xml.cpp @@ -20,7 +20,7 @@ #include "template.hpp" -registerRuleExt(xml, "009", "(.+)[.](xml)") +registerRuleExt(xml, "009", R"( \.xml$ )") startRule(xml) { @@ -39,4 +39,3 @@ parseLineRule(xml) print("Wrong xml header. Must be '" + str + "'"); } } - |