Platform: Fix CFGDIR handling

This commit is contained in:
Daniel Marjamäki 2018-02-10 22:24:40 +01:00
parent 3c00a22c42
commit f5b91ffca8
1 changed files with 3 additions and 5 deletions

View File

@ -23,7 +23,6 @@
#include <cstring>
#include <limits>
#include <vector>
#include <iostream>
cppcheck::Platform::Platform()
{
@ -168,14 +167,13 @@ bool cppcheck::Platform::platformFile(const char exename[], const std::string &f
}
#ifdef CFGDIR
std::string cfgdir = CFGDIR;
if (cfgdir[cfgdir.size()-1] != '/')
if (!cfgdir.empty() && cfgdir[cfgdir.size()-1] != '/')
cfgdir += '/';
filenames.push_back(CFGDIR + ("../platforms/" + filename));
filenames.push_back(CFGDIR + ("../platforms/" + filename + ".xml"));
filenames.push_back(cfgdir + ("../platforms/" + filename));
filenames.push_back(cfgdir + ("../platforms/" + filename + ".xml"));
#endif
bool success = false;
for (int i = 0; i < filenames.size(); ++i) {
std::cout << "platform:" << filenames[i] << std::endl;
if (doc.LoadFile(filenames[i].c_str()) == tinyxml2::XML_SUCCESS) {
success = true;
break;