diff options
Diffstat (limited to 'Source/cmProcessTools.cxx')
-rw-r--r-- | Source/cmProcessTools.cxx | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/Source/cmProcessTools.cxx b/Source/cmProcessTools.cxx index e7b6051..b756650 100644 --- a/Source/cmProcessTools.cxx +++ b/Source/cmProcessTools.cxx @@ -1,29 +1,46 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmProcessTools.h" +#include "cmProcessOutput.h" #include <cmsys/Process.h> #include <ostream> void cmProcessTools::RunProcess(struct cmsysProcess_s* cp, OutputParser* out, - OutputParser* err) + OutputParser* err, Encoding encoding) { cmsysProcess_Execute(cp); char* data = CM_NULLPTR; int length = 0; int p; + cmProcessOutput processOutput(encoding); + std::string strdata; while ((out || err) && (p = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR), p)) { if (out && p == cmsysProcess_Pipe_STDOUT) { - if (!out->Process(data, length)) { + processOutput.DecodeText(data, length, strdata, 1); + if (!out->Process(strdata.c_str(), int(strdata.size()))) { out = CM_NULLPTR; } } else if (err && p == cmsysProcess_Pipe_STDERR) { - if (!err->Process(data, length)) { + processOutput.DecodeText(data, length, strdata, 2); + if (!err->Process(strdata.c_str(), int(strdata.size()))) { err = CM_NULLPTR; } } } + if (out) { + processOutput.DecodeText(std::string(), strdata, 1); + if (!strdata.empty()) { + out->Process(strdata.c_str(), int(strdata.size())); + } + } + if (err) { + processOutput.DecodeText(std::string(), strdata, 2); + if (!strdata.empty()) { + out->Process(strdata.c_str(), int(strdata.size())); + } + } cmsysProcess_WaitForExit(cp, CM_NULLPTR); } |