Source: Reduce string allocations, part 2

This commit is contained in:
AJIOB
2026-09-22 11:37:41 +03:00
parent 509ac6160a
commit cb20c5bd89
24 changed files with 115 additions and 90 deletions
+7 -5
View File
@@ -80,8 +80,9 @@ int cmCPackAppImageGenerator::PackageFiles()
cmCPackLogger(cmCPackLog::LOG_OUTPUT, cmCPackLogger(cmCPackLog::LOG_OUTPUT,
"Found Desktop file: \"" << desktopFile.value() << "\"" "Found Desktop file: \"" << desktopFile.value() << "\""
<< std::endl); << std::endl);
std::string desktopSymLink = this->toplevel + "/" + std::string desktopSymLink =
cmSystemTools::GetFilenameName(desktopFile.value()); cmStrCat(this->toplevel, '/',
cmSystemTools::GetFilenameName(desktopFile.value()));
cmCPackLogger(cmCPackLog::LOG_OUTPUT, cmCPackLogger(cmCPackLog::LOG_OUTPUT,
"Desktop file destination: \"" << desktopSymLink << "\"" "Desktop file destination: \"" << desktopSymLink << "\""
<< std::endl); << std::endl);
@@ -139,7 +140,7 @@ int cmCPackAppImageGenerator::PackageFiles()
cmCPackLogger(cmCPackLog::LOG_OUTPUT, cmCPackLogger(cmCPackLog::LOG_OUTPUT,
"Icon file: \"" << *iconFile << "\"" << std::endl); "Icon file: \"" << *iconFile << "\"" << std::endl);
std::string iconSymLink = std::string iconSymLink =
this->toplevel + "/" + cmSystemTools::GetFilenameName(*iconFile); cmStrCat(this->toplevel, '/', cmSystemTools::GetFilenameName(*iconFile));
cmCPackLogger(cmCPackLog::LOG_OUTPUT, cmCPackLogger(cmCPackLog::LOG_OUTPUT,
"Icon link destination: \"" << iconSymLink << "\"" "Icon link destination: \"" << iconSymLink << "\""
<< std::endl); << std::endl);
@@ -239,8 +240,9 @@ int cmCPackAppImageGenerator::PackageFiles()
this->AppimagetoolPath, this->AppimagetoolPath,
this->toplevel, this->toplevel,
}; };
command.emplace_back("../" + *this->GetOption("CPACK_PACKAGE_FILE_NAME") + command.emplace_back(cmStrCat("../",
this->GetOutputExtension()); *this->GetOption("CPACK_PACKAGE_FILE_NAME"),
this->GetOutputExtension()));
auto addOptionFlag = [&command, this](std::string const& op, auto addOptionFlag = [&command, this](std::string const& op,
std::string commandFlag) { std::string commandFlag) {
+14 -10
View File
@@ -286,8 +286,8 @@ std::string cmCPackArchiveGenerator::GetArchiveComponentFileName(
std::string componentUpper(cmSystemTools::UpperCase(component)); std::string componentUpper(cmSystemTools::UpperCase(component));
std::string packageFileName; std::string packageFileName;
if (cmValue v = this->GetOptionIfSet("CPACK_ARCHIVE_" + componentUpper + if (cmValue v = this->GetOptionIfSet(
"_FILE_NAME")) { cmStrCat("CPACK_ARCHIVE_", componentUpper, "_FILE_NAME"))) {
packageFileName += *v; packageFileName += *v;
} else if ((v = this->GetOptionIfSet("CPACK_ARCHIVE_FILE_NAME"))) { } else if ((v = this->GetOptionIfSet("CPACK_ARCHIVE_FILE_NAME"))) {
packageFileName += packageFileName +=
@@ -328,8 +328,9 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(
cmCPackLogger(cmCPackLog::LOG_VERBOSE, cmCPackLogger(cmCPackLog::LOG_VERBOSE,
" - packaging component: " << component->Name << std::endl); " - packaging component: " << component->Name << std::endl);
// Add the files of this component to the archive // Add the files of this component to the archive
std::string localToplevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY")); std::string localToplevel(
localToplevel += "/" + this->GetSanitizedDirOrFileName(component->Name); cmStrCat(this->GetOption("CPACK_TEMPORARY_DIRECTORY"), '/',
this->GetSanitizedDirOrFileName(component->Name)));
// Change to local toplevel // Change to local toplevel
cmWorkingDirectory workdir(localToplevel); cmWorkingDirectory workdir(localToplevel);
if (workdir.Failed()) { if (workdir.Failed()) {
@@ -426,8 +427,9 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup)
cmCPackLogger(cmCPackLog::LOG_VERBOSE, cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Packaging component group: " << compG.first << std::endl); "Packaging component group: " << compG.first << std::endl);
// Begin the archive for this group // Begin the archive for this group
std::string packageFileName = std::string(this->toplevel) + "/" + std::string packageFileName =
this->GetArchiveComponentFileName(compG.first, true); cmStrCat(this->toplevel, '/',
this->GetArchiveComponentFileName(compG.first, true));
Deduplicator deduplicator; Deduplicator deduplicator;
@@ -455,8 +457,9 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup)
<< "> does not belong to any group, package it separately." << "> does not belong to any group, package it separately."
<< std::endl); << std::endl);
std::string packageFileName = std::string(this->toplevel); std::string packageFileName = std::string(this->toplevel);
packageFileName += packageFileName =
"/" + this->GetArchiveComponentFileName(comp.first, false); cmStrCat(packageFileName, '/',
this->GetArchiveComponentFileName(comp.first, false));
{ {
DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive); DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive);
@@ -473,8 +476,9 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup)
else { else {
for (auto& comp : this->Components) { for (auto& comp : this->Components) {
std::string packageFileName = std::string(this->toplevel); std::string packageFileName = std::string(this->toplevel);
packageFileName += packageFileName =
"/" + this->GetArchiveComponentFileName(comp.first, false); cmStrCat(packageFileName, '/',
this->GetArchiveComponentFileName(comp.first, false));
{ {
DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive); DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive);
+7 -6
View File
@@ -520,9 +520,10 @@ bool DebGenerator::generateDeb() const
deb.SetUNAMEAndGNAME("root", "root"); deb.SetUNAMEAndGNAME("root", "root");
if (!deb.Add(tlDir + "debian-binary", tlDir.length()) || if (!deb.Add(tlDir + "debian-binary", tlDir.length()) ||
!deb.Add(tlDir + "control.tar" + this->CompressionSuffix, !deb.Add(cmStrCat(tlDir, "control.tar", this->CompressionSuffix),
tlDir.length()) || tlDir.length()) ||
!deb.Add(tlDir + "data.tar" + this->CompressionSuffix, tlDir.length())) { !deb.Add(cmStrCat(tlDir, "data.tar", this->CompressionSuffix),
tlDir.length())) {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error creating debian package:\n" "Error creating debian package:\n"
"#top level directory: " "#top level directory: "
@@ -919,8 +920,8 @@ bool cmCPackDebGenerator::createDbgsymDDeb()
controlValues["Version"] = *debian_pkg_version; controlValues["Version"] = *debian_pkg_version;
controlValues["Auto-Built-Package"] = "debug-symbols"; controlValues["Auto-Built-Package"] = "debug-symbols";
controlValues["Depends"] = controlValues["Depends"] =
*this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_NAME") + std::string(" (= ") + cmStrCat(*this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_NAME"),
*debian_pkg_version + ")"; " (= ", *debian_pkg_version, ')');
controlValues["Section"] = "debug"; controlValues["Section"] = "debug";
controlValues["Priority"] = "optional"; controlValues["Priority"] = "optional";
controlValues["Architecture"] = controlValues["Architecture"] =
@@ -973,8 +974,8 @@ std::string cmCPackDebGenerator::GetComponentInstallSuffix(
} }
// We have to find the name of the COMPONENT GROUP // We have to find the name of the COMPONENT GROUP
// the current COMPONENT belongs to. // the current COMPONENT belongs to.
std::string groupVar = std::string groupVar = cmStrCat(
"CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP"; "CPACK_COMPONENT_", cmSystemTools::UpperCase(componentName), "_GROUP");
if (cmValue v = this->GetOption(groupVar)) { if (cmValue v = this->GetOption(groupVar)) {
return *v; return *v;
} }
+14 -11
View File
@@ -114,7 +114,7 @@ int cmCPackGenerator::PrepareNames()
// Determine temporary packaging-directory. // Determine temporary packaging-directory.
std::string tmpDirectory = cmStrCat(topDirectory, '/', pkgBaseFileName); std::string tmpDirectory = cmStrCat(topDirectory, '/', pkgBaseFileName);
// Determine path to temporary package file. // Determine path to temporary package file.
std::string tmpPkgFilePath = topDirectory + "/" + pkgFileName; std::string tmpPkgFilePath = cmStrCat(topDirectory, '/', pkgFileName);
// Set CPack variables which are not set already. // Set CPack variables which are not set already.
this->SetOptionIfNotSet("CPACK_REMOVE_TOPLEVEL_DIRECTORY", "1"); this->SetOptionIfNotSet("CPACK_REMOVE_TOPLEVEL_DIRECTORY", "1");
@@ -620,8 +620,9 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
if (this->SupportsComponentInstallation() && if (this->SupportsComponentInstallation() &&
!(this->IsOn("CPACK_MONOLITHIC_INSTALL"))) { !(this->IsOn("CPACK_MONOLITHIC_INSTALL"))) {
// Determine the installation types for this project (if provided). // Determine the installation types for this project (if provided).
std::string installTypesVar = "CPACK_" + std::string installTypesVar =
cmSystemTools::UpperCase(project.Component) + "_INSTALL_TYPES"; cmStrCat("CPACK_", cmSystemTools::UpperCase(project.Component),
"_INSTALL_TYPES");
cmValue installTypes = this->GetOption(installTypesVar); cmValue installTypes = this->GetOption(installTypesVar);
if (!installTypes.IsEmpty()) { if (!installTypes.IsEmpty()) {
cmList installTypesList{ installTypes }; cmList installTypesList{ installTypes };
@@ -837,7 +838,7 @@ int cmCPackGenerator::InstallCMakeProject(
if (cmHasPrefix(dir, '/')) { if (cmHasPrefix(dir, '/')) {
dir = tempInstallDirectory + dir; dir = tempInstallDirectory + dir;
} else { } else {
dir = tempInstallDirectory + "/" + dir; dir = cmStrCat(tempInstallDirectory, '/', dir);
} }
/* /*
* We must re-set DESTDIR for each component * We must re-set DESTDIR for each component
@@ -987,8 +988,8 @@ int cmCPackGenerator::InstallCMakeProject(
// define component specific var // define component specific var
if (componentInstall) { if (componentInstall) {
std::string absoluteDestFileComponent = std::string absoluteDestFileComponent =
std::string("CPACK_ABSOLUTE_DESTINATION_FILES") + "_" + cmStrCat("CPACK_ABSOLUTE_DESTINATION_FILES_",
this->GetComponentInstallSuffix(component); this->GetComponentInstallSuffix(component));
if (cmValue v = this->GetOption(absoluteDestFileComponent)) { if (cmValue v = this->GetOption(absoluteDestFileComponent)) {
std::string absoluteDestFilesListComponent = cmStrCat(*v, ';', *d); std::string absoluteDestFilesListComponent = cmStrCat(*v, ';', *d);
this->SetOption(absoluteDestFileComponent, this->SetOption(absoluteDestFileComponent,
@@ -1665,12 +1666,13 @@ std::string cmCPackGenerator::GetComponentPackageFileName(
std::string suffix = "-" + groupOrComponentName; std::string suffix = "-" + groupOrComponentName;
/* check if we should use DISPLAY name */ /* check if we should use DISPLAY name */
std::string dispNameVar = std::string dispNameVar =
"CPACK_" + this->Name + "_USE_DISPLAY_NAME_IN_FILENAME"; cmStrCat("CPACK_", this->Name, "_USE_DISPLAY_NAME_IN_FILENAME");
if (this->IsOn(dispNameVar)) { if (this->IsOn(dispNameVar)) {
/* the component Group case */ /* the component Group case */
if (isGroupName) { if (isGroupName) {
std::string groupDispVar = "CPACK_COMPONENT_GROUP_" + std::string groupDispVar = cmStrCat(
cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME"; "CPACK_COMPONENT_GROUP_",
cmSystemTools::UpperCase(groupOrComponentName), "_DISPLAY_NAME");
cmValue groupDispName = this->GetOption(groupDispVar); cmValue groupDispName = this->GetOption(groupDispVar);
if (groupDispName) { if (groupDispName) {
suffix = "-" + *groupDispName; suffix = "-" + *groupDispName;
@@ -1678,8 +1680,9 @@ std::string cmCPackGenerator::GetComponentPackageFileName(
} }
/* the [single] component case */ /* the [single] component case */
else { else {
std::string dispVar = "CPACK_COMPONENT_" + std::string dispVar = cmStrCat(
cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME"; "CPACK_COMPONENT_", cmSystemTools::UpperCase(groupOrComponentName),
"_DISPLAY_NAME");
cmValue dispName = this->GetOption(dispVar); cmValue dispName = this->GetOption(dispVar);
if (dispName) { if (dispName) {
suffix = "-" + *dispName; suffix = "-" + *dispName;
+2 -2
View File
@@ -750,8 +750,8 @@ bool cmCPackInnoSetupGenerator::ProcessComponents()
return false; return false;
} }
codeIncludes.push_back("#include " + QuotePath(componentsScriptTemplate) + codeIncludes.push_back(
"\n"); cmStrCat("#include ", QuotePath(componentsScriptTemplate), '\n'));
return true; return true;
} }
+2 -1
View File
@@ -13,6 +13,7 @@
#include "cmCPackComponentGroup.h" #include "cmCPackComponentGroup.h"
#include "cmCPackLog.h" #include "cmCPackLog.h"
#include "cmList.h" #include "cmList.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmValue.h" #include "cmValue.h"
@@ -81,7 +82,7 @@ void cmCPackNuGetGenerator::SetupGroupComponentVariables(bool ignoreGroup)
end(compG.second.Components), end(compG.second.Components),
std::back_inserter(components), std::back_inserter(components),
[](cmCPackComponent const* comp) { return comp->Name; }); [](cmCPackComponent const* comp) { return comp->Name; });
this->SetOption("CPACK_NUGET_" + compGUp + "_GROUP_COMPONENTS", this->SetOption(cmStrCat("CPACK_NUGET_", compGUp, "_GROUP_COMPONENTS"),
cmList::to_string(components)); cmList::to_string(components));
} }
if (!groups.empty()) { if (!groups.empty()) {
+18 -13
View File
@@ -82,10 +82,10 @@ int cmCPackRPMGenerator::PackageOnePack(std::string const& initialToplevel,
this->GetOption("CPACK_PACKAGE_FILE_NAME"), packageName, true) + this->GetOption("CPACK_PACKAGE_FILE_NAME"), packageName, true) +
this->GetOutputExtension()); this->GetOutputExtension());
localToplevel += "/" + sanitizedPkgDirName; localToplevel = cmStrCat(localToplevel, '/', sanitizedPkgDirName);
/* replace the TEMP DIRECTORY with the component one */ /* replace the TEMP DIRECTORY with the component one */
this->SetOption("CPACK_TEMPORARY_DIRECTORY", localToplevel); this->SetOption("CPACK_TEMPORARY_DIRECTORY", localToplevel);
packageFileName += "/" + outputFileName; packageFileName = cmStrCat(packageFileName, '/', outputFileName);
/* replace proposed CPACK_OUTPUT_FILE_NAME */ /* replace proposed CPACK_OUTPUT_FILE_NAME */
this->SetOption("CPACK_OUTPUT_FILE_NAME", outputFileName); this->SetOption("CPACK_OUTPUT_FILE_NAME", outputFileName);
/* replace the TEMPORARY package file name */ /* replace the TEMPORARY package file name */
@@ -146,8 +146,10 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
std::transform(component.begin(), component.end(), component.begin(), std::transform(component.begin(), component.end(), component.begin(),
cmsysString_toupper); cmsysString_toupper);
if (this->IsOn("CPACK_RPM_" + compIt->first + "_DEBUGINFO_PACKAGE") || if (this->IsOn(
this->IsOn("CPACK_RPM_" + component + "_DEBUGINFO_PACKAGE")) { cmStrCat("CPACK_RPM_", compIt->first, "_DEBUGINFO_PACKAGE")) ||
this->IsOn(
cmStrCat("CPACK_RPM_", component, "_DEBUGINFO_PACKAGE"))) {
shouldSet = false; shouldSet = false;
break; break;
} }
@@ -160,8 +162,10 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
std::transform(component.begin(), component.end(), component.begin(), std::transform(component.begin(), component.end(), component.begin(),
cmsysString_toupper); cmsysString_toupper);
if (this->IsOn("CPACK_RPM_" + compGIt->first + "_DEBUGINFO_PACKAGE") || if (this->IsOn(
this->IsOn("CPACK_RPM_" + component + "_DEBUGINFO_PACKAGE")) { cmStrCat("CPACK_RPM_", compGIt->first, "_DEBUGINFO_PACKAGE")) ||
this->IsOn(
cmStrCat("CPACK_RPM_", component, "_DEBUGINFO_PACKAGE"))) {
shouldSet = false; shouldSet = false;
break; break;
} }
@@ -177,9 +181,10 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
std::transform(component.begin(), component.end(), std::transform(component.begin(), component.end(),
component.begin(), cmsysString_toupper); component.begin(), cmsysString_toupper);
if (this->IsOn("CPACK_RPM_" + compIt->first + if (this->IsOn(cmStrCat("CPACK_RPM_", compIt->first,
"_DEBUGINFO_PACKAGE") || "_DEBUGINFO_PACKAGE")) ||
this->IsOn("CPACK_RPM_" + component + "_DEBUGINFO_PACKAGE")) { this->IsOn(
cmStrCat("CPACK_RPM_", component, "_DEBUGINFO_PACKAGE"))) {
shouldSet = false; shouldSet = false;
break; break;
} }
@@ -389,11 +394,11 @@ int cmCPackRPMGenerator::PackageComponentsAllInOne(
std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) + std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) +
this->GetOutputExtension()); this->GetOutputExtension());
// all GROUP in one vs all COMPONENT in one // all GROUP in one vs all COMPONENT in one
localToplevel += "/" + compInstDirName; localToplevel = cmStrCat(localToplevel, '/', compInstDirName);
/* replace the TEMP DIRECTORY with the component one */ /* replace the TEMP DIRECTORY with the component one */
this->SetOption("CPACK_TEMPORARY_DIRECTORY", localToplevel); this->SetOption("CPACK_TEMPORARY_DIRECTORY", localToplevel);
packageFileName += "/" + outputFileName; packageFileName = cmStrCat(packageFileName, '/', outputFileName);
/* replace proposed CPACK_OUTPUT_FILE_NAME */ /* replace proposed CPACK_OUTPUT_FILE_NAME */
this->SetOption("CPACK_OUTPUT_FILE_NAME", outputFileName); this->SetOption("CPACK_OUTPUT_FILE_NAME", outputFileName);
/* replace the TEMPORARY package file name */ /* replace the TEMPORARY package file name */
@@ -457,8 +462,8 @@ std::string cmCPackRPMGenerator::GetComponentInstallSuffix(
} }
// We have to find the name of the COMPONENT GROUP // We have to find the name of the COMPONENT GROUP
// the current COMPONENT belongs to. // the current COMPONENT belongs to.
std::string groupVar = std::string groupVar = cmStrCat(
"CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP"; "CPACK_COMPONENT_", cmSystemTools::UpperCase(componentName), "_GROUP");
if (cmValue v = this->GetOption(groupVar)) { if (cmValue v = this->GetOption(groupVar)) {
return *v; return *v;
} }
+3 -2
View File
@@ -15,6 +15,7 @@
#include "cmArchiveWrite.h" #include "cmArchiveWrite.h"
#include "cmCPackGenerator.h" #include "cmCPackGenerator.h"
#include "cmCPackLog.h" #include "cmCPackLog.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmValue.h" #include "cmValue.h"
@@ -77,7 +78,7 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os)
cmsys::ifstream ilfs(inLicFile.c_str()); cmsys::ifstream ilfs(inLicFile.c_str());
std::string licenseText; std::string licenseText;
while (cmSystemTools::GetLineFromStream(ilfs, line)) { while (cmSystemTools::GetLineFromStream(ilfs, line)) {
licenseText += line + "\n"; licenseText = cmStrCat(licenseText, line, '\n');
} }
this->SetOptionIfNotSet("CPACK_RESOURCE_FILE_LICENSE_CONTENT", licenseText); this->SetOptionIfNotSet("CPACK_RESOURCE_FILE_LICENSE_CONTENT", licenseText);
@@ -88,7 +89,7 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os)
cmsys::ifstream ifs(inFile.c_str()); cmsys::ifstream ifs(inFile.c_str());
std::string packageHeaderText; std::string packageHeaderText;
while (cmSystemTools::GetLineFromStream(ifs, line)) { while (cmSystemTools::GetLineFromStream(ifs, line)) {
packageHeaderText += line + "\n"; packageHeaderText = cmStrCat(packageHeaderText, line, '\n');
} }
// Configure in the values // Configure in the values
+2 -1
View File
@@ -17,6 +17,7 @@
#include "cmCTest.h" #include "cmCTest.h"
#include "cmCTestVC.h" #include "cmCTestVC.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmXMLParser.h" #include "cmXMLParser.h"
@@ -399,7 +400,7 @@ bool cmCTestBZR::LoadRevisions()
std::string revs; std::string revs;
if (atoi(this->OldRevision.c_str()) <= atoi(this->NewRevision.c_str())) { if (atoi(this->OldRevision.c_str()) <= atoi(this->NewRevision.c_str())) {
// DoRevision takes care of discarding the information about OldRevision // DoRevision takes care of discarding the information about OldRevision
revs = this->OldRevision + ".." + this->NewRevision; revs = cmStrCat(this->OldRevision, "..", this->NewRevision);
} else { } else {
return true; return true;
} }
+2 -1
View File
@@ -1099,7 +1099,8 @@ void cmCTestBuildHandler::ProcessBuffer(char const* data, size_t length,
// Copy pre-context to report // Copy pre-context to report
for (std::string const& pc : this->PreContext) { for (std::string const& pc : this->PreContext) {
errorwarning.PreContext += pc + "\n"; errorwarning.PreContext =
cmStrCat(errorwarning.PreContext, pc, '\n');
} }
this->PreContext.clear(); this->PreContext.clear();
+2 -2
View File
@@ -87,7 +87,7 @@ bool cmCTestCVS::UpdateImpl()
// Specify the start time for nightly testing. // Specify the start time for nightly testing.
if (this->CTest->GetTestModel() == cmCTest::NIGHTLY) { if (this->CTest->GetTestModel() == cmCTest::NIGHTLY) {
args.push_back("-D" + this->GetNightlyTime() + " UTC"); args.push_back(cmStrCat("-D", this->GetNightlyTime(), " UTC"));
} }
// Run "cvs update" to update the work tree. // Run "cvs update" to update the work tree.
@@ -241,7 +241,7 @@ void cmCTestCVS::WriteXMLDirectory(cmXMLWriter& xml, std::string const& path,
// Load revisions and write an entry for each file in this directory. // Load revisions and write an entry for each file in this directory.
std::vector<Revision> revisions; std::vector<Revision> revisions;
for (auto const& fi : dir) { for (auto const& fi : dir) {
std::string full = path + slash + fi.first; std::string full = cmStrCat(path, slash, fi.first);
// Load two real or unknown revisions. // Load two real or unknown revisions.
revisions.clear(); revisions.clear();
+5 -5
View File
@@ -164,7 +164,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(std::string const& file,
} else { } else {
checkDir = fSrcDir; checkDir = fSrcDir;
} }
fFile = checkDir + "/" + relPath; fFile = cmStrCat(checkDir, '/', relPath);
fFile = cmSystemTools::GetFilenamePath(fFile); fFile = cmSystemTools::GetFilenamePath(fFile);
if (fileDir == fFile) { if (fileDir == fFile) {
@@ -492,7 +492,7 @@ int cmCTestCoverageHandler::ProcessHandler()
// Handle all the files in the extra coverage globs that have no cov data // Handle all the files in the extra coverage globs that have no cov data
for (std::string const& u : uncovered) { for (std::string const& u : uncovered) {
std::string fileName = cmSystemTools::GetFilenameName(u); std::string fileName = cmSystemTools::GetFilenameName(u);
std::string fullPath = cont.SourceDir + "/" + u; std::string fullPath = cmStrCat(cont.SourceDir, '/', u);
covLogXML.StartElement("File"); covLogXML.StartElement("File");
covLogXML.Attribute("Name", fileName); covLogXML.Attribute("Name", fileName);
@@ -1866,11 +1866,11 @@ std::string cmCTestCoverageHandler::FindFile(
std::string fileNameNoE = std::string fileNameNoE =
cmSystemTools::GetFilenameWithoutLastExtension(fileName); cmSystemTools::GetFilenameWithoutLastExtension(fileName);
// First check in source and binary directory // First check in source and binary directory
std::string fullName = cont->SourceDir + "/" + fileNameNoE + ".py"; std::string fullName = cmStrCat(cont->SourceDir, '/', fileNameNoE, ".py");
if (cmSystemTools::FileExists(fullName)) { if (cmSystemTools::FileExists(fullName)) {
return fullName; return fullName;
} }
fullName = cont->BinaryDir + "/" + fileNameNoE + ".py"; fullName = cmStrCat(cont->BinaryDir, '/', fileNameNoE, ".py");
if (cmSystemTools::FileExists(fullName)) { if (cmSystemTools::FileExists(fullName)) {
return fullName; return fullName;
} }
@@ -2436,7 +2436,7 @@ std::set<std::string> cmCTestCoverageHandler::FindUncoveredFiles(
cmsys::Glob gl; cmsys::Glob gl;
gl.RecurseOn(); gl.RecurseOn();
gl.RecurseThroughSymlinksOff(); gl.RecurseThroughSymlinksOff();
std::string glob = cont->SourceDir + "/" + ecg; std::string glob = cmStrCat(cont->SourceDir, '/', ecg);
gl.FindFiles(glob); gl.FindFiles(glob);
std::vector<std::string> files = gl.GetFiles(); std::vector<std::string> files = gl.GetFiles();
for (std::string const& f : files) { for (std::string const& f : files) {
+2 -2
View File
@@ -103,8 +103,8 @@ bool cmCTestDiscoverTests(cmTestDiscoveryArgs const& args,
cmsys::RegularExpression re; cmsys::RegularExpression re;
if (!re.compile(AddAnchors(args.DiscoveryMatch))) { if (!re.compile(AddAnchors(args.DiscoveryMatch))) {
std::string e = "DISCOVERY_MATCH failed to compile regex \"" + std::string e = cmStrCat("DISCOVERY_MATCH failed to compile regex \"",
args.DiscoveryMatch + "\"."; args.DiscoveryMatch, "\".");
status.SetError(e); status.SetError(e);
return false; return false;
} }
+2 -2
View File
@@ -110,7 +110,7 @@ std::string cmCTestGIT::FindGitDir()
// Git reports a relative path only when the .git directory is in // Git reports a relative path only when the .git directory is in
// the current directory. // the current directory.
if (git_dir[0] == '.') { if (git_dir[0] == '.') {
git_dir = this->SourceDirectory + "/" + git_dir; git_dir = cmStrCat(this->SourceDirectory, '/', git_dir);
} }
#if defined(_WIN32) && !defined(__CYGWIN__) #if defined(_WIN32) && !defined(__CYGWIN__)
else if (git_dir[0] == '/') { else if (git_dir[0] == '/') {
@@ -602,7 +602,7 @@ char const cmCTestGIT::CommitParser::SectionSep[SectionCount] = { '\n', '\n',
bool cmCTestGIT::LoadRevisions() bool cmCTestGIT::LoadRevisions()
{ {
// Use 'git rev-list ... | git diff-tree ...' to get revisions. // Use 'git rev-list ... | git diff-tree ...' to get revisions.
std::string range = this->OldRevision + ".." + this->NewRevision; std::string range = cmStrCat(this->OldRevision, "..", this->NewRevision);
std::string git = this->CommandLineTool; std::string git = this->CommandLineTool;
std::vector<std::string> git_rev_list = { git, "rev-list", "--reverse", std::vector<std::string> git_rev_list = { git, "rev-list", "--reverse",
range, "--" }; range, "--" };
+2 -1
View File
@@ -6,6 +6,7 @@
#include <utility> #include <utility>
#include "cmCTest.h" #include "cmCTest.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmXMLWriter.h" #include "cmXMLWriter.h"
@@ -82,7 +83,7 @@ void cmCTestGlobalVC::WriteXMLDirectory(cmXMLWriter& xml,
xml.StartElement("Directory"); xml.StartElement("Directory");
xml.Element("Name", path); xml.Element("Name", path);
for (auto const& f : dir) { for (auto const& f : dir) {
std::string const full = path + slash + f.first; std::string const full = cmStrCat(path, slash, f.first);
this->WriteXMLEntry(xml, path, f.first, full, f.second); this->WriteXMLEntry(xml, path, f.first, full, f.second);
} }
xml.EndElement(); // Directory xml.EndElement(); // Directory
+2 -1
View File
@@ -12,6 +12,7 @@
#include "cmCTest.h" #include "cmCTest.h"
#include "cmCTestVC.h" #include "cmCTestVC.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmXMLParser.h" #include "cmXMLParser.h"
@@ -272,7 +273,7 @@ bool cmCTestHG::LoadRevisions()
// The "list of strings" templates like {files} will not work when // The "list of strings" templates like {files} will not work when
// the project has spaces in the path. Also, they may not have // the project has spaces in the path. Also, they may not have
// proper XML escapes. // proper XML escapes.
std::string range = this->OldRevision + ":" + this->NewRevision; std::string range = cmStrCat(this->OldRevision, ':', this->NewRevision);
std::string hg = this->CommandLineTool; std::string hg = this->CommandLineTool;
std::string hgXMLTemplate = "<logentry\n" std::string hgXMLTemplate = "<logentry\n"
" revision=\"{node|short}\">\n" " revision=\"{node|short}\">\n"
+2 -2
View File
@@ -249,7 +249,7 @@ bool cmCTestSVN::UpdateImpl()
// Specify the start time for nightly testing. // Specify the start time for nightly testing.
if (this->CTest->GetTestModel() == cmCTest::NIGHTLY) { if (this->CTest->GetTestModel() == cmCTest::NIGHTLY) {
args.push_back("-r{" + this->GetNightlyTime() + " +0000}"); args.push_back(cmStrCat("-r{", this->GetNightlyTime(), " +0000}"));
} }
std::vector<std::string> svn_update; std::vector<std::string> svn_update;
@@ -383,7 +383,7 @@ bool cmCTestSVN::LoadRevisions(SVNInfo& svninfo)
// We are interested in every revision included in the update. // We are interested in every revision included in the update.
std::string revs; std::string revs;
if (atoi(svninfo.OldRevision.c_str()) < atoi(svninfo.NewRevision.c_str())) { if (atoi(svninfo.OldRevision.c_str()) < atoi(svninfo.NewRevision.c_str())) {
revs = "-r" + svninfo.OldRevision + ":" + svninfo.NewRevision; revs = cmStrCat("-r", svninfo.OldRevision, ':', svninfo.NewRevision);
} else { } else {
revs = "-r" + svninfo.NewRevision; revs = "-r" + svninfo.NewRevision;
} }
+14 -13
View File
@@ -280,7 +280,8 @@ bool cmCTestDiscoverTestsCommand::InitialPass(
} }
if (!unparsed.empty()) { if (!unparsed.empty()) {
status.SetError(" given unknown argument \"" + unparsed.front() + "\"."); status.SetError(
cmStrCat(" given unknown argument \"", unparsed.front(), "\"."));
return false; return false;
} }
@@ -1083,7 +1084,7 @@ void cmCTestTestHandler::ComputeOutOfDateTests()
continue; continue;
} }
std::string const stampFile = stampDir + "/" + tp.GetStampFile(); std::string const stampFile = cmStrCat(stampDir, '/', tp.GetStampFile());
if (!cmSystemTools::FileExists(stampFile)) { if (!cmSystemTools::FileExists(stampFile)) {
finalList.push_back(tp); finalList.push_back(tp);
@@ -1129,17 +1130,17 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
setupRegExp = this->TestOptions.ExcludeFixtureSetupRegularExpression; setupRegExp = this->TestOptions.ExcludeFixtureSetupRegularExpression;
} else { } else {
setupRegExp.append( setupRegExp.append(
"(" + setupRegExp + ")|(" + cmStrCat('(', setupRegExp, ")|(",
this->TestOptions.ExcludeFixtureSetupRegularExpression + ")"); this->TestOptions.ExcludeFixtureSetupRegularExpression, ')'));
} }
} }
if (!this->TestOptions.ExcludeFixtureCleanupRegularExpression.empty()) { if (!this->TestOptions.ExcludeFixtureCleanupRegularExpression.empty()) {
if (cleanupRegExp.empty()) { if (cleanupRegExp.empty()) {
cleanupRegExp = this->TestOptions.ExcludeFixtureCleanupRegularExpression; cleanupRegExp = this->TestOptions.ExcludeFixtureCleanupRegularExpression;
} else { } else {
cleanupRegExp.append( cleanupRegExp.append(cmStrCat(
"(" + cleanupRegExp + ")|(" + '(', cleanupRegExp, ")|(",
this->TestOptions.ExcludeFixtureCleanupRegularExpression + ")"); this->TestOptions.ExcludeFixtureCleanupRegularExpression, ')'));
} }
} }
cmsys::RegularExpression excludeSetupRegex(setupRegExp); cmsys::RegularExpression excludeSetupRegex(setupRegExp);
@@ -1574,7 +1575,7 @@ void cmCTestTestHandler::GenerateCTestXML(cmXMLWriter& xml)
xml.Element("StartTestTime", this->StartTestTime); xml.Element("StartTestTime", this->StartTestTime);
xml.StartElement("TestList"); xml.StartElement("TestList");
for (cmCTestTestResult const& result : this->TestResults) { for (cmCTestTestResult const& result : this->TestResults) {
std::string testPath = result.Path + "/" + result.Name; std::string testPath = cmStrCat(result.Path, '/', result.Name);
xml.Element("Test", this->CTest->GetShortPathToFile(testPath)); xml.Element("Test", this->CTest->GetShortPathToFile(testPath));
} }
xml.EndElement(); // TestList xml.EndElement(); // TestList
@@ -1696,7 +1697,7 @@ void cmCTestTestHandler::WriteTestResultHeader(cmXMLWriter& xml,
} else { } else {
xml.Attribute("Status", "failed"); xml.Attribute("Status", "failed");
} }
std::string testPath = result.Path + "/" + result.Name; std::string testPath = cmStrCat(result.Path, '/', result.Name);
xml.Element("Name", result.Name); xml.Element("Name", result.Name);
xml.Element("Path", this->CTest->GetShortPathToFile(result.Path)); xml.Element("Path", this->CTest->GetShortPathToFile(result.Path));
xml.Element("FullName", this->CTest->GetShortPathToFile(testPath)); xml.Element("FullName", this->CTest->GetShortPathToFile(testPath));
@@ -2128,7 +2129,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed()
} }
std::string lastTestsFailedLog = std::string lastTestsFailedLog =
this->CTest->GetBinaryDir() + "/Testing/Temporary/" + logName; cmStrCat(this->CTest->GetBinaryDir(), "/Testing/Temporary/", logName);
if (!cmSystemTools::FileExists(lastTestsFailedLog)) { if (!cmSystemTools::FileExists(lastTestsFailedLog)) {
if (!this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels()) { if (!this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels()) {
@@ -2210,7 +2211,7 @@ void cmCTestTestHandler::RecordCustomTestMeasurements(cmXMLWriter& xml,
xml.StartElement("NamedMeasurement"); xml.StartElement("NamedMeasurement");
xml.Attribute("name", parser.MeasurementName); xml.Attribute("name", parser.MeasurementName);
xml.Attribute("text", "text/string"); xml.Attribute("text", "text/string");
xml.Element("Value", "File " + filename + " not found"); xml.Element("Value", cmStrCat("File ", filename, " not found"));
xml.EndElement(); xml.EndElement();
cmCTestOptionalLog( cmCTestOptionalLog(
this->CTest, HANDLER_OUTPUT, this->CTest, HANDLER_OUTPUT,
@@ -2222,7 +2223,7 @@ void cmCTestTestHandler::RecordCustomTestMeasurements(cmXMLWriter& xml,
xml.Attribute("name", parser.MeasurementName); xml.Attribute("name", parser.MeasurementName);
xml.Attribute("type", "text/string"); xml.Attribute("type", "text/string");
xml.Attribute("encoding", "none"); xml.Attribute("encoding", "none");
xml.Element("Value", "Image " + filename + " is empty"); xml.Element("Value", cmStrCat("Image ", filename, " is empty"));
xml.EndElement(); xml.EndElement();
} else { } else {
if (parser.MeasurementType == "file") { if (parser.MeasurementType == "file") {
@@ -2328,7 +2329,7 @@ void cmCTestTestHandler::CleanTestOutput(std::string& output, size_t length,
} else if (truncate == cmCTestTypes::TruncationMode::Middle) { } else if (truncate == cmCTestTypes::TruncationMode::Middle) {
char const* current = utf8_advance(begin, end, length / 2); char const* current = utf8_advance(begin, end, length / 2);
output.erase(current - begin, output.size() - length); output.erase(current - begin, output.size() - length);
output.insert(current - begin, "..." + msg + "..."); output.insert(current - begin, cmStrCat("...", msg, "..."));
} else { // default or "tail" } else { // default or "tail"
char const* current = utf8_advance(begin, end, length); char const* current = utf8_advance(begin, end, length);
output.erase(current - begin); output.erase(current - begin);
+2 -2
View File
@@ -260,8 +260,8 @@ bool cmCTestUpdateCommand::ExecuteUpdate(UpdateArguments& args,
xml.Element("Site", mf.GetSafeDefinition("CTEST_SITE")); xml.Element("Site", mf.GetSafeDefinition("CTEST_SITE"));
xml.Element("BuildName", buildname); xml.Element("BuildName", buildname);
xml.Element("BuildStamp", xml.Element("BuildStamp",
this->CTest->GetCurrentTag() + "-" + cmStrCat(this->CTest->GetCurrentTag(), '-',
this->CTest->GetTestGroupString()); this->CTest->GetTestGroupString()));
xml.Element("StartDateTime", start_time); xml.Element("StartDateTime", start_time);
xml.Element("StartTime", start_time_time); xml.Element("StartTime", start_time_time);
xml.Element("UpdateCommand", vc->GetUpdateCommandLine()); xml.Element("UpdateCommand", vc->GetUpdateCommandLine());
+3 -2
View File
@@ -16,6 +16,7 @@
#include "cmGeneratedFileStream.h" #include "cmGeneratedFileStream.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmMessageType.h" #include "cmMessageType.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmVersion.h" #include "cmVersion.h"
#include "cmXMLWriter.h" #include "cmXMLWriter.h"
@@ -59,8 +60,8 @@ bool cmCTestUploadCommand::ExecuteUpload(UploadArguments& args,
xml.StartElement("Site"); xml.StartElement("Site");
xml.Attribute("BuildName", buildname); xml.Attribute("BuildName", buildname);
xml.Attribute("BuildStamp", xml.Attribute("BuildStamp",
this->CTest->GetCurrentTag() + "-" + cmStrCat(this->CTest->GetCurrentTag(), '-',
this->CTest->GetTestGroupString()); this->CTest->GetTestGroupString()));
xml.Attribute("Name", mf.GetSafeDefinition("CTEST_SITE")); xml.Attribute("Name", mf.GetSafeDefinition("CTEST_SITE"));
xml.Attribute("Generator", xml.Attribute("Generator",
std::string("ctest-") + cmVersion::GetCMakeVersion()); std::string("ctest-") + cmVersion::GetCMakeVersion());
+2 -1
View File
@@ -8,6 +8,7 @@
#include "cmCTest.h" #include "cmCTest.h"
#include "cmCTestCoverageHandler.h" #include "cmCTestCoverageHandler.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
class cmParseDelphiCoverage::HTMLParser class cmParseDelphiCoverage::HTMLParser
@@ -133,7 +134,7 @@ public:
cmsys::Glob gl; cmsys::Glob gl;
gl.RecurseOn(); gl.RecurseOn();
gl.RecurseThroughSymlinksOff(); gl.RecurseThroughSymlinksOff();
std::string glob = this->Coverage.SourceDir + "*/" + filename; std::string glob = cmStrCat(this->Coverage.SourceDir, "*/", filename);
gl.FindFiles(glob); gl.FindFiles(glob);
std::vector<std::string> const& files = gl.GetFiles(); std::vector<std::string> const& files = gl.GetFiles();
if (files.empty()) { if (files.empty()) {
+1 -1
View File
@@ -48,7 +48,7 @@ protected:
"Reading file: " << fileName << std::endl, "Reading file: " << fileName << std::endl,
this->Coverage.Quiet); this->Coverage.Quiet);
this->FilePath = this->PackagePath + "/" + fileName; this->FilePath = cmStrCat(this->PackagePath, '/', fileName);
cmsys::ifstream fin(this->FilePath.c_str()); cmsys::ifstream fin(this->FilePath.c_str());
if (!fin) { if (!fin) {
cmCTestLog(this->CTest, ERROR_MESSAGE, cmCTestLog(this->CTest, ERROR_MESSAGE,
+3 -2
View File
@@ -456,10 +456,11 @@ void cmCursesMainForm::UpdateProgress(std::string const& msg, float prog)
int percentCompleted = static_cast<int>(100 * prog); int percentCompleted = static_cast<int>(100 * prog);
this->LastProgress = (percentCompleted < 100 ? " " : ""); this->LastProgress = (percentCompleted < 100 ? " " : "");
this->LastProgress += (percentCompleted < 10 ? " " : ""); this->LastProgress += (percentCompleted < 10 ? " " : "");
this->LastProgress += std::to_string(percentCompleted) + "% ["; this->LastProgress =
cmStrCat(this->LastProgress, std::to_string(percentCompleted), "% [");
this->LastProgress.append(progressBarCompleted, '#'); this->LastProgress.append(progressBarCompleted, '#');
this->LastProgress.append(progressBarWidth - progressBarCompleted, ' '); this->LastProgress.append(progressBarWidth - progressBarCompleted, ' ');
this->LastProgress += "] " + msg + "..."; this->LastProgress = cmStrCat(this->LastProgress, "] ", msg, "...");
this->DisplayOutputs(std::string()); this->DisplayOutputs(std::string());
} else { } else {
this->Outputs.emplace_back(msg); this->Outputs.emplace_back(msg);
+2 -2
View File
@@ -64,7 +64,7 @@ std::vector<std::string> cmEnvironment::GetVariables() const
result.reserve(this->Map.size()); result.reserve(this->Map.size());
for (auto const& elem : this->Map) { for (auto const& elem : this->Map) {
if (elem.second) { if (elem.second) {
result.push_back(elem.first + '=' + *elem.second); result.push_back(cmStrCat(elem.first, '=', *elem.second));
} }
} }
return result; return result;
@@ -208,7 +208,7 @@ void cmEnvironmentModification::ApplyTo(cmEnvironment& env)
for (auto const& e : this->Entries) { for (auto const& e : this->Entries) {
if (e.Op == "set") { if (e.Op == "set") {
env.PutEnv(e.Name + "=" + e.Value); env.PutEnv(cmStrCat(e.Name, '=', e.Value));
} else if (e.Op == "unset") { } else if (e.Op == "unset") {
env.UnPutEnv(e.Name); env.UnPutEnv(e.Name);
} else if (e.Op == "string_append") { } else if (e.Op == "string_append") {