diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 594795995..8d7c71615 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -412,7 +412,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) // Report progress else if (strcmp(argv[i], "--report-progress") == 0) { - _settings->reportProgress = true; + _settings->reportProgressTime = 10; } // --std diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index ad95b0eeb..085b6d8ba 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -161,7 +161,7 @@ int CppCheckExecutor::check(int argc, const char* const argv[]) return EXIT_FAILURE; } - if (cppCheck.settings().reportProgress) + if (_settings.reportProgressTime > 0) time1 = std::time(0); _settings = cppCheck.settings(); @@ -247,12 +247,12 @@ void CppCheckExecutor::reportProgress(const std::string &filename, const char st { (void)filename; - if (!time1) + if (_settings.reportProgressTime == 0) return; // Report progress messages every 10 seconds const std::time_t time2 = std::time(NULL); - if (time2 >= (time1 + 10)) { + if (time2 >= (time1 + _settings.reportProgressTime)) { time1 = time2; // current time in the format "Www Mmm dd hh:mm:ss yyyy" diff --git a/lib/settings.cpp b/lib/settings.cpp index 4e5595bde..118fc8004 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -43,7 +43,7 @@ Settings::Settings() inconclusive = false; experimental = false; test_2_pass = false; - reportProgress = false; + reportProgressTime = 0; ifcfg = false; checkConfiguration = false; diff --git a/lib/settings.h b/lib/settings.h index d11536e96..f110ee62d 100644 --- a/lib/settings.h +++ b/lib/settings.h @@ -156,8 +156,8 @@ public: /** @brief Experimental 2 pass checking of files */ bool test_2_pass; - /** @brief --report-progress */ - bool reportProgress; + /** @brief 0 => don't report progress. 1-.. => report progress every T seconds */ + unsigned char reportProgressTime; /** * @brief Is there any preprocessor configurations in the source code? diff --git a/test/testcmdlineparser.cpp b/test/testcmdlineparser.cpp index d3bce588f..13ac98063 100644 --- a/test/testcmdlineparser.cpp +++ b/test/testcmdlineparser.cpp @@ -616,7 +616,7 @@ private: Settings settings; CmdLineParser parser(&settings); ASSERT(parser.ParseFromArgs(3, argv)); - ASSERT(settings.reportProgress); + ASSERT_EQUALS(10U, settings.reportProgressTime); } void stdposix() {