@@ -175,11 +175,12 @@ unsigned int ThreadExecutor::check()
175175 std::map<pid_t , std::string> childFile;
176176 std::map<int , std::string> pipeFile;
177177 std::size_t processedsize = 0 ;
178- std::map<std::string, std::size_t >::const_iterator i = _files.begin ();
178+ std::map<std::string, std::size_t >::const_iterator iFile = _files.begin ();
179+ std::list<ImportProject::FileSettings>::const_iterator iFileSettings = _settings.project .fileSettings .begin ();
179180 for (;;) {
180181 // Start a new child
181182 size_t nchildren = rpipes.size ();
182- if (i != _files.end () && nchildren < _settings.jobs && checkLoadAverage (nchildren)) {
183+ if ((iFile != _files.end () || iFileSettings != _settings. project . fileSettings . end () ) && nchildren < _settings.jobs && checkLoadAverage (nchildren)) {
183184 int pipes[2 ];
184185 if (pipe (pipes) == -1 ) {
185186 std::cerr << " pipe() failed: " << std::strerror (errno) << std::endl;
@@ -210,12 +211,14 @@ unsigned int ThreadExecutor::check()
210211 fileChecker.settings () = _settings;
211212 unsigned int resultOfCheck = 0 ;
212213
213- if (!_fileContents.empty () && _fileContents.find (i->first ) != _fileContents.end ()) {
214+ if (iFileSettings != _settings.project .fileSettings .end ()) {
215+ resultOfCheck = fileChecker.check (*iFileSettings);
216+ } else if (!_fileContents.empty () && _fileContents.find (iFile->first ) != _fileContents.end ()) {
214217 // File content was given as a string
215- resultOfCheck = fileChecker.check (i ->first , _fileContents[ i ->first ]);
218+ resultOfCheck = fileChecker.check (iFile ->first , _fileContents[ iFile ->first ]);
216219 } else {
217220 // Read file from a file
218- resultOfCheck = fileChecker.check (i ->first );
221+ resultOfCheck = fileChecker.check (iFile ->first );
219222 }
220223
221224 std::ostringstream oss;
@@ -226,10 +229,15 @@ unsigned int ThreadExecutor::check()
226229
227230 close (pipes[1 ]);
228231 rpipes.push_back (pipes[0 ]);
229- childFile[pid] = i->first ;
230- pipeFile[pipes[0 ]] = i->first ;
231-
232- ++i;
232+ if (iFileSettings != _settings.project .fileSettings .end ()) {
233+ childFile[pid] = iFileSettings->filename + ' ' + iFileSettings->cfg ;
234+ pipeFile[pipes[0 ]] = iFileSettings->filename + ' ' + iFileSettings->cfg ;
235+ ++iFileSettings;
236+ } else {
237+ childFile[pid] = iFile->first ;
238+ pipeFile[pipes[0 ]] = iFile->first ;
239+ ++iFile;
240+ }
233241 } else if (!rpipes.empty ()) {
234242 fd_set rfds;
235243 FD_ZERO (&rfds);
@@ -260,7 +268,7 @@ unsigned int ThreadExecutor::check()
260268 _fileCount++;
261269 processedsize += size;
262270 if (!_settings.quiet )
263- CppCheckExecutor::reportStatus (_fileCount, _files.size (), processedsize, totalfilesize);
271+ CppCheckExecutor::reportStatus (_fileCount, _files.size () + _settings. project . fileSettings . size () , processedsize, totalfilesize);
264272
265273 close (*rp);
266274 rp = rpipes.erase (rp);
@@ -352,10 +360,11 @@ unsigned int ThreadExecutor::check()
352360 HANDLE *threadHandles = new HANDLE[_settings.jobs ];
353361
354362 _itNextFile = _files.begin ();
363+ _itNextFileSettings = _settings.project .fileSettings .begin ();
355364
356365 _processedFiles = 0 ;
357366 _processedSize = 0 ;
358- _totalFiles = _files.size ();
367+ _totalFiles = _files.size () + _settings. project . fileSettings . size () ;
359368 _totalFileSize = 0 ;
360369 for (std::map<std::string, std::size_t >::const_iterator i = _files.begin (); i != _files.end (); ++i) {
361370 _totalFileSize += i->second ;
@@ -415,7 +424,8 @@ unsigned int __stdcall ThreadExecutor::threadProc(void *args)
415424 unsigned int result = 0 ;
416425
417426 ThreadExecutor *threadExecutor = static_cast <ThreadExecutor*>(args);
418- std::map<std::string, std::size_t >::const_iterator &it = threadExecutor->_itNextFile ;
427+ std::map<std::string, std::size_t >::const_iterator &itFile = threadExecutor->_itNextFile ;
428+ std::list<ImportProject::FileSettings>::const_iterator &itFileSettings = threadExecutor->_itNextFileSettings ;
419429
420430 // guard static members of CppCheck against concurrent access
421431 EnterCriticalSection (&threadExecutor->_fileSync );
@@ -424,24 +434,32 @@ unsigned int __stdcall ThreadExecutor::threadProc(void *args)
424434 fileChecker.settings () = threadExecutor->_settings ;
425435
426436 for (;;) {
427- if (it == threadExecutor->_files .end ()) {
437+ if (itFile == threadExecutor->_files . end () && itFileSettings == threadExecutor-> _settings . project . fileSettings .end ()) {
428438 LeaveCriticalSection (&threadExecutor->_fileSync );
429439 break ;
430-
431440 }
432- const std::string &file = it->first ;
433- const std::size_t fileSize = it->second ;
434- ++it;
435441
436- LeaveCriticalSection (&threadExecutor->_fileSync );
442+ std::size_t fileSize = 0 ;
443+ if (itFile != threadExecutor->_files .end ()) {
444+ const std::string &file = itFile->first ;
445+ fileSize = itFile->second ;
446+ ++itFile;
437447
438- std::map<std::string, std::string>::const_iterator fileContent = threadExecutor->_fileContents .find (file);
439- if (fileContent != threadExecutor->_fileContents .end ()) {
440- // File content was given as a string
441- result += fileChecker.check (file, fileContent->second );
442- } else {
443- // Read file from a file
444- result += fileChecker.check (file);
448+ LeaveCriticalSection (&threadExecutor->_fileSync );
449+
450+ std::map<std::string, std::string>::const_iterator fileContent = threadExecutor->_fileContents .find (file);
451+ if (fileContent != threadExecutor->_fileContents .end ()) {
452+ // File content was given as a string
453+ result += fileChecker.check (file, fileContent->second );
454+ } else {
455+ // Read file from a file
456+ result += fileChecker.check (file);
457+ }
458+ } else { // file settings..
459+ const ImportProject::FileSettings &fs = *itFileSettings;
460+ ++itFileSettings;
461+ LeaveCriticalSection (&threadExecutor->_fileSync );
462+ result += fileChecker.check (fs);
445463 }
446464
447465 EnterCriticalSection (&threadExecutor->_fileSync );
0 commit comments