From afed93d7d631398876b75f0f398748d03f0a772e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 17 Aug 2011 20:08:55 +0200 Subject: [PATCH] Command line: Added --std option. Right now only --std=posix is possible but other options might be added later. --- cli/cmdlineparser.cpp | 8 ++++++++ lib/settings.h | 2 +- test/testcmdlineparser.cpp | 11 +++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 9966a6832..a461a76a7 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -409,6 +409,12 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) _settings->reportProgress = true; } + // --std + else if (strcmp(argv[i], "--std=posix") == 0) + { + _settings->posix = true; + } + // Output formatter else if (strcmp(argv[i], "--template") == 0) { @@ -700,6 +706,8 @@ void CmdLineParser::PrintHelp() " https://sourceforge.net/projects/cppcheck/files/Articles/\n" #endif " -s, --style Deprecated, use --enable=style\n" + " --std=posix Code is posix => it is not compatible with non-posix\n" + " environments.\n" " --suppress= Suppress warnings that match . The format of\n" " is:\n" " [error id]:[filename]:[line]\n" diff --git a/lib/settings.h b/lib/settings.h index afe4b306f..c2f019fb1 100644 --- a/lib/settings.h +++ b/lib/settings.h @@ -304,7 +304,7 @@ public: /** Is the 'configuration checking' wanted? */ bool checkConfiguration; - /** Posix checks */ + /** Code is posix - it is not compatible with non-posix environments */ bool posix; }; diff --git a/test/testcmdlineparser.cpp b/test/testcmdlineparser.cpp index 341a3e8b6..cb18829d1 100644 --- a/test/testcmdlineparser.cpp +++ b/test/testcmdlineparser.cpp @@ -74,6 +74,7 @@ private: TEST_CASE(jobsMissingCount); TEST_CASE(jobsInvalid); TEST_CASE(reportProgress); + TEST_CASE(stdposix); TEST_CASE(suppressionsOld); // TODO: Create and test real suppression file TEST_CASE(suppressions); TEST_CASE(suppressionsNoFile); @@ -543,6 +544,16 @@ private: ASSERT(settings.reportProgress); } + void stdposix() + { + REDIRECT; + const char *argv[] = {"cppcheck", "--std=posix", "file.cpp"}; + Settings settings; + CmdLineParser parser(&settings); + ASSERT(parser.ParseFromArgs(3, argv)); + ASSERT(settings.posix); + } + void suppressionsOld() { // TODO: Fails because there is no suppr.txt file!