This commit is contained in:
parent
70ccfa5947
commit
fab2c96622
|
@ -352,10 +352,11 @@ unsigned int ThreadExecutor::check()
|
|||
HANDLE *threadHandles = new HANDLE[_settings.jobs];
|
||||
|
||||
_itNextFile = _files.begin();
|
||||
_itNextFileSettings = _settings.fileSettings.begin();
|
||||
|
||||
_processedFiles = 0;
|
||||
_processedSize = 0;
|
||||
_totalFiles = _files.size();
|
||||
_totalFiles = _files.size() + _settings.fileSettings.size();
|
||||
_totalFileSize = 0;
|
||||
for (std::map<std::string, std::size_t>::const_iterator i = _files.begin(); i != _files.end(); ++i) {
|
||||
_totalFileSize += i->second;
|
||||
|
@ -415,7 +416,8 @@ unsigned int __stdcall ThreadExecutor::threadProc(void *args)
|
|||
unsigned int result = 0;
|
||||
|
||||
ThreadExecutor *threadExecutor = static_cast<ThreadExecutor*>(args);
|
||||
std::map<std::string, std::size_t>::const_iterator &it = threadExecutor->_itNextFile;
|
||||
std::map<std::string, std::size_t>::const_iterator &itFile = threadExecutor->_itNextFile;
|
||||
std::list<Settings::FileSettings>::const_iterator &itFileSettings = threadExecutor->_itNextFileSettings;
|
||||
|
||||
// guard static members of CppCheck against concurrent access
|
||||
EnterCriticalSection(&threadExecutor->_fileSync);
|
||||
|
@ -424,24 +426,32 @@ unsigned int __stdcall ThreadExecutor::threadProc(void *args)
|
|||
fileChecker.settings() = threadExecutor->_settings;
|
||||
|
||||
for (;;) {
|
||||
if (it == threadExecutor->_files.end()) {
|
||||
if (itFile == threadExecutor->_files.end() && itFileSettings == threadExecutor->_settings.fileSettings.end()) {
|
||||
LeaveCriticalSection(&threadExecutor->_fileSync);
|
||||
break;
|
||||
|
||||
}
|
||||
const std::string &file = it->first;
|
||||
const std::size_t fileSize = it->second;
|
||||
++it;
|
||||
|
||||
LeaveCriticalSection(&threadExecutor->_fileSync);
|
||||
std::size_t fileSize = 0;
|
||||
if (itFile != threadExecutor->_files.end()) {
|
||||
const std::string &file = itFile->first;
|
||||
fileSize = itFile->second;
|
||||
++itFile;
|
||||
|
||||
std::map<std::string, std::string>::const_iterator fileContent = threadExecutor->_fileContents.find(file);
|
||||
if (fileContent != threadExecutor->_fileContents.end()) {
|
||||
// File content was given as a string
|
||||
result += fileChecker.check(file, fileContent->second);
|
||||
} else {
|
||||
// Read file from a file
|
||||
result += fileChecker.check(file);
|
||||
LeaveCriticalSection(&threadExecutor->_fileSync);
|
||||
|
||||
std::map<std::string, std::string>::const_iterator fileContent = threadExecutor->_fileContents.find(file);
|
||||
if (fileContent != threadExecutor->_fileContents.end()) {
|
||||
// File content was given as a string
|
||||
result += fileChecker.check(file, fileContent->second);
|
||||
} else {
|
||||
// Read file from a file
|
||||
result += fileChecker.check(file);
|
||||
}
|
||||
} else { // file settings..
|
||||
const Settings::FileSettings &fs = *itFileSettings;
|
||||
++itFileSettings;
|
||||
LeaveCriticalSection(&threadExecutor->_fileSync);
|
||||
result += fileChecker.check(fs);
|
||||
}
|
||||
|
||||
EnterCriticalSection(&threadExecutor->_fileSync);
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <string>
|
||||
#include <list>
|
||||
#include "errorlogger.h"
|
||||
#include "settings.h" // Settings::FileSettings
|
||||
|
||||
#if (defined(__GNUC__) || defined(__sun)) && !defined(__MINGW32__)
|
||||
#define THREADING_MODEL_FORK
|
||||
|
@ -109,6 +110,7 @@ private:
|
|||
|
||||
std::map<std::string, std::string> _fileContents;
|
||||
std::map<std::string, std::size_t>::const_iterator _itNextFile;
|
||||
std::list<Settings::FileSettings>::const_iterator _itNextFileSettings;
|
||||
std::size_t _processedFiles;
|
||||
std::size_t _totalFiles;
|
||||
std::size_t _processedSize;
|
||||
|
|
Loading…
Reference in New Issue