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