summaryrefslogtreecommitdiff
path: root/Source/kwsys/testConsoleBuf.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/kwsys/testConsoleBuf.cxx')
-rw-r--r--Source/kwsys/testConsoleBuf.cxx60
1 files changed, 31 insertions, 29 deletions
diff --git a/Source/kwsys/testConsoleBuf.cxx b/Source/kwsys/testConsoleBuf.cxx
index b6ad1188d..4b7ddf053 100644
--- a/Source/kwsys/testConsoleBuf.cxx
+++ b/Source/kwsys/testConsoleBuf.cxx
@@ -51,7 +51,7 @@ static void displayError(DWORD errorCode)
LPWSTR message;
if (FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
- NULL, errorCode, 0, (LPWSTR)&message, 0, NULL)) {
+ nullptr, errorCode, 0, (LPWSTR)&message, 0, nullptr)) {
std::cerr << "Error message: " << kwsys::Encoding::ToNarrow(message)
<< std::endl;
HeapFree(GetProcessHeap(), 0, message);
@@ -124,7 +124,7 @@ static bool createProcess(HANDLE hIn, HANDLE hOut, HANDLE hErr)
}
WCHAR cmd[MAX_PATH];
- if (GetModuleFileNameW(NULL, cmd, MAX_PATH) == 0) {
+ if (GetModuleFileNameW(nullptr, cmd, MAX_PATH) == 0) {
std::cerr << "GetModuleFileName failed!" << std::endl;
return false;
}
@@ -136,14 +136,14 @@ static bool createProcess(HANDLE hIn, HANDLE hOut, HANDLE hErr)
wcscat(cmd, L".exe");
bool success =
- CreateProcessW(NULL, // No module name (use command line)
+ CreateProcessW(nullptr, // No module name (use command line)
cmd, // Command line
- NULL, // Process handle not inheritable
- NULL, // Thread handle not inheritable
+ nullptr, // Process handle not inheritable
+ nullptr, // Thread handle not inheritable
bInheritHandles, // Set handle inheritance
dwCreationFlags,
- NULL, // Use parent's environment block
- NULL, // Use parent's starting directory
+ nullptr, // Use parent's environment block
+ nullptr, // Use parent's starting directory
&startupInfo, // Pointer to STARTUPINFO structure
&processInfo) !=
0; // Pointer to PROCESS_INFORMATION structure
@@ -174,7 +174,7 @@ static bool createPipe(PHANDLE readPipe, PHANDLE writePipe)
SECURITY_ATTRIBUTES securityAttributes;
securityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
securityAttributes.bInheritHandle = TRUE;
- securityAttributes.lpSecurityDescriptor = NULL;
+ securityAttributes.lpSecurityDescriptor = nullptr;
return CreatePipe(readPipe, writePipe, &securityAttributes, 0) == 0 ? false
: true;
}
@@ -194,7 +194,7 @@ static HANDLE createFile(LPCWSTR fileName)
SECURITY_ATTRIBUTES securityAttributes;
securityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
securityAttributes.bInheritHandle = TRUE;
- securityAttributes.lpSecurityDescriptor = NULL;
+ securityAttributes.lpSecurityDescriptor = nullptr;
HANDLE file =
CreateFileW(fileName, GENERIC_READ | GENERIC_WRITE,
@@ -202,7 +202,7 @@ static HANDLE createFile(LPCWSTR fileName)
&securityAttributes,
CREATE_ALWAYS, // overwrite existing
FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE,
- NULL); // no template
+ nullptr); // no template
if (file == INVALID_HANDLE_VALUE) {
DWORD lastError = GetLastError();
std::cerr << "CreateFile(" << kwsys::Encoding::ToNarrow(fileName) << ")"
@@ -288,7 +288,7 @@ static int testPipe()
DWORD bytesWritten = 0;
if (!WriteFile(inPipeWrite, encodedInputTestString.c_str(),
(DWORD)encodedInputTestString.size(), &bytesWritten,
- NULL) ||
+ nullptr) ||
bytesWritten == 0) {
throw std::runtime_error("WriteFile failed!");
}
@@ -305,7 +305,8 @@ static int testPipe()
throw std::runtime_error("WaitForSingleObject failed!");
}
DWORD bytesRead = 0;
- if (!ReadFile(outPipeRead, buffer, sizeof(buffer), &bytesRead, NULL) ||
+ if (!ReadFile(outPipeRead, buffer, sizeof(buffer), &bytesRead,
+ nullptr) ||
bytesRead == 0) {
throw std::runtime_error("ReadFile#1 failed!");
}
@@ -313,7 +314,7 @@ static int testPipe()
if ((bytesRead <
encodedTestString.size() + 1 + encodedInputTestString.size() &&
!ReadFile(outPipeRead, buffer + bytesRead,
- sizeof(buffer) - bytesRead, &bytesRead, NULL)) ||
+ sizeof(buffer) - bytesRead, &bytesRead, nullptr)) ||
bytesRead == 0) {
throw std::runtime_error("ReadFile#2 failed!");
}
@@ -324,7 +325,7 @@ static int testPipe()
encodedInputTestString.size()) == 0) {
bytesRead = 0;
if (!ReadFile(errPipeRead, buffer2, sizeof(buffer2), &bytesRead,
- NULL) ||
+ nullptr) ||
bytesRead == 0) {
throw std::runtime_error("ReadFile#3 failed!");
}
@@ -383,13 +384,13 @@ static int testFile()
char buffer2[200];
int length;
- if ((length =
- WideCharToMultiByte(TestCodepage, 0, UnicodeInputTestString, -1,
- buffer, sizeof(buffer), NULL, NULL)) == 0) {
+ if ((length = WideCharToMultiByte(TestCodepage, 0, UnicodeInputTestString,
+ -1, buffer, sizeof(buffer), nullptr,
+ nullptr)) == 0) {
throw std::runtime_error("WideCharToMultiByte failed!");
}
buffer[length - 1] = '\n';
- if (!WriteFile(inFile, buffer, length, &bytesWritten, NULL) ||
+ if (!WriteFile(inFile, buffer, length, &bytesWritten, nullptr) ||
bytesWritten == 0) {
throw std::runtime_error("WriteFile failed!");
}
@@ -413,7 +414,7 @@ static int testFile()
INVALID_SET_FILE_POINTER) {
throw std::runtime_error("SetFilePointer#1 failed!");
}
- if (!ReadFile(outFile, buffer, sizeof(buffer), &bytesRead, NULL) ||
+ if (!ReadFile(outFile, buffer, sizeof(buffer), &bytesRead, nullptr) ||
bytesRead == 0) {
throw std::runtime_error("ReadFile#1 failed!");
}
@@ -429,7 +430,8 @@ static int testFile()
throw std::runtime_error("SetFilePointer#2 failed!");
}
- if (!ReadFile(errFile, buffer2, sizeof(buffer2), &bytesRead, NULL) ||
+ if (!ReadFile(errFile, buffer2, sizeof(buffer2), &bytesRead,
+ nullptr) ||
bytesRead == 0) {
throw std::runtime_error("ReadFile#2 failed!");
}
@@ -519,12 +521,12 @@ static int testConsole()
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Console", 0, KEY_READ | KEY_WRITE,
&hConsoleKey) == ERROR_SUCCESS) {
DWORD dwordSize = sizeof(DWORD);
- if (RegQueryValueExW(hConsoleKey, L"FontFamily", NULL, NULL,
+ if (RegQueryValueExW(hConsoleKey, L"FontFamily", nullptr, nullptr,
(LPBYTE)&FontFamily, &dwordSize) == ERROR_SUCCESS) {
if (FontFamily != TestFontFamily) {
- RegQueryValueExW(hConsoleKey, L"FaceName", NULL, NULL,
+ RegQueryValueExW(hConsoleKey, L"FaceName", nullptr, nullptr,
(LPBYTE)FaceName, &FaceNameSize);
- RegQueryValueExW(hConsoleKey, L"FontSize", NULL, NULL,
+ RegQueryValueExW(hConsoleKey, L"FontSize", nullptr, nullptr,
(LPBYTE)&FontSize, &dwordSize);
RegSetValueExW(hConsoleKey, L"FontFamily", 0, REG_DWORD,
@@ -557,10 +559,10 @@ static int testConsole()
SECURITY_ATTRIBUTES securityAttributes;
securityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
securityAttributes.bInheritHandle = TRUE;
- securityAttributes.lpSecurityDescriptor = NULL;
+ securityAttributes.lpSecurityDescriptor = nullptr;
hIn = CreateFileW(L"CONIN$", GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, &securityAttributes,
- OPEN_EXISTING, 0, NULL);
+ OPEN_EXISTING, 0, nullptr);
if (hIn == INVALID_HANDLE_VALUE) {
DWORD lastError = GetLastError();
std::cerr << "CreateFile(CONIN$)" << std::endl;
@@ -568,7 +570,7 @@ static int testConsole()
}
hOut = CreateFileW(L"CONOUT$", GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, &securityAttributes,
- OPEN_EXISTING, 0, NULL);
+ OPEN_EXISTING, 0, nullptr);
if (hOut == INVALID_HANDLE_VALUE) {
DWORD lastError = GetLastError();
std::cerr << "CreateFile(CONOUT$)" << std::endl;
@@ -630,7 +632,7 @@ static int testConsole()
}
# endif
- if (createProcess(NULL, NULL, NULL)) {
+ if (createProcess(nullptr, nullptr, nullptr)) {
try {
DWORD status;
if ((status = WaitForSingleObject(beforeInputEvent, waitTimeout)) !=
@@ -746,7 +748,7 @@ int testConsoleBuf(int, char* [])
int ret = 0;
#if defined(_WIN32)
- beforeInputEvent = CreateEventW(NULL,
+ beforeInputEvent = CreateEventW(nullptr,
FALSE, // auto-reset event
FALSE, // initial state is nonsignaled
BeforeInputEventName); // object name
@@ -755,7 +757,7 @@ int testConsoleBuf(int, char* [])
return 1;
}
- afterOutputEvent = CreateEventW(NULL, FALSE, FALSE, AfterOutputEventName);
+ afterOutputEvent = CreateEventW(nullptr, FALSE, FALSE, AfterOutputEventName);
if (!afterOutputEvent) {
std::cerr << "CreateEvent#2 failed " << GetLastError() << std::endl;
return 1;