Change output to be a reference and not a pointer.

This avoids having to check the pointer value at each use which
was not being done.
This commit is contained in:
Bill Hoffman 2014-08-04 15:16:40 -04:00
parent ba60ff99ed
commit 7762fffa23
3 changed files with 23 additions and 29 deletions

View File

@ -77,7 +77,7 @@ int cmCTestConfigureHandler::ProcessHandler()
this->StartLogFile("Configure", ofs); this->StartLogFile("Configure", ofs);
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Configure with command: " cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Configure with command: "
<< cCommand << std::endl); << cCommand << std::endl);
res = this->CTest->RunMakeCommand(cCommand.c_str(), &output, res = this->CTest->RunMakeCommand(cCommand.c_str(), output,
&retVal, buildDirectory.c_str(), &retVal, buildDirectory.c_str(),
0, ofs); 0, ofs);

View File

@ -1147,7 +1147,7 @@ int cmCTest::GetTestModelFromString(const char* str)
//###################################################################### //######################################################################
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCTest::RunMakeCommand(const char* command, std::string* output, int cmCTest::RunMakeCommand(const char* command, std::string& output,
int* retVal, const char* dir, int timeout, std::ostream& ofs) int* retVal, const char* dir, int timeout, std::ostream& ofs)
{ {
// First generate the command and arguments // First generate the command and arguments
@ -1166,11 +1166,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string* output,
} }
argv.push_back(0); argv.push_back(0);
if ( output ) output = "";
{
*output = "";
}
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Run command:"); cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Run command:");
std::vector<const char*>::iterator ait; std::vector<const char*>::iterator ait;
for ( ait = argv.begin(); ait != argv.end() && *ait; ++ ait ) for ( ait = argv.begin(); ait != argv.end() && *ait; ++ ait )
@ -1198,8 +1194,6 @@ int cmCTest::RunMakeCommand(const char* command, std::string* output,
" Each . represents " << tick_len << " bytes of output" << std::endl " Each . represents " << tick_len << " bytes of output" << std::endl
<< " " << std::flush); << " " << std::flush);
while(cmsysProcess_WaitForData(cp, &data, &length, 0)) while(cmsysProcess_WaitForData(cp, &data, &length, 0))
{
if ( output )
{ {
for(int cc =0; cc < length; ++cc) for(int cc =0; cc < length; ++cc)
{ {
@ -1208,20 +1202,20 @@ int cmCTest::RunMakeCommand(const char* command, std::string* output,
data[cc] = '\n'; data[cc] = '\n';
} }
} }
output.append(data, length);
output->append(data, length); while ( output.size() > (tick * tick_len) )
while ( output->size() > (tick * tick_len) )
{ {
tick ++; tick ++;
cmCTestLog(this, HANDLER_OUTPUT, "." << std::flush); cmCTestLog(this, HANDLER_OUTPUT, "." << std::flush);
if ( tick % tick_line_len == 0 && tick > 0 ) if ( tick % tick_line_len == 0 && tick > 0 )
{ {
cmCTestLog(this, HANDLER_OUTPUT, " Size: " cmCTestLog(this, HANDLER_OUTPUT,
<< int((double(output->size()) / 1024.0) + 1) << "K" << std::endl " Size: "
<< int((double(output.size()) / 1024.0) + 1)
<< "K" << std::endl
<< " " << std::flush); << " " << std::flush);
} }
} }
}
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, cmCTestLogWrite(data, length)); cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, cmCTestLogWrite(data, length));
if ( ofs ) if ( ofs )
{ {
@ -1229,7 +1223,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string* output,
} }
} }
cmCTestLog(this, OUTPUT, " Size of output: " cmCTestLog(this, OUTPUT, " Size of output: "
<< int(double(output->size()) / 1024.0) << "K" << std::endl); << int(double(output.size()) / 1024.0) << "K" << std::endl);
cmsysProcess_WaitForExit(cp, 0); cmsysProcess_WaitForExit(cp, 0);
@ -1253,9 +1247,9 @@ int cmCTest::RunMakeCommand(const char* command, std::string* output,
} }
else if(result == cmsysProcess_State_Error) else if(result == cmsysProcess_State_Error)
{ {
*output += "\n*** ERROR executing: "; output += "\n*** ERROR executing: ";
*output += cmsysProcess_GetErrorString(cp); output += cmsysProcess_GetErrorString(cp);
*output += "\n***The build process failed."; output += "\n***The build process failed.";
cmCTestLog(this, ERROR_MESSAGE, "There was an error: " cmCTestLog(this, ERROR_MESSAGE, "There was an error: "
<< cmsysProcess_GetErrorString(cp) << std::endl); << cmsysProcess_GetErrorString(cp) << std::endl);
} }

View File

@ -271,7 +271,7 @@ public:
//! Run command specialized for make and configure. Returns process status //! Run command specialized for make and configure. Returns process status
// and retVal is return value or exception. // and retVal is return value or exception.
int RunMakeCommand(const char* command, std::string* output, int RunMakeCommand(const char* command, std::string& output,
int* retVal, const char* dir, int timeout, int* retVal, const char* dir, int timeout,
std::ostream& ofs); std::ostream& ofs);