Addons: Add same handling in Windows as in Linux
This commit is contained in:
parent
58d88e149f
commit
a508b2abfd
|
@ -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)
|
std::string CppCheck::executeAddon(const std::string &addon, const std::string &dumpFile)
|
||||||
{
|
{
|
||||||
const std::string addonFile = "addons/" + addon + ".py";
|
const std::string addonFile = "addons/" + addon + ".py";
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
return "";
|
|
||||||
#else
|
|
||||||
const std::string cmd = "python " + addonFile + " --cli " + dumpFile;
|
const std::string cmd = "python " + addonFile + " --cli " + dumpFile;
|
||||||
|
|
||||||
char buffer[1024];
|
#ifdef _WIN32
|
||||||
std::string result;
|
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);
|
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd.c_str(), "r"), pclose);
|
||||||
|
#endif
|
||||||
if (!pipe)
|
if (!pipe)
|
||||||
return "";
|
return "";
|
||||||
|
char buffer[1024];
|
||||||
|
std::string result;
|
||||||
while (fgets(buffer, sizeof(buffer), pipe.get()) != nullptr) {
|
while (fgets(buffer, sizeof(buffer), pipe.get()) != nullptr) {
|
||||||
result += buffer;
|
result += buffer;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings &CppCheck::settings()
|
Settings &CppCheck::settings()
|
||||||
|
|
Loading…
Reference in New Issue