Browse Source

strings: use character literals where possible

Ben Boeckel 2 years ago
parent
commit
809248a0c9

+ 15 - 15
Source/CPack/WiX/cmCPackWIXGenerator.cxx

@@ -113,12 +113,12 @@ bool cmCPackWIXGenerator::RunCandleCommand(std::string const& sourceFile,
   }
 
   if (!cmHasSuffix(sourceFile, this->CPackTopLevel)) {
-    command << " " << QuotePath(cmStrCat("-I", this->CPackTopLevel));
+    command << ' ' << QuotePath(cmStrCat("-I", this->CPackTopLevel));
   }
 
   AddCustomFlags("CPACK_WIX_CANDLE_EXTRA_FLAGS", command);
 
-  command << " " << QuotePath(sourceFile);
+  command << ' ' << QuotePath(sourceFile);
 
   return RunWiXCommand(command.str());
 }
@@ -147,7 +147,7 @@ bool cmCPackWIXGenerator::RunLightCommand(std::string const& objectFiles)
 
   AddCustomFlags("CPACK_WIX_LIGHT_EXTRA_FLAGS", command);
 
-  command << " " << objectFiles;
+  command << ' ' << objectFiles;
 
   return RunWiXCommand(command.str());
 }
@@ -296,14 +296,14 @@ bool cmCPackWIXGenerator::PackageFilesImpl()
     usedBaseNames.insert(uniqueBaseName);
 
     std::string objectFilename =
-      cmStrCat(this->CPackTopLevel, "/", uniqueBaseName, ".wixobj");
+      cmStrCat(this->CPackTopLevel, '/', uniqueBaseName, ".wixobj");
 
     if (!RunCandleCommand(CMakeToWixPath(sourceFilename),
                           CMakeToWixPath(objectFilename))) {
       return false;
     }
 
-    objectFiles << " " << QuotePath(CMakeToWixPath(objectFilename));
+    objectFiles << ' ' << QuotePath(CMakeToWixPath(objectFilename));
   }
 
   AppendUserSuppliedExtraObjects(objectFiles);
@@ -795,13 +795,13 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType(
 
   std::string idSuffix;
   if (!cpackComponentName.empty()) {
-    idSuffix += "_";
+    idSuffix += '_';
     idSuffix += cpackComponentName;
   }
 
   std::string componentId = "CM_SHORTCUT";
   if (idPrefix.size()) {
-    componentId += cmStrCat("_", idPrefix);
+    componentId += cmStrCat('_', idPrefix);
   }
 
   componentId += idSuffix;
@@ -817,7 +817,7 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType(
   this->Patch->ApplyFragment(componentId, fileDefinitions);
 
   std::string registryKey =
-    cmStrCat("Software\\", cpackVendor, "\\", cpackPackageName);
+    cmStrCat("Software\\", cpackVendor, '\\', cpackPackageName);
 
   shortcuts.EmitShortcuts(type, registryKey, cpackComponentName,
                           fileDefinitions);
@@ -934,7 +934,7 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitions(
       continue;
     }
 
-    std::string fullPath = cmStrCat(topdir, "/", fileName);
+    std::string fullPath = cmStrCat(topdir, '/', fileName);
 
     std::string relativePath =
       cmSystemTools::RelativePath(toplevel.c_str(), fullPath.c_str());
@@ -1041,7 +1041,7 @@ std::string cmCPackWIXGenerator::GenerateGUID()
 
 std::string cmCPackWIXGenerator::QuotePath(std::string const& path)
 {
-  return cmStrCat("\"", path, '"');
+  return cmStrCat('"', path, '"');
 }
 
 std::string cmCPackWIXGenerator::GetRightmostExtension(
@@ -1095,18 +1095,18 @@ std::string cmCPackWIXGenerator::CreateNewIdForPath(std::string const& path)
   }
 
   std::ostringstream result;
-  result << idPrefix << "_" << identifier;
+  result << idPrefix << '_' << identifier;
 
   size_t ambiguityCount = ++IdAmbiguityCounter[identifier];
 
   if (ambiguityCount > 999) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
                   "Error while trying to generate a unique Id for '"
-                    << path << "'" << std::endl);
+                    << path << '\'' << std::endl);
 
     return std::string();
   } else if (ambiguityCount > 1) {
-    result << "_" << ambiguityCount;
+    result << '_' << ambiguityCount;
   }
 
   std::string resultString = result.str();
@@ -1190,7 +1190,7 @@ void cmCPackWIXGenerator::CollectXmlNamespaces(std::string const& variableName,
       cmCPackLogger(cmCPackLog::LOG_ERROR,
                     "Invalid element in CPACK_WIX_CUSTOM_XMLNS ignored: "
                     "\""
-                      << str << "\"" << std::endl);
+                      << str << '"' << std::endl);
     }
   }
   std::ostringstream oss;
@@ -1211,7 +1211,7 @@ void cmCPackWIXGenerator::AddCustomFlags(std::string const& variableName,
   cmList list{ variableContent };
 
   for (std::string const& i : list) {
-    stream << " " << QuotePath(i);
+    stream << ' ' << QuotePath(i);
   }
 }
 

+ 1 - 1
Source/CPack/WiX/cmWIXAccessControlList.cxx

@@ -119,7 +119,7 @@ void cmWIXAccessControlList::EmitBooleanAttribute(std::string const& entry,
 {
   if (!this->IsBooleanAttribute(name)) {
     this->ReportError(entry,
-                      cmStrCat("Unknown boolean attribute '", name, "'"));
+                      cmStrCat("Unknown boolean attribute '", name, '\''));
   }
 
   this->SourceWriter.AddAttribute(name, "yes");

+ 3 - 3
Source/CPack/WiX/cmWIXPatch.cxx

@@ -14,7 +14,7 @@ bool cmWIXPatch::LoadFragments(std::string const& patchFilePath)
   cmWIXPatchParser parser(Fragments, Logger);
   if (!parser.ParseFile(patchFilePath.c_str())) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
-                  "Failed parsing XML patch file: '" << patchFilePath << "'"
+                  "Failed parsing XML patch file: '" << patchFilePath << '\''
                                                      << std::endl);
     return false;
   }
@@ -75,9 +75,9 @@ bool cmWIXPatch::CheckForUnappliedFragments()
       fragmentList += ", ";
     }
 
-    fragmentList += "'";
+    fragmentList += '\'';
     fragmentList += fragment.first;
-    fragmentList += "'";
+    fragmentList += '\'';
   }
 
   if (!fragmentList.empty()) {

+ 1 - 1
Source/CPack/WiX/cmWIXPatchParser.cxx

@@ -143,7 +143,7 @@ void cmWIXPatchParser::ReportError(int line, int column, const char* msg)
 {
   cmCPackLogger(cmCPackLog::LOG_ERROR,
                 "Error while processing XML patch file at "
-                  << line << ":" << column << ":  " << msg << std::endl);
+                  << line << ':' << column << ":  " << msg << std::endl);
   Valid = false;
 }
 

+ 3 - 3
Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx

@@ -135,7 +135,7 @@ void cmWIXRichTextFormatWriter::WriteDocumentPrefix()
 
 void cmWIXRichTextFormatWriter::ControlWord(std::string const& keyword)
 {
-  File << "\\" << keyword;
+  File << '\\' << keyword;
 }
 
 void cmWIXRichTextFormatWriter::NewControlWord(std::string const& keyword)
@@ -175,12 +175,12 @@ void cmWIXRichTextFormatWriter::EmitUnicodeSurrogate(int c)
   } else {
     File << (c - 65536);
   }
-  File << "?";
+  File << '?';
 }
 
 void cmWIXRichTextFormatWriter::EmitInvalidCodepoint(int c)
 {
   ControlWord("cf1 ");
-  File << "[INVALID-BYTE-" << int(c) << "]";
+  File << "[INVALID-BYTE-" << int(c) << ']';
   ControlWord("cf0 ");
 }

+ 14 - 14
Source/CPack/WiX/cmWIXSourceWriter.cxx

@@ -34,7 +34,7 @@ cmWIXSourceWriter::~cmWIXSourceWriter()
     cmCPackLogger(cmCPackLog::LOG_ERROR,
                   Elements.size() - 1
                     << " WiX elements were still open when closing '"
-                    << SourceFilename << "'" << std::endl);
+                    << SourceFilename << '\'' << std::endl);
     return;
   }
 
@@ -44,12 +44,12 @@ cmWIXSourceWriter::~cmWIXSourceWriter()
 void cmWIXSourceWriter::BeginElement(std::string const& name)
 {
   if (State == BEGIN) {
-    File << ">";
+    File << '>';
   }
 
-  File << "\n";
+  File << '\n';
   Indent(Elements.size());
-  File << "<" << name;
+  File << '<' << name;
 
   Elements.push_back(name);
   State = BEGIN;
@@ -60,7 +60,7 @@ void cmWIXSourceWriter::EndElement(std::string const& name)
   if (Elements.empty()) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
                   "can not end WiX element with no open elements in '"
-                    << SourceFilename << "'" << std::endl);
+                    << SourceFilename << '\'' << std::endl);
     return;
   }
 
@@ -68,14 +68,14 @@ void cmWIXSourceWriter::EndElement(std::string const& name)
     cmCPackLogger(cmCPackLog::LOG_ERROR,
                   "WiX element <"
                     << Elements.back() << "> can not be closed by </" << name
-                    << "> in '" << SourceFilename << "'" << std::endl);
+                    << "> in '" << SourceFilename << '\'' << std::endl);
     return;
   }
 
   if (State == DEFAULT) {
-    File << "\n";
+    File << '\n';
     Indent(Elements.size() - 1);
-    File << "</" << Elements.back() << ">";
+    File << "</" << Elements.back() << '>';
   } else {
     File << "/>";
   }
@@ -87,13 +87,13 @@ void cmWIXSourceWriter::EndElement(std::string const& name)
 void cmWIXSourceWriter::AddTextNode(std::string const& text)
 {
   if (State == BEGIN) {
-    File << ">";
+    File << '>';
   }
 
   if (Elements.empty()) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
                   "can not add text without open WiX element in '"
-                    << SourceFilename << "'" << std::endl);
+                    << SourceFilename << '\'' << std::endl);
     return;
   }
 
@@ -105,12 +105,12 @@ void cmWIXSourceWriter::AddProcessingInstruction(std::string const& target,
                                                  std::string const& content)
 {
   if (State == BEGIN) {
-    File << ">";
+    File << '>';
   }
 
-  File << "\n";
+  File << '\n';
   Indent(Elements.size());
-  File << "<?" << target << " " << content << "?>";
+  File << "<?" << target << ' ' << content << "?>";
 
   State = DEFAULT;
 }
@@ -118,7 +118,7 @@ void cmWIXSourceWriter::AddProcessingInstruction(std::string const& target,
 void cmWIXSourceWriter::AddAttribute(std::string const& key,
                                      std::string const& value)
 {
-  File << " " << key << "=\"" << EscapeAttributeValue(value) << '"';
+  File << ' ' << key << "=\"" << EscapeAttributeValue(value) << '"';
 }
 
 void cmWIXSourceWriter::AddAttributeUnlessEmpty(std::string const& key,

+ 3 - 3
Source/CPack/cmCPackCygwinBinaryGenerator.cxx

@@ -44,9 +44,9 @@ int cmCPackCygwinBinaryGenerator::PackageFiles()
     cmGeneratedFileStream ofs(manifestFile);
     for (std::string const& file : files) {
       // remove the temp dir and replace with /usr
-      ofs << file.substr(tempdir.size()) << "\n";
+      ofs << file.substr(tempdir.size()) << '\n';
     }
-    ofs << manifest << "\n";
+    ofs << manifest << '\n';
   }
   // add the manifest file to the list of all files
   files.push_back(manifestFile);
@@ -60,7 +60,7 @@ const char* cmCPackCygwinBinaryGenerator::GetOutputExtension()
   this->OutputExtension = "-";
   cmValue patchNumber = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
   if (!patchNumber) {
-    this->OutputExtension += "1";
+    this->OutputExtension += '1';
     cmCPackLogger(cmCPackLog::LOG_WARNING,
                   "CPACK_CYGWIN_PATCH_NUMBER not specified using 1"
                     << std::endl);

+ 2 - 2
Source/CPack/cmCPackCygwinSourceGenerator.cxx

@@ -98,7 +98,7 @@ int cmCPackCygwinSourceGenerator::PackageFiles()
     cmCPackLogger(cmCPackLog::LOG_WARNING,
                   "CPACK_CYGWIN_PATCH_NUMBER"
                     << " not specified, defaulting to 1\n");
-    outerTarFile += "1";
+    outerTarFile += '1';
   } else {
     outerTarFile += patch;
   }
@@ -150,7 +150,7 @@ const char* cmCPackCygwinSourceGenerator::GetOutputExtension()
     cmCPackLogger(cmCPackLog::LOG_WARNING,
                   "CPACK_CYGWIN_PATCH_NUMBER"
                     << " not specified, defaulting to 1\n");
-    this->OutputExtension += "1";
+    this->OutputExtension += '1';
   } else {
     this->OutputExtension += patch;
   }

+ 5 - 5
Source/cmGlobalVisualStudio10Generator.cxx

@@ -198,7 +198,7 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
     std::string versionToolset = this->GeneratorToolsetVersion;
     cmsys::RegularExpression regex("[0-9][0-9]\\.[0-9][0-9]");
     if (regex.find(versionToolset)) {
-      versionToolset = cmStrCat("v", versionToolset.erase(2, 1));
+      versionToolset = cmStrCat('v', versionToolset.erase(2, 1));
     } else {
       // Version not recognized. Clear it.
       versionToolset.clear();
@@ -441,7 +441,7 @@ bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf)
       mf->IssueMessage(
         MessageType::FATAL_ERROR,
         cmStrCat("CMAKE_SYSTEM_NAME is 'Android' but CMAKE_GENERATOR ",
-                 "specifies a platform too: '", this->GetName(), "'"));
+                 "specifies a platform too: '", this->GetName(), '\''));
       return false;
     }
     if (mf->GetSafeDefinition("CMAKE_GENERATOR_PLATFORM") ==
@@ -471,7 +471,7 @@ bool cmGlobalVisualStudio10Generator::InitializeWindowsCE(cmMakefile* mf)
     mf->IssueMessage(
       MessageType::FATAL_ERROR,
       cmStrCat("CMAKE_SYSTEM_NAME is 'WindowsCE' but CMAKE_GENERATOR ",
-               "specifies a platform too: '", this->GetName(), "'"));
+               "specifies a platform too: '", this->GetName(), '\''));
     return false;
   }
 
@@ -848,7 +848,7 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf)
     wd = cmStrCat(this->GetCMakeInstance()->GetHomeOutputDirectory(),
                   "/CMakeFiles");
   }
-  wd += "/";
+  wd += '/';
   wd += cmVersion::GetCMakeVersion();
 
   // We record the result persistently in a file.
@@ -875,7 +875,7 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf)
   // Generate a project file for MSBuild to tell us the VCTargetsPath value.
   std::string const vcxproj = "VCTargetsPath.vcxproj";
   {
-    std::string const vcxprojAbs = cmStrCat(wd, "/", vcxproj);
+    std::string const vcxprojAbs = cmStrCat(wd, '/', vcxproj);
     cmsys::ofstream fout(vcxprojAbs.c_str());
     cmXMLWriter xw(fout);
 

+ 3 - 3
Source/cmGlobalVisualStudio14Generator.cxx

@@ -161,11 +161,11 @@ bool cmGlobalVisualStudio14Generator::VerifyNoGeneratorPlatformVersion(
     "given platform specification containing a\n"
     "  version=" << *this->GeneratorPlatformVersion << "\n"
     "field.  The version field is not supported when targeting\n"
-    "  " << this->SystemName << " " << this->SystemVersion << "\n"
+    "  " << this->SystemName << ' ' << this->SystemVersion << '\n'
     ;
   /* clang-format on */
   if (reason) {
-    e << *reason << ".";
+    e << *reason << '.';
   }
   mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
   return false;
@@ -256,7 +256,7 @@ void cmGlobalVisualStudio14Generator::SetWindowsTargetPlatformVersion(
     mf->DisplayStatus(cmStrCat("Selecting Windows SDK version ",
                                this->WindowsTargetPlatformVersion,
                                " to target Windows ", this->SystemVersion,
-                               "."),
+                               '.'),
                       -1);
   }
   mf->AddDefinition("CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION",

+ 3 - 3
Source/cmGlobalVisualStudio71Generator.cxx

@@ -86,7 +86,7 @@ void cmGlobalVisualStudio71Generator::WriteSolutionConfigurations(
 {
   fout << "\tGlobalSection(SolutionConfiguration) = preSolution\n";
   for (std::string const& i : configs) {
-    fout << "\t\t" << i << " = " << i << "\n";
+    fout << "\t\t" << i << " = " << i << '\n';
   }
   fout << "\tEndGlobalSection\n";
 }
@@ -217,11 +217,11 @@ void cmGlobalVisualStudio71Generator::WriteProjectConfigurations(
         }
       }
     }
-    fout << "\t\t{" << guid << "}." << i << ".ActiveCfg = " << dstConfig << "|"
+    fout << "\t\t{" << guid << "}." << i << ".ActiveCfg = " << dstConfig << '|'
          << platformName << std::endl;
     auto ci = configsPartOfDefaultBuild.find(i);
     if (!(ci == configsPartOfDefaultBuild.end())) {
-      fout << "\t\t{" << guid << "}." << i << ".Build.0 = " << dstConfig << "|"
+      fout << "\t\t{" << guid << "}." << i << ".Build.0 = " << dstConfig << '|'
            << platformName << std::endl;
     }
   }

+ 4 - 4
Source/cmGlobalVisualStudio7Generator.cxx

@@ -486,9 +486,9 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
             cumulativePath = cmStrCat("CMAKE_FOLDER_GUID_", iter);
           } else {
             VisualStudioFolders[cumulativePath].insert(
-              cmStrCat(cumulativePath, "/", iter));
+              cmStrCat(cumulativePath, '/', iter));
 
-            cumulativePath = cmStrCat(cumulativePath, "/", iter);
+            cumulativePath = cmStrCat(cumulativePath, '/', iter);
           }
         }
 
@@ -581,7 +581,7 @@ void cmGlobalVisualStudio7Generator::WriteSLNGlobalSections(
                    sectionType == "postSolution"_s) {
           extensibilityAddInsOverridden = true;
         }
-        fout << "\tGlobalSection(" << name << ") = " << sectionType << "\n";
+        fout << "\tGlobalSection(" << name << ") = " << sectionType << '\n';
         cmValue p = root->GetMakefile()->GetProperty(it);
         cmList keyValuePairs{ *p };
         for (std::string const& itPair : keyValuePairs) {
@@ -591,7 +591,7 @@ void cmGlobalVisualStudio7Generator::WriteSLNGlobalSections(
               cmTrimWhitespace(itPair.substr(0, posEqual));
             const std::string value =
               cmTrimWhitespace(itPair.substr(posEqual + 1));
-            fout << "\t\t" << key << " = " << value << "\n";
+            fout << "\t\t" << key << " = " << value << '\n';
             if (key == "SolutionGuid"_s) {
               addGuid = false;
             }

+ 13 - 13
Source/cmGlobalVisualStudio8Generator.cxx

@@ -304,7 +304,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
     for (const auto& gi : generators) {
       stampFile = cmStrCat(gi->GetMakefile()->GetCurrentBinaryDirectory(),
                            "/CMakeFiles/generate.stamp");
-      fout << stampFile << "\n";
+      fout << stampFile << '\n';
       stamps.push_back(stampFile);
     }
   }
@@ -341,7 +341,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
     std::string argS = cmStrCat("-S", lg.GetSourceDirectory());
     std::string argB = cmStrCat("-B", lg.GetBinaryDirectory());
     std::string const sln =
-      cmStrCat(lg.GetBinaryDirectory(), "/", lg.GetProjectName(), ".sln");
+      cmStrCat(lg.GetBinaryDirectory(), '/', lg.GetProjectName(), ".sln");
     cmCustomCommandLines commandLines = cmMakeSingleCommandLine(
       { cmSystemTools::GetCMakeCommand(), argS, argB, "--check-stamp-list",
         stampList, "--vs-solution-file", sln });
@@ -392,8 +392,8 @@ void cmGlobalVisualStudio8Generator::WriteSolutionConfigurations(
 {
   fout << "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n";
   for (std::string const& i : configs) {
-    fout << "\t\t" << i << "|" << this->GetPlatformName() << " = " << i << "|"
-         << this->GetPlatformName() << "\n";
+    fout << "\t\t" << i << '|' << this->GetPlatformName() << " = " << i << '|'
+         << this->GetPlatformName() << '\n';
   }
   fout << "\tEndGlobalSection\n";
 }
@@ -417,25 +417,25 @@ void cmGlobalVisualStudio8Generator::WriteProjectConfigurations(
         }
       }
     }
-    fout << "\t\t{" << guid << "}." << i << "|" << this->GetPlatformName()
-         << ".ActiveCfg = " << dstConfig << "|"
+    fout << "\t\t{" << guid << "}." << i << '|' << this->GetPlatformName()
+         << ".ActiveCfg = " << dstConfig << '|'
          << (!platformMapping.empty() ? platformMapping
                                       : this->GetPlatformName())
-         << "\n";
+         << '\n';
     auto ci = configsPartOfDefaultBuild.find(i);
     if (!(ci == configsPartOfDefaultBuild.end())) {
-      fout << "\t\t{" << guid << "}." << i << "|" << this->GetPlatformName()
-           << ".Build.0 = " << dstConfig << "|"
+      fout << "\t\t{" << guid << "}." << i << '|' << this->GetPlatformName()
+           << ".Build.0 = " << dstConfig << '|'
            << (!platformMapping.empty() ? platformMapping
                                         : this->GetPlatformName())
-           << "\n";
+           << '\n';
     }
     if (this->NeedsDeploy(target, dstConfig)) {
-      fout << "\t\t{" << guid << "}." << i << "|" << this->GetPlatformName()
-           << ".Deploy.0 = " << dstConfig << "|"
+      fout << "\t\t{" << guid << "}." << i << '|' << this->GetPlatformName()
+           << ".Deploy.0 = " << dstConfig << '|'
            << (!platformMapping.empty() ? platformMapping
                                         : this->GetPlatformName())
-           << "\n";
+           << '\n';
     }
   }
 }

+ 3 - 3
Source/cmGlobalVisualStudioGenerator.cxx

@@ -243,12 +243,12 @@ void cmGlobalVisualStudioGenerator::ComputeTargetObjectDirectory(
   std::string tgtDir = gt->LocalGenerator->GetTargetDirectory(gt);
   if (!tgtDir.empty()) {
     dir += tgtDir;
-    dir += "/";
+    dir += '/';
   }
   const char* cd = this->GetCMakeCFGIntDir();
   if (cd && *cd) {
     dir += cd;
-    dir += "/";
+    dir += '/';
   }
   gt->ObjectDirectory = dir;
 }
@@ -977,7 +977,7 @@ bool cmGlobalVisualStudioGenerator::Open(const std::string& bindir,
                                          const std::string& projectName,
                                          bool dryRun)
 {
-  std::string sln = cmStrCat(bindir, "/", projectName, ".sln");
+  std::string sln = cmStrCat(bindir, '/', projectName, ".sln");
 
   if (dryRun) {
     return cmSystemTools::FileExists(sln, true);

+ 2 - 2
Source/cmGlobalVisualStudioVersionedGenerator.cxx

@@ -524,7 +524,7 @@ bool cmGlobalVisualStudioVersionedGenerator::SetGeneratorInstance(
   if (!this->GeneratorInstanceVersion.empty()) {
     std::string const majorStr = VSVersionToMajorString(this->Version);
     cmsys::RegularExpression versionRegex(
-      cmStrCat("^", majorStr, R"(\.[0-9]+\.[0-9]+\.[0-9]+$)"));
+      cmStrCat('^', majorStr, R"(\.[0-9]+\.[0-9]+\.[0-9]+$)"));
     if (!versionRegex.find(this->GeneratorInstanceVersion)) {
       mf->IssueMessage(
         MessageType::FATAL_ERROR,
@@ -538,7 +538,7 @@ bool cmGlobalVisualStudioVersionedGenerator::SetGeneratorInstance(
                  "\n"
                  "but the version field is not 4 integer components"
                  " starting in ",
-                 majorStr, "."));
+                 majorStr, '.'));
       return false;
     }
   }

+ 8 - 8
Source/cmLocalVisualStudio7Generator.cxx

@@ -961,7 +961,7 @@ std::string cmLocalVisualStudio7Generator::GetBuildTypeLinkerFlags(
 {
   std::string configTypeUpper = cmSystemTools::UpperCase(configName);
   std::string extraLinkOptionsBuildTypeDef =
-    cmStrCat(rootLinkerFlags, "_", configTypeUpper);
+    cmStrCat(rootLinkerFlags, '_', configTypeUpper);
 
   const std::string& extraLinkOptionsBuildType =
     this->Makefile->GetRequiredDefinition(extraLinkOptionsBuildTypeDef);
@@ -979,30 +979,30 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
   std::string extraLinkOptions;
   if (target->GetType() == cmStateEnums::EXECUTABLE) {
     extraLinkOptions = cmStrCat(
-      this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS"), " ",
+      this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS"), ' ',
       GetBuildTypeLinkerFlags("CMAKE_EXE_LINKER_FLAGS", configName));
   }
   if (target->GetType() == cmStateEnums::SHARED_LIBRARY) {
     extraLinkOptions = cmStrCat(
-      this->Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS"), " ",
+      this->Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS"), ' ',
       GetBuildTypeLinkerFlags("CMAKE_SHARED_LINKER_FLAGS", configName));
   }
   if (target->GetType() == cmStateEnums::MODULE_LIBRARY) {
     extraLinkOptions = cmStrCat(
-      this->Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS"), " ",
+      this->Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS"), ' ',
       GetBuildTypeLinkerFlags("CMAKE_MODULE_LINKER_FLAGS", configName));
   }
 
   cmValue targetLinkFlags = target->GetProperty("LINK_FLAGS");
   if (targetLinkFlags) {
-    extraLinkOptions += " ";
+    extraLinkOptions += ' ';
     extraLinkOptions += *targetLinkFlags;
   }
   std::string configTypeUpper = cmSystemTools::UpperCase(configName);
   std::string linkFlagsConfig = cmStrCat("LINK_FLAGS_", configTypeUpper);
   targetLinkFlags = target->GetProperty(linkFlagsConfig);
   if (targetLinkFlags) {
-    extraLinkOptions += " ";
+    extraLinkOptions += ' ';
     extraLinkOptions += *targetLinkFlags;
   }
 
@@ -1286,7 +1286,7 @@ void cmLocalVisualStudio7Generator::OutputDeploymentDebuggerTool(
 
     if (dir) {
       std::string const exe =
-        cmStrCat(*dir, "\\", target->GetFullName(config));
+        cmStrCat(*dir, '\\', target->GetFullName(config));
 
       fout << "\t\t\t<DebuggerTool\n"
               "\t\t\t\tRemoteExecutable=\""
@@ -1372,7 +1372,7 @@ void cmLocalVisualStudio7Generator::OutputLibraryDirectories(
     fout << comma
          << this->ConvertToXMLOutputPath(
               cmStrCat(dir, "/$(ConfigurationName)"))
-         << "," << this->ConvertToXMLOutputPath(dir);
+         << ',' << this->ConvertToXMLOutputPath(dir);
     comma = ",";
   }
 }

+ 45 - 44
Source/cmVisualStudio10TargetGenerator.cxx

@@ -104,7 +104,7 @@ struct cmVisualStudio10TargetGenerator::Elem
   void SetHasElements()
   {
     if (!HasElements) {
-      this->S << ">";
+      this->S << '>';
       HasElements = true;
     }
   }
@@ -116,13 +116,13 @@ struct cmVisualStudio10TargetGenerator::Elem
   }
   Elem& Attribute(const char* an, std::string av)
   {
-    this->S << " " << an << "=\"" << cmVS10EscapeAttr(std::move(av)) << "\"";
+    this->S << ' ' << an << "=\"" << cmVS10EscapeAttr(std::move(av)) << '"';
     return *this;
   }
   void Content(std::string val)
   {
     if (!this->HasContent) {
-      this->S << ">";
+      this->S << '>';
       this->HasContent = true;
     }
     this->S << cmVS10EscapeXML(std::move(val));
@@ -135,9 +135,9 @@ struct cmVisualStudio10TargetGenerator::Elem
     }
 
     if (HasElements) {
-      this->WriteString("</") << this->Tag << ">";
+      this->WriteString("</") << this->Tag << '>';
     } else if (HasContent) {
-      this->S << "</" << this->Tag << ">";
+      this->S << "</" << this->Tag << '>';
     } else {
       this->S << " />";
     }
@@ -291,7 +291,7 @@ cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator(
   this->TargetCompileAsWinRT = false;
   this->IsMissingFiles = false;
   this->DefaultArtifactDir =
-    cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), "/",
+    cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), '/',
              this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget));
   this->InSourceBuild = (this->Makefile->GetCurrentSourceDirectory() ==
                          this->Makefile->GetCurrentBinaryDirectory());
@@ -304,8 +304,8 @@ std::string cmVisualStudio10TargetGenerator::CalcCondition(
   const std::string& config) const
 {
   std::ostringstream oss;
-  oss << "'$(Configuration)|$(Platform)'=='" << config << "|" << this->Platform
-      << "'";
+  oss << "'$(Configuration)|$(Platform)'=='" << config << '|' << this->Platform
+      << '\'';
   // handle special case for 32 bit C# targets
   if (this->ProjectType == VsProjectType::csproj &&
       this->Platform == "Win32"_s) {
@@ -870,7 +870,8 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile(
     if (this->ProjectType == VsProjectType::csproj) {
       for (std::string const& c : this->Configurations) {
         Elem e1(e0, "PropertyGroup");
-        e1.Attribute("Condition", cmStrCat("'$(Configuration)' == '", c, "'"));
+        e1.Attribute("Condition",
+                     cmStrCat("'$(Configuration)' == '", c, '\''));
         e1.SetHasElements();
         this->WriteEvents(e1, c);
       }
@@ -991,12 +992,12 @@ void cmVisualStudio10TargetGenerator::WriteSdkStyleProjectFile(
   for (const std::string& config : this->Configurations) {
     Elem e1(e0, "PropertyGroup");
     e1.Attribute("Condition",
-                 cmStrCat("'$(Configuration)' == '", config, "'"));
+                 cmStrCat("'$(Configuration)' == '", config, '\''));
     e1.SetHasElements();
     this->WriteEvents(e1, config);
 
     std::string outDir =
-      cmStrCat(this->GeneratorTarget->GetDirectory(config), "/");
+      cmStrCat(this->GeneratorTarget->GetDirectory(config), '/');
     ConvertToWindowsSlash(outDir);
     e1.Element("OutputPath", outDir);
 
@@ -1017,7 +1018,7 @@ void cmVisualStudio10TargetGenerator::WriteSdkStyleProjectFile(
 void cmVisualStudio10TargetGenerator::WriteCommonPropertyGroupGlobals(Elem& e1)
 {
   e1.Attribute("Label", "Globals");
-  e1.Element("ProjectGuid", cmStrCat("{", this->GUID, "}"));
+  e1.Element("ProjectGuid", cmStrCat('{', this->GUID, '}'));
 
   cmValue vsProjectTypes =
     this->GeneratorTarget->GetProperty("VS_GLOBAL_PROJECT_TYPES");
@@ -1114,7 +1115,7 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences(Elem& e0)
       std::string path = i.second;
       if (!cmsys::SystemTools::FileIsFullPath(path)) {
         path =
-          cmStrCat(this->Makefile->GetCurrentSourceDirectory(), "/", path);
+          cmStrCat(this->Makefile->GetCurrentSourceDirectory(), '/', path);
       }
       ConvertToWindowsSlash(path);
       this->DotNetHintReferences[""].emplace_back(
@@ -1184,7 +1185,7 @@ void cmVisualStudio10TargetGenerator::WriteImports(Elem& e0)
     for (auto& path : argsSplit) {
       if (!cmsys::SystemTools::FileIsFullPath(path)) {
         path =
-          cmStrCat(this->Makefile->GetCurrentSourceDirectory(), "/", path);
+          cmStrCat(this->Makefile->GetCurrentSourceDirectory(), '/', path);
       }
       ConvertToWindowsSlash(path);
       Elem e1(e0, "Import");
@@ -1280,7 +1281,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup(Elem& e0)
         }
         // Determine if this is a generated resource from a .Designer.cs file
         std::string designerResource = cmStrCat(
-          cmSystemTools::GetFilenamePath(oi->GetFullPath()), "/",
+          cmSystemTools::GetFilenamePath(oi->GetFullPath()), '/',
           cmSystemTools::GetFilenameWithoutLastExtension(oi->GetFullPath()),
           ".Designer.cs");
         if (cmsys::SystemTools::FileExists(designerResource)) {
@@ -1368,9 +1369,9 @@ void cmVisualStudio10TargetGenerator::WriteTargetsFileReferences(Elem& e1)
         if (j > 0) {
           oss << " Or ";
         }
-        oss << "'$(Configuration)'=='" << tac.Configs[j] << "'";
+        oss << "'$(Configuration)'=='" << tac.Configs[j] << '\'';
       }
-      oss << ")";
+      oss << ')';
     }
 
     Elem(e1, "Import")
@@ -1410,7 +1411,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurations(Elem& e0)
   e1.Attribute("Label", "ProjectConfigurations");
   for (std::string const& c : this->Configurations) {
     Elem e2(e1, "ProjectConfiguration");
-    e2.Attribute("Include", cmStrCat(c, "|", this->Platform));
+    e2.Attribute("Include", cmStrCat(c, '|', this->Platform));
     e2.Element("Configuration", c);
     e2.Element("Platform", this->Platform);
   }
@@ -1587,7 +1588,7 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged(
   }
 
   std::string outDir =
-    cmStrCat(this->GeneratorTarget->GetDirectory(config), "/");
+    cmStrCat(this->GeneratorTarget->GetDirectory(config), '/');
   ConvertToWindowsSlash(outDir);
   e1.Element("OutputPath", outDir);
 
@@ -1822,7 +1823,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule(
     }
     script += lg->FinishConstructScript(this->ProjectType);
     if (this->ProjectType == VsProjectType::csproj) {
-      std::string name = cmStrCat("CustomCommand_", c, "_",
+      std::string name = cmStrCat("CustomCommand_", c, '_',
                                   cmSystemTools::ComputeStringMD5(sourcePath));
       this->WriteCustomRuleCSharp(e0, c, name, script, additional_inputs.str(),
                                   outputs.str(), comment, ccg);
@@ -2029,7 +2030,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
           std::string guid = this->GlobalGenerator->GetGUID(guidName);
           Elem e2(e1, "Filter");
           e2.Attribute("Include", name);
-          e2.Element("UniqueIdentifier", cmStrCat("{", guid, "}"));
+          e2.Element("UniqueIdentifier", cmStrCat('{', guid, '}'));
         }
       }
 
@@ -2038,7 +2039,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
         std::string guid = this->GlobalGenerator->GetGUID(guidName);
         Elem e2(e1, "Filter");
         e2.Attribute("Include", "Resource Files");
-        e2.Element("UniqueIdentifier", cmStrCat("{", guid, "}"));
+        e2.Element("UniqueIdentifier", cmStrCat('{', guid, '}'));
         e2.Element("Extensions",
                    "rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;"
                    "gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms");
@@ -2052,7 +2053,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
           std::string guid = this->GlobalGenerator->GetGUID(guidName);
           Elem e2(e1, "Filter");
           e2.Attribute("Include", filter);
-          e2.Element("UniqueIdentifier", cmStrCat("{", guid, "}"));
+          e2.Element("UniqueIdentifier", cmStrCat('{', guid, '}'));
         }
       }
     }
@@ -2426,14 +2427,14 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(
         if (cge->Evaluate(this->LocalGenerator, config) == "1"_s) {
           e2.WritePlatformConfigTag(
             "DeploymentContent",
-            cmStrCat("'$(Configuration)|$(Platform)'=='", config, "|",
-                     this->Platform, "'"),
+            cmStrCat("'$(Configuration)|$(Platform)'=='", config, '|',
+                     this->Platform, '\''),
             "true");
         } else {
           e2.WritePlatformConfigTag(
             "ExcludedFromBuild",
-            cmStrCat("'$(Configuration)|$(Platform)'=='", config, "|",
-                     this->Platform, "'"),
+            cmStrCat("'$(Configuration)|$(Platform)'=='", config, '|',
+                     this->Platform, '\''),
             "true");
         }
       }
@@ -2616,7 +2617,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0)
             conditions << " Or ";
           }
           conditions << "('$(Configuration)|$(Platform)'=='"
-                     << this->Configurations[ci] << "|" << this->Platform
+                     << this->Configurations[ci] << '|' << this->Platform
                      << "')";
           firstConditionSet = true;
         }
@@ -2698,8 +2699,8 @@ void cmVisualStudio10TargetGenerator::FinishWritingSource(
       } else {
         e2.WritePlatformConfigTag(setting.first,
                                   cmStrCat("'$(Configuration)|$(Platform)'=='",
-                                           configSettings.first, "|",
-                                           this->Platform, "'"),
+                                           configSettings.first, '|',
+                                           this->Platform, '\''),
                                   setting.second);
       }
     }
@@ -2793,7 +2794,7 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
     std::string defPropName = cmStrCat("COMPILE_DEFINITIONS_", configUpper);
     if (cmValue ccdefs = sf.GetProperty(defPropName)) {
       if (!configDefines.empty()) {
-        configDefines += ";";
+        configDefines += ';';
       }
       configDependentDefines |=
         cmGeneratorExpression::Find(*ccdefs) != std::string::npos;
@@ -2997,8 +2998,8 @@ void cmVisualStudio10TargetGenerator::WriteExcludeFromBuild(
   for (size_t ci : exclude_configs) {
     e2.WritePlatformConfigTag("ExcludedFromBuild",
                               cmStrCat("'$(Configuration)|$(Platform)'=='",
-                                       this->Configurations[ci], "|",
-                                       this->Platform, "'"),
+                                       this->Configurations[ci], '|',
+                                       this->Platform, '\''),
                               "true");
   }
 }
@@ -3032,7 +3033,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions(
         outDir = intermediateDir;
         targetNameFull = cmStrCat(this->GeneratorTarget->GetName(), ".lib");
       } else {
-        outDir = cmStrCat(this->GeneratorTarget->GetDirectory(config), "/");
+        outDir = cmStrCat(this->GeneratorTarget->GetDirectory(config), '/');
         targetNameFull = this->GeneratorTarget->GetFullName(config);
       }
       ConvertToWindowsSlash(intermediateDir);
@@ -3360,7 +3361,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
           this->GeneratorTarget->GetProperty("COMMON_LANGUAGE_RUNTIME")) {
       std::string clrString = *clr;
       if (!clrString.empty()) {
-        clrString = cmStrCat(":", clrString);
+        clrString = cmStrCat(':', clrString);
       }
       flags += cmStrCat(" /clr", clrString);
     }
@@ -3611,7 +3612,7 @@ bool cmVisualStudio10TargetGenerator::ComputeRcOptions(
   std::string CONFIG = cmSystemTools::UpperCase(configName);
   std::string rcConfigFlagsVar = cmStrCat("CMAKE_RC_FLAGS_", CONFIG);
   std::string flags =
-    cmStrCat(this->Makefile->GetSafeDefinition("CMAKE_RC_FLAGS"), " ",
+    cmStrCat(this->Makefile->GetSafeDefinition("CMAKE_RC_FLAGS"), ' ',
              this->Makefile->GetSafeDefinition(rcConfigFlagsVar));
 
   rcOptions.Parse(flags);
@@ -4304,19 +4305,19 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
   }
   std::string flags;
   std::string linkFlagVarBase = cmStrCat("CMAKE_", linkType, "_LINKER_FLAGS");
-  flags += " ";
+  flags += ' ';
   flags += this->Makefile->GetRequiredDefinition(linkFlagVarBase);
-  std::string linkFlagVar = cmStrCat(linkFlagVarBase, "_", CONFIG);
-  flags += " ";
+  std::string linkFlagVar = cmStrCat(linkFlagVarBase, '_', CONFIG);
+  flags += ' ';
   flags += this->Makefile->GetRequiredDefinition(linkFlagVar);
   cmValue targetLinkFlags = this->GeneratorTarget->GetProperty("LINK_FLAGS");
   if (targetLinkFlags) {
-    flags += " ";
+    flags += ' ';
     flags += *targetLinkFlags;
   }
   std::string flagsProp = cmStrCat("LINK_FLAGS_", CONFIG);
   if (cmValue flagsConfig = this->GeneratorTarget->GetProperty(flagsProp)) {
-    flags += " ";
+    flags += ' ';
     flags += *flagsConfig;
   }
 
@@ -4812,7 +4813,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0)
     Elem e2(e1, "ProjectReference");
     e2.Attribute("Include", path);
     e2.Element("Project",
-               cmStrCat("{", this->GlobalGenerator->GetGUID(name), "}"));
+               cmStrCat('{', this->GlobalGenerator->GetGUID(name), '}'));
     e2.Element("Name", name);
     this->WriteDotNetReferenceCustomTags(e2, name);
     if (dt->IsCSharpOnly() || cmHasLiteralSuffix(path, "csproj")) {
@@ -4940,7 +4941,7 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile(
         this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
       ConvertToWindowsSlash(artifactDir);
       Elem e1(e0, "PropertyGroup");
-      e1.Element("AppxPackageArtifactsDir", cmStrCat(artifactDir, "\\"));
+      e1.Element("AppxPackageArtifactsDir", cmStrCat(artifactDir, '\\'));
       std::string resourcePriFile =
         cmStrCat(this->DefaultArtifactDir, "/resources.pri");
       ConvertToWindowsSlash(resourcePriFile);
@@ -5631,7 +5632,7 @@ std::string cmVisualStudio10TargetGenerator::GetCSharpSourceLink(
     this->Makefile->FindSourceGroup(fullFileName, sourceGroups);
   if (sourceGroup && !sourceGroup->GetFullName().empty()) {
     sourceGroupedFile =
-      cmStrCat(sourceGroup->GetFullName(), "/",
+      cmStrCat(sourceGroup->GetFullName(), '/',
                cmsys::SystemTools::GetFilenameName(fullFileName));
     cmsys::SystemTools::ConvertToUnixSlashes(sourceGroupedFile);
   }

+ 3 - 3
Source/cmVisualStudioGeneratorOptions.cxx

@@ -361,7 +361,7 @@ void cmVisualStudioGeneratorOptions::OutputPreprocessorDefinitions(
 
   std::ostringstream oss;
   if (this->Version != cmGlobalVisualStudioGenerator::VSVersion::VS9) {
-    oss << "%(" << tag << ")";
+    oss << "%(" << tag << ')';
   }
   auto de = cmRemoveDuplicates(this->Defines);
   for (std::string const& di : cmMakeRange(this->Defines.cbegin(), de)) {
@@ -411,7 +411,7 @@ void cmVisualStudioGeneratorOptions::OutputAdditionalIncludeDirectories(
     }
 
     if (lang == "ASM_NASM"_s) {
-      include += "\\";
+      include += '\\';
     }
 
     // Escape this include for the MSBuild.
@@ -428,7 +428,7 @@ void cmVisualStudioGeneratorOptions::OutputAdditionalIncludeDirectories(
   }
 
   if (this->Version != cmGlobalVisualStudioGenerator::VSVersion::VS9) {
-    oss << sep << "%(" << tag << ")";
+    oss << sep << "%(" << tag << ')';
   }
 
   this->OutputFlag(fout, indent, tag, oss.str());

+ 1 - 1
Source/cmVisualStudioSlnData.cxx

@@ -74,7 +74,7 @@ std::string cmSlnData::GetConfigurationTarget(
   const std::string& platformName)
 {
   std::string solutionTarget =
-    cmStrCat(solutionConfiguration, "|", platformName);
+    cmStrCat(solutionConfiguration, '|', platformName);
   cm::optional<cmSlnProjectEntry> project = GetProjectByName(projectName);
   if (!project) {
     return platformName;

+ 1 - 1
Source/cmVisualStudioWCEPlatformParser.cxx

@@ -40,7 +40,7 @@ std::string cmVisualStudioWCEPlatformParser::GetOSVersion() const
     return OSMajorVersion;
   }
 
-  return cmStrCat(OSMajorVersion, ".", OSMinorVersion);
+  return cmStrCat(OSMajorVersion, '.', OSMinorVersion);
 }
 
 const char* cmVisualStudioWCEPlatformParser::GetArchitectureFamily() const