From 903769a388b8c76bcc0836fd4ab2e7227f3bcf6e Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sat, 23 Apr 2011 15:20:55 +0300 Subject: [PATCH] CLI: Give files to Cppcheck class one at a time. When doing single-threaded checking give checked files to Cppcheck class one file at a time. Like GUI and multithreaded checking already do. This unifies how we call Cppcheck class from different clients. --- cli/cppcheckexecutor.cpp | 14 ++++++++++---- cli/cppcheckexecutor.h | 6 ++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index 32607e947..74d32ce25 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -114,7 +114,7 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c { std::vector::iterator iter; for (iter = filenames.begin(); iter != filenames.end(); ++iter) - cppcheck->addFile(*iter); + _filenames.push_back(*iter); return true; } @@ -146,7 +146,14 @@ int CppCheckExecutor::check(int argc, const char* const argv[]) if (_settings._jobs == 1) { // Single process - returnValue = cppCheck.check(); + for (unsigned int c = 0; c < _filenames.size(); c++) + { + cppCheck.addFile(_filenames[c]); + returnValue += cppCheck.check(); + cppCheck.clearFiles(); + + reportStatus(c + 1, _filenames.size()); + } } else if (!ThreadExecutor::isEnabled()) { @@ -155,9 +162,8 @@ int CppCheckExecutor::check(int argc, const char* const argv[]) else { // Multiple processes - const std::vector &filenames = cppCheck.filenames(); Settings &settings = cppCheck.settings(); - ThreadExecutor executor(filenames, settings, *this); + ThreadExecutor executor(_filenames, settings, *this); returnValue = executor.check(); } diff --git a/cli/cppcheckexecutor.h b/cli/cppcheckexecutor.h index 339d16959..3a0828024 100644 --- a/cli/cppcheckexecutor.h +++ b/cli/cppcheckexecutor.h @@ -22,6 +22,7 @@ #include "errorlogger.h" #include "settings.h" #include +#include class CppCheck; @@ -107,6 +108,11 @@ private: * Has --errorlist been given? */ bool errorlist; + + /** + * List of files to check. + */ + std::vector _filenames; }; #endif // CPPCHECKEXECUTOR_H