summaryrefslogtreecommitdiffstats
path: root/Source/CPack/WiX
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-03-26 13:15:02 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-03-26 13:15:41 (GMT)
commit577fc3ef1942fd11791a4b6cd557b6da32daa5d6 (patch)
tree4ebc154a8be482113f395343df34adb208a238b1 /Source/CPack/WiX
parent607e790f4b627637a1884af4fc150afa0675c152 (diff)
parentec7928ef266599f1de08b30da84a42d7da3fd6a0 (diff)
downloadCMake-577fc3ef1942fd11791a4b6cd557b6da32daa5d6.zip
CMake-577fc3ef1942fd11791a4b6cd557b6da32daa5d6.tar.gz
CMake-577fc3ef1942fd11791a4b6cd557b6da32daa5d6.tar.bz2
Merge topic 'string-prefix'
ec7928ef26 use _s to construct static string_views at several places 94de927cab VS10Generator: avoid many string allocations 8ca2504a4d use string_views to avoid memory allocations 761f1adcae check for a valid URL scheme before starting to do any splitting ef778d77e0 replace std::string::substr() with operations that do not allocate memory 77616f4681 pass cm::string_view to cmVisualStudioSlnParser::ParseTag() ada6a3226f use cm::string_view for language extension lookups 48adc29721 replace "std::string::find(x) == 0" with cmHasPrefix() ... Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4501
Diffstat (limited to 'Source/CPack/WiX')
-rw-r--r--Source/CPack/WiX/cmCPackWIXGenerator.cxx15
-rw-r--r--Source/CPack/WiX/cmWIXAccessControlList.cxx15
2 files changed, 16 insertions, 14 deletions
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
index 67d3d32..e481d13 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
@@ -98,7 +98,7 @@ bool cmCPackWIXGenerator::RunCandleCommand(std::string const& sourceFile,
command << " -ext " << QuotePath(ext);
}
- if (sourceFile.rfind(this->CPackTopLevel, 0) != 0) {
+ if (!cmHasSuffix(sourceFile, this->CPackTopLevel)) {
command << " " << QuotePath("-I" + this->CPackTopLevel);
}
@@ -350,8 +350,7 @@ void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile()
std::vector<std::string> options = GetOptions();
for (std::string const& name : options) {
- if (name.length() > prefix.length() &&
- name.substr(0, prefix.length()) == prefix) {
+ if (cmHasPrefix(name, prefix)) {
std::string id = name.substr(prefix.length());
std::string value = GetOption(name.c_str());
@@ -1099,14 +1098,14 @@ std::string cmCPackWIXGenerator::CreateHashedId(
cmCryptoHash sha1(cmCryptoHash::AlgoSHA1);
std::string const hash = sha1.HashString(path);
- std::string identifier = cmStrCat(cm::string_view(hash).substr(0, 7), '_');
-
const size_t maxFileNameLength = 52;
+ std::string identifier =
+ cmStrCat(cm::string_view(hash).substr(0, 7), '_',
+ cm::string_view(normalizedFilename).substr(0, maxFileNameLength));
+
+ // if the name was truncated
if (normalizedFilename.length() > maxFileNameLength) {
- identifier += normalizedFilename.substr(0, maxFileNameLength - 3);
identifier += "...";
- } else {
- identifier += normalizedFilename;
}
return identifier;
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));