mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-07 22:59:56 -05:00
ENH: Create cmXMLSafe to help escapes in XML
This class provides easy syntax to efficiently insert blocks of data into XML documents with proper escapes. It replaces the old cmCTest::MakeXMLSafe and cmSystemTools::MakeXMLSafe methods which allocated extra memory instead of directly streaming the data.
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "cmLocalGenerator.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmGeneratedFileStream.h"
|
||||
#include "cmXMLSafe.h"
|
||||
|
||||
//#include <cmsys/RegularExpression.hxx>
|
||||
#include <cmsys/Process.h>
|
||||
@@ -490,7 +491,7 @@ void cmCTestBuildHandler::GenerateXMLHeader(std::ostream& os)
|
||||
static_cast<unsigned int>(this->StartBuildTime)
|
||||
<< "</StartBuildTime>\n"
|
||||
<< "<BuildCommand>"
|
||||
<< this->CTest->MakeXMLSafe(
|
||||
<< cmXMLSafe(
|
||||
this->CTest->GetCTestConfiguration("MakeCommand"))
|
||||
<< "</BuildCommand>" << std::endl;
|
||||
}
|
||||
@@ -526,7 +527,7 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(std::ostream& os)
|
||||
}
|
||||
os << "\t<" << (cm->Error ? "Error" : "Warning") << ">\n"
|
||||
<< "\t\t<BuildLogLine>" << cm->LogLine << "</BuildLogLine>\n"
|
||||
<< "\t\t<Text>" << this->CTest->MakeXMLSafe(cm->Text)
|
||||
<< "\t\t<Text>" << cmXMLSafe(cm->Text).Quotes(false)
|
||||
<< "\n</Text>" << std::endl;
|
||||
std::vector<cmCTestCompileErrorWarningRex>::iterator rit;
|
||||
for ( rit = this->ErrorWarningFileLineRegex.begin();
|
||||
@@ -579,9 +580,9 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(std::ostream& os)
|
||||
<< "</SourceLineNumber>" << std::endl;
|
||||
}
|
||||
}
|
||||
os << "\t\t<PreContext>" << this->CTest->MakeXMLSafe(cm->PreContext)
|
||||
os << "\t\t<PreContext>" << cmXMLSafe(cm->PreContext).Quotes(false)
|
||||
<< "</PreContext>\n"
|
||||
<< "\t\t<PostContext>" << this->CTest->MakeXMLSafe(cm->PostContext);
|
||||
<< "\t\t<PostContext>" << cmXMLSafe(cm->PostContext).Quotes(false);
|
||||
// is this the last warning or error, if so notify
|
||||
if (cm->Error && !numErrorsAllowed ||
|
||||
!cm->Error && !numWarningsAllowed)
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "cmCTest.h"
|
||||
#include "cmGeneratedFileStream.h"
|
||||
#include "cmake.h"
|
||||
#include "cmXMLSafe.h"
|
||||
#include <cmsys/Process.h>
|
||||
|
||||
|
||||
@@ -106,7 +107,7 @@ int cmCTestConfigureHandler::ProcessHandler()
|
||||
os << "<ConfigureCommand>" << cCommand.c_str() << "</ConfigureCommand>"
|
||||
<< std::endl;
|
||||
cmCTestLog(this->CTest, DEBUG, "End" << std::endl);
|
||||
os << "<Log>" << cmCTest::MakeXMLSafe(output) << "</Log>" << std::endl;
|
||||
os << "<Log>" << cmXMLSafe(output) << "</Log>" << std::endl;
|
||||
std::string end_time = this->CTest->CurrentTime();
|
||||
os << "\t<ConfigureStatus>" << retVal << "</ConfigureStatus>\n"
|
||||
<< "\t<EndDateTime>" << end_time << "</EndDateTime>\n"
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "cmake.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmGeneratedFileStream.h"
|
||||
#include "cmXMLSafe.h"
|
||||
|
||||
#include <cmsys/Process.h>
|
||||
#include <cmsys/RegularExpression.hxx>
|
||||
@@ -470,8 +471,8 @@ int cmCTestCoverageHandler::ProcessHandler()
|
||||
const cmCTestCoverageHandlerContainer::SingleFileCoverageVector& fcov
|
||||
= fileIterator->second;
|
||||
covLogFile << "\t<File Name=\""
|
||||
<< this->CTest->MakeXMLSafe(fileName.c_str())
|
||||
<< "\" FullPath=\"" << this->CTest->MakeXMLSafe(
|
||||
<< cmXMLSafe(fileName)
|
||||
<< "\" FullPath=\"" << cmXMLSafe(
|
||||
this->CTest->GetShortPathToFile(
|
||||
fileIterator->first.c_str())) << "\">" << std::endl
|
||||
<< "\t\t<Report>" << std::endl;
|
||||
@@ -507,7 +508,7 @@ int cmCTestCoverageHandler::ProcessHandler()
|
||||
}
|
||||
covLogFile << "\t\t<Line Number=\"" << cc << "\" Count=\"" << fcov[cc]
|
||||
<< "\">"
|
||||
<< this->CTest->MakeXMLSafe(line.c_str()) << "</Line>" << std::endl;
|
||||
<< cmXMLSafe(line) << "</Line>" << std::endl;
|
||||
if ( fcov[cc] == 0 )
|
||||
{
|
||||
untested ++;
|
||||
@@ -536,8 +537,8 @@ int cmCTestCoverageHandler::ProcessHandler()
|
||||
total_untested += untested;
|
||||
covLogFile << "\t\t</Report>" << std::endl
|
||||
<< "\t</File>" << std::endl;
|
||||
covSumFile << "\t<File Name=\"" << this->CTest->MakeXMLSafe(fileName)
|
||||
<< "\" FullPath=\"" << this->CTest->MakeXMLSafe(
|
||||
covSumFile << "\t<File Name=\"" << cmXMLSafe(fileName)
|
||||
<< "\" FullPath=\"" << cmXMLSafe(
|
||||
this->CTest->GetShortPathToFile(fullFileName.c_str()))
|
||||
<< "\" Covered=\"" << (tested > 0 ? "true":"false") << "\">\n"
|
||||
<< "\t\t<LOCTested>" << tested << "</LOCTested>\n"
|
||||
@@ -1329,8 +1330,8 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch(
|
||||
<< std::endl);
|
||||
// start the file output
|
||||
covLogFile << "\t<File Name=\""
|
||||
<< this->CTest->MakeXMLSafe(i->first.c_str())
|
||||
<< "\" FullPath=\"" << this->CTest->MakeXMLSafe(
|
||||
<< cmXMLSafe(i->first)
|
||||
<< "\" FullPath=\"" << cmXMLSafe(
|
||||
this->CTest->GetShortPathToFile(
|
||||
i->second.c_str())) << "\">" << std::endl
|
||||
<< "\t\t<Report>" << std::endl;
|
||||
@@ -1339,7 +1340,7 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch(
|
||||
for(int k =0; bullseyeHelp[k] != 0; ++k)
|
||||
{
|
||||
covLogFile << "\t\t<Line Number=\"" << line << "\" Count=\"-1\">"
|
||||
<< this->CTest->MakeXMLSafe(bullseyeHelp[k])
|
||||
<< cmXMLSafe(bullseyeHelp[k])
|
||||
<< "</Line>" << std::endl;
|
||||
line++;
|
||||
}
|
||||
@@ -1355,7 +1356,7 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch(
|
||||
else if(valid)
|
||||
{
|
||||
covLogFile << "\t\t<Line Number=\"" << line << "\" Count=\"-1\">"
|
||||
<< this->CTest->MakeXMLSafe(lineIn.c_str())
|
||||
<< cmXMLSafe(lineIn)
|
||||
<< "</Line>" << std::endl;
|
||||
line++;
|
||||
}
|
||||
@@ -1561,8 +1562,8 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
|
||||
tmpLog << "percentBranch: " << percentBranch << "\n";
|
||||
tmpLog << "percentCoverage: " << percent_coverage << "\n";
|
||||
tmpLog << "coverage metric: " << cmet << "\n";
|
||||
covSumFile << "\t<File Name=\"" << this->CTest->MakeXMLSafe(sourceFile)
|
||||
<< "\" FullPath=\"" << this->CTest->MakeXMLSafe(
|
||||
covSumFile << "\t<File Name=\"" << cmXMLSafe(sourceFile)
|
||||
<< "\" FullPath=\"" << cmXMLSafe(
|
||||
this->CTest->GetShortPathToFile(file.c_str()))
|
||||
<< "\" Covered=\"" << (cmet>0?"true":"false") << "\">\n"
|
||||
<< "\t\t<BranchesTested>"
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <cmsys/RegularExpression.hxx>
|
||||
#include <cmsys/Base64.h>
|
||||
#include "cmMakefile.h"
|
||||
#include "cmXMLSafe.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
@@ -77,8 +78,8 @@ public:
|
||||
int i = 0;
|
||||
for(; atts[i] != 0; i+=2)
|
||||
{
|
||||
ostr << " " << this->CTest->MakeXMLSafe(atts[i]).c_str()
|
||||
<< " - " << this->CTest->MakeXMLSafe(atts[i+1]).c_str() << "\n";
|
||||
ostr << " " << cmXMLSafe(atts[i])
|
||||
<< " - " << cmXMLSafe(atts[i+1]) << "\n";
|
||||
}
|
||||
ostr << "\n";
|
||||
this->Log += ostr.str();
|
||||
@@ -313,7 +314,7 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os)
|
||||
{
|
||||
cmCTestTestResult *result = &this->TestResults[cc];
|
||||
std::string testPath = result->Path + "/" + result->Name;
|
||||
os << "\t\t<Test>" << cmCTest::MakeXMLSafe(
|
||||
os << "\t\t<Test>" << cmXMLSafe(
|
||||
this->CTest->GetShortPathToFile(testPath.c_str()))
|
||||
<< "</Test>" << std::endl;
|
||||
}
|
||||
@@ -610,7 +611,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput(
|
||||
results[failure] ++;
|
||||
defects ++;
|
||||
}
|
||||
ostr << cmCTest::MakeXMLSafe(*i) << std::endl;
|
||||
ostr << cmXMLSafe(*i) << std::endl;
|
||||
}
|
||||
|
||||
log = ostr.str();
|
||||
@@ -750,7 +751,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
|
||||
defects ++;
|
||||
}
|
||||
totalOutputSize += lines[cc].size();
|
||||
ostr << cmCTest::MakeXMLSafe(lines[cc]) << std::endl;
|
||||
ostr << cmXMLSafe(lines[cc]) << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -767,9 +768,9 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
|
||||
cmCTestLog(this->CTest, DEBUG, "before xml safe "
|
||||
<< lines[*i] << std::endl);
|
||||
cmCTestLog(this->CTest, DEBUG, "after xml safe "
|
||||
<< cmCTest::MakeXMLSafe(lines[*i]) << std::endl);
|
||||
<< cmXMLSafe(lines[*i]) << std::endl);
|
||||
|
||||
ostr << cmCTest::MakeXMLSafe(lines[*i]) << std::endl;
|
||||
ostr << cmXMLSafe(lines[*i]) << std::endl;
|
||||
if(!unlimitedOutput && totalOutputSize >
|
||||
static_cast<size_t>(this->CustomMaximumFailedTestOutputSize))
|
||||
{
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "cmLocalGenerator.h"
|
||||
#include "cmCommand.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmXMLSafe.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
@@ -1464,7 +1465,7 @@ void cmCTestTestHandler::GenerateDartOutput(std::ostream& os)
|
||||
{
|
||||
cmCTestTestResult *result = &this->TestResults[cc];
|
||||
std::string testPath = result->Path + "/" + result->Name;
|
||||
os << "\t\t<Test>" << cmCTest::MakeXMLSafe(
|
||||
os << "\t\t<Test>" << cmXMLSafe(
|
||||
this->CTest->GetShortPathToFile(testPath.c_str()))
|
||||
<< "</Test>" << std::endl;
|
||||
}
|
||||
@@ -1481,7 +1482,7 @@ void cmCTestTestHandler::GenerateDartOutput(std::ostream& os)
|
||||
{
|
||||
os << "\t\t\t<NamedMeasurement type=\"text/string\" "
|
||||
"name=\"Exit Code\"><Value>"
|
||||
<< cmCTest::MakeXMLSafe(this->GetTestStatus(result->Status))
|
||||
<< cmXMLSafe(this->GetTestStatus(result->Status))
|
||||
<< "</Value>"
|
||||
"</NamedMeasurement>\n"
|
||||
<< "\t\t\t<NamedMeasurement type=\"text/string\" "
|
||||
@@ -1498,13 +1499,13 @@ void cmCTestTestHandler::GenerateDartOutput(std::ostream& os)
|
||||
os
|
||||
<< "\t\t\t<NamedMeasurement type=\"text/string\" "
|
||||
<< "name=\"Completion Status\"><Value>"
|
||||
<< cmCTest::MakeXMLSafe(result->CompletionStatus)
|
||||
<< cmXMLSafe(result->CompletionStatus)
|
||||
<< "</Value></NamedMeasurement>\n";
|
||||
}
|
||||
os
|
||||
<< "\t\t\t<NamedMeasurement type=\"text/string\" "
|
||||
<< "name=\"Command Line\"><Value>"
|
||||
<< cmCTest::MakeXMLSafe(result->FullCommandLine)
|
||||
<< cmXMLSafe(result->FullCommandLine)
|
||||
<< "</Value></NamedMeasurement>\n";
|
||||
std::map<cmStdString,cmStdString>::iterator measureIt;
|
||||
for ( measureIt = result->Properties->Measurements.begin();
|
||||
@@ -1514,13 +1515,13 @@ void cmCTestTestHandler::GenerateDartOutput(std::ostream& os)
|
||||
os
|
||||
<< "\t\t\t<NamedMeasurement type=\"text/string\" "
|
||||
<< "name=\"" << measureIt->first.c_str() << "\"><Value>"
|
||||
<< cmCTest::MakeXMLSafe(measureIt->second.c_str())
|
||||
<< cmXMLSafe(measureIt->second)
|
||||
<< "</Value></NamedMeasurement>\n";
|
||||
}
|
||||
os
|
||||
<< "\t\t\t<Measurement>\n"
|
||||
<< "\t\t\t\t<Value>";
|
||||
os << cmCTest::MakeXMLSafe(result->Output);
|
||||
os << cmXMLSafe(result->Output);
|
||||
os
|
||||
<< "</Value>\n"
|
||||
<< "\t\t\t</Measurement>\n"
|
||||
@@ -1556,13 +1557,13 @@ void cmCTestTestHandler::WriteTestResultHeader(std::ostream& os,
|
||||
}
|
||||
std::string testPath = result->Path + "/" + result->Name;
|
||||
os << "\">\n"
|
||||
<< "\t\t<Name>" << cmCTest::MakeXMLSafe(result->Name) << "</Name>\n"
|
||||
<< "\t\t<Path>" << cmCTest::MakeXMLSafe(
|
||||
<< "\t\t<Name>" << cmXMLSafe(result->Name) << "</Name>\n"
|
||||
<< "\t\t<Path>" << cmXMLSafe(
|
||||
this->CTest->GetShortPathToFile(result->Path.c_str())) << "</Path>\n"
|
||||
<< "\t\t<FullName>" << cmCTest::MakeXMLSafe(
|
||||
<< "\t\t<FullName>" << cmXMLSafe(
|
||||
this->CTest->GetShortPathToFile(testPath.c_str())) << "</FullName>\n"
|
||||
<< "\t\t<FullCommandLine>"
|
||||
<< cmCTest::MakeXMLSafe(result->FullCommandLine)
|
||||
<< cmXMLSafe(result->FullCommandLine)
|
||||
<< "</FullCommandLine>\n";
|
||||
}
|
||||
|
||||
@@ -1577,7 +1578,7 @@ void cmCTestTestHandler::WriteTestResultFooter(std::ostream& os,
|
||||
for(std::vector<std::string>::const_iterator li = labels.begin();
|
||||
li != labels.end(); ++li)
|
||||
{
|
||||
os << "\t\t\t<Label>" << cmCTest::MakeXMLSafe(*li) << "</Label>\n";
|
||||
os << "\t\t\t<Label>" << cmXMLSafe(*li) << "</Label>\n";
|
||||
}
|
||||
os << "\t\t</Labels>\n";
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "cmVersion.h"
|
||||
#include "cmGeneratedFileStream.h"
|
||||
#include "cmXMLParser.h"
|
||||
#include "cmXMLSafe.h"
|
||||
|
||||
//#include <cmsys/RegularExpression.hxx>
|
||||
#include <cmsys/Process.h>
|
||||
@@ -653,9 +654,9 @@ int cmCTestUpdateHandler::ProcessHandler()
|
||||
<< this->CTest->GetTestModelString() << "</BuildStamp>" << std::endl;
|
||||
os << "\t<StartDateTime>" << start_time << "</StartDateTime>\n"
|
||||
<< "\t<StartTime>" << start_time_time << "</StartTime>\n"
|
||||
<< "\t<UpdateCommand>" << this->CTest->MakeXMLSafe(command)
|
||||
<< "\t<UpdateCommand>" << cmXMLSafe(command)
|
||||
<< "</UpdateCommand>\n"
|
||||
<< "\t<UpdateType>" << this->CTest->MakeXMLSafe(
|
||||
<< "\t<UpdateType>" << cmXMLSafe(
|
||||
cmCTestUpdateHandlerUpdateToString(updateType))
|
||||
<< "</UpdateType>\n";
|
||||
|
||||
@@ -1009,17 +1010,17 @@ int cmCTestUpdateHandler::ProcessHandler()
|
||||
<< path.c_str() << " / " << fname.c_str() << " was updated by "
|
||||
<< sauthor1.c_str() << " to revision: " << srevision1.c_str()
|
||||
<< " from revision: " << srevision2.c_str() << std::endl);
|
||||
os << "\t\t<File Directory=\"" << cmCTest::MakeXMLSafe(path) << "\">"
|
||||
<< cmCTest::MakeXMLSafe(fname)
|
||||
os << "\t\t<File Directory=\"" << cmXMLSafe(path) << "\">"
|
||||
<< cmXMLSafe(fname)
|
||||
<< "</File>\n"
|
||||
<< "\t\t<Directory>" << cmCTest::MakeXMLSafe(path)
|
||||
<< "\t\t<Directory>" << cmXMLSafe(path)
|
||||
<< "</Directory>\n"
|
||||
<< "\t\t<FullName>" << cmCTest::MakeXMLSafe(file) << "</FullName>\n"
|
||||
<< "\t\t<CheckinDate>" << cmCTest::MakeXMLSafe(sdate1)
|
||||
<< "\t\t<FullName>" << cmXMLSafe(file) << "</FullName>\n"
|
||||
<< "\t\t<CheckinDate>" << cmXMLSafe(sdate1)
|
||||
<< "</CheckinDate>\n"
|
||||
<< "\t\t<Author>" << cmCTest::MakeXMLSafe(sauthor1) << "</Author>\n"
|
||||
<< "\t\t<Email>" << cmCTest::MakeXMLSafe(semail1) << "</Email>\n"
|
||||
<< "\t\t<Log>" << cmCTest::MakeXMLSafe(comment1) << "</Log>\n"
|
||||
<< "\t\t<Author>" << cmXMLSafe(sauthor1) << "</Author>\n"
|
||||
<< "\t\t<Email>" << cmXMLSafe(semail1) << "</Email>\n"
|
||||
<< "\t\t<Log>" << cmXMLSafe(comment1) << "</Log>\n"
|
||||
<< "\t\t<Revision>" << srevision1 << "</Revision>\n"
|
||||
<< "\t\t<PriorRevision>" << srevision2 << "</PriorRevision>"
|
||||
<< std::endl;
|
||||
@@ -1030,26 +1031,26 @@ int cmCTestUpdateHandler::ProcessHandler()
|
||||
<< "\t\t\t<Revision>" << srevision1 << "</Revision>\n"
|
||||
<< "\t\t\t<PreviousRevision>" << srevision2
|
||||
<< "</PreviousRevision>\n"
|
||||
<< "\t\t\t<Author>" << cmCTest::MakeXMLSafe(sauthor1)
|
||||
<< "\t\t\t<Author>" << cmXMLSafe(sauthor1)
|
||||
<< "</Author>\n"
|
||||
<< "\t\t\t<Date>" << cmCTest::MakeXMLSafe(sdate1)
|
||||
<< "\t\t\t<Date>" << cmXMLSafe(sdate1)
|
||||
<< "</Date>\n"
|
||||
<< "\t\t\t<Comment>" << cmCTest::MakeXMLSafe(comment1)
|
||||
<< "\t\t\t<Comment>" << cmXMLSafe(comment1)
|
||||
<< "</Comment>\n"
|
||||
<< "\t\t\t<Email>" << cmCTest::MakeXMLSafe(semail1)
|
||||
<< "\t\t\t<Email>" << cmXMLSafe(semail1)
|
||||
<< "</Email>\n"
|
||||
<< "\t\t</Revisions>\n"
|
||||
<< "\t\t<Revisions>\n"
|
||||
<< "\t\t\t<Revision>" << srevision2 << "</Revision>\n"
|
||||
<< "\t\t\t<PreviousRevision>" << srevision2
|
||||
<< "</PreviousRevision>\n"
|
||||
<< "\t\t\t<Author>" << cmCTest::MakeXMLSafe(sauthor2)
|
||||
<< "\t\t\t<Author>" << cmXMLSafe(sauthor2)
|
||||
<< "</Author>\n"
|
||||
<< "\t\t\t<Date>" << cmCTest::MakeXMLSafe(sdate2)
|
||||
<< "\t\t\t<Date>" << cmXMLSafe(sdate2)
|
||||
<< "</Date>\n"
|
||||
<< "\t\t\t<Comment>" << cmCTest::MakeXMLSafe(comment2)
|
||||
<< "\t\t\t<Comment>" << cmXMLSafe(comment2)
|
||||
<< "</Comment>\n"
|
||||
<< "\t\t\t<Email>" << cmCTest::MakeXMLSafe(semail2)
|
||||
<< "\t\t\t<Email>" << cmXMLSafe(semail2)
|
||||
<< "</Email>\n"
|
||||
<< "\t\t</Revisions>" << std::endl;
|
||||
}
|
||||
@@ -1147,7 +1148,7 @@ int cmCTestUpdateHandler::ProcessHandler()
|
||||
if ( updateProducedError )
|
||||
{
|
||||
os << "Update error: ";
|
||||
os << this->CTest->MakeXMLSafe(checkoutErrorMessages);
|
||||
os << cmXMLSafe(checkoutErrorMessages);
|
||||
cmCTestLog(this->CTest, ERROR_MESSAGE, " Update with command: "
|
||||
<< command << " failed" << std::endl);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user