From a508b2abfdf5e501befec7f06491ae50d026f742 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 7 Apr 2019 19:53:34 +0200 Subject: [PATCH] Addons: Add same handling in Windows as in Linux --- lib/cppcheck.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 247d9cf38..efd02cc89 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -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 pipe(_popen(cmd.c_str(), "r"), _pclose); +#else std::unique_ptr 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()