mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 00:11:07 -06:00
cmSystemTools: Simplify RunSingleCommand output string construction
Assign to the result strings instead setting to empty and appending. The old approach was left from when we directly buffered output in the strings.
This commit is contained in:
@@ -660,14 +660,6 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command,
|
||||
argv.push_back(a->c_str());
|
||||
}
|
||||
argv.push_back(0);
|
||||
if ( captureStdOut )
|
||||
{
|
||||
*captureStdOut = "";
|
||||
}
|
||||
if (captureStdErr && captureStdErr != captureStdOut)
|
||||
{
|
||||
*captureStdErr = "";
|
||||
}
|
||||
|
||||
cmsysProcess* cp = cmsysProcess_New();
|
||||
cmsysProcess_SetCommand(cp, &*argv.begin());
|
||||
@@ -745,14 +737,13 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command,
|
||||
}
|
||||
|
||||
cmsysProcess_WaitForExit(cp, 0);
|
||||
if ( captureStdOut && tempStdOut.begin() != tempStdOut.end())
|
||||
if (captureStdOut)
|
||||
{
|
||||
captureStdOut->append(&*tempStdOut.begin(), tempStdOut.size());
|
||||
captureStdOut->assign(tempStdOut.begin(), tempStdOut.end());
|
||||
}
|
||||
if ( captureStdErr && captureStdErr != captureStdOut &&
|
||||
tempStdErr.begin() != tempStdErr.end())
|
||||
if (captureStdErr && captureStdErr != captureStdOut)
|
||||
{
|
||||
captureStdErr->append(&*tempStdErr.begin(), tempStdErr.size());
|
||||
captureStdErr->assign(tempStdErr.begin(), tempStdErr.end());
|
||||
}
|
||||
|
||||
bool result = true;
|
||||
|
||||
Reference in New Issue
Block a user