MCPcopy Create free account
hub / github.com/Kitware/CMake / DecodeText

Method DecodeText

Source/cmProcessOutput.cxx:56–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56bool cmProcessOutput::DecodeText(std::string raw, std::string& decoded,
57 size_t id)
58{
59#if !defined(_WIN32)
60 static_cast<void>(id);
61 decoded.swap(raw);
62 return true;
63#else
64 bool success = true;
65 decoded = raw;
66 if (id > 0) {
67 if (rawparts.size() < id) {
68 rawparts.reserve(id);
69 while (rawparts.size() < id)
70 rawparts.push_back(std::string());
71 }
72 raw = rawparts[id - 1] + raw;
73 rawparts[id - 1].clear();
74 decoded = raw;
75 }
76 if (raw.size() > 0 && codepage != defaultCodepage) {
77 success = false;
78 CPINFOEXW cpinfo;
79 if (id > 0 && bufferSize > 0 && raw.size() == bufferSize &&
80 GetCPInfoExW(codepage, 0, &cpinfo) == 1 && cpinfo.MaxCharSize > 1) {
81 if (cpinfo.MaxCharSize == 2 && cpinfo.LeadByte[0] != 0) {
82 LPSTR prevChar =
83 CharPrevExA(codepage, raw.c_str(), raw.c_str() + raw.size(), 0);
84 bool isLeadByte =
85 (*(prevChar + 1) == 0) && IsDBCSLeadByteEx(codepage, *prevChar);
86 if (isLeadByte) {
87 rawparts[id - 1] += *(raw.end() - 1);
88 raw.resize(raw.size() - 1);
89 }
90 success = DoDecodeText(raw, decoded, nullptr);
91 } else {
92 bool restoreDecoded = false;
93 std::string firstDecoded = decoded;
94 wchar_t lastChar = 0;
95 for (UINT i = 0; i < cpinfo.MaxCharSize; i++) {
96 success = DoDecodeText(raw, decoded, &lastChar);
97 if (success && lastChar != 0) {
98 if (i == 0) {
99 firstDecoded = decoded;
100 }
101 if (lastChar == cpinfo.UnicodeDefaultChar) {
102 restoreDecoded = true;
103 rawparts[id - 1] = *(raw.end() - 1) + rawparts[id - 1];
104 raw.resize(raw.size() - 1);
105 } else {
106 restoreDecoded = false;
107 break;
108 }
109 } else {
110 break;
111 }
112 }
113 if (restoreDecoded) {

Callers 12

RunProcessMethod · 0.80
RunCommandFunction · 0.80
RunMakeCommandMethod · 0.80
RunCommandMethod · 0.80
cmExecuteProcessCommandFunction · 0.80
startMethod · 0.80
RunSingleCommandMethod · 0.80
WaitForLineMethod · 0.80
OnReadMethod · 0.80
RunChildMethod · 0.80
RunMakeCommandMethod · 0.80
RunTestMethod · 0.80

Calls 10

reserveMethod · 0.80
push_backMethod · 0.80
c_strMethod · 0.80
assignMethod · 0.80
swapMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45
endMethod · 0.45
resizeMethod · 0.45
beginMethod · 0.45

Tested by 5

RunMakeCommandMethod · 0.64
RunCommandMethod · 0.64
RunChildMethod · 0.64
RunMakeCommandMethod · 0.64
RunTestMethod · 0.64