style fixes (something messed up if-else formatting)

This commit is contained in:
Guenter Obiltschnig 2016-04-16 09:39:24 +02:00
parent 3e0d788162
commit 9710a828a3
2 changed files with 58 additions and 30 deletions

View File

@ -39,6 +39,7 @@ ProcessHandleImpl::~ProcessHandleImpl()
closeHandle(); closeHandle();
} }
void ProcessHandleImpl::closeHandle() void ProcessHandleImpl::closeHandle()
{ {
if (_hProcess) if (_hProcess)
@ -48,6 +49,7 @@ void ProcessHandleImpl::closeHandle()
} }
} }
UInt32 ProcessHandleImpl::id() const UInt32 ProcessHandleImpl::id() const
{ {
return _pid; return _pid;
@ -99,7 +101,8 @@ void ProcessImpl::timesImpl(long& userTime, long& kernelTime)
time.LowPart = ftUser.dwLowDateTime; time.LowPart = ftUser.dwLowDateTime;
time.HighPart = ftUser.dwHighDateTime; time.HighPart = ftUser.dwHighDateTime;
userTime = long(time.QuadPart / 10000000L); userTime = long(time.QuadPart / 10000000L);
} else }
else
{ {
userTime = kernelTime = -1; userTime = kernelTime = -1;
} }
@ -136,11 +139,13 @@ static std::string escapeArg(const std::string& arg)
{ {
quotedArg.append(2 * backslashCount, '\\'); quotedArg.append(2 * backslashCount, '\\');
break; break;
} else if ('"' == *it) }
else if ('"' == *it)
{ {
quotedArg.append(2 * backslashCount + 1, '\\'); quotedArg.append(2 * backslashCount + 1, '\\');
quotedArg.push_back('"'); quotedArg.push_back('"');
} else }
else
{ {
quotedArg.append(backslashCount, '\\'); quotedArg.append(backslashCount, '\\');
quotedArg.push_back(*it); quotedArg.push_back(*it);
@ -148,7 +153,8 @@ static std::string escapeArg(const std::string& arg)
} }
quotedArg.push_back('"'); quotedArg.push_back('"');
return quotedArg; return quotedArg;
} else }
else
{ {
return arg; return arg;
} }
@ -181,11 +187,13 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
DuplicateHandle(hProc, inPipe->readHandle(), hProc, &startupInfo.hStdInput, 0, TRUE, DUPLICATE_SAME_ACCESS); DuplicateHandle(hProc, inPipe->readHandle(), hProc, &startupInfo.hStdInput, 0, TRUE, DUPLICATE_SAME_ACCESS);
mustInheritHandles = true; mustInheritHandles = true;
inPipe->close(Pipe::CLOSE_READ); inPipe->close(Pipe::CLOSE_READ);
} else if (GetStdHandle(STD_INPUT_HANDLE)) }
else if (GetStdHandle(STD_INPUT_HANDLE))
{ {
DuplicateHandle(hProc, GetStdHandle(STD_INPUT_HANDLE), hProc, &startupInfo.hStdInput, 0, TRUE, DUPLICATE_SAME_ACCESS); DuplicateHandle(hProc, GetStdHandle(STD_INPUT_HANDLE), hProc, &startupInfo.hStdInput, 0, TRUE, DUPLICATE_SAME_ACCESS);
mustInheritHandles = true; mustInheritHandles = true;
} else }
else
{ {
startupInfo.hStdInput = 0; startupInfo.hStdInput = 0;
} }
@ -194,11 +202,13 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
{ {
DuplicateHandle(hProc, outPipe->writeHandle(), hProc, &startupInfo.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS); DuplicateHandle(hProc, outPipe->writeHandle(), hProc, &startupInfo.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS);
mustInheritHandles = true; mustInheritHandles = true;
} else if (GetStdHandle(STD_OUTPUT_HANDLE)) }
else if (GetStdHandle(STD_OUTPUT_HANDLE))
{ {
DuplicateHandle(hProc, GetStdHandle(STD_OUTPUT_HANDLE), hProc, &startupInfo.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS); DuplicateHandle(hProc, GetStdHandle(STD_OUTPUT_HANDLE), hProc, &startupInfo.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS);
mustInheritHandles = true; mustInheritHandles = true;
} else }
else
{ {
startupInfo.hStdOutput = 0; startupInfo.hStdOutput = 0;
} }
@ -206,11 +216,13 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
{ {
DuplicateHandle(hProc, errPipe->writeHandle(), hProc, &startupInfo.hStdError, 0, TRUE, DUPLICATE_SAME_ACCESS); DuplicateHandle(hProc, errPipe->writeHandle(), hProc, &startupInfo.hStdError, 0, TRUE, DUPLICATE_SAME_ACCESS);
mustInheritHandles = true; mustInheritHandles = true;
} else if (GetStdHandle(STD_ERROR_HANDLE)) }
else if (GetStdHandle(STD_ERROR_HANDLE))
{ {
DuplicateHandle(hProc, GetStdHandle(STD_ERROR_HANDLE), hProc, &startupInfo.hStdError, 0, TRUE, DUPLICATE_SAME_ACCESS); DuplicateHandle(hProc, GetStdHandle(STD_ERROR_HANDLE), hProc, &startupInfo.hStdError, 0, TRUE, DUPLICATE_SAME_ACCESS);
mustInheritHandles = true; mustInheritHandles = true;
} else }
else
{ {
startupInfo.hStdError = 0; startupInfo.hStdError = 0;
} }
@ -253,7 +265,8 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
{ {
CloseHandle(processInfo.hThread); CloseHandle(processInfo.hThread);
return new ProcessHandleImpl(processInfo.hProcess, processInfo.dwProcessId); return new ProcessHandleImpl(processInfo.hProcess, processInfo.dwProcessId);
} else throw SystemException("Cannot launch process", command); }
else throw SystemException("Cannot launch process", command);
} }
@ -281,7 +294,8 @@ void ProcessImpl::killImpl(PIDImpl pid)
throw SystemException("cannot kill process"); throw SystemException("cannot kill process");
} }
CloseHandle(hProc); CloseHandle(hProc);
} else }
else
{ {
switch (GetLastError()) switch (GetLastError())
{ {

View File

@ -40,6 +40,7 @@ ProcessHandleImpl::~ProcessHandleImpl()
closeHandle(); closeHandle();
} }
void ProcessHandleImpl::closeHandle() void ProcessHandleImpl::closeHandle()
{ {
if (_hProcess) if (_hProcess)
@ -49,6 +50,7 @@ void ProcessHandleImpl::closeHandle()
} }
} }
UInt32 ProcessHandleImpl::id() const UInt32 ProcessHandleImpl::id() const
{ {
return _pid; return _pid;
@ -100,7 +102,8 @@ void ProcessImpl::timesImpl(long& userTime, long& kernelTime)
time.LowPart = ftUser.dwLowDateTime; time.LowPart = ftUser.dwLowDateTime;
time.HighPart = ftUser.dwHighDateTime; time.HighPart = ftUser.dwHighDateTime;
userTime = long(time.QuadPart / 10000000L); userTime = long(time.QuadPart / 10000000L);
} else }
else
{ {
userTime = kernelTime = -1; userTime = kernelTime = -1;
} }
@ -137,11 +140,13 @@ static std::string escapeArg(const std::string& arg)
{ {
quotedArg.append(2 * backslashCount, '\\'); quotedArg.append(2 * backslashCount, '\\');
break; break;
} else if ('"' == *it) }
else if ('"' == *it)
{ {
quotedArg.append(2 * backslashCount + 1, '\\'); quotedArg.append(2 * backslashCount + 1, '\\');
quotedArg.push_back('"'); quotedArg.push_back('"');
} else }
else
{ {
quotedArg.append(backslashCount, '\\'); quotedArg.append(backslashCount, '\\');
quotedArg.push_back(*it); quotedArg.push_back(*it);
@ -149,7 +154,8 @@ static std::string escapeArg(const std::string& arg)
} }
quotedArg.push_back('"'); quotedArg.push_back('"');
return quotedArg; return quotedArg;
} else }
else
{ {
return arg; return arg;
} }
@ -185,11 +191,13 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
DuplicateHandle(hProc, inPipe->readHandle(), hProc, &startupInfo.hStdInput, 0, TRUE, DUPLICATE_SAME_ACCESS); DuplicateHandle(hProc, inPipe->readHandle(), hProc, &startupInfo.hStdInput, 0, TRUE, DUPLICATE_SAME_ACCESS);
mustInheritHandles = true; mustInheritHandles = true;
inPipe->close(Pipe::CLOSE_READ); inPipe->close(Pipe::CLOSE_READ);
} else if (GetStdHandle(STD_INPUT_HANDLE)) }
else if (GetStdHandle(STD_INPUT_HANDLE))
{ {
DuplicateHandle(hProc, GetStdHandle(STD_INPUT_HANDLE), hProc, &startupInfo.hStdInput, 0, TRUE, DUPLICATE_SAME_ACCESS); DuplicateHandle(hProc, GetStdHandle(STD_INPUT_HANDLE), hProc, &startupInfo.hStdInput, 0, TRUE, DUPLICATE_SAME_ACCESS);
mustInheritHandles = true; mustInheritHandles = true;
} else }
else
{ {
startupInfo.hStdInput = 0; startupInfo.hStdInput = 0;
} }
@ -198,11 +206,13 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
{ {
DuplicateHandle(hProc, outPipe->writeHandle(), hProc, &startupInfo.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS); DuplicateHandle(hProc, outPipe->writeHandle(), hProc, &startupInfo.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS);
mustInheritHandles = true; mustInheritHandles = true;
} else if (GetStdHandle(STD_OUTPUT_HANDLE)) }
else if (GetStdHandle(STD_OUTPUT_HANDLE))
{ {
DuplicateHandle(hProc, GetStdHandle(STD_OUTPUT_HANDLE), hProc, &startupInfo.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS); DuplicateHandle(hProc, GetStdHandle(STD_OUTPUT_HANDLE), hProc, &startupInfo.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS);
mustInheritHandles = true; mustInheritHandles = true;
} else }
else
{ {
startupInfo.hStdOutput = 0; startupInfo.hStdOutput = 0;
} }
@ -210,11 +220,13 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
{ {
DuplicateHandle(hProc, errPipe->writeHandle(), hProc, &startupInfo.hStdError, 0, TRUE, DUPLICATE_SAME_ACCESS); DuplicateHandle(hProc, errPipe->writeHandle(), hProc, &startupInfo.hStdError, 0, TRUE, DUPLICATE_SAME_ACCESS);
mustInheritHandles = true; mustInheritHandles = true;
} else if (GetStdHandle(STD_ERROR_HANDLE)) }
else if (GetStdHandle(STD_ERROR_HANDLE))
{ {
DuplicateHandle(hProc, GetStdHandle(STD_ERROR_HANDLE), hProc, &startupInfo.hStdError, 0, TRUE, DUPLICATE_SAME_ACCESS); DuplicateHandle(hProc, GetStdHandle(STD_ERROR_HANDLE), hProc, &startupInfo.hStdError, 0, TRUE, DUPLICATE_SAME_ACCESS);
mustInheritHandles = true; mustInheritHandles = true;
} else }
else
{ {
startupInfo.hStdError = 0; startupInfo.hStdError = 0;
} }
@ -259,7 +271,8 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
{ {
CloseHandle(processInfo.hThread); CloseHandle(processInfo.hThread);
return new ProcessHandleImpl(processInfo.hProcess, processInfo.dwProcessId); return new ProcessHandleImpl(processInfo.hProcess, processInfo.dwProcessId);
} else throw SystemException("Cannot launch process", command); }
else throw SystemException("Cannot launch process", command);
} }
@ -287,7 +300,8 @@ void ProcessImpl::killImpl(PIDImpl pid)
throw SystemException("cannot kill process"); throw SystemException("cannot kill process");
} }
CloseHandle(hProc); CloseHandle(hProc);
} else }
else
{ {
switch (GetLastError()) switch (GetLastError())
{ {