summaryrefslogtreecommitdiffstats
path: root/Source/CPack/WiX
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2023-07-27 16:23:22 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2023-07-27 23:10:39 (GMT)
commit3f1378fbcab72a849908bbc988254f392d04c41a (patch)
tree0dcf9d2e38272b101fa4bfb12133a22c9fb2def7 /Source/CPack/WiX
parent7e3b9af191b1ae596b228d8ac3d709eecf8d82d4 (diff)
downloadCMake-3f1378fbcab72a849908bbc988254f392d04c41a.zip
CMake-3f1378fbcab72a849908bbc988254f392d04c41a.tar.gz
CMake-3f1378fbcab72a849908bbc988254f392d04c41a.tar.bz2
strings: compare to static `string_view` instances in Windows-only code
Diffstat (limited to 'Source/CPack/WiX')
-rw-r--r--Source/CPack/WiX/cmCPackWIXGenerator.cxx17
-rw-r--r--Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx4
-rw-r--r--Source/CPack/WiX/cmWIXPatchParser.cxx11
3 files changed, 18 insertions, 14 deletions
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
index 1ea78fd..2330935 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
@@ -7,6 +7,7 @@
#include <cm/memory>
#include <cm/string_view>
#include <cmext/algorithm>
+#include <cmext/string_view>
#include "cmsys/Directory.hxx"
#include "cmsys/Encoding.hxx"
@@ -556,7 +557,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
bool emitUninstallShortcut = true;
cmValue cpackWixProgramMenuFolder =
GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER");
- if (cpackWixProgramMenuFolder && cpackWixProgramMenuFolder == ".") {
+ if (cpackWixProgramMenuFolder && cpackWixProgramMenuFolder == "."_s) {
emitUninstallShortcut = false;
} else if (emittedShortcutTypes.find(cmWIXShortcuts::START_MENU) ==
emittedShortcutTypes.end()) {
@@ -613,7 +614,7 @@ std::string cmCPackWIXGenerator::GetRootFolderId() const
result = *rootFolderId;
}
- if (GetArchitecture() == "x86") {
+ if (GetArchitecture() == "x86"_s) {
cmSystemTools::ReplaceString(result, "<64>", "");
} else {
cmSystemTools::ReplaceString(result, "<64>", "64");
@@ -757,7 +758,7 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType(
case cmWIXShortcuts::START_MENU: {
cmValue cpackWixProgramMenuFolder =
GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER");
- if (cpackWixProgramMenuFolder && cpackWixProgramMenuFolder == ".") {
+ if (cpackWixProgramMenuFolder && cpackWixProgramMenuFolder == "."_s) {
directoryId = "ProgramMenuFolder";
} else {
directoryId = "PROGRAM_MENU_FOLDER";
@@ -818,7 +819,7 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType(
if (type == cmWIXShortcuts::START_MENU) {
cmValue cpackWixProgramMenuFolder =
GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER");
- if (cpackWixProgramMenuFolder && cpackWixProgramMenuFolder != ".") {
+ if (cpackWixProgramMenuFolder && cpackWixProgramMenuFolder != "."_s) {
fileDefinitions.EmitRemoveFolder("CM_REMOVE_PROGRAM_MENU_FOLDER" +
idSuffix);
}
@@ -851,10 +852,10 @@ bool cmCPackWIXGenerator::CreateLicenseFile()
std::string extension = GetRightmostExtension(licenseSourceFilename);
- if (extension == ".rtf") {
+ if (extension == ".rtf"_s) {
cmSystemTools::CopyAFile(licenseSourceFilename.c_str(),
licenseDestinationFilename.c_str());
- } else if (extension == ".txt") {
+ } else if (extension == ".txt"_s) {
cmWIXRichTextFormatWriter rtfWriter(licenseDestinationFilename);
cmsys::ifstream licenseSource(licenseSourceFilename.c_str());
@@ -923,7 +924,7 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitions(
for (size_t i = 0; i < dir.GetNumberOfFiles(); ++i) {
std::string fileName = dir.GetFile(static_cast<unsigned long>(i));
- if (fileName == "." || fileName == "..") {
+ if (fileName == "."_s || fileName == ".."_s) {
continue;
}
@@ -1001,7 +1002,7 @@ std::string cmCPackWIXGenerator::GetArchitecture() const
std::string void_p_size;
RequireOption("CPACK_WIX_SIZEOF_VOID_P", void_p_size);
- if (void_p_size == "8") {
+ if (void_p_size == "8"_s) {
return "x64";
} else {
return "x86";
diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
index 0a83ca2..13bbf37 100644
--- a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
@@ -2,6 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmWIXDirectoriesSourceWriter.h"
+#include <cmext/string_view>
+
cmWIXDirectoriesSourceWriter::cmWIXDirectoriesSourceWriter(
cmCPackLog* logger, std::string const& filename, GuidType componentGuidType)
: cmWIXSourceWriter(logger, filename, componentGuidType)
@@ -14,7 +16,7 @@ void cmWIXDirectoriesSourceWriter::EmitStartMenuFolder(
BeginElement("Directory");
AddAttribute("Id", "ProgramMenuFolder");
- if (startMenuFolder != ".") {
+ if (startMenuFolder != "."_s) {
BeginElement("Directory");
AddAttribute("Id", "PROGRAM_MENU_FOLDER");
AddAttribute("Name", startMenuFolder);
diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx
index 8b26c4e..57539d3 100644
--- a/Source/CPack/WiX/cmWIXPatchParser.cxx
+++ b/Source/CPack/WiX/cmWIXPatchParser.cxx
@@ -5,6 +5,7 @@
#include <utility>
#include <cm/memory>
+#include <cmext/string_view>
#include <cm3p/expat.h>
@@ -39,13 +40,13 @@ cmWIXPatchParser::cmWIXPatchParser(fragment_map_t& fragments,
void cmWIXPatchParser::StartElement(const std::string& name, const char** atts)
{
if (State == BEGIN_DOCUMENT) {
- if (name == "CPackWiXPatch") {
+ if (name == "CPackWiXPatch"_s) {
State = BEGIN_FRAGMENTS;
} else {
ReportValidationError("Expected root element 'CPackWiXPatch'");
}
} else if (State == BEGIN_FRAGMENTS) {
- if (name == "CPackWiXFragment") {
+ if (name == "CPackWiXFragment"_s) {
State = INSIDE_FRAGMENT;
StartFragment(atts);
} else {
@@ -78,7 +79,7 @@ void cmWIXPatchParser::StartFragment(const char** attributes)
const std::string key = attributes[i];
const std::string value = attributes[i + 1];
- if (key == "Id") {
+ if (key == "Id"_s) {
if (Fragments.find(value) != Fragments.end()) {
std::ostringstream tmp;
tmp << "Invalid reuse of 'CPackWixFragment' 'Id': " << value;
@@ -98,7 +99,7 @@ void cmWIXPatchParser::StartFragment(const char** attributes)
const std::string key = attributes[i];
const std::string value = attributes[i + 1];
- if (key != "Id") {
+ if (key != "Id"_s) {
new_element->attributes[key] = value;
}
}
@@ -108,7 +109,7 @@ void cmWIXPatchParser::StartFragment(const char** attributes)
void cmWIXPatchParser::EndElement(const std::string& name)
{
if (State == INSIDE_FRAGMENT) {
- if (name == "CPackWiXFragment") {
+ if (name == "CPackWiXFragment"_s) {
State = BEGIN_FRAGMENTS;
ElementStack.clear();
} else {