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.
This commit is contained in:
Kimmo Varis 2011-04-23 15:20:55 +03:00
parent 3c415e7833
commit 903769a388
2 changed files with 16 additions and 4 deletions

View File

@ -114,7 +114,7 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
{
std::vector<std::string>::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<std::string> &filenames = cppCheck.filenames();
Settings &settings = cppCheck.settings();
ThreadExecutor executor(filenames, settings, *this);
ThreadExecutor executor(_filenames, settings, *this);
returnValue = executor.check();
}

View File

@ -22,6 +22,7 @@
#include "errorlogger.h"
#include "settings.h"
#include <ctime>
#include <vector>
class CppCheck;
@ -107,6 +108,11 @@ private:
* Has --errorlist been given?
*/
bool errorlist;
/**
* List of files to check.
*/
std::vector<std::string> _filenames;
};
#endif // CPPCHECKEXECUTOR_H