4343#endif
4444
4545#include < algorithm>
46+ #include < cassert>
4647#include < cstdio>
4748#include < cstdlib> // EXIT_SUCCESS and EXIT_FAILURE
4849#include < functional>
6667#include < windows.h>
6768#endif
6869
70+ // TODO: do not directly write to stdout
71+
6972
7073/* static*/ FILE* CppCheckExecutor::mExceptionOutput = stdout;
7174
@@ -319,21 +322,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck)
319322
320323bool CppCheckExecutor::loadLibraries (Settings& settings)
321324{
322- const bool std = tryLoadLibrary (settings.library , settings.exename , " std.cfg" );
323-
324- const auto failed_lib = std::find_if (settings.libraries .begin (), settings.libraries .end (), [&](const std::string& lib) {
325- return !tryLoadLibrary (settings.library , settings.exename , lib.c_str ());
326- });
327- if (failed_lib != settings.libraries .end ()) {
328- const std::string msg (" Failed to load the library " + *failed_lib);
329- const std::list<ErrorMessage::FileLocation> callstack;
330- ErrorMessage errmsg (callstack, emptyString, Severity::information, msg, " failedToLoadCfg" , Certainty::normal);
331- reportErr (errmsg);
332- return false ;
333- }
334-
335- if (!std) {
336- const std::list<ErrorMessage::FileLocation> callstack;
325+ if (!tryLoadLibrary (settings.library , settings.exename , " std.cfg" )) {
337326 const std::string msg (" Failed to load std.cfg. Your Cppcheck installation is broken, please re-install." );
338327#ifdef FILESDIR
339328 const std::string details (" The Cppcheck binary was compiled with FILESDIR set to \" "
@@ -345,12 +334,17 @@ bool CppCheckExecutor::loadLibraries(Settings& settings)
345334 " std.cfg should be available in " + cfgfolder + " or the FILESDIR "
346335 " should be configured." );
347336#endif
348- ErrorMessage errmsg (callstack, emptyString, Severity::information, msg+" " +details, " failedToLoadCfg" , Certainty::normal);
349- reportErr (errmsg);
337+ std::cout << msg << " " << details << std::endl;
350338 return false ;
351339 }
352340
353- return true ;
341+ bool result = true ;
342+ for (const auto & lib : settings.libraries ) {
343+ if (!tryLoadLibrary (settings.library , settings.exename , lib.c_str ())) {
344+ result = false ;
345+ }
346+ }
347+ return result;
354348}
355349
356350#ifdef _WIN32
@@ -424,6 +418,8 @@ void CppCheckExecutor::reportErr(const ErrorMessage &msg)
424418 return ;
425419 }
426420
421+ assert (mSettings != nullptr );
422+
427423 // Alert only about unique errors
428424 if (!mShownErrors .insert (msg.toString (mSettings ->verbose )).second )
429425 return ;
0 commit comments