Addons: Add same handling in Windows as in Linux

This commit is contained in:
Daniel Marjamäki 2019-04-07 19:53:34 +02:00
parent 58d88e149f
commit a508b2abfd
1 changed files with 6 additions and 7 deletions

View File

@ -947,22 +947,21 @@ void CppCheck::executeRules(const std::string &tokenlist, const Tokenizer &token
std::string CppCheck::executeAddon(const std::string &addon, const std::string &dumpFile)
{
const std::string addonFile = "addons/" + addon + ".py";
#ifdef _WIN32
return "";
#else
const std::string cmd = "python " + addonFile + " --cli " + dumpFile;
char buffer[1024];
std::string result;
#ifdef _WIN32
std::unique_ptr<FILE, decltype(&_pclose)> pipe(_popen(cmd.c_str(), "r"), _pclose);
#else
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd.c_str(), "r"), pclose);
#endif
if (!pipe)
return "";
char buffer[1024];
std::string result;
while (fgets(buffer, sizeof(buffer), pipe.get()) != nullptr) {
result += buffer;
}
return result;
#endif
}
Settings &CppCheck::settings()