From 40a6941577bdaa1a14e1af51994794edb917f422 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Sat, 25 Jul 2015 17:17:52 +0200 Subject: [PATCH] Warn about usage of --suppressions or --exitcode-suppressions (they are deprecated) Removed two redundant strncmp calls --- cli/cmdlineparser.cpp | 31 ++++++++++++++++--------------- man/manual.docbook | 2 +- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 9d4fd7d23..99be75a3d 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -180,12 +180,12 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) std::string filename; // exitcode-suppressions filename.txt - // Deprecated if (std::strcmp(argv[i], "--exitcode-suppressions") == 0) { - ++i; + // This is deprecated and will be removed soon + PrintMessage("cppcheck: '--exitcode-suppressions ' is deprecated, use '--exitcode-suppressions=' instead."); - if (i >= argc || std::strncmp(argv[i], "-", 1) == 0 || - std::strncmp(argv[i], "--", 2) == 0) { + ++i; + if (i >= argc || argv[i][0] == '-') { PrintMessage("cppcheck: No filename specified for the '--exitcode-suppressions' option."); return false; } @@ -235,9 +235,10 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) } } - // Filter errors - // This is deprecated, see --suppressions-list above else if (std::strcmp(argv[i], "--suppressions") == 0) { + // This is deprecated and will be removed soon + PrintMessage("cppcheck: '--suppressions' is deprecated, use '--suppressions-list' instead."); + ++i; if (i >= argc) { @@ -756,7 +757,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) break; } - else if (std::strncmp(argv[i], "-", 1) == 0 || std::strncmp(argv[i], "--", 2) == 0) { + else if (argv[i][0] == '-') { std::string message("cppcheck: error: unrecognized command line option: \""); message += argv[i]; message += "\"."; @@ -810,7 +811,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) void CmdLineParser::PrintHelp() { - std::cout << "Cppcheck - A tool for static C/C++ code analysis\n" + std::cout << "Cppcheck - A tool for static C/C++ code analysis\n" "\n" "Syntax:\n" " cppcheck [OPTIONS] [files or paths]\n" @@ -824,6 +825,13 @@ void CmdLineParser::PrintHelp() " analysis is disabled by this flag.\n" " --check-library Show information messages when library files have\n" " incomplete info.\n" + " --config-exclude=\n" + " Path (prefix) to be excluded from configuration checking.\n" + " Preprocessor configurations defined in headers (but not sources)\n" + " matching the prefix will not be considered for evaluation\n" + " of configuration alternatives\n" + " --config-excludes-file=\n" + " A file that contains a list of config-excludes\n" " --dump Dump xml data for each translation unit. The dump\n" " files have the extension .dump and contain ast,\n" " tokenlist, symboldatabase, valueflow.\n" @@ -886,13 +894,6 @@ void CmdLineParser::PrintHelp() " First given path is searched for contained header\n" " files first. If paths are relative to source files,\n" " this is not needed.\n" - " --config-exclude=\n" - " Path (prefix) to be excluded from configuration checking.\n" - " Preprocessor configurations defined in headers (but not sources)\n" - " matching the prefix will not be considered for evaluation\n" - " of configuration alternatives\n" - " --config-excludes-file=\n" - " A file that contains a list of config-excludes\n" " --include=\n" " Force inclusion of a file before the checked file. Can\n" " be used for example when checking the Linux kernel,\n" diff --git a/man/manual.docbook b/man/manual.docbook index 9415badcc..4fe34412f 100644 --- a/man/manual.docbook +++ b/man/manual.docbook @@ -563,7 +563,7 @@ uninitvar You can use the suppressions file like this: - cppcheck --suppressions suppressions.txt src/ + cppcheck --suppressions-list=suppressions.txt src/