mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-13 02:29:02 -06:00
Merge branch 'upstream-KWSys' into update-kwsys
# By KWSys Upstream * upstream-KWSys: KWSys 2024-05-28 (0d6eac1f)
This commit is contained in:
@@ -476,6 +476,22 @@ static int testFile()
|
|||||||
# define _WIN32_WINNT_VISTA 0x0600
|
# define _WIN32_WINNT_VISTA 0x0600
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
static bool consoleIsConhost()
|
||||||
|
{
|
||||||
|
wchar_t consoleClassNameBuf[64];
|
||||||
|
int const consoleClassNameLen = GetClassNameW(
|
||||||
|
GetConsoleWindow(), &consoleClassNameBuf[0], sizeof(consoleClassNameBuf));
|
||||||
|
// Windows Console Host: ConsoleWindowClass
|
||||||
|
// Windows Terminal / ConPTY: PseudoConsoleWindow (undocumented)
|
||||||
|
return (consoleClassNameLen > 0 &&
|
||||||
|
wcscmp(consoleClassNameBuf, L"ConsoleWindowClass") == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool charIsNUL(wchar_t c)
|
||||||
|
{
|
||||||
|
return c == 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int testConsole()
|
static int testConsole()
|
||||||
{
|
{
|
||||||
int didFail = 1;
|
int didFail = 1;
|
||||||
@@ -691,7 +707,15 @@ static int testConsole()
|
|||||||
throw std::runtime_error("ReadConsoleOutputCharacter failed!");
|
throw std::runtime_error("ReadConsoleOutputCharacter failed!");
|
||||||
}
|
}
|
||||||
std::wstring wideTestString = kwsys::Encoding::ToWide(encodedTestString);
|
std::wstring wideTestString = kwsys::Encoding::ToWide(encodedTestString);
|
||||||
std::replace(wideTestString.begin(), wideTestString.end(), '\0', ' ');
|
if (consoleIsConhost()) {
|
||||||
|
// Windows Console Host converts NUL bytes to spaces.
|
||||||
|
std::replace(wideTestString.begin(), wideTestString.end(), '\0', ' ');
|
||||||
|
} else {
|
||||||
|
// Windows Terminal / ConPTY removes NUL bytes.
|
||||||
|
wideTestString.erase(std::remove_if(wideTestString.begin(),
|
||||||
|
wideTestString.end(), charIsNUL),
|
||||||
|
wideTestString.end());
|
||||||
|
}
|
||||||
std::wstring wideInputTestString =
|
std::wstring wideInputTestString =
|
||||||
kwsys::Encoding::ToWide(encodedInputTestString);
|
kwsys::Encoding::ToWide(encodedInputTestString);
|
||||||
if (memcmp(outputBuffer, wideTestString.c_str(),
|
if (memcmp(outputBuffer, wideTestString.c_str(),
|
||||||
|
|||||||
Reference in New Issue
Block a user