From f097319d197b847ad9386290b7f5377fece8c102 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 25 May 2014 13:30:09 +0300 Subject: Check what debug.h must be last from includes. --- src/rules/debug.cpp | 34 ++++++++++++++++++++++++++++++---- 1 file 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; + } } -- cgit v1.2.3-60-g2f50