diff options
author | Brad King <brad.king@kitware.com> | 2018-01-16 18:59:55 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-01-17 15:41:51 (GMT) |
commit | c10119df62cf212f9274c6a5c0af609bae4f1b03 (patch) | |
tree | e79d94e43eb7a87ee4eb8da54d91f93ffcc540b9 /Source | |
parent | b4dfe1d8163055f9f40a4c18f5eccccb28f06559 (diff) | |
download | CMake-c10119df62cf212f9274c6a5c0af609bae4f1b03.zip CMake-c10119df62cf212f9274c6a5c0af609bae4f1b03.tar.gz CMake-c10119df62cf212f9274c6a5c0af609bae4f1b03.tar.bz2 |
CTest: Fix decoding of MBCS character split by buffering
Use a single `cmProcessOutput` instance persistently to decode
all output of a test process so that partial character bytes
can be buffered.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CTest/cmProcess.cxx | 15 | ||||
-rw-r--r-- | Source/CTest/cmProcess.h | 4 |
2 files changed, 10 insertions, 9 deletions
diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx index c8806a7..4454715 100644 --- a/Source/CTest/cmProcess.cxx +++ b/Source/CTest/cmProcess.cxx @@ -5,19 +5,19 @@ #include "cmCTest.h" #include "cmCTestRunTest.h" #include "cmCTestTestHandler.h" -#include "cmProcessOutput.h" #include "cmsys/Process.h" #include <algorithm> #include <fcntl.h> #include <iostream> #include <signal.h> -#include <stdint.h> #include <string> #if !defined(_WIN32) #include <unistd.h> #endif +#define CM_PROCESS_BUF_SIZE 65536 + #if defined(_WIN32) && !defined(__CYGWIN__) #include <io.h> @@ -60,6 +60,7 @@ static int cmProcessGetPipes(int* fds) cmProcess::cmProcess(cmCTestRunTest& runner) : Runner(runner) + , Conv(cmProcessOutput::UTF8, CM_PROCESS_BUF_SIZE) { this->Timeout = std::chrono::duration<double>::zero(); this->TotalTime = std::chrono::duration<double>::zero(); @@ -232,9 +233,7 @@ void cmProcess::OnRead(ssize_t nread, const uv_buf_t* buf) std::string line; if (nread > 0) { std::string strdata; - cmProcessOutput processOutput(cmProcessOutput::UTF8, - static_cast<unsigned int>(buf->len)); - processOutput.DecodeText(buf->base, static_cast<size_t>(nread), strdata); + this->Conv.DecodeText(buf->base, static_cast<size_t>(nread), strdata); this->Output.insert(this->Output.end(), strdata.begin(), strdata.end()); while (this->Output.GetLine(line)) { @@ -271,10 +270,10 @@ void cmProcess::OnAllocateCB(uv_handle_t* handle, size_t suggested_size, self->OnAllocate(suggested_size, buf); } -void cmProcess::OnAllocate(size_t suggested_size, uv_buf_t* buf) +void cmProcess::OnAllocate(size_t /*suggested_size*/, uv_buf_t* buf) { - if (this->Buf.size() < suggested_size) { - this->Buf.resize(suggested_size); + if (this->Buf.size() != CM_PROCESS_BUF_SIZE) { + this->Buf.resize(CM_PROCESS_BUF_SIZE); } *buf = diff --git a/Source/CTest/cmProcess.h b/Source/CTest/cmProcess.h index 9250896..633be24 100644 --- a/Source/CTest/cmProcess.h +++ b/Source/CTest/cmProcess.h @@ -5,13 +5,14 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include "cmProcessOutput.h" #include "cmUVHandlePtr.h" #include "cm_uv.h" #include <chrono> #include <stddef.h> +#include <stdint.h> #include <string> -#include <sys/types.h> #include <vector> class cmCTestRunTest; @@ -80,6 +81,7 @@ private: std::vector<char> Buf; cmCTestRunTest& Runner; + cmProcessOutput Conv; int Signal = 0; cmProcess::State ProcessState = cmProcess::State::Starting; |