From 6cb7fefdbf4a1c07f6b0c023d0d68c41eaec2d8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 12 Aug 2010 21:03:33 +0200 Subject: [PATCH] Added command line option --report-progress. ticket: #1926 --- cli/cppcheckexecutor.cpp | 8 +++++++- lib/cppcheck.cpp | 13 ++++++++++--- lib/settings.cpp | 1 + lib/settings.h | 3 +++ man/cppcheck.1.xml | 7 +++++++ 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index f79fd2527..113f45b33 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -25,7 +25,7 @@ CppCheckExecutor::CppCheckExecutor() { - time1 = std::time(0); + time1 = 0; } CppCheckExecutor::~CppCheckExecutor() @@ -41,6 +41,9 @@ int CppCheckExecutor::check(int argc, const char* const argv[]) return EXIT_FAILURE; } + if (cppCheck.settings().reportProgress) + time1 = std::time(0); + _settings = cppCheck.settings(); if (_settings._xml) { @@ -91,6 +94,9 @@ void CppCheckExecutor::reportProgress(const std::string &filename, const char st { (void)filename; + if (!time1) + return; + // Report progress messages every 10 seconds const std::time_t time2 = std::time(NULL); if (time2 >= (time1 + 10)) diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index bcf0395d5..5439c3d7b 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -444,6 +444,12 @@ bool CppCheck::parseFromArgs(int argc, const char* const argv[]) AddFilesToList(12 + argv[i], pathnames); } + // Report progress + else if (strcmp(argv[i], "--report-progress") == 0) + { + _settings.reportProgress = true; + } + // Output formatter else if (strcmp(argv[i], "--template") == 0) { @@ -577,9 +583,9 @@ bool CppCheck::parseFromArgs(int argc, const char* const argv[]) "Syntax:\n" " cppcheck [--append=file] [-D] [--enable=] [--error-exitcode=[n]]\n" " [--exitcode-suppressions file] [--file-list=file.txt] [--force]\n" - " [--help] [-Idir] [--inline-suppr] [-j [jobs]] [--quiet] [--style]\n" - " [--suppressions file.txt] [--verbose] [--version] [--xml]\n" - " [file or path1] [file or path] ..\n" + " [--help] [-Idir] [--inline-suppr] [-j [jobs]] [--quiet]\n" + " [--report-progress] [--style] [--suppressions file.txt]\n" + " [--verbose] [--version] [--xml] [file or path1] [file or path]\n" "\n" "If path is given instead of filename, *.cpp, *.cxx, *.cc, *.c++ and *.c files\n" "are checked recursively from given directory.\n\n" @@ -617,6 +623,7 @@ bool CppCheck::parseFromArgs(int argc, const char* const argv[]) " on the lines before the warning to suppress.\n" " -j [jobs] Start [jobs] threads to do the checking simultaneously.\n" " -q, --quiet Only print error messages\n" + " --report-progress Report progress messages while checking a file.\n" " -s, --style deprecated, use --enable=style\n" " --suppressions file Suppress warnings listed in the file. Filename and line\n" " are optional. The format of the single line in file is:\n" diff --git a/lib/settings.cpp b/lib/settings.cpp index bd3b78d64..068e1a6ef 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -42,6 +42,7 @@ Settings::Settings() _terminate = false; inconclusive = false; test_2_pass = false; + reportProgress = false; ifcfg = false; } diff --git a/lib/settings.h b/lib/settings.h index 746e3c530..c9310a97c 100644 --- a/lib/settings.h +++ b/lib/settings.h @@ -171,6 +171,9 @@ public: /** @brief Experimentat 2 pass checking of files */ bool test_2_pass; + /** @brief --report-progress */ + bool reportProgress; + /** * @brief Is there any #if configurations in the source code? * As usual, include guards are not counted. diff --git a/man/cppcheck.1.xml b/man/cppcheck.1.xml index 4dec5ec96..7999da39a 100644 --- a/man/cppcheck.1.xml +++ b/man/cppcheck.1.xml @@ -114,6 +114,7 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/ + @@ -256,6 +257,12 @@ files, this is not needed. Only print something when there is an error. + + + + Report progress when checking a file. + +