summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-25 13:30:09 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-25 13:30:09 +0300
commitf097319d197b847ad9386290b7f5377fece8c102 (patch)
tree5a2cb99823e6a47804adc213be2ef66285352070
parent0091365325a1b1608d4e8dac4b3d0756bd14d6f8 (diff)
downloadmplint-f097319d197b847ad9386290b7f5377fece8c102.tar.gz
mplint-f097319d197b847ad9386290b7f5377fece8c102.tar.bz2
mplint-f097319d197b847ad9386290b7f5377fece8c102.tar.xz
mplint-f097319d197b847ad9386290b7f5377fece8c102.zip
Check what debug.h must be last from includes.
-rw-r--r--src/rules/debug.cpp34
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;
+ }
}