diff options
-rw-r--r-- | Source/CPack/WiX/cmWIXAccessControlList.cxx | 15 | ||||
-rw-r--r-- | Source/CPack/cmCPackNSISGenerator.cxx | 13 | ||||
-rw-r--r-- | Source/CPack/cmCPackNSISGenerator.h | 5 | ||||
-rw-r--r-- | Source/cmAddSubDirectoryCommand.cxx | 5 | ||||
-rw-r--r-- | Source/cmBinUtilsLinuxELFLinker.cxx | 15 | ||||
-rw-r--r-- | Source/cmCTest.cxx | 9 |
6 files changed, 37 insertions, 25 deletions
diff --git a/Source/CPack/WiX/cmWIXAccessControlList.cxx b/Source/CPack/WiX/cmWIXAccessControlList.cxx index 3668b46..9685a7f 100644 --- a/Source/CPack/WiX/cmWIXAccessControlList.cxx +++ b/Source/CPack/WiX/cmWIXAccessControlList.cxx @@ -2,6 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmWIXAccessControlList.h" +#include <cm/string_view> + #include "cmCPackGenerator.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -35,12 +37,13 @@ void cmWIXAccessControlList::CreatePermissionElement(std::string const& entry) return; } - std::string user_and_domain = entry.substr(0, pos); - std::string permission_string = entry.substr(pos + 1); + cm::string_view enview(entry); + cm::string_view user_and_domain = enview.substr(0, pos); + cm::string_view permission_string = enview.substr(pos + 1); pos = user_and_domain.find('@'); - std::string user; - std::string domain; + cm::string_view user; + cm::string_view domain; if (pos != std::string::npos) { user = user_and_domain.substr(0, pos); domain = user_and_domain.substr(pos + 1); @@ -51,9 +54,9 @@ void cmWIXAccessControlList::CreatePermissionElement(std::string const& entry) std::vector<std::string> permissions = cmTokenize(permission_string, ","); this->SourceWriter.BeginElement("Permission"); - this->SourceWriter.AddAttribute("User", user); + this->SourceWriter.AddAttribute("User", std::string(user)); if (!domain.empty()) { - this->SourceWriter.AddAttribute("Domain", domain); + this->SourceWriter.AddAttribute("Domain", std::string(domain)); } for (std::string const& permission : permissions) { this->EmitBooleanAttribute(entry, cmTrimWhitespace(permission)); diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index f7edc91..6b30407 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -68,7 +68,7 @@ int cmCPackNSISGenerator::PackageFiles() // Use the custom component install directory if we have one if (pos != std::string::npos) { - const std::string componentName = fileN.substr(0, pos); + auto componentName = cm::string_view(fileN).substr(0, pos); outputDir = CustomComponentInstallDirectory(componentName); } else { outputDir = CustomComponentInstallDirectory(fileN); @@ -672,7 +672,7 @@ std::string cmCPackNSISGenerator::CreateComponentDescription( const std::string componentOutputDir = CustomComponentInstallDirectory(component->Name); - componentCode += " SetOutPath \"" + componentOutputDir + "\"\n"; + componentCode += cmStrCat(" SetOutPath \"", componentOutputDir, "\"\n"); // Create the actual installation commands if (component->IsDownloaded) { @@ -921,12 +921,11 @@ std::string cmCPackNSISGenerator::CreateComponentGroupDescription( } std::string cmCPackNSISGenerator::CustomComponentInstallDirectory( - const std::string& componentName) + cm::string_view componentName) { - const char* outputDir = - this->GetOption("CPACK_NSIS_" + componentName + "_INSTALL_DIRECTORY"); - const std::string componentOutputDir = (outputDir ? outputDir : "$INSTDIR"); - return componentOutputDir; + const char* outputDir = this->GetOption( + cmStrCat("CPACK_NSIS_", componentName, "_INSTALL_DIRECTORY")); + return outputDir ? outputDir : "$INSTDIR"; } std::string cmCPackNSISGenerator::TranslateNewlines(std::string str) diff --git a/Source/CPack/cmCPackNSISGenerator.h b/Source/CPack/cmCPackNSISGenerator.h index 0af37af..88cba45 100644 --- a/Source/CPack/cmCPackNSISGenerator.h +++ b/Source/CPack/cmCPackNSISGenerator.h @@ -10,6 +10,8 @@ #include <string> #include <vector> +#include <cm/string_view> + #include "cmCPackGenerator.h" class cmCPackComponent; @@ -75,8 +77,7 @@ protected: /// Returns the custom install directory if available for the specified /// component, otherwise $INSTDIR is returned. - std::string CustomComponentInstallDirectory( - const std::string& componentName); + std::string CustomComponentInstallDirectory(cm::string_view componentName); /// Translations any newlines found in the string into \\r\\n, so that the /// resulting string can be used within NSIS. diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx index 35eabaf..83d6306 100644 --- a/Source/cmAddSubDirectoryCommand.cxx +++ b/Source/cmAddSubDirectoryCommand.cxx @@ -4,6 +4,8 @@ #include <cstring> +#include <cm/string_view> + #include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmRange.h" @@ -86,7 +88,8 @@ bool cmAddSubDirectoryCommand(std::vector<std::string> const& args, if (binLen > 0 && bin.back() == '/') { --binLen; } - binPath = bin.substr(0, binLen) + srcPath.substr(srcLen); + binPath = cmStrCat(cm::string_view(bin).substr(0, binLen), + cm::string_view(srcPath).substr(srcLen)); } else { // Use the binary directory specified. // Interpret a relative path with respect to the current binary directory. diff --git a/Source/cmBinUtilsLinuxELFLinker.cxx b/Source/cmBinUtilsLinuxELFLinker.cxx index 0dea825..9ce403d 100644 --- a/Source/cmBinUtilsLinuxELFLinker.cxx +++ b/Source/cmBinUtilsLinuxELFLinker.cxx @@ -6,6 +6,7 @@ #include <sstream> #include <cm/memory> +#include <cm/string_view> #include <cmsys/RegularExpression.hxx> @@ -26,14 +27,16 @@ static std::string ReplaceOrigin(const std::string& rpath, cmsys::RegularExpressionMatch match; if (originRegex.find(rpath.c_str(), match)) { - std::string begin = rpath.substr(0, match.start(1)); - std::string end = rpath.substr(match.end(1)); - return begin + origin + end; + cm::string_view pathv(rpath); + auto begin = pathv.substr(0, match.start(1)); + auto end = pathv.substr(match.end(1)); + return cmStrCat(begin, origin, end); } if (originCurlyRegex.find(rpath.c_str(), match)) { - std::string begin = rpath.substr(0, match.start()); - std::string end = rpath.substr(match.end()); - return begin + origin + end; + cm::string_view pathv(rpath); + auto begin = pathv.substr(0, match.start()); + auto end = pathv.substr(match.end()); + return cmStrCat(begin, origin, end); } return rpath; } diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 72ec1b5..01c5131 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -17,6 +17,7 @@ #include <vector> #include <cm/memory> +#include <cm/string_view> #include <cmext/algorithm> #include "cmsys/Base64.h" @@ -2046,13 +2047,15 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, return true; } - const std::string noTestsPrefix = "--no-tests="; + cm::string_view noTestsPrefix = "--no-tests="; if (cmHasPrefix(arg, noTestsPrefix)) { - const std::string noTestsMode = arg.substr(noTestsPrefix.length()); + cm::string_view noTestsMode = + cm::string_view(arg).substr(noTestsPrefix.length()); if (noTestsMode == "error") { this->Impl->NoTestsMode = cmCTest::NoTests::Error; } else if (noTestsMode != "ignore") { - errormsg = "'--no-tests=' given unknown value '" + noTestsMode + "'"; + errormsg = + cmStrCat("'--no-tests=' given unknown value '", noTestsMode, '\''); return false; } else { this->Impl->NoTestsMode = cmCTest::NoTests::Ignore; |