diff options
-rw-r--r-- | src/rules/debug.cpp | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/src/rules/debug.cpp b/src/rules/debug.cpp index f7154a6..82e16fe 100644 --- a/src/rules/debug.cpp +++ b/src/rules/debug.cpp @@ -41,24 +41,50 @@ parseLineRule(debugH) } +bool foundDebug(false); + registerRuleExt(debugCpp, "004", "(.+)[.]cpp") startRule(debugCpp) { if (isMatch(file, "(.*)[/]debug[/]([^/]*)[.](cpp|h)")) terminateRule(); + foundDebug = false; } endRule(debugCpp) { - print("Missing #include \"debug.h\". " - "It need for profiling and memory debugging."); + if (!foundDebug) + { + print("Missing #include \"debug.h\". " + "It need for profiling and memory debugging."); + } } parseLineRule(debugCpp) { // need check what debug.h will be last include in file trim(data); - if (data == "#include \"debug.h\"") - terminateRule(); + if (foundDebug) + { + if (!data.empty() && data[0] != '#') + { + terminateRule(); + } + else + { + if (strStartWith(data, "#include ") + && data != "#include \"debug.h\"") + { + if (!strEndWith(file, "/utils/copynpaste.cpp")) + print("Last include must be #include \"debug.h\""); + terminateRule(); + } + } + } + else + { + if (data == "#include \"debug.h\"") + foundDebug = true; + } } |