diff options
Diffstat (limited to 'Source')
92 files changed, 576 insertions, 628 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index e63e262..5d065cd 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 9) -set(CMake_VERSION_PATCH 20170918) +set(CMake_VERSION_PATCH 20170920) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx index 97e792a..825a888 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx +++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx @@ -49,19 +49,15 @@ int cmCPackIFWGenerator::PackageFiles() ifwCmd += " -p " + this->toplevel + "/packages"; if (!this->PkgsDirsVector.empty()) { - for (std::vector<std::string>::iterator it = - this->PkgsDirsVector.begin(); - it != this->PkgsDirsVector.end(); ++it) { - ifwCmd += " -p " + *it; + for (std::string const& it : this->PkgsDirsVector) { + ifwCmd += " -p " + it; } } if (!this->RepoDirsVector.empty()) { if (!this->IsVersionLess("3.1")) { - for (std::vector<std::string>::iterator it = - this->RepoDirsVector.begin(); - it != this->RepoDirsVector.end(); ++it) { - ifwCmd += " --repository " + *it; + for (std::string const& rd : this->RepoDirsVector) { + ifwCmd += " --repository " + rd; } } else { cmCPackIFWLogger(WARNING, "The \"CPACK_IFW_REPOSITORIES_DIRECTORIES\" " @@ -137,19 +133,15 @@ int cmCPackIFWGenerator::PackageFiles() ifwCmd += " -p " + this->toplevel + "/packages"; if (!this->PkgsDirsVector.empty()) { - for (std::vector<std::string>::iterator it = - this->PkgsDirsVector.begin(); - it != this->PkgsDirsVector.end(); ++it) { - ifwCmd += " -p " + *it; + for (std::string const& it : this->PkgsDirsVector) { + ifwCmd += " -p " + it; } } if (!this->RepoDirsVector.empty()) { if (!this->IsVersionLess("3.1")) { - for (std::vector<std::string>::iterator it = - this->RepoDirsVector.begin(); - it != this->RepoDirsVector.end(); ++it) { - ifwCmd += " --repository " + *it; + for (std::string const& rd : this->RepoDirsVector) { + ifwCmd += " --repository " + rd; } } else { cmCPackIFWLogger(WARNING, "The \"CPACK_IFW_REPOSITORIES_DIRECTORIES\" " @@ -258,7 +250,7 @@ int cmCPackIFWGenerator::InitializeInternal() const char* BinCreatorStr = this->GetOption(BinCreatorOpt); if (!BinCreatorStr || cmSystemTools::IsNOTFOUND(BinCreatorStr)) { - this->BinCreator = ""; + this->BinCreator.clear(); } else { this->BinCreator = BinCreatorStr; } @@ -274,7 +266,7 @@ int cmCPackIFWGenerator::InitializeInternal() const char* RepoGenStr = this->GetOption(RepoGenOpt); if (!RepoGenStr || cmSystemTools::IsNOTFOUND(RepoGenStr)) { - this->RepoGen = ""; + this->RepoGen.clear(); } else { this->RepoGen = RepoGenStr; } @@ -321,9 +313,8 @@ int cmCPackIFWGenerator::InitializeInternal() if (const char* RepoAllStr = this->GetOption("CPACK_IFW_REPOSITORIES_ALL")) { std::vector<std::string> RepoAllVector; cmSystemTools::ExpandListArgument(RepoAllStr, RepoAllVector); - for (std::vector<std::string>::iterator rit = RepoAllVector.begin(); - rit != RepoAllVector.end(); ++rit) { - this->GetRepository(*rit); + for (std::string const& r : RepoAllVector) { + this->GetRepository(r); } } diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx index e5c19bb..422f5d5 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx +++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx @@ -406,9 +406,8 @@ void cmCPackIFWInstaller::GenerateInstallerFile() // Remote repositories if (!this->RemoteRepositories.empty()) { xout.StartElement("RemoteRepositories"); - for (RepositoriesVector::iterator rit = this->RemoteRepositories.begin(); - rit != this->RemoteRepositories.end(); ++rit) { - (*rit)->WriteRepositoryConfig(xout); + for (cmCPackIFWRepository* r : this->RemoteRepositories) { + r->WriteRepositoryConfig(xout); } xout.EndElement(); } @@ -492,9 +491,8 @@ void cmCPackIFWInstaller::GeneratePackageFiles() } // Generate packages meta information - for (PackagesMap::iterator pit = this->Packages.begin(); - pit != this->Packages.end(); ++pit) { - cmCPackIFWPackage* package = pit->second; + for (auto& p : this->Packages) { + cmCPackIFWPackage* package = p.second; package->GeneratePackageFile(); } } diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx index 8461309..7b23005 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.cxx +++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx @@ -111,19 +111,19 @@ void cmCPackIFWPackage::DefaultConfiguration() { this->DisplayName.clear(); this->Description.clear(); - this->Version = ""; - this->ReleaseDate = ""; - this->Script = ""; + this->Version.clear(); + this->ReleaseDate.clear(); + this->Script.clear(); this->Licenses.clear(); this->UserInterfaces.clear(); this->Translations.clear(); - this->SortingPriority = ""; - this->UpdateText = ""; - this->Default = ""; - this->Essential = ""; - this->Virtual = ""; - this->ForcedInstallation = ""; - this->RequiresAdminRights = ""; + this->SortingPriority.clear(); + this->UpdateText.clear(); + this->Default.clear(); + this->Essential.clear(); + this->Virtual.clear(); + this->ForcedInstallation.clear(); + this->RequiresAdminRights.clear(); } // Defaul configuration (all in one package) @@ -203,10 +203,8 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component) // CMake dependencies if (!component->Dependencies.empty()) { - std::vector<cmCPackComponent*>::iterator dit; - for (dit = component->Dependencies.begin(); - dit != component->Dependencies.end(); ++dit) { - this->Dependencies.insert(this->Generator->ComponentPackages[*dit]); + for (cmCPackComponent* dep : component->Dependencies) { + this->Dependencies.insert(this->Generator->ComponentPackages[dep]); } } @@ -413,9 +411,8 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix) if (const char* value = this->GetOption(option)) { cmSystemTools::ExpandListArgument(value, deps); } - for (std::vector<std::string>::iterator dit = deps.begin(); - dit != deps.end(); ++dit) { - DependenceStruct dep(*dit); + for (std::string const& d : deps) { + DependenceStruct dep(d); if (this->Generator->Packages.count(dep.Name)) { cmCPackIFWPackage& depPkg = this->Generator->Packages[dep.Name]; dep.Name = depPkg.Name; @@ -435,9 +432,8 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix) } else if (const char* value = this->GetOption(option)) { std::vector<std::string> depsOn; cmSystemTools::ExpandListArgument(value, depsOn); - for (std::vector<std::string>::iterator dit = depsOn.begin(); - dit != depsOn.end(); ++dit) { - DependenceStruct dep(*dit); + for (std::string const& d : depsOn) { + DependenceStruct dep(d); if (this->Generator->Packages.count(dep.Name)) { cmCPackIFWPackage& depPkg = this->Generator->Packages[dep.Name]; dep.Name = depPkg.Name; @@ -521,26 +517,22 @@ void cmCPackIFWPackage::GeneratePackageFile() xout.StartElement("Package"); // DisplayName (with translations) - for (std::map<std::string, std::string>::iterator it = - this->DisplayName.begin(); - it != this->DisplayName.end(); ++it) { + for (auto const& dn : this->DisplayName) { xout.StartElement("DisplayName"); - if (!it->first.empty()) { - xout.Attribute("xml:lang", it->first); + if (!dn.first.empty()) { + xout.Attribute("xml:lang", dn.first); } - xout.Content(it->second); + xout.Content(dn.second); xout.EndElement(); } // Description (with translations) - for (std::map<std::string, std::string>::iterator it = - this->Description.begin(); - it != this->Description.end(); ++it) { + for (auto const& d : this->Description) { xout.StartElement("Description"); - if (!it->first.empty()) { - xout.Attribute("xml:lang", it->first); + if (!d.first.empty()) { + xout.Attribute("xml:lang", d.first); } - xout.Content(it->second); + xout.Content(d.second); xout.EndElement(); } @@ -568,46 +560,43 @@ void cmCPackIFWPackage::GeneratePackageFile() // User Interfaces (copy to meta dir) std::vector<std::string> userInterfaces = UserInterfaces; - for (size_t i = 0; i < userInterfaces.size(); i++) { - std::string name = cmSystemTools::GetFilenameName(userInterfaces[i]); + for (std::string& userInterface : userInterfaces) { + std::string name = cmSystemTools::GetFilenameName(userInterface); std::string path = this->Directory + "/meta/" + name; - cmsys::SystemTools::CopyFileIfDifferent(userInterfaces[i], path); - userInterfaces[i] = name; + cmsys::SystemTools::CopyFileIfDifferent(userInterface, path); + userInterface = name; } if (!userInterfaces.empty()) { xout.StartElement("UserInterfaces"); - for (size_t i = 0; i < userInterfaces.size(); i++) { - xout.Element("UserInterface", userInterfaces[i]); + for (std::string const& userInterface : userInterfaces) { + xout.Element("UserInterface", userInterface); } xout.EndElement(); } // Translations (copy to meta dir) std::vector<std::string> translations = Translations; - for (size_t i = 0; i < translations.size(); i++) { - std::string name = cmSystemTools::GetFilenameName(translations[i]); + for (std::string& translation : translations) { + std::string name = cmSystemTools::GetFilenameName(translation); std::string path = this->Directory + "/meta/" + name; - cmsys::SystemTools::CopyFileIfDifferent(translations[i], path); - translations[i] = name; + cmsys::SystemTools::CopyFileIfDifferent(translation, path); + translation = name; } if (!translations.empty()) { xout.StartElement("Translations"); - for (size_t i = 0; i < translations.size(); i++) { - xout.Element("Translation", translations[i]); + for (std::string const& translation : translations) { + xout.Element("Translation", translation); } xout.EndElement(); } // Dependencies std::set<DependenceStruct> compDepSet; - for (std::set<DependenceStruct*>::iterator ait = - this->AlienDependencies.begin(); - ait != this->AlienDependencies.end(); ++ait) { - compDepSet.insert(*(*ait)); + for (DependenceStruct* ad : this->AlienDependencies) { + compDepSet.insert(*ad); } - for (std::set<cmCPackIFWPackage*>::iterator it = this->Dependencies.begin(); - it != this->Dependencies.end(); ++it) { - compDepSet.insert(DependenceStruct((*it)->Name)); + for (cmCPackIFWPackage* d : this->Dependencies) { + compDepSet.insert(DependenceStruct(d->Name)); } // Write dependencies if (!compDepSet.empty()) { @@ -624,10 +613,8 @@ void cmCPackIFWPackage::GeneratePackageFile() // Automatic dependency on std::set<DependenceStruct> compAutoDepSet; - for (std::set<DependenceStruct*>::iterator ait = - this->AlienAutoDependOn.begin(); - ait != this->AlienAutoDependOn.end(); ++ait) { - compAutoDepSet.insert(*(*ait)); + for (DependenceStruct* aad : this->AlienAutoDependOn) { + compAutoDepSet.insert(*aad); } // Write automatic dependency on if (!compAutoDepSet.empty()) { diff --git a/Source/CPack/IFW/cmCPackIFWRepository.cxx b/Source/CPack/IFW/cmCPackIFWRepository.cxx index 990ee74..87e7089 100644 --- a/Source/CPack/IFW/cmCPackIFWRepository.cxx +++ b/Source/CPack/IFW/cmCPackIFWRepository.cxx @@ -62,49 +62,49 @@ bool cmCPackIFWRepository::ConfigureFromOptions() if (const char* url = this->GetOption(prefix + "URL")) { this->Url = url; } else { - this->Url = ""; + this->Url.clear(); } // Old url if (const char* oldUrl = this->GetOption(prefix + "OLD_URL")) { this->OldUrl = oldUrl; } else { - this->OldUrl = ""; + this->OldUrl.clear(); } // New url if (const char* newUrl = this->GetOption(prefix + "NEW_URL")) { this->NewUrl = newUrl; } else { - this->NewUrl = ""; + this->NewUrl.clear(); } // Enabled if (this->IsOn(prefix + "DISABLED")) { this->Enabled = "0"; } else { - this->Enabled = ""; + this->Enabled.clear(); } // Username if (const char* username = this->GetOption(prefix + "USERNAME")) { this->Username = username; } else { - this->Username = ""; + this->Username.clear(); } // Password if (const char* password = this->GetOption(prefix + "PASSWORD")) { this->Password = password; } else { - this->Password = ""; + this->Password.clear(); } // DisplayName if (const char* displayName = this->GetOption(prefix + "DISPLAY_NAME")) { this->DisplayName = displayName; } else { - this->DisplayName = ""; + this->DisplayName.clear(); } return this->IsValid(); @@ -279,9 +279,8 @@ void cmCPackIFWRepository::WriteRepositoryUpdates(cmXMLWriter& xout) { if (!this->RepositoryUpdate.empty()) { xout.StartElement("RepositoryUpdate"); - for (RepositoriesVector::iterator rit = this->RepositoryUpdate.begin(); - rit != this->RepositoryUpdate.end(); ++rit) { - (*rit)->WriteRepositoryUpdate(xout); + for (cmCPackIFWRepository* r : this->RepositoryUpdate) { + r->WriteRepositoryUpdate(xout); } xout.EndElement(); } diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 274dfd0..ba07d08 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -89,9 +89,8 @@ bool cmCPackWIXGenerator::RunCandleCommand(std::string const& sourceFile, command << " -arch " << GetArchitecture(); command << " -out " << QuotePath(objectFile); - for (extension_set_t::const_iterator i = CandleExtensions.begin(); - i != CandleExtensions.end(); ++i) { - command << " -ext " << QuotePath(*i); + for (std::string const& ext : CandleExtensions) { + command << " -ext " << QuotePath(ext); } AddCustomFlags("CPACK_WIX_CANDLE_EXTRA_FLAGS", command); @@ -113,9 +112,8 @@ bool cmCPackWIXGenerator::RunLightCommand(std::string const& objectFiles) command << " -nologo"; command << " -out " << QuotePath(packageFileNames.at(0)); - for (extension_set_t::const_iterator i = this->LightExtensions.begin(); - i != this->LightExtensions.end(); ++i) { - command << " -ext " << QuotePath(*i); + for (std::string const& ext : this->LightExtensions) { + command << " -ext " << QuotePath(ext); } const char* const cultures = GetOption("CPACK_WIX_CULTURES"); @@ -219,8 +217,8 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration() std::vector<std::string> patchFilePaths; cmSystemTools::ExpandListArgument(patchFilePath, patchFilePaths); - for (size_t i = 0; i < patchFilePaths.size(); ++i) { - if (!this->Patch->LoadFragments(patchFilePaths[i])) { + for (std::string const& p : patchFilePaths) { + if (!this->Patch->LoadFragments(p)) { return false; } } @@ -254,9 +252,7 @@ bool cmCPackWIXGenerator::PackageFilesImpl() std::set<std::string> usedBaseNames; std::ostringstream objectFiles; - for (size_t i = 0; i < this->WixSources.size(); ++i) { - std::string const& sourceFilename = this->WixSources[i]; - + for (std::string const& sourceFilename : this->WixSources) { std::string baseName = cmSystemTools::GetFilenameWithoutLastExtension(sourceFilename); @@ -306,8 +302,8 @@ void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream) cmSystemTools::ExpandListArgument(cpackWixExtraObjects, expandedExtraObjects); - for (size_t i = 0; i < expandedExtraObjects.size(); ++i) { - stream << " " << QuotePath(expandedExtraObjects[i]); + for (std::string const& obj : expandedExtraObjects) { + stream << " " << QuotePath(obj); } } @@ -345,9 +341,7 @@ void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile() std::string prefix = "CPACK_WIX_PROPERTY_"; std::vector<std::string> options = GetOptions(); - for (size_t i = 0; i < options.size(); ++i) { - std::string const& name = options[i]; - + for (std::string const& name : options) { if (name.length() > prefix.length() && name.substr(0, prefix.length()) == prefix) { std::string id = name.substr(prefix.length()); @@ -503,16 +497,14 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() globalShortcuts.AddShortcutTypes(emittedShortcutTypes); } else { - for (std::map<std::string, cmCPackComponent>::const_iterator i = - this->Components.begin(); - i != this->Components.end(); ++i) { - cmCPackComponent const& component = i->second; + for (auto const& i : this->Components) { + cmCPackComponent const& component = i.second; std::string componentPath = toplevel; componentPath += "/"; componentPath += component.Name; - std::string componentFeatureId = "CM_C_" + component.Name; + std::string const componentFeatureId = "CM_C_" + component.Name; cmWIXShortcuts featureShortcuts; AddComponentsToFeature(componentPath, componentFeatureId, @@ -623,19 +615,15 @@ bool cmCPackWIXGenerator::GenerateMainSourceFileFromTemplate() bool cmCPackWIXGenerator::CreateFeatureHierarchy( cmWIXFeaturesSourceWriter& featureDefinitions) { - for (std::map<std::string, cmCPackComponentGroup>::const_iterator i = - ComponentGroups.begin(); - i != ComponentGroups.end(); ++i) { - cmCPackComponentGroup const& group = i->second; + for (auto const& i : ComponentGroups) { + cmCPackComponentGroup const& group = i.second; if (group.ParentGroup == 0) { featureDefinitions.EmitFeatureForComponentGroup(group, *this->Patch); } } - for (std::map<std::string, cmCPackComponent>::const_iterator i = - this->Components.begin(); - i != this->Components.end(); ++i) { - cmCPackComponent const& component = i->second; + for (auto const& i : this->Components) { + cmCPackComponent const& component = i.second; if (!component.Group) { featureDefinitions.EmitFeatureForComponent(component, *this->Patch); @@ -1135,9 +1123,8 @@ void cmCPackWIXGenerator::AddCustomFlags(std::string const& variableName, std::vector<std::string> list; cmSystemTools::ExpandListArgument(variableContent, list); - for (std::vector<std::string>::const_iterator i = list.begin(); - i != list.end(); ++i) { - stream << " " << QuotePath(*i); + for (std::string const& i : list) { + stream << " " << QuotePath(i); } } diff --git a/Source/CPack/WiX/cmWIXAccessControlList.cxx b/Source/CPack/WiX/cmWIXAccessControlList.cxx index 744a932..1603bf8 100644 --- a/Source/CPack/WiX/cmWIXAccessControlList.cxx +++ b/Source/CPack/WiX/cmWIXAccessControlList.cxx @@ -20,8 +20,8 @@ bool cmWIXAccessControlList::Apply() std::vector<std::string> entries; this->InstalledFile.GetPropertyAsList("CPACK_WIX_ACL", entries); - for (size_t i = 0; i < entries.size(); ++i) { - this->CreatePermissionElement(entries[i]); + for (std::string const& entry : entries) { + this->CreatePermissionElement(entry); } return true; @@ -56,9 +56,9 @@ void cmWIXAccessControlList::CreatePermissionElement(std::string const& entry) if (!domain.empty()) { this->SourceWriter.AddAttribute("Domain", domain); } - for (size_t i = 0; i < permissions.size(); ++i) { + for (std::string const& permission : permissions) { this->EmitBooleanAttribute(entry, - cmSystemTools::TrimWhitespace(permissions[i])); + cmSystemTools::TrimWhitespace(permission)); } this->SourceWriter.EndElement("Permission"); } diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx index 0be4377..a7a0648 100644 --- a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx @@ -46,16 +46,12 @@ void cmWIXFeaturesSourceWriter::EmitFeatureForComponentGroup( patch.ApplyFragment("CM_G_" + group.Name, *this); - for (std::vector<cmCPackComponentGroup*>::const_iterator i = - group.Subgroups.begin(); - i != group.Subgroups.end(); ++i) { - EmitFeatureForComponentGroup(**i, patch); + for (cmCPackComponentGroup* subgroup : group.Subgroups) { + EmitFeatureForComponentGroup(*subgroup, patch); } - for (std::vector<cmCPackComponent*>::const_iterator i = - group.Components.begin(); - i != group.Components.end(); ++i) { - EmitFeatureForComponent(**i, patch); + for (cmCPackComponent* component : group.Components) { + EmitFeatureForComponent(*component, patch); } EndElement("Feature"); diff --git a/Source/CPack/WiX/cmWIXPatch.cxx b/Source/CPack/WiX/cmWIXPatch.cxx index 287a644..dec95fb 100644 --- a/Source/CPack/WiX/cmWIXPatch.cxx +++ b/Source/CPack/WiX/cmWIXPatch.cxx @@ -29,10 +29,8 @@ void cmWIXPatch::ApplyFragment(std::string const& id, return; const cmWIXPatchElement& fragment = i->second; - for (cmWIXPatchElement::attributes_t::const_iterator attr_i = - fragment.attributes.begin(); - attr_i != fragment.attributes.end(); ++attr_i) { - writer.AddAttribute(attr_i->first, attr_i->second); + for (auto const& attr : fragment.attributes) { + writer.AddAttribute(attr.first, attr.second); } this->ApplyElementChildren(fragment, writer); @@ -42,11 +40,7 @@ void cmWIXPatch::ApplyFragment(std::string const& id, void cmWIXPatch::ApplyElementChildren(const cmWIXPatchElement& element, cmWIXSourceWriter& writer) { - for (cmWIXPatchElement::child_list_t::const_iterator j = - element.children.begin(); - j != element.children.end(); ++j) { - cmWIXPatchNode* node = *j; - + for (cmWIXPatchNode* node : element.children) { switch (node->type()) { case cmWIXPatchNode::ELEMENT: ApplyElement(dynamic_cast<const cmWIXPatchElement&>(*node), writer); @@ -63,10 +57,8 @@ void cmWIXPatch::ApplyElement(const cmWIXPatchElement& element, { writer.BeginElement(element.name); - for (cmWIXPatchElement::attributes_t::const_iterator i = - element.attributes.begin(); - i != element.attributes.end(); ++i) { - writer.AddAttribute(i->first, i->second); + for (auto const& attr : element.attributes) { + writer.AddAttribute(attr.first, attr.second); } this->ApplyElementChildren(element, writer); @@ -77,14 +69,13 @@ void cmWIXPatch::ApplyElement(const cmWIXPatchElement& element, bool cmWIXPatch::CheckForUnappliedFragments() { std::string fragmentList; - for (cmWIXPatchParser::fragment_map_t::const_iterator i = Fragments.begin(); - i != Fragments.end(); ++i) { + for (auto const& fragment : Fragments) { if (!fragmentList.empty()) { fragmentList += ", "; } fragmentList += "'"; - fragmentList += i->first; + fragmentList += fragment.first; fragmentList += "'"; } diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx index b050b85..e6aeed3 100644 --- a/Source/CPack/WiX/cmWIXPatchParser.cxx +++ b/Source/CPack/WiX/cmWIXPatchParser.cxx @@ -22,8 +22,8 @@ cmWIXPatchNode::~cmWIXPatchNode() cmWIXPatchElement::~cmWIXPatchElement() { - for (child_list_t::iterator i = children.begin(); i != children.end(); ++i) { - delete *i; + for (cmWIXPatchNode* child : children) { + delete child; } } diff --git a/Source/CPack/WiX/cmWIXShortcut.cxx b/Source/CPack/WiX/cmWIXShortcut.cxx index e5dea94..cd1988a 100644 --- a/Source/CPack/WiX/cmWIXShortcut.cxx +++ b/Source/CPack/WiX/cmWIXShortcut.cxx @@ -47,10 +47,9 @@ bool cmWIXShortcuts::EmitShortcuts( return false; } - for (shortcut_id_map_t::const_iterator j = id_map.begin(); j != id_map.end(); - ++j) { - std::string const& id = j->first; - shortcut_list_t const& shortcutList = j->second; + for (auto const& j : id_map) { + std::string const& id = j.first; + shortcut_list_t const& shortcutList = j.second; for (size_t shortcutListIndex = 0; shortcutListIndex < shortcutList.size(); ++shortcutListIndex) { @@ -68,9 +67,8 @@ bool cmWIXShortcuts::EmitShortcuts( void cmWIXShortcuts::AddShortcutTypes(std::set<Type>& types) { - for (shortcut_type_map_t::const_iterator i = this->Shortcuts.begin(); - i != this->Shortcuts.end(); ++i) { - types.insert(i->first); + for (auto const& shortcut : this->Shortcuts) { + types.insert(shortcut.first); } } @@ -96,9 +94,9 @@ void cmWIXShortcuts::CreateFromProperty(std::string const& propertyName, std::vector<std::string> list; installedFile.GetPropertyAsList(propertyName, list); - for (size_t i = 0; i < list.size(); ++i) { + for (std::string const& label : list) { cmWIXShortcut shortcut; - shortcut.label = list[i]; + shortcut.label = label; shortcut.workingDirectoryId = directoryId; insert(type, id, shortcut); } diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx index a86e28d..dc730e0 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx @@ -158,9 +158,7 @@ std::string cmWIXSourceWriter::EscapeAttributeValue(std::string const& value) std::string result; result.reserve(value.size()); - char c = 0; - for (size_t i = 0; i < value.size(); ++i) { - c = value[i]; + for (char c : value) { switch (c) { case '<': result += "<"; diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index 1e45b48..641be38 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -9,7 +9,6 @@ #include "cmSystemTools.h" #include "cmWorkingDirectory.h" -#include <map> #include <ostream> #include <utility> #include <vector> @@ -74,10 +73,8 @@ int cmCPackArchiveGenerator::addOneComponentToArchive( filePrefix += installPrefix + 1; filePrefix += "/"; } - std::vector<std::string>::const_iterator fileIt; - for (fileIt = component->Files.begin(); fileIt != component->Files.end(); - ++fileIt) { - std::string rp = filePrefix + *fileIt; + for (std::string const& file : component->Files) { + std::string rp = filePrefix + file; cmCPackLogger(cmCPackLog::LOG_DEBUG, "Adding file: " << rp << std::endl); archive.Add(rp, 0, nullptr, false); if (!archive) { @@ -117,53 +114,47 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup) // The default behavior is to have one package by component group // unless CPACK_COMPONENTS_IGNORE_GROUP is specified. if (!ignoreGroup) { - std::map<std::string, cmCPackComponentGroup>::iterator compGIt; - for (compGIt = this->ComponentGroups.begin(); - compGIt != this->ComponentGroups.end(); ++compGIt) { - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: " - << compGIt->first << std::endl); + for (auto const& compG : this->ComponentGroups) { + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Packaging component group: " << compG.first << std::endl); // Begin the archive for this group std::string packageFileName = std::string(toplevel) + "/" + - this->GetArchiveComponentFileName(compGIt->first, true); + this->GetArchiveComponentFileName(compG.first, true); // open a block in order to automatically close archive // at the end of the block { DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive); // now iterate over the component of this group - std::vector<cmCPackComponent*>::iterator compIt; - for (compIt = (compGIt->second).Components.begin(); - compIt != (compGIt->second).Components.end(); ++compIt) { + for (cmCPackComponent* comp : (compG.second).Components) { // Add the files of this component to the archive - addOneComponentToArchive(archive, *compIt); + addOneComponentToArchive(archive, comp); } } // add the generated package to package file names list packageFileNames.push_back(packageFileName); } // Handle Orphan components (components not belonging to any groups) - std::map<std::string, cmCPackComponent>::iterator compIt; - for (compIt = this->Components.begin(); compIt != this->Components.end(); - ++compIt) { + for (auto& comp : this->Components) { // Does the component belong to a group? - if (compIt->second.Group == nullptr) { + if (comp.second.Group == nullptr) { cmCPackLogger( cmCPackLog::LOG_VERBOSE, "Component <" - << compIt->second.Name + << comp.second.Name << "> does not belong to any group, package it separately." << std::endl); std::string localToplevel( this->GetOption("CPACK_TEMPORARY_DIRECTORY")); std::string packageFileName = std::string(toplevel); - localToplevel += "/" + compIt->first; + localToplevel += "/" + comp.first; packageFileName += - "/" + this->GetArchiveComponentFileName(compIt->first, false); + "/" + this->GetArchiveComponentFileName(comp.first, false); { DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive); // Add the files of this component to the archive - addOneComponentToArchive(archive, &(compIt->second)); + addOneComponentToArchive(archive, &(comp.second)); } // add the generated package to package file names list packageFileNames.push_back(packageFileName); @@ -173,20 +164,18 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup) // CPACK_COMPONENTS_IGNORE_GROUPS is set // We build 1 package per component else { - std::map<std::string, cmCPackComponent>::iterator compIt; - for (compIt = this->Components.begin(); compIt != this->Components.end(); - ++compIt) { + for (auto& comp : this->Components) { std::string localToplevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY")); std::string packageFileName = std::string(toplevel); - localToplevel += "/" + compIt->first; + localToplevel += "/" + comp.first; packageFileName += - "/" + this->GetArchiveComponentFileName(compIt->first, false); + "/" + this->GetArchiveComponentFileName(comp.first, false); { DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive); // Add the files of this component to the archive - addOneComponentToArchive(archive, &(compIt->second)); + addOneComponentToArchive(archive, &(comp.second)); } // add the generated package to package file names list packageFileNames.push_back(packageFileName); @@ -217,11 +206,9 @@ int cmCPackArchiveGenerator::PackageComponentsAllInOne() DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0], archive); // The ALL COMPONENTS in ONE package case - std::map<std::string, cmCPackComponent>::iterator compIt; - for (compIt = this->Components.begin(); compIt != this->Components.end(); - ++compIt) { + for (auto& comp : this->Components) { // Add the files of this component to the archive - addOneComponentToArchive(archive, &(compIt->second)); + addOneComponentToArchive(archive, &(comp.second)); } // archive goes out of scope so it will finalized and closed. @@ -249,16 +236,15 @@ int cmCPackArchiveGenerator::PackageFiles() // CASE 3 : NON COMPONENT package. DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0], archive); - std::vector<std::string>::const_iterator fileIt; cmWorkingDirectory workdir(toplevel); - for (fileIt = files.begin(); fileIt != files.end(); ++fileIt) { + for (std::string const& file : files) { // Get the relative path to the file std::string rp = - cmSystemTools::RelativePath(toplevel.c_str(), fileIt->c_str()); + cmSystemTools::RelativePath(toplevel.c_str(), file.c_str()); archive.Add(rp, 0, nullptr, false); if (!archive) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem while adding file< " - << *fileIt << "> to archive <" << packageFileNames[0] + << file << "> to archive <" << packageFileNames[0] << "> .ERROR =" << archive.GetError() << std::endl); return 0; } diff --git a/Source/CPack/cmCPackComponentGroup.cxx b/Source/CPack/cmCPackComponentGroup.cxx index e39398a..f888a5f 100644 --- a/Source/CPack/cmCPackComponentGroup.cxx +++ b/Source/CPack/cmCPackComponentGroup.cxx @@ -5,7 +5,6 @@ #include "cmSystemTools.h" #include <string> -#include <vector> unsigned long cmCPackComponent::GetInstalledSize( const std::string& installDir) const @@ -14,11 +13,10 @@ unsigned long cmCPackComponent::GetInstalledSize( return this->TotalSize; } - std::vector<std::string>::const_iterator fileIt; - for (fileIt = this->Files.begin(); fileIt != this->Files.end(); ++fileIt) { + for (std::string const& file : this->Files) { std::string path = installDir; path += '/'; - path += *fileIt; + path += file; this->TotalSize += cmSystemTools::FileLength(path); } diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 18d559e..7fc3c26 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -12,7 +12,6 @@ #include "cm_sys_stat.h" #include "cmsys/Glob.hxx" -#include <map> #include <ostream> #include <set> #include <string.h> @@ -105,37 +104,31 @@ int cmCPackDebGenerator::PackageComponents(bool ignoreGroup) // The default behavior is to have one package by component group // unless CPACK_COMPONENTS_IGNORE_GROUP is specified. if (!ignoreGroup) { - std::map<std::string, cmCPackComponentGroup>::iterator compGIt; - for (compGIt = this->ComponentGroups.begin(); - compGIt != this->ComponentGroups.end(); ++compGIt) { - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: " - << compGIt->first << std::endl); + for (auto const& compG : this->ComponentGroups) { + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Packaging component group: " << compG.first << std::endl); // Begin the archive for this group - retval &= PackageOnePack(initialTopLevel, compGIt->first); + retval &= PackageOnePack(initialTopLevel, compG.first); } // Handle Orphan components (components not belonging to any groups) - std::map<std::string, cmCPackComponent>::iterator compIt; - for (compIt = this->Components.begin(); compIt != this->Components.end(); - ++compIt) { + for (auto const& comp : this->Components) { // Does the component belong to a group? - if (compIt->second.Group == nullptr) { + if (comp.second.Group == nullptr) { cmCPackLogger( cmCPackLog::LOG_VERBOSE, "Component <" - << compIt->second.Name + << comp.second.Name << "> does not belong to any group, package it separately." << std::endl); // Begin the archive for this orphan component - retval &= PackageOnePack(initialTopLevel, compIt->first); + retval &= PackageOnePack(initialTopLevel, comp.first); } } } // CPACK_COMPONENTS_IGNORE_GROUPS is set // We build 1 package per component else { - std::map<std::string, cmCPackComponent>::iterator compIt; - for (compIt = this->Components.begin(); compIt != this->Components.end(); - ++compIt) { - retval &= PackageOnePack(initialTopLevel, compIt->first); + for (auto const& comp : this->Components) { + retval &= PackageOnePack(initialTopLevel, comp.first); } } return retval; @@ -336,10 +329,8 @@ int cmCPackDebGenerator::createDeb() { std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); dirName += '/'; - for (std::vector<std::string>::const_iterator fileIt = - packageFiles.begin(); - fileIt != packageFiles.end(); ++fileIt) { - totalSize += cmSystemTools::FileLength(*fileIt); + for (std::string const& file : packageFiles) { + totalSize += cmSystemTools::FileLength(file); } } out << "Installed-Size: " << (totalSize + 1023) / 1024 << "\n"; @@ -400,7 +391,7 @@ int cmCPackDebGenerator::createDeb() compression_suffix = ".gz"; tar_compression_type = cmArchiveWrite::CompressGZip; } else if (!strcmp(debian_compression_type, "none")) { - compression_suffix = ""; + compression_suffix.clear(); tar_compression_type = cmArchiveWrite::CompressNone; } else { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -446,10 +437,7 @@ int cmCPackDebGenerator::createDeb() // we have to reconstruct the parent folders as well - for (std::vector<std::string>::const_iterator fileIt = - packageFiles.begin(); - fileIt != packageFiles.end(); ++fileIt) { - std::string currentPath = *fileIt; + for (std::string currentPath : packageFiles) { while (currentPath != strGenWDIR) { // the last one IS strGenWDIR, but we do not want this one: // XXX/application/usr/bin/myprogram with GEN_WDIR=XXX/application @@ -459,18 +447,17 @@ int cmCPackDebGenerator::createDeb() } } - for (std::set<std::string>::const_iterator fileIt = orderedFiles.begin(); - fileIt != orderedFiles.end(); ++fileIt) { - cmCPackLogger(cmCPackLog::LOG_DEBUG, "FILEIT: \"" << *fileIt << "\"" + for (std::string const& file : orderedFiles) { + cmCPackLogger(cmCPackLog::LOG_DEBUG, "FILEIT: \"" << file << "\"" << std::endl); - std::string::size_type slashPos = fileIt->find('/', topLevelLength + 1); + std::string::size_type slashPos = file.find('/', topLevelLength + 1); std::string relativeDir = - fileIt->substr(topLevelLength, slashPos - topLevelLength); + file.substr(topLevelLength, slashPos - topLevelLength); cmCPackLogger(cmCPackLog::LOG_DEBUG, "RELATIVEDIR: \"" << relativeDir << "\"" << std::endl); #ifdef WIN32 - std::string mode_t_adt_filename = *fileIt + ":cmake_mode_t"; + std::string mode_t_adt_filename = file + ":cmake_mode_t"; cmsys::ifstream permissionStream(mode_t_adt_filename.c_str()); mode_t permissions = 0; @@ -481,7 +468,7 @@ int cmCPackDebGenerator::createDeb() if (permissions != 0) { data_tar.SetPermissions(permissions); - } else if (cmSystemTools::FileIsDirectory(*fileIt)) { + } else if (cmSystemTools::FileIsDirectory(file)) { data_tar.SetPermissions(0755); } else { data_tar.ClearPermissions(); @@ -489,11 +476,11 @@ int cmCPackDebGenerator::createDeb() #endif // do not recurse because the loop will do it - if (!data_tar.Add(*fileIt, topLevelLength, ".", false)) { + if (!data_tar.Add(file, topLevelLength, ".", false)) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem adding file to tar:" << std::endl << "#top level directory: " << strGenWDIR << std::endl - << "#file: " << *fileIt << std::endl + << "#file: " << file << std::endl << "#error:" << data_tar.GetError() << std::endl); return 0; } @@ -508,23 +495,21 @@ int cmCPackDebGenerator::createDeb() std::string topLevelWithTrailingSlash = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); topLevelWithTrailingSlash += '/'; - for (std::vector<std::string>::const_iterator fileIt = - packageFiles.begin(); - fileIt != packageFiles.end(); ++fileIt) { + for (std::string const& file : packageFiles) { // hash only regular files - if (cmSystemTools::FileIsDirectory(*fileIt) || - cmSystemTools::FileIsSymlink(*fileIt)) { + if (cmSystemTools::FileIsDirectory(file) || + cmSystemTools::FileIsSymlink(file)) { continue; } std::string output = - cmSystemTools::ComputeFileHash(*fileIt, cmCryptoHash::AlgoMD5); + cmSystemTools::ComputeFileHash(file, cmCryptoHash::AlgoMD5); if (output.empty()) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem computing the md5 of " - << *fileIt << std::endl); + << file << std::endl); } - output += " " + *fileIt + "\n"; + output += " " + file + "\n"; // debian md5sums entries are like this: // 014f3604694729f3bf19263bac599765 usr/bin/ccmake // thus strip the full path (with the trailing slash) @@ -641,9 +626,8 @@ int cmCPackDebGenerator::createDeb() std::vector<std::string> controlExtraList; cmSystemTools::ExpandListArgument(controlExtra, controlExtraList); - for (std::vector<std::string>::iterator i = controlExtraList.begin(); - i != controlExtraList.end(); ++i) { - std::string filenamename = cmsys::SystemTools::GetFilenameName(*i); + for (std::string const& i : controlExtraList) { + std::string filenamename = cmsys::SystemTools::GetFilenameName(i); std::string localcopy = strGenWDIR + "/" + filenamename; if (permissionStrictPolicy) { @@ -653,7 +637,7 @@ int cmCPackDebGenerator::createDeb() } // if we can copy the file, it means it does exist, let's add it: - if (cmsys::SystemTools::CopyFileIfDifferent(*i, localcopy)) { + if (cmsys::SystemTools::CopyFileIfDifferent(i, localcopy)) { control_tar.Add(localcopy, strGenWDIR.length(), "."); } } diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 44c7915..e72fcc1 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -248,25 +248,23 @@ int cmCPackGenerator::InstallProjectViaInstallCommands( cmSystemTools::PutEnv(tempInstallDirectoryEnv); std::vector<std::string> installCommandsVector; cmSystemTools::ExpandListArgument(installCommands, installCommandsVector); - std::vector<std::string>::iterator it; - for (it = installCommandsVector.begin(); it != installCommandsVector.end(); - ++it) { - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << *it << std::endl); + for (std::string const& ic : installCommandsVector) { + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ic << std::endl); std::string output; int retVal = 1; bool resB = - cmSystemTools::RunSingleCommand(it->c_str(), &output, &output, &retVal, + cmSystemTools::RunSingleCommand(ic.c_str(), &output, &output, &retVal, nullptr, this->GeneratorVerbose, 0); if (!resB || retVal) { std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/InstallOutput.log"; cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << *it << std::endl + ofs << "# Run command: " << ic << std::endl << "# Output:" << std::endl << output << std::endl; cmCPackLogger( cmCPackLog::LOG_ERROR, "Problem running install command: " - << *it << std::endl + << ic << std::endl << "Please check " << tmpFile << " for errors" << std::endl); return 0; } @@ -286,12 +284,10 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( std::vector<std::string> ignoreFilesRegexString; cmSystemTools::ExpandListArgument(cpackIgnoreFiles, ignoreFilesRegexString); - std::vector<std::string>::iterator it; - for (it = ignoreFilesRegexString.begin(); - it != ignoreFilesRegexString.end(); ++it) { + for (std::string const& ifr : ignoreFilesRegexString) { cmCPackLogger(cmCPackLog::LOG_VERBOSE, - "Create ignore files regex for: " << *it << std::endl); - ignoreFilesRegex.push_back(it->c_str()); + "Create ignore files regex for: " << ifr << std::endl); + ignoreFilesRegex.push_back(ifr.c_str()); } } const char* installDirectories = @@ -334,15 +330,14 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( files = gl.GetFiles(); std::vector<std::string>::iterator gfit; std::vector<cmsys::RegularExpression>::iterator regIt; - for (gfit = files.begin(); gfit != files.end(); ++gfit) { + for (std::string const& gf : files) { bool skip = false; - std::string inFile = *gfit; - if (cmSystemTools::FileIsDirectory(*gfit)) { + std::string inFile = gf; + if (cmSystemTools::FileIsDirectory(gf)) { inFile += '/'; } - for (regIt = ignoreFilesRegex.begin(); regIt != ignoreFilesRegex.end(); - ++regIt) { - if (regIt->find(inFile.c_str())) { + for (cmsys::RegularExpression& reg : ignoreFilesRegex) { + if (reg.find(inFile.c_str())) { cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Ignore file: " << inFile << std::endl); skip = true; @@ -353,7 +348,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( } std::string filePath = tempDir; filePath += "/" + subdir + "/" + - cmSystemTools::RelativePath(top.c_str(), gfit->c_str()); + cmSystemTools::RelativePath(top.c_str(), gf.c_str()); cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: " << inFile << " -> " << filePath << std::endl); /* If the file is a symlink we will have to re-create it */ @@ -377,32 +372,30 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( } /* rebuild symlinks in the installed tree */ if (!symlinkedFiles.empty()) { - std::vector<std::pair<std::string, std::string>>::iterator symlinkedIt; std::string curDir = cmSystemTools::GetCurrentWorkingDirectory(); std::string goToDir = tempDir; goToDir += "/" + subdir; cmCPackLogger(cmCPackLog::LOG_DEBUG, "Change dir to: " << goToDir << std::endl); cmWorkingDirectory workdir(goToDir); - for (symlinkedIt = symlinkedFiles.begin(); - symlinkedIt != symlinkedFiles.end(); ++symlinkedIt) { + for (auto const& symlinked : symlinkedFiles) { cmCPackLogger(cmCPackLog::LOG_DEBUG, "Will create a symlink: " - << symlinkedIt->second << "--> " - << symlinkedIt->first << std::endl); + << symlinked.second << "--> " << symlinked.first + << std::endl); // make sure directory exists for symlink std::string destDir = - cmSystemTools::GetFilenamePath(symlinkedIt->second); + cmSystemTools::GetFilenamePath(symlinked.second); if (!destDir.empty() && !cmSystemTools::MakeDirectory(destDir)) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot create dir: " << destDir << "\nTrying to create symlink: " - << symlinkedIt->second << "--> " - << symlinkedIt->first << std::endl); + << symlinked.second << "--> " << symlinked.first + << std::endl); } - if (!cmSystemTools::CreateSymlink(symlinkedIt->first, - symlinkedIt->second)) { + if (!cmSystemTools::CreateSymlink(symlinked.first, + symlinked.second)) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot create symlink: " - << symlinkedIt->second << "--> " - << symlinkedIt->first << std::endl); + << symlinked.second << "--> " << symlinked.first + << std::endl); return 0; } } @@ -423,10 +416,7 @@ int cmCPackGenerator::InstallProjectViaInstallScript( << std::endl); std::vector<std::string> cmakeScriptsVector; cmSystemTools::ExpandListArgument(cmakeScripts, cmakeScriptsVector); - std::vector<std::string>::iterator it; - for (it = cmakeScriptsVector.begin(); it != cmakeScriptsVector.end(); - ++it) { - std::string installScript = *it; + for (std::string const& installScript : cmakeScriptsVector) { cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Install script: " << installScript << std::endl); @@ -532,10 +522,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( if (installTypes && *installTypes) { std::vector<std::string> installTypesVector; cmSystemTools::ExpandListArgument(installTypes, installTypesVector); - std::vector<std::string>::iterator installTypeIt; - for (installTypeIt = installTypesVector.begin(); - installTypeIt != installTypesVector.end(); ++installTypeIt) { - this->GetInstallationType(installProjectName, *installTypeIt); + for (std::string const& installType : installTypesVector) { + this->GetInstallationType(installProjectName, installType); } } @@ -545,10 +533,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( const char* components = this->GetOption(componentsVar); if (components && *components) { cmSystemTools::ExpandListArgument(components, componentsVector); - std::vector<std::string>::iterator compIt; - for (compIt = componentsVector.begin(); - compIt != componentsVector.end(); ++compIt) { - GetComponent(installProjectName, *compIt); + for (std::string const& comp : componentsVector) { + GetComponent(installProjectName, comp); } componentInstall = true; } @@ -609,11 +595,9 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( "- Install project: " << installProjectName << std::endl); // Run the installation for each component - std::vector<std::string>::iterator componentIt; - for (componentIt = componentsVector.begin(); - componentIt != componentsVector.end(); ++componentIt) { + for (std::string const& component : componentsVector) { std::string tempInstallDirectory = baseTempInstallDirectory; - installComponent = *componentIt; + installComponent = component; if (componentInstall) { cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Install component: " << installComponent << std::endl); @@ -990,12 +974,11 @@ int cmCPackGenerator::DoPackage() */ cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Copying final package(s) [" << packageFileNames.size() << "]:" << std::endl); - std::vector<std::string>::iterator it; /* now copy package one by one */ - for (it = packageFileNames.begin(); it != packageFileNames.end(); ++it) { + for (std::string const& pkgFileName : packageFileNames) { std::string tmpPF(this->GetOption("CPACK_OUTPUT_FILE_PREFIX")); - std::string filename(cmSystemTools::GetFilenameName(*it)); - tempPackageFileName = it->c_str(); + std::string filename(cmSystemTools::GetFilenameName(pkgFileName)); + tempPackageFileName = pkgFileName.c_str(); tmpPF += "/" + filename; const char* packageFileName = tmpPF.c_str(); cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy final package(s): " @@ -1419,10 +1402,9 @@ cmCPackComponent* cmCPackGenerator::GetComponent( std::vector<std::string> installTypesVector; cmSystemTools::ExpandListArgument(installTypes, installTypesVector); std::vector<std::string>::iterator installTypesIt; - for (installTypesIt = installTypesVector.begin(); - installTypesIt != installTypesVector.end(); ++installTypesIt) { + for (std::string const& installType : installTypesVector) { component->InstallationTypes.push_back( - this->GetInstallationType(projectName, *installTypesIt)); + this->GetInstallationType(projectName, installType)); } } @@ -1432,9 +1414,8 @@ cmCPackComponent* cmCPackGenerator::GetComponent( std::vector<std::string> dependsVector; cmSystemTools::ExpandListArgument(depends, dependsVector); std::vector<std::string>::iterator dependIt; - for (dependIt = dependsVector.begin(); dependIt != dependsVector.end(); - ++dependIt) { - cmCPackComponent* child = GetComponent(projectName, *dependIt); + for (std::string const& depend : dependsVector) { + cmCPackComponent* child = GetComponent(projectName, depend); component->Dependencies.push_back(child); child->ReverseDependencies.push_back(component); } diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index d04ea13..ddf104c 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -59,11 +59,10 @@ int cmCPackNSISGenerator::PackageFiles() std::string nsisInstallOptions = nsisFileName + "/NSIS.InstallOptions.ini"; nsisFileName += "/project.nsi"; std::ostringstream str; - std::vector<std::string>::const_iterator it; - for (it = files.begin(); it != files.end(); ++it) { + for (std::string const& file : files) { std::string outputDir = "$INSTDIR"; std::string fileN = - cmSystemTools::RelativePath(toplevel.c_str(), it->c_str()); + cmSystemTools::RelativePath(toplevel.c_str(), file.c_str()); if (!this->Components.empty()) { const std::string::size_type pos = fileN.find('/'); @@ -87,12 +86,11 @@ int cmCPackNSISGenerator::PackageFiles() this->SetOptionIfNotSet("CPACK_NSIS_DELETE_FILES", str.str().c_str()); std::vector<std::string> dirs; this->GetListOfSubdirectories(toplevel.c_str(), dirs); - std::vector<std::string>::const_iterator sit; std::ostringstream dstr; - for (sit = dirs.begin(); sit != dirs.end(); ++sit) { + for (std::string const& dir : dirs) { std::string componentName; std::string fileN = - cmSystemTools::RelativePath(toplevel.c_str(), sit->c_str()); + cmSystemTools::RelativePath(toplevel.c_str(), dir.c_str()); if (fileN.empty()) { continue; } @@ -205,65 +203,57 @@ int cmCPackNSISGenerator::PackageFiles() // in a vector based on the indices, and print them in that order. std::vector<cmCPackInstallationType*> installTypes( this->InstallationTypes.size()); - std::map<std::string, cmCPackInstallationType>::iterator installTypeIt; - for (installTypeIt = this->InstallationTypes.begin(); - installTypeIt != this->InstallationTypes.end(); ++installTypeIt) { - installTypes[installTypeIt->second.Index - 1] = &installTypeIt->second; - } - std::vector<cmCPackInstallationType*>::iterator installTypeIt2; - for (installTypeIt2 = installTypes.begin(); - installTypeIt2 != installTypes.end(); ++installTypeIt2) { + for (auto& installType : this->InstallationTypes) { + installTypes[installType.second.Index - 1] = &installType.second; + } + for (cmCPackInstallationType* installType : installTypes) { installTypesCode += "InstType \""; - installTypesCode += (*installTypeIt2)->DisplayName; + installTypesCode += installType->DisplayName; installTypesCode += "\"\n"; } // Create installation groups first - std::map<std::string, cmCPackComponentGroup>::iterator groupIt; - for (groupIt = this->ComponentGroups.begin(); - groupIt != this->ComponentGroups.end(); ++groupIt) { - if (groupIt->second.ParentGroup == nullptr) { + for (auto& group : this->ComponentGroups) { + if (group.second.ParentGroup == nullptr) { componentCode += - this->CreateComponentGroupDescription(&groupIt->second, macrosOut); + this->CreateComponentGroupDescription(&group.second, macrosOut); } // Add the group description, if any. - if (!groupIt->second.Description.empty()) { + if (!group.second.Description.empty()) { groupDescriptions += " !insertmacro MUI_DESCRIPTION_TEXT ${" + - groupIt->first + "} \"" + - this->TranslateNewlines(groupIt->second.Description) + "\"\n"; + group.first + "} \"" + + this->TranslateNewlines(group.second.Description) + "\"\n"; } } // Create the remaining components, which aren't associated with groups. - std::map<std::string, cmCPackComponent>::iterator compIt; - for (compIt = this->Components.begin(); compIt != this->Components.end(); - ++compIt) { - if (compIt->second.Files.empty()) { + for (auto& comp : this->Components) { + if (comp.second.Files.empty()) { // NSIS cannot cope with components that have no files. continue; } anyDownloadedComponents = - anyDownloadedComponents || compIt->second.IsDownloaded; + anyDownloadedComponents || comp.second.IsDownloaded; - if (!compIt->second.Group) { + if (!comp.second.Group) { componentCode += - this->CreateComponentDescription(&compIt->second, macrosOut); + this->CreateComponentDescription(&comp.second, macrosOut); } // Add this component to the various section lists. sectionList += " !insertmacro \"${MacroName}\" \""; - sectionList += compIt->first; + sectionList += comp.first; sectionList += "\"\n"; - selectedVarsList += "Var " + compIt->first + "_selected\n"; - selectedVarsList += "Var " + compIt->first + "_was_installed\n"; + selectedVarsList += "Var " + comp.first + "_selected\n"; + selectedVarsList += "Var " + comp.first + "_was_installed\n"; // Add the component description, if any. - if (!compIt->second.Description.empty()) { + if (!comp.second.Description.empty()) { componentDescriptions += " !insertmacro MUI_DESCRIPTION_TEXT ${" + - compIt->first + "} \"" + - this->TranslateNewlines(compIt->second.Description) + "\"\n"; + comp.first + "} \"" + + this->TranslateNewlines(comp.second.Description) + "\"\n"; } } @@ -463,11 +453,9 @@ int cmCPackNSISGenerator::InitializeInternal() cmSystemTools::ExpandListArgument(cpackPackageDeskTopLinks, cpackPackageDesktopLinksVector); - for (std::vector<std::string>::iterator i = - cpackPackageDesktopLinksVector.begin(); - i != cpackPackageDesktopLinksVector.end(); ++i) { + for (std::string const& cpdl : cpackPackageDesktopLinksVector) { cmCPackLogger(cmCPackLog::LOG_DEBUG, - "CPACK_CREATE_DESKTOP_LINKS: " << *i << std::endl); + "CPACK_CREATE_DESKTOP_LINKS: " << cpdl << std::endl); } } else { cmCPackLogger(cmCPackLog::LOG_DEBUG, "CPACK_CREATE_DESKTOP_LINKS: " @@ -647,11 +635,9 @@ std::string cmCPackNSISGenerator::CreateComponentDescription( componentCode += " SectionIn RO\n"; } else if (!component->InstallationTypes.empty()) { std::ostringstream out; - std::vector<cmCPackInstallationType*>::iterator installTypeIter; - for (installTypeIter = component->InstallationTypes.begin(); - installTypeIter != component->InstallationTypes.end(); - ++installTypeIter) { - out << " " << (*installTypeIter)->Index; + for (cmCPackInstallationType const* installType : + component->InstallationTypes) { + out << " " << installType->Index; } componentCode += " SectionIn" + out.str() + "\n"; } @@ -730,19 +716,17 @@ std::string cmCPackNSISGenerator::CreateComponentDescription( unsigned long totalSize = 0; { // the scope is needed for cmGeneratedFileStream cmGeneratedFileStream out(zipListFileName.c_str()); - std::vector<std::string>::iterator fileIt; - for (fileIt = component->Files.begin(); fileIt != component->Files.end(); - ++fileIt) { + for (std::string const& file : component->Files) { if (needQuotesInFile) { out << "\""; } - out << *fileIt; + out << file; if (needQuotesInFile) { out << "\""; } out << std::endl; - totalSize += cmSystemTools::FileLength(dirName + *fileIt); + totalSize += cmSystemTools::FileLength(dirName + file); } } @@ -798,17 +782,14 @@ std::string cmCPackNSISGenerator::CreateComponentDescription( macrosOut << "!macro Remove_${" << component->Name << "}\n"; macrosOut << " IntCmp $" << component->Name << "_was_installed 0 noremove_" << component->Name << "\n"; - std::vector<std::string>::iterator pathIt; std::string path; - for (pathIt = component->Files.begin(); pathIt != component->Files.end(); - ++pathIt) { - path = *pathIt; + for (std::string const& pathIt : component->Files) { + path = pathIt; std::replace(path.begin(), path.end(), '/', '\\'); macrosOut << " Delete \"" << componentOutputDir << "\\" << path << "\"\n"; } - for (pathIt = component->Directories.begin(); - pathIt != component->Directories.end(); ++pathIt) { - path = *pathIt; + for (std::string const& pathIt : component->Directories) { + path = pathIt; std::replace(path.begin(), path.end(), '/', '\\'); macrosOut << " RMDir \"" << componentOutputDir << "\\" << path << "\"\n"; } @@ -841,17 +822,14 @@ std::string cmCPackNSISGenerator::CreateSelectionDependenciesDescription( visited.insert(component); std::ostringstream out; - std::vector<cmCPackComponent*>::iterator dependIt; - for (dependIt = component->Dependencies.begin(); - dependIt != component->Dependencies.end(); ++dependIt) { + for (cmCPackComponent* depend : component->Dependencies) { // Write NSIS code to select this dependency - out << " SectionGetFlags ${" << (*dependIt)->Name << "} $0\n"; + out << " SectionGetFlags ${" << depend->Name << "} $0\n"; out << " IntOp $0 $0 | ${SF_SELECTED}\n"; - out << " SectionSetFlags ${" << (*dependIt)->Name << "} $0\n"; - out << " IntOp $" << (*dependIt)->Name - << "_selected 0 + ${SF_SELECTED}\n"; + out << " SectionSetFlags ${" << depend->Name << "} $0\n"; + out << " IntOp $" << depend->Name << "_selected 0 + ${SF_SELECTED}\n"; // Recurse - out << CreateSelectionDependenciesDescription(*dependIt, visited).c_str(); + out << CreateSelectionDependenciesDescription(depend, visited).c_str(); } return out.str(); @@ -867,19 +845,16 @@ std::string cmCPackNSISGenerator::CreateDeselectionDependenciesDescription( visited.insert(component); std::ostringstream out; - std::vector<cmCPackComponent*>::iterator dependIt; - for (dependIt = component->ReverseDependencies.begin(); - dependIt != component->ReverseDependencies.end(); ++dependIt) { + for (cmCPackComponent* depend : component->ReverseDependencies) { // Write NSIS code to deselect this dependency - out << " SectionGetFlags ${" << (*dependIt)->Name << "} $0\n"; + out << " SectionGetFlags ${" << depend->Name << "} $0\n"; out << " IntOp $1 ${SF_SELECTED} ~\n"; out << " IntOp $0 $0 & $1\n"; - out << " SectionSetFlags ${" << (*dependIt)->Name << "} $0\n"; - out << " IntOp $" << (*dependIt)->Name << "_selected 0 + 0\n"; + out << " SectionSetFlags ${" << depend->Name << "} $0\n"; + out << " IntOp $" << depend->Name << "_selected 0 + 0\n"; // Recurse - out - << CreateDeselectionDependenciesDescription(*dependIt, visited).c_str(); + out << CreateDeselectionDependenciesDescription(depend, visited).c_str(); } return out.str(); @@ -903,20 +878,16 @@ std::string cmCPackNSISGenerator::CreateComponentGroupDescription( code += "\"" + group->DisplayName + "\" " + group->Name + "\n"; } - std::vector<cmCPackComponentGroup*>::iterator groupIt; - for (groupIt = group->Subgroups.begin(); groupIt != group->Subgroups.end(); - ++groupIt) { - code += this->CreateComponentGroupDescription(*groupIt, macrosOut); + for (cmCPackComponentGroup* g : group->Subgroups) { + code += this->CreateComponentGroupDescription(g, macrosOut); } - std::vector<cmCPackComponent*>::iterator comp; - for (comp = group->Components.begin(); comp != group->Components.end(); - ++comp) { - if ((*comp)->Files.empty()) { + for (cmCPackComponent* comp : group->Components) { + if (comp->Files.empty()) { continue; } - code += this->CreateComponentDescription(*comp, macrosOut); + code += this->CreateComponentDescription(comp, macrosOut); } code += "SectionGroupEnd\n"; return code; diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx index c541614..3d7fd3c 100644 --- a/Source/CPack/cmCPackSTGZGenerator.cxx +++ b/Source/CPack/cmCPackSTGZGenerator.cxx @@ -6,7 +6,6 @@ #include <sstream> #include <stdio.h> #include <string> -#include <vector> #include "cmCPackGenerator.h" #include "cmCPackLog.h" @@ -48,9 +47,8 @@ int cmCPackSTGZGenerator::PackageFiles() * have generated several packages (component packaging) * so we must iterate over generated packages. */ - for (std::vector<std::string>::iterator it = packageFileNames.begin(); - it != packageFileNames.end(); ++it) { - retval &= cmSystemTools::SetPermissions((*it).c_str(), + for (std::string const& pfn : packageFileNames) { + retval &= cmSystemTools::SetPermissions(pfn.c_str(), #if defined(_MSC_VER) || defined(__MINGW32__) S_IREAD | S_IWRITE | S_IEXEC #else diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 9970721..33d03e5 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -135,7 +135,7 @@ int main(int argc, char const* const* argv) cpackDefinitions definitions; definitions.Log = &log; - cpackConfigFile = ""; + cpackConfigFile.clear(); cmsys::CommandLineArguments arg; arg.Initialize(argc, argv); @@ -293,10 +293,8 @@ int main(int argc, char const* const* argv) cpackProjectDirectory.c_str()); } } - cpackDefinitions::MapType::iterator cdit; - for (cdit = definitions.Map.begin(); cdit != definitions.Map.end(); - ++cdit) { - globalMF->AddDefinition(cdit->first, cdit->second.c_str()); + for (auto const& cd : definitions.Map) { + globalMF->AddDefinition(cd.first, cd.second.c_str()); } const char* cpackModulesPath = @@ -311,9 +309,7 @@ int main(int argc, char const* const* argv) } else { std::vector<std::string> generatorsVector; cmSystemTools::ExpandListArgument(genList, generatorsVector); - std::vector<std::string>::iterator it; - for (it = generatorsVector.begin(); it != generatorsVector.end(); ++it) { - const char* gen = it->c_str(); + for (std::string const& gen : generatorsVector) { cmMakefile::ScopePushPop raii(globalMF.get()); cmMakefile* mf = globalMF.get(); cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, @@ -413,12 +409,10 @@ int main(int argc, char const* const* argv) doc.PrependSection("Options", cmDocumentationOptions); std::vector<cmDocumentationEntry> v; - cmCPackGeneratorFactory::DescriptionsMap::const_iterator generatorIt; - for (generatorIt = generators.GetGeneratorsList().begin(); - generatorIt != generators.GetGeneratorsList().end(); ++generatorIt) { + for (auto const& g : generators.GetGeneratorsList()) { cmDocumentationEntry e; - e.Name = generatorIt->first; - e.Brief = generatorIt->second; + e.Name = g.first; + e.Brief = g.second; v.push_back(e); } doc.SetSection("Generators", v); diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx index 861c2b0..0152200 100644 --- a/Source/CTest/cmCTestBZR.cxx +++ b/Source/CTest/cmCTestBZR.cxx @@ -309,11 +309,11 @@ private: // Hand this line to the subclass implementation. if (!this->ProcessLine()) { - this->Line = ""; + this->Line.clear(); return false; } - this->Line = ""; + this->Line.clear(); last_is_new_line = true; } } else { diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index aae3c63..a0d68a0 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -32,7 +32,7 @@ const char* cmCTestBuildAndTestHandler::GetOutput() } int cmCTestBuildAndTestHandler::ProcessHandler() { - this->Output = ""; + this->Output.clear(); std::string output; cmSystemTools::ResetErrorOccuredFlag(); int retv = this->RunCMakeAndTest(&this->Output); diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 361b43b..28fc113 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -171,8 +171,8 @@ cmCTestBuildHandler::cmCTestBuildHandler() void cmCTestBuildHandler::Initialize() { this->Superclass::Initialize(); - this->StartBuild = ""; - this->EndBuild = ""; + this->StartBuild.clear(); + this->EndBuild.clear(); this->CustomErrorMatches.clear(); this->CustomErrorExceptions.clear(); this->CustomWarningMatches.clear(); @@ -190,8 +190,8 @@ void cmCTestBuildHandler::Initialize() this->BuildOutputLogSize = 0; this->CurrentProcessingLine.clear(); - this->SimplifySourceDir = ""; - this->SimplifyBuildDir = ""; + this->SimplifySourceDir.clear(); + this->SimplifyBuildDir.clear(); this->OutputLineCounter = 0; this->ErrorsAndWarnings.clear(); this->LastErrorOrWarning = this->ErrorsAndWarnings.end(); @@ -371,8 +371,8 @@ int cmCTestBuildHandler::ProcessHandler() this->WarningExceptionRegex); // Determine source and binary tree substitutions to simplify the output. - this->SimplifySourceDir = ""; - this->SimplifyBuildDir = ""; + this->SimplifySourceDir.clear(); + this->SimplifyBuildDir.clear(); if (this->CTest->GetCTestConfiguration("SourceDirectory").size() > 20) { std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory") + "/"; @@ -888,8 +888,8 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal, errorwarning.Text = "*** WARNING non-zero return value in ctest from: "; errorwarning.Text += argv[0]; - errorwarning.PreContext = ""; - errorwarning.PostContext = ""; + errorwarning.PreContext.clear(); + errorwarning.PostContext.clear(); errorwarning.Error = false; this->ErrorsAndWarnings.push_back(errorwarning); this->TotalWarnings++; @@ -911,8 +911,8 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal, errorwarning.LogLine = 1; errorwarning.Text = "*** ERROR executing: "; errorwarning.Text += cmsysProcess_GetErrorString(cp); - errorwarning.PreContext = ""; - errorwarning.PostContext = ""; + errorwarning.PreContext.clear(); + errorwarning.PostContext.clear(); errorwarning.Error = true; this->ErrorsAndWarnings.push_back(errorwarning); this->TotalErrors++; @@ -996,8 +996,8 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, size_t length, // This is an error or warning, so generate report errorwarning.LogLine = static_cast<int>(this->OutputLineCounter + 1); errorwarning.Text = line; - errorwarning.PreContext = ""; - errorwarning.PostContext = ""; + errorwarning.PreContext.clear(); + errorwarning.PostContext.clear(); // Copy pre-context to report for (std::string const& pc : this->PreContext) { diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 95d56ec..70f011a 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -560,6 +560,8 @@ int cmCTestCoverageHandler::ProcessHandler() ostr << "Cannot open source file: " << fullPath; errorsWhileAccumulating.push_back(ostr.str()); error++; + covLogXML.EndElement(); // Report + covLogXML.EndElement(); // File continue; } int untested = 0; @@ -1073,7 +1075,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( break; } - actualSourceFile = ""; + actualSourceFile.clear(); sourceFile = st1re1.match(2); } else if (st1re2.find(line.c_str())) { if (gcovStyle == 0) { @@ -1098,7 +1100,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( break; } - actualSourceFile = ""; + actualSourceFile.clear(); sourceFile = st2re1.match(1); } else if (st2re2.find(line.c_str())) { if (gcovStyle == 0) { @@ -1240,11 +1242,11 @@ int cmCTestCoverageHandler::HandleGCovCoverage( } } - actualSourceFile = ""; + actualSourceFile.clear(); } if (!sourceFile.empty() && actualSourceFile.empty()) { - gcovFile = ""; + gcovFile.clear(); // Is it in the source dir or the binary dir? // @@ -1541,7 +1543,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage( } } - actualSourceFile = ""; + actualSourceFile.clear(); } } } diff --git a/Source/CTest/cmCTestCurl.cxx b/Source/CTest/cmCTestCurl.cxx index 022afd2..7b5ea60 100644 --- a/Source/CTest/cmCTestCurl.cxx +++ b/Source/CTest/cmCTestCurl.cxx @@ -109,7 +109,7 @@ bool cmCTestCurl::UploadFile(std::string const& local_file, std::string const& url, std::string const& fields, std::string& response) { - response = ""; + response.clear(); if (!this->InitCurl()) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Initialization of curl failed"); return false; @@ -185,7 +185,7 @@ bool cmCTestCurl::UploadFile(std::string const& local_file, bool cmCTestCurl::HttpRequest(std::string const& url, std::string const& fields, std::string& response) { - response = ""; + response.clear(); cmCTestOptionalLog(this->CTest, DEBUG, "HttpRequest\n" << "url: " << url << "\n" << "fields " << fields << "\n", @@ -240,10 +240,10 @@ bool cmCTestCurl::HttpRequest(std::string const& url, void cmCTestCurl::SetProxyType() { - this->HTTPProxy = ""; + this->HTTPProxy.clear(); // this is the default this->HTTPProxyType = CURLPROXY_HTTP; - this->HTTPProxyAuth = ""; + this->HTTPProxyAuth.clear(); if (cmSystemTools::GetEnv("HTTP_PROXY", this->HTTPProxy)) { std::string port; if (cmSystemTools::GetEnv("HTTP_PROXY_PORT", port)) { diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx index 735d92d..525dacc 100644 --- a/Source/CTest/cmCTestHG.cxx +++ b/Source/CTest/cmCTestHG.cxx @@ -250,7 +250,7 @@ private: currPath += i; } else { output.push_back(currPath); - currPath = ""; + currPath.clear(); } } output.push_back(currPath); diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 6e46a31..3efb039 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -122,11 +122,11 @@ void cmCTestMemCheckHandler::Initialize() this->LogWithPID = false; this->CustomMaximumPassedTestOutputSize = 0; this->CustomMaximumFailedTestOutputSize = 0; - this->MemoryTester = ""; + this->MemoryTester.clear(); this->MemoryTesterDynamicOptions.clear(); this->MemoryTesterOptions.clear(); this->MemoryTesterStyle = UNKNOWN; - this->MemoryTesterOutputFile = ""; + this->MemoryTesterOutputFile.clear(); this->DefectCount = 0; } @@ -417,8 +417,8 @@ void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml) bool cmCTestMemCheckHandler::InitializeMemoryChecking() { - this->MemoryTesterEnvironmentVariable = ""; - this->MemoryTester = ""; + this->MemoryTesterEnvironmentVariable.clear(); + this->MemoryTester.clear(); // Setup the command if (cmSystemTools::FileExists( this->CTest->GetCTestConfiguration("MemoryCheckCommand").c_str())) { @@ -725,7 +725,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput( std::vector<std::string> lines; cmSystemTools::Split(str.c_str(), lines); std::ostringstream ostr; - log = ""; + log.clear(); for (std::string const& l : lines) { std::string resultFound; if (leakWarning.find(l)) { @@ -755,7 +755,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput( std::vector<std::string> lines; cmSystemTools::Split(str.c_str(), lines); std::ostringstream ostr; - log = ""; + log.clear(); cmsys::RegularExpression pfW("^\\[[WEI]\\] ([A-Z][A-Z][A-Z][A-Z]*): "); @@ -805,7 +805,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput( std::string::size_type cc; std::ostringstream ostr; - log = ""; + log.clear(); int defects = 0; @@ -928,7 +928,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput( bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput( const std::string& str, std::string& log, std::vector<int>& results) { - log = ""; + log.clear(); double sttime = cmSystemTools::GetTime(); std::vector<std::string> lines; cmSystemTools::Split(str.c_str(), lines); @@ -1079,7 +1079,7 @@ void cmCTestMemCheckHandler::TestOutputFileNames( if (g.GetFiles().empty()) { std::string log = "Cannot find memory tester output file: " + ofile; cmCTestLog(this->CTest, ERROR_MESSAGE, log << std::endl); - ofile = ""; + ofile.clear(); } else { files = g.GetFiles(); return; @@ -1087,7 +1087,7 @@ void cmCTestMemCheckHandler::TestOutputFileNames( } else if (!cmSystemTools::FileExists(ofile.c_str())) { std::string log = "Cannot find memory tester output file: " + ofile; cmCTestLog(this->CTest, ERROR_MESSAGE, log << std::endl); - ofile = ""; + ofile.clear(); } files.push_back(ofile); } diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index a71e2ec..56a9cb8 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -30,8 +30,8 @@ cmCTestRunTest::cmCTestRunTest(cmCTestTestHandler* handler) this->TestResult.Status = cmCTestTestHandler::NOT_RUN; this->TestResult.TestCount = 0; this->TestResult.Properties = nullptr; - this->ProcessOutput = ""; - this->CompressedOutput = ""; + this->ProcessOutput.clear(); + this->CompressedOutput.clear(); this->CompressionRatio = 2; this->StopTimePassed = false; this->NumberOfRunsLeft = 1; // default to 1 run of the test @@ -426,7 +426,7 @@ bool cmCTestRunTest::StartTest(size_t total) this->TestResult.Path = this->TestProperties->Directory; this->TestProcess = new cmProcess; this->TestResult.Output = "Disabled"; - this->TestResult.FullCommandLine = ""; + this->TestResult.FullCommandLine.clear(); return false; } @@ -451,7 +451,7 @@ bool cmCTestRunTest::StartTest(size_t total) *this->TestHandler->LogFile << msg << std::endl; cmCTestLog(this->CTest, HANDLER_OUTPUT, msg << std::endl); this->TestResult.Output = msg; - this->TestResult.FullCommandLine = ""; + this->TestResult.FullCommandLine.clear(); this->TestResult.CompletionStatus = "Fixture dependency failed"; this->TestResult.Status = cmCTestTestHandler::NOT_RUN; return false; @@ -471,7 +471,7 @@ bool cmCTestRunTest::StartTest(size_t total) *this->TestHandler->LogFile << msg << std::endl; cmCTestLog(this->CTest, ERROR_MESSAGE, msg << std::endl); this->TestResult.Output = msg; - this->TestResult.FullCommandLine = ""; + this->TestResult.FullCommandLine.clear(); this->TestResult.CompletionStatus = "Missing Configuration"; this->TestResult.Status = cmCTestTestHandler::NOT_RUN; return false; @@ -487,7 +487,7 @@ bool cmCTestRunTest::StartTest(size_t total) cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to find required file: " << file << std::endl); this->TestResult.Output = "Unable to find required file: " + file; - this->TestResult.FullCommandLine = ""; + this->TestResult.FullCommandLine.clear(); this->TestResult.CompletionStatus = "Required Files Missing"; this->TestResult.Status = cmCTestTestHandler::NOT_RUN; return false; @@ -503,7 +503,7 @@ bool cmCTestRunTest::StartTest(size_t total) cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to find executable: " << args[1] << std::endl); this->TestResult.Output = "Unable to find executable: " + args[1]; - this->TestResult.FullCommandLine = ""; + this->TestResult.FullCommandLine.clear(); this->TestResult.CompletionStatus = "Unable to find executable"; this->TestResult.Status = cmCTestTestHandler::NOT_RUN; return false; diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index bb3e96d..fdd9622 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -93,18 +93,18 @@ void cmCTestScriptHandler::Initialize() this->EmptyBinDir = false; this->EmptyBinDirOnce = false; - this->SourceDir = ""; - this->BinaryDir = ""; - this->BackupSourceDir = ""; - this->BackupBinaryDir = ""; - this->CTestRoot = ""; - this->CVSCheckOut = ""; - this->CTestCmd = ""; - this->UpdateCmd = ""; - this->CTestEnv = ""; - this->InitialCache = ""; - this->CMakeCmd = ""; - this->CMOutFile = ""; + this->SourceDir.clear(); + this->BinaryDir.clear(); + this->BackupSourceDir.clear(); + this->BackupBinaryDir.clear(); + this->CTestRoot.clear(); + this->CVSCheckOut.clear(); + this->CTestCmd.clear(); + this->UpdateCmd.clear(); + this->CTestEnv.clear(); + this->InitialCache.clear(); + this->CMakeCmd.clear(); + this->CMOutFile.clear(); this->ExtraUpdates.clear(); this->MinimumInterval = 20 * 60; @@ -593,7 +593,7 @@ int cmCTestScriptHandler::CheckOutSourceDir() if (!cmSystemTools::FileExists(this->SourceDir.c_str()) && !this->CVSCheckOut.empty()) { // we must now checkout the src dir - output = ""; + output.clear(); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run cvs: " << this->CVSCheckOut << std::endl); res = cmSystemTools::RunSingleCommand( @@ -659,7 +659,7 @@ int cmCTestScriptHandler::PerformExtraUpdates() std::string fullCommand = command; fullCommand += " update "; fullCommand += cvsArgs[1]; - output = ""; + output.clear(); retVal = 0; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run Update: " << fullCommand << std::endl); @@ -762,7 +762,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() command = this->CMakeCmd; command += " \""; command += this->SourceDir; - output = ""; + output.clear(); command += "\""; retVal = 0; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, @@ -802,7 +802,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() // for each variable/argument do a putenv for (std::string const& ctestCommand : ctestCommands) { command = ctestCommand; - output = ""; + output.clear(); retVal = 0; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run ctest command: " << command << std::endl); diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 371d2d5..137cea9 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -140,10 +140,10 @@ void cmCTestSubmitHandler::Initialize() this->HasWarnings = false; this->HasErrors = false; this->Superclass::Initialize(); - this->HTTPProxy = ""; + this->HTTPProxy.clear(); this->HTTPProxyType = 0; - this->HTTPProxyAuth = ""; - this->FTPProxy = ""; + this->HTTPProxyAuth.clear(); + this->FTPProxy.clear(); this->FTPProxyType = 0; this->LogFile = nullptr; this->Files.clear(); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index c99c4fb..f3404a5 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -351,8 +351,8 @@ void cmCTestTestHandler::Initialize() this->TestResults.clear(); this->CustomTestsIgnore.clear(); - this->StartTest = ""; - this->EndTest = ""; + this->StartTest.clear(); + this->EndTest.clear(); this->CustomPreTest.clear(); this->CustomPostTest.clear(); @@ -368,13 +368,13 @@ void cmCTestTestHandler::Initialize() this->UseExcludeRegExpFirst = false; this->IncludeLabelRegularExpression = ""; this->ExcludeLabelRegularExpression = ""; - this->IncludeRegExp = ""; - this->ExcludeRegExp = ""; + this->IncludeRegExp.clear(); + this->ExcludeRegExp.clear(); this->ExcludeFixtureRegExp.clear(); this->ExcludeFixtureSetupRegExp.clear(); this->ExcludeFixtureCleanupRegExp.clear(); - TestsToRunString = ""; + TestsToRunString.clear(); this->UseUnion = false; this->TestList.clear(); } @@ -1595,9 +1595,9 @@ std::string cmCTestTestHandler::FindExecutable( // if everything else failed, check the users path, but only if a full path // wasn't specified if (fullPath.empty() && filepath.empty()) { - std::string path = cmSystemTools::FindProgram(filename.c_str()); + std::string const path = cmSystemTools::FindProgram(filename.c_str()); if (path != "") { - resultingConfig = ""; + resultingConfig.clear(); return path; } } diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx index 0504f90..7173439 100644 --- a/Source/CTest/cmCTestUpdateHandler.cxx +++ b/Source/CTest/cmCTestUpdateHandler.cxx @@ -39,7 +39,7 @@ cmCTestUpdateHandler::cmCTestUpdateHandler() void cmCTestUpdateHandler::Initialize() { this->Superclass::Initialize(); - this->UpdateCommand = ""; + this->UpdateCommand.clear(); this->UpdateType = e_CVS; } diff --git a/Source/CTest/cmParseCacheCoverage.cxx b/Source/CTest/cmParseCacheCoverage.cxx index bf03c45..4cd6588 100644 --- a/Source/CTest/cmParseCacheCoverage.cxx +++ b/Source/CTest/cmParseCacheCoverage.cxx @@ -146,7 +146,7 @@ bool cmParseCacheCoverage::ReadCMCovFile(const char* file) cmCTestLog(this->CTest, ERROR_MESSAGE, "Could not find mumps file for routine: " << routine << "\n"); - filepath = ""; + filepath.clear(); continue; // move to next line } } @@ -154,8 +154,8 @@ bool cmParseCacheCoverage::ReadCMCovFile(const char* file) else { // Totals in arg 0 marks the end of a routine if (separateLine[0].substr(0, 6) == "Totals") { - routine = ""; // at the end of this routine - filepath = ""; + routine.clear(); // at the end of this routine + filepath.clear(); continue; // move to next line } } diff --git a/Source/CTest/cmParseCoberturaCoverage.cxx b/Source/CTest/cmParseCoberturaCoverage.cxx index 9407935..3e85339 100644 --- a/Source/CTest/cmParseCoberturaCoverage.cxx +++ b/Source/CTest/cmParseCoberturaCoverage.cxx @@ -21,7 +21,7 @@ public: this->SkipThisClass = false; this->FilePaths.push_back(this->Coverage.SourceDir); this->FilePaths.push_back(this->Coverage.BinaryDir); - this->CurFileName = ""; + this->CurFileName.clear(); } ~XMLParser() override {} @@ -67,7 +67,7 @@ protected: << std::endl, this->Coverage.Quiet); std::string filename = atts[tagCount + 1]; - this->CurFileName = ""; + this->CurFileName.clear(); // Check if this is an absolute path that falls within our // source or binary directories. diff --git a/Source/CTest/cmParseGTMCoverage.cxx b/Source/CTest/cmParseGTMCoverage.cxx index e4ee699..9948ede 100644 --- a/Source/CTest/cmParseGTMCoverage.cxx +++ b/Source/CTest/cmParseGTMCoverage.cxx @@ -182,7 +182,7 @@ bool cmParseGTMCoverage::ParseMCOVLine(std::string const& line, // save the argument into the argument vector args.push_back(arg); // start on a new argument - arg = ""; + arg.clear(); // if we are at the end of the ), then finish while loop if (cur == ')') { done = true; @@ -233,8 +233,8 @@ bool cmParseGTMCoverage::ParseMCOVLine(std::string const& line, // To avoid double counting of line 0 of each entry point, // Don't count the lines that do not give an explicit line // number. - routine = ""; - function = ""; + routine.clear(); + function.clear(); } else { // this is the format for this line // ^COVERAGE("%RSEL","SRC",count) diff --git a/Source/CTest/cmParseJacocoCoverage.cxx b/Source/CTest/cmParseJacocoCoverage.cxx index a2c20ec..56d07e7 100644 --- a/Source/CTest/cmParseJacocoCoverage.cxx +++ b/Source/CTest/cmParseJacocoCoverage.cxx @@ -18,9 +18,9 @@ public: : CTest(ctest) , Coverage(cont) { - this->FilePath = ""; - this->PackagePath = ""; - this->PackageName = ""; + this->FilePath.clear(); + this->PackagePath.clear(); + this->PackageName.clear(); } ~XMLParser() override {} @@ -32,7 +32,7 @@ protected: { if (name == "package") { this->PackageName = atts[1]; - this->PackagePath = ""; + this->PackagePath.clear(); } else if (name == "sourcefile") { std::string fileName = atts[1]; diff --git a/Source/Checks/cm_cxx_features.cmake b/Source/Checks/cm_cxx_features.cmake index ab80f5b..2c39cbe 100644 --- a/Source/Checks/cm_cxx_features.cmake +++ b/Source/Checks/cm_cxx_features.cmake @@ -14,8 +14,11 @@ function(cm_check_cxx_feature name) CMAKE_FLAGS ${maybe_cxx_standard} OUTPUT_VARIABLE OUTPUT ) + set(check_output "${OUTPUT}") # Filter out MSBuild output that looks like a warning. - string(REGEX REPLACE " +0 Warning\\(s\\)" "" check_output "${OUTPUT}") + string(REGEX REPLACE " +0 Warning\\(s\\)" "" check_output "${check_output}") + # Filter out warnings caused by user flags. + string(REGEX REPLACE "[^\n]*warning:[^\n]*-Winvalid-command-line-argument[^\n]*" "" check_output "${check_output}") # If using the feature causes warnings, treat it as broken/unavailable. if(check_output MATCHES "[Ww]arning") set(CMake_HAVE_CXX_${FEATURE} OFF CACHE INTERNAL "TRY_COMPILE" FORCE) diff --git a/Source/bindexplib.cxx b/Source/bindexplib.cxx index 05e1c66..2eb47f3 100644 --- a/Source/bindexplib.cxx +++ b/Source/bindexplib.cxx @@ -218,7 +218,7 @@ public: * The name of the Function entry points */ if (pSymbolTable->N.Name.Short != 0) { - symbol = ""; + symbol.clear(); symbol.insert(0, (const char*)pSymbolTable->N.ShortName, 8); } else { symbol = stringTable + pSymbolTable->N.Name.Long; diff --git a/Source/cmBuildNameCommand.cxx b/Source/cmBuildNameCommand.cxx index 9d2c0c6..5f54338 100644 --- a/Source/cmBuildNameCommand.cxx +++ b/Source/cmBuildNameCommand.cxx @@ -36,7 +36,7 @@ bool cmBuildNameCommand::InitialPass(std::vector<std::string> const& args, std::string buildname = "WinNT"; if (this->Makefile->GetDefinition("UNIX")) { - buildname = ""; + buildname.clear(); cmSystemTools::RunSingleCommand("uname -a", &buildname, &buildname); if (!buildname.empty()) { std::string RegExp = "([^ ]*) [^ ]* ([^ ]*) "; diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index bcc45ce..d60ce55 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -281,9 +281,9 @@ cmCTest::cmCTest() this->GlobalTimeout = 0; this->LastStopTimeout = 24 * 60 * 60; this->CompressXMLFiles = false; - this->CTestConfigFile = ""; - this->ScheduleType = ""; - this->StopTime = ""; + this->CTestConfigFile.clear(); + this->ScheduleType.clear(); + this->StopTime.clear(); this->NextDayStopTime = false; this->OutputLogFile = nullptr; this->OutputLogFileLastTag = -1; @@ -477,7 +477,7 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) &min); if (year != lctime->tm_year + 1900 || mon != lctime->tm_mon + 1 || day != lctime->tm_mday) { - tag = ""; + tag.clear(); } std::string tagmode; if (cmSystemTools::GetLineFromStream(tfin, tagmode)) { @@ -975,7 +975,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output, } argv.push_back(nullptr); - output = ""; + output.clear(); cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Run command:"); for (char const* arg : argv) { if (!arg) { @@ -1147,7 +1147,7 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output, } std::vector<char> tempOutput; if (output) { - *output = ""; + output->clear(); } CM_AUTO_PTR<cmSystemTools::SaveRestoreEnvironment> saveEnv; @@ -2513,7 +2513,7 @@ const char* cmCTest::GetSpecificTrack() void cmCTest::SetSpecificTrack(const char* track) { if (!track) { - this->SpecificTrack = ""; + this->SpecificTrack.clear(); return; } this->SpecificTrack = track; diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 56f48c3..44095ec 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -480,7 +480,7 @@ void cmCacheManager::AddCacheEntry(const std::string& key, const char* value, e.Value = value; e.Initialized = true; } else { - e.Value = ""; + e.Value.clear(); } e.Type = type; // make sure we only use unix style paths @@ -543,7 +543,7 @@ void cmCacheManager::CacheIterator::SetValue(const char* value) entry->Value = value; entry->Initialized = true; } else { - entry->Value = ""; + entry->Value.clear(); } } diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index f9daf5f..6ae58d6 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -234,7 +234,7 @@ int cmCommandArgumentParserHelper::ParseString(const char* str, int verb) this->InputBufferPos = 0; this->CurrentLine = 0; - this->Result = ""; + this->Result.clear(); yyscan_t yyscanner; cmCommandArgument_yylex_init(&yyscanner); @@ -298,7 +298,7 @@ void cmCommandArgumentParserHelper::SetMakefile(const cmMakefile* mf) void cmCommandArgumentParserHelper::SetResult(const char* value) { if (!value) { - this->Result = ""; + this->Result.clear(); return; } this->Result = value; diff --git a/Source/cmCommandArgumentsHelper.cxx b/Source/cmCommandArgumentsHelper.cxx index 651b3c8..968b17c 100644 --- a/Source/cmCommandArgumentsHelper.cxx +++ b/Source/cmCommandArgumentsHelper.cxx @@ -133,7 +133,7 @@ bool cmCAString::DoConsume(const std::string& arg, unsigned int index) void cmCAString::DoReset() { - this->String = ""; + this->String.clear(); } cmCAEnabler::cmCAEnabler(cmCommandArgumentsHelper* args, const char* key, diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 0311043..fb13a58 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1483,7 +1483,7 @@ void cmComputeLinkInformation::PrintLinkPolicyDiagnosis(std::ostream& os) if (!line.empty() && (line.size() + i.size() + 2) > max_size) { os << line << "\n"; sep = " "; - line = ""; + line.clear(); } line += sep; line += i; diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index f4d48d2..90b3f6d 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -83,7 +83,7 @@ bool cmConditionEvaluator::IsTrue( const std::vector<cmExpandedCommandArgument>& args, std::string& errorString, cmake::MessageType& status) { - errorString = ""; + errorString.clear(); // handle empty invocation if (args.empty()) { diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index d1270a0..fd258fe 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -71,7 +71,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, bool isTryRun) { this->BinaryDirectory = argv[1]; - this->OutputFile = ""; + this->OutputFile.clear(); // which signature were we called with ? this->SrcFileSignature = true; @@ -919,8 +919,8 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir) void cmCoreTryCompile::FindOutputFile(const std::string& targetName, cmStateEnums::TargetType targetType) { - this->FindErrorMessage = ""; - this->OutputFile = ""; + this->FindErrorMessage.clear(); + this->OutputFile.clear(); std::string tmpOutputFile = "/"; if (targetType == cmStateEnums::EXECUTABLE) { tmpOutputFile += targetName; diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index f209f3c..fdbc086 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -219,7 +219,7 @@ void cmDependsFortran::LocateModules() info.Provides.end()); for (std::string const& r : info.Requires) { - this->Internal->TargetRequires[r] = ""; + this->Internal->TargetRequires[r].clear(); } } diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 52f0e27..e729632 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -137,7 +137,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty( if (input) { if (!*input) { // Set to empty - properties[outputName] = ""; + properties[outputName].clear(); return; } @@ -313,7 +313,7 @@ static void prefixItems(std::string& exportDirs) { std::vector<std::string> entries; cmGeneratorExpression::Split(exportDirs, entries); - exportDirs = ""; + exportDirs.clear(); const char* sep = ""; for (std::string const& e : entries) { exportDirs += sep; @@ -341,7 +341,7 @@ void cmExportFileGenerator::PopulateSourcesInterface( } if (!*input) { - properties[propName] = ""; + properties[propName].clear(); return; } @@ -394,7 +394,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( } if ((input && !*input) && exportDirs.empty()) { // Set to empty - properties[propName] = ""; + properties[propName].clear(); return; } @@ -565,7 +565,7 @@ void cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( cmGeneratorExpression::Split(input, parts); std::string sep; - input = ""; + input.clear(); for (std::string& li : parts) { if (cmGeneratorExpression::Find(li) == std::string::npos) { this->AddTargetNamespace(li, target, missingTargets); @@ -713,7 +713,7 @@ void cmExportFileGenerator::SetImportLinkInterface( } if (!*propContent) { - properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = ""; + properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix].clear(); return; } diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index b2c1589..a200385 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -222,7 +222,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(std::ostream& out, std::string valueToUse; if (!envVarSet && cacheValue == nullptr) { // nothing known, do nothing - valueToUse = ""; + valueToUse.clear(); } else if (envVarSet && cacheValue == nullptr) { // The variable is in the env, but not in the cache. Use it and put it // in the cache @@ -891,7 +891,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const std::string subdir = lgen->ConvertToRelativePath( this->HomeOutputDirectory, lgen->GetCurrentBinaryDirectory()); if (subdir == ".") { - subdir = ""; + subdir.clear(); } for (cmGeneratorTarget* target : targets) { diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 78cf3ec..73a9c85 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -274,7 +274,7 @@ void cmExtraSublimeTextGenerator::AppendTarget( if (flagRegex.end() < workString.size()) { workString = workString.substr(flagRegex.end()); } else { - workString = ""; + workString.clear(); } } } diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 35ebb47..98c5733 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -656,7 +656,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) c = current_str[current_str.size() - 1 - j]; fin.putback(static_cast<char>(c)); } - current_str = ""; + current_str.clear(); } } @@ -667,14 +667,14 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) if (s.length() >= minlen && (!have_regex || regex.find(s.c_str()))) { output_size += static_cast<int>(s.size()) + 1; if (limit_output >= 0 && output_size >= limit_output) { - s = ""; + s.clear(); break; } strings.push_back(s); } // Reset the string to empty. - s = ""; + s.clear(); } else if (current_str.empty()) { // A non-string character has been found. Check if the current // string matches the requirements. We require that the length @@ -683,14 +683,14 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) (!have_regex || regex.find(s.c_str()))) { output_size += static_cast<int>(s.size()) + 1; if (limit_output >= 0 && output_size >= limit_output) { - s = ""; + s.clear(); break; } strings.push_back(s); } // Reset the string to empty. - s = ""; + s.clear(); } else { s += current_str; } @@ -700,12 +700,12 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) if (s.length() >= minlen && (!have_regex || regex.find(s.c_str()))) { output_size += static_cast<int>(s.size()) + 1; if (limit_output >= 0 && output_size >= limit_output) { - s = ""; + s.clear(); break; } strings.push_back(s); } - s = ""; + s.clear(); } } diff --git a/Source/cmFileLock.cxx b/Source/cmFileLock.cxx index 786d6c6..f309241 100644 --- a/Source/cmFileLock.cxx +++ b/Source/cmFileLock.cxx @@ -42,7 +42,7 @@ cmFileLockResult cmFileLock::Lock(const std::string& filename, } if (!result.IsOk()) { - this->Filename = ""; + this->Filename.clear(); } return result; diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx index 35a8a44..ea26410 100644 --- a/Source/cmFindPathCommand.cxx +++ b/Source/cmFindPathCommand.cxx @@ -85,7 +85,7 @@ std::string cmFindPathCommand::FindHeaderInFramework(std::string const& file, // if the framework has a path in it then just use the filename if (frameWorkName.find('/') != std::string::npos) { fileName = file; - frameWorkName = ""; + frameWorkName.clear(); } if (!frameWorkName.empty()) { std::string fpath = dir; diff --git a/Source/cmFortranParserImpl.cxx b/Source/cmFortranParserImpl.cxx index ce98c6b..81f1286 100644 --- a/Source/cmFortranParserImpl.cxx +++ b/Source/cmFortranParserImpl.cxx @@ -126,7 +126,7 @@ int cmFortranParser_Input(cmFortranParser* parser, char* buffer, void cmFortranParser_StringStart(cmFortranParser* parser) { - parser->TokenString = ""; + parser->TokenString.clear(); } const char* cmFortranParser_StringEnd(cmFortranParser* parser) diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index dd76ad5..d4b501f 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -68,7 +68,7 @@ const char* cmCompiledGeneratorExpression::EvaluateWithContext( return this->Input.c_str(); } - this->Output = ""; + this->Output.clear(); std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it = this->Evaluators.begin(); @@ -81,7 +81,7 @@ const char* cmCompiledGeneratorExpression::EvaluateWithContext( this->SeenTargetProperties.insert(context.SeenTargetProperties.begin(), context.SeenTargetProperties.end()); if (context.HadError) { - this->Output = ""; + this->Output.clear(); break; } } @@ -296,7 +296,7 @@ void cmGeneratorExpression::Split(const std::string& input, std::string::size_type startPos = input.rfind(';', pos); if (startPos == std::string::npos) { preGenex = part; - part = ""; + part.clear(); } else if (startPos != pos - 1 && startPos >= lastPos) { part = input.substr(lastPos, startPos - lastPos); preGenex = input.substr(startPos + 1, pos - startPos - 1); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 9946b1e..28b43e7 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3023,7 +3023,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName, impName = this->GetFullNameInternal(config, cmStateEnums::ImportLibraryArtifact); } else { - impName = ""; + impName.clear(); } // The program database file name. @@ -3126,9 +3126,9 @@ void cmGeneratorTarget::GetFullNameInternal( this->GetType() != cmStateEnums::SHARED_LIBRARY && this->GetType() != cmStateEnums::MODULE_LIBRARY && this->GetType() != cmStateEnums::EXECUTABLE) { - outPrefix = ""; + outPrefix.clear(); outBase = this->GetName(); - outSuffix = ""; + outSuffix.clear(); return; } @@ -3139,9 +3139,9 @@ void cmGeneratorTarget::GetFullNameInternal( // does not support import libraries. if (isImportedLibraryArtifact && !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) { - outPrefix = ""; - outBase = ""; - outSuffix = ""; + outPrefix.clear(); + outBase.clear(); + outSuffix.clear(); return; } @@ -4488,7 +4488,7 @@ bool cmGeneratorTarget::ComputeOutputDir(const std::string& config, out = cge->Evaluate(this->LocalGenerator, config); // Skip per-configuration subdirectory. - conf = ""; + conf.clear(); } else if (const char* outdir = this->GetProperty(propertyName)) { // Use the user-specified output directory. cmGeneratorExpression ge; @@ -4498,7 +4498,7 @@ bool cmGeneratorTarget::ComputeOutputDir(const std::string& config, // Skip per-configuration subdirectory if the value contained a // generator expression. if (out != outdir) { - conf = ""; + conf.clear(); } } else if (this->GetType() == cmStateEnums::EXECUTABLE) { // Lookup the output path for executables. @@ -4564,7 +4564,7 @@ bool cmGeneratorTarget::ComputePDBOutputDir(const std::string& kind, out = config_outdir; // Skip per-configuration subdirectory. - conf = ""; + conf.clear(); } else if (const char* outdir = this->GetProperty(propertyName)) { // Use the user-specified output directory. out = outdir; diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 392b6e1..8c9e461 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -407,14 +407,14 @@ bool cmGlobalVisualStudio10Generator::InitializeWindowsStore(cmMakefile* mf) bool cmGlobalVisualStudio10Generator::SelectWindowsPhoneToolset( std::string& toolset) const { - toolset = ""; + toolset.clear(); return false; } bool cmGlobalVisualStudio10Generator::SelectWindowsStoreToolset( std::string& toolset) const { - toolset = ""; + toolset.clear(); return false; } diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 2ed51a0..8c1111e 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -403,7 +403,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( std::string dir = lg->GetCurrentBinaryDirectory(); dir = root->ConvertToRelativePath(rootBinaryDir, dir.c_str()); if (dir == ".") { - dir = ""; // msbuild cannot handle ".\" prefix + dir.clear(); // msbuild cannot handle ".\" prefix } this->WriteProject(fout, vcprojName, dir.c_str(), target); written = true; @@ -418,7 +418,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( std::vector<cmsys::String> tokens = cmSystemTools::SplitString(targetFolder, '/', false); - std::string cumulativePath = ""; + std::string cumulativePath; for (std::vector<cmsys::String>::iterator iter = tokens.begin(); iter != tokens.end(); ++iter) { diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 9a08084..cc1d1a2 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -301,7 +301,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() // file as the main dependency because it would get // overwritten by the CreateVCProjBuildRule. // (this could be avoided with per-target source files) - std::string no_main_dependency = ""; + std::string no_main_dependency; std::vector<std::string> no_byproducts; if (cmSourceFile* file = mf->AddCustomCommandToOutput( stamps, no_byproducts, listFiles, no_main_dependency, commandLines, diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx index b81f7cb..4c30607 100644 --- a/Source/cmIncludeDirectoryCommand.cxx +++ b/Source/cmIncludeDirectoryCommand.cxx @@ -116,7 +116,7 @@ void cmIncludeDirectoryCommand::NormalizeInclude(std::string& inc) if ((b != std::string::npos) && (e != std::string::npos)) { inc.assign(inc, b, 1 + e - b); // copy the remaining substring } else { - inc = ""; + inc.clear(); return; } diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx index 179521e..ff6420d 100644 --- a/Source/cmInstallCommandArguments.cxx +++ b/Source/cmInstallCommandArguments.cxx @@ -153,7 +153,7 @@ void cmInstallCommandArguments::Parse(const std::vector<std::string>* args, bool cmInstallCommandArguments::CheckPermissions() { - this->PermissionsString = ""; + this->PermissionsString.clear(); for (std::string const& perm : this->Permissions.GetVector()) { if (!this->CheckPermissions(perm, this->PermissionsString)) { return false; diff --git a/Source/cmLoadCacheCommand.cxx b/Source/cmLoadCacheCommand.cxx index 419b2e4..32fdef5 100644 --- a/Source/cmLoadCacheCommand.cxx +++ b/Source/cmLoadCacheCommand.cxx @@ -124,7 +124,7 @@ bool cmLoadCacheCommand::ReadWithPrefix(std::vector<std::string> const& args) if (i != end) { // Completed a line. this->CheckLine(line.c_str()); - line = ""; + line.clear(); // Skip the newline character. ++i; diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx index d255173..50ebfa1 100644 --- a/Source/cmLocalCommonGenerator.cxx +++ b/Source/cmLocalCommonGenerator.cxx @@ -22,7 +22,7 @@ cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg, this->ConfigName = config; } else { // No configuration type given. - this->ConfigName = ""; + this->ConfigName.clear(); } } diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 8a7f455..73f5a16 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -55,7 +55,7 @@ void cmLocalNinjaGenerator::Generate() this->HomeRelativeOutputPath = this->ConvertToRelativePath( this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory()); if (this->HomeRelativeOutputPath == ".") { - this->HomeRelativeOutputPath = ""; + this->HomeRelativeOutputPath.clear(); } this->WriteProcessedMakefile(this->GetBuildFileStream()); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 7f7ec4f..df02f84 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -144,7 +144,7 @@ void cmLocalUnixMakefileGenerator3::ComputeHomeRelativeOutputPath() this->HomeRelativeOutputPath = this->MaybeConvertToRelativePath( this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory()); if (this->HomeRelativeOutputPath == ".") { - this->HomeRelativeOutputPath = ""; + this->HomeRelativeOutputPath.clear(); } if (!this->HomeRelativeOutputPath.empty()) { this->HomeRelativeOutputPath += "/"; @@ -1163,7 +1163,7 @@ void cmLocalUnixMakefileGenerator3::AppendEcho( } // Reset the line to emtpy. - line = ""; + line.clear(); // Progress appears only on first line. progress = nullptr; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index fc42d6e..c978936 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -121,7 +121,7 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() force_command.push_back("."); cmCustomCommandLines force_commands; force_commands.push_back(force_command); - std::string no_main_dependency = ""; + std::string no_main_dependency; std::string force = this->GetCurrentBinaryDirectory(); force += cmake::GetCMakeFilesDirectory(); force += "/"; @@ -2081,7 +2081,7 @@ public: this->GUID = atts[i + 1]; this->GUID = this->GUID.substr(1, this->GUID.size() - 2); } else { - this->GUID = ""; + this->GUID.clear(); } return; } diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index d772d95..718c8cd 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -135,7 +135,7 @@ std::string cmLocalVisualStudioGenerator::ConstructScript( std::string workingDirectory = ccg.GetWorkingDirectory(); // Avoid leading or trailing newlines. - std::string newline = ""; + std::string newline; // Line to check for error between commands. std::string check_error = newline_text; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 845568b..e51cfcc 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1645,7 +1645,7 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, nvalue = value ? value : ""; cmSystemTools::ExpandListArgument(nvalue, files); - nvalue = ""; + nvalue.clear(); for (cc = 0; cc < files.size(); cc++) { if (!cmSystemTools::IsOff(files[cc].c_str())) { files[cc] = cmSystemTools::CollapseFullPath(files[cc]); @@ -2448,7 +2448,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringOld( std::string input = source; // Start with empty output. - source = ""; + source.clear(); // Look for one @VAR@ at a time. const char* in = input.c_str(); @@ -3348,7 +3348,7 @@ std::string cmMakefile::GetModulesFile(const char* filename) const moduleInCMakeRoot += filename; cmSystemTools::ConvertToUnixSlashes(moduleInCMakeRoot); if (!cmSystemTools::FileExists(moduleInCMakeRoot.c_str())) { - moduleInCMakeRoot = ""; + moduleInCMakeRoot.clear(); } // Normally, prefer the files found in CMAKE_MODULE_PATH. Only when the file @@ -3532,7 +3532,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile, std::string inLine; std::string outLine; while (cmSystemTools::GetLineFromStream(fin, inLine)) { - outLine = ""; + outLine.clear(); this->ConfigureString(inLine, outLine, atOnly, escapeQuotes); fout << outLine << newLineCharacters; } diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 1e4e02e..d0aad30 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1261,7 +1261,7 @@ public: (this->CurrentString.length() + 1 + this->NextObject.length() > this->LengthLimit)) { this->Strings.push_back(this->CurrentString); - this->CurrentString = ""; + this->CurrentString.clear(); this->Space = ""; } diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 8b331d5..e0844e8 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -667,7 +667,7 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement() std::string t = vars["ARCH_FLAGS"]; localGen.AddArchitectureFlags(t, &genTarget, cudaLinkLanguage, cfgName); vars["ARCH_FLAGS"] = t; - t = ""; + t.clear(); localGen.AddLanguageFlagsForLinking(t, &genTarget, cudaLinkLanguage, cfgName); vars["LANGUAGE_COMPILE_FLAGS"] = t; @@ -884,7 +884,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() std::string t = vars["ARCH_FLAGS"]; localGen.AddArchitectureFlags(t, &genTarget, TargetLinkLanguage, cfgName); vars["ARCH_FLAGS"] = t; - t = ""; + t.clear(); t += lwyuFlags; localGen.AddLanguageFlagsForLinking(t, &genTarget, TargetLinkLanguage, cfgName); @@ -1070,7 +1070,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() if (targetOutputReal == soName || targetOutput == soName) { symlinkVars["SONAME"] = soName; } else { - symlinkVars["SONAME"] = ""; + symlinkVars["SONAME"].clear(); symlinks.push_back(soName); } symlinks.push_back(targetOutput); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 3c1463a..a464d6e 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -425,7 +425,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang) // The explicit preprocessing step will handle dependency scanning. } else if (this->NeedDepTypeMSVC(lang)) { deptype = "msvc"; - depfile = ""; + depfile.clear(); flags += " /showIncludes"; } else if (mf->IsOn("CMAKE_NINJA_CMCLDEPS_" + lang)) { // For the MS resource compiler we need cmcldeps, but skip dependencies diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index 26816cb..c430298 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -362,7 +362,7 @@ protected: } else { // Destroy the name of the file so that it won't be output as a // dependency. - info->FullPath = ""; + info->FullPath.clear(); } } } diff --git a/Source/cmProcessTools.cxx b/Source/cmProcessTools.cxx index 67b4a97..05b1b00 100644 --- a/Source/cmProcessTools.cxx +++ b/Source/cmProcessTools.cxx @@ -73,11 +73,11 @@ bool cmProcessTools::LineParser::ProcessChunk(const char* first, int length) // Hand this line to the subclass implementation. if (!this->ProcessLine()) { - this->Line = ""; + this->Line.clear(); return false; } - this->Line = ""; + this->Line.clear(); } else if (*c != '\r' || !this->IgnoreCR) { // Append this character to the line under construction. this->Line.append(1, *c); diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx index 783e308..112be4d 100644 --- a/Source/cmRST.cxx +++ b/Source/cmRST.cxx @@ -86,7 +86,7 @@ void cmRST::ProcessModule(std::istream& is) if (line[0] != '#') { this->ProcessLine(line.substr(0, pos)); } - rst = ""; + rst.clear(); this->Reset(); this->OutputLinePending = true; } @@ -101,7 +101,7 @@ void cmRST::ProcessModule(std::istream& is) this->ProcessLine(line.substr(2)); continue; } - rst = ""; + rst.clear(); this->Reset(); this->OutputLinePending = true; } @@ -345,7 +345,7 @@ void cmRST::ProcessDirectiveReplace() // Record markup lines as replacement text. std::string& replacement = this->Replace[this->ReplaceName]; replacement += cmJoin(this->MarkupLines, " "); - this->ReplaceName = ""; + this->ReplaceName.clear(); } void cmRST::ProcessDirectiveTocTree() diff --git a/Source/cmScriptGenerator.cxx b/Source/cmScriptGenerator.cxx index 5346b77..2cae714 100644 --- a/Source/cmScriptGenerator.cxx +++ b/Source/cmScriptGenerator.cxx @@ -26,7 +26,7 @@ void cmScriptGenerator::Generate( this->ConfigurationName = config; this->ConfigurationTypes = &configurationTypes; this->GenerateScript(os); - this->ConfigurationName = ""; + this->ConfigurationName.clear(); this->ConfigurationTypes = nullptr; } diff --git a/Source/cmSearchPath.cxx b/Source/cmSearchPath.cxx index 26c0de2..a40c987 100644 --- a/Source/cmSearchPath.cxx +++ b/Source/cmSearchPath.cxx @@ -172,7 +172,7 @@ void cmSearchPath::AddPrefixPaths(const std::vector<std::string>& paths, } else if (this->FC->CMakePathName == "LIBRARY") { subdir = "lib"; } else if (this->FC->CMakePathName == "FRAMEWORK") { - subdir = ""; // ? what to do for frameworks ? + subdir.clear(); // ? what to do for frameworks ? } for (std::string const& path : paths) { diff --git a/Source/cmStateDirectory.cxx b/Source/cmStateDirectory.cxx index 418f051..5aa8e5b 100644 --- a/Source/cmStateDirectory.cxx +++ b/Source/cmStateDirectory.cxx @@ -80,7 +80,7 @@ void cmStateDirectory::ComputeRelativePathTopBinary() if (result.size() < 2 || result.substr(0, 2) != "//") { this->DirectoryState->RelativePathTopBinary = result; } else { - this->DirectoryState->RelativePathTopBinary = ""; + this->DirectoryState->RelativePathTopBinary.clear(); } } @@ -422,7 +422,7 @@ const char* cmStateDirectory::GetProperty(const std::string& prop, bool chain) const { static std::string output; - output = ""; + output.clear(); if (prop == "PARENT_DIRECTORY") { cmStateSnapshot parent = this->Snapshot_.GetBuildsystemDirectoryParent(); if (parent.IsValid()) { diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 4118664..5f2737d 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -458,7 +458,7 @@ void cmSystemTools::ParseWindowsCommandLine(const char* command, arg.append(1, *c); } else if (in_argument) { args.push_back(arg); - arg = ""; + arg.clear(); in_argument = false; } } else { @@ -559,7 +559,7 @@ std::vector<std::string> cmSystemTools::ParseArguments(const char* command) while (*c == ' ' || *c == '\t') { ++c; } - arg = ""; + arg.clear(); if (*c == '"') { // Parse a quoted argument. ++c; @@ -1184,7 +1184,7 @@ void cmSystemTools::ExpandListArgument(const std::string& arg, if (!newArg.empty() || emptyArgs) { // Add the last argument if the string is not empty. newargs.push_back(newArg); - newArg = ""; + newArg.clear(); } } } break; @@ -1771,7 +1771,7 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line, double timeout, std::vector<char>& out, std::vector<char>& err) { - line = ""; + line.clear(); std::vector<char>::iterator outiter = out.begin(); std::vector<char>::iterator erriter = err.begin(); cmProcessOutput processOutput; @@ -2111,19 +2111,19 @@ void cmSystemTools::FindCMakeResources(const char* argv0) cmSystemToolsCMakeGUICommand += "/cmake-gui"; cmSystemToolsCMakeGUICommand += cmSystemTools::GetExecutableExtension(); if (!cmSystemTools::FileExists(cmSystemToolsCMakeGUICommand.c_str())) { - cmSystemToolsCMakeGUICommand = ""; + cmSystemToolsCMakeGUICommand.clear(); } cmSystemToolsCMakeCursesCommand = exe_dir; cmSystemToolsCMakeCursesCommand += "/ccmake"; cmSystemToolsCMakeCursesCommand += cmSystemTools::GetExecutableExtension(); if (!cmSystemTools::FileExists(cmSystemToolsCMakeCursesCommand.c_str())) { - cmSystemToolsCMakeCursesCommand = ""; + cmSystemToolsCMakeCursesCommand.clear(); } cmSystemToolsCMClDepsCommand = exe_dir; cmSystemToolsCMClDepsCommand += "/cmcldeps"; cmSystemToolsCMClDepsCommand += cmSystemTools::GetExecutableExtension(); if (!cmSystemTools::FileExists(cmSystemToolsCMClDepsCommand.c_str())) { - cmSystemToolsCMClDepsCommand = ""; + cmSystemToolsCMClDepsCommand.clear(); } #ifdef CMAKE_BUILD_WITH_CMAKE diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8d21e68..c26d49a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1530,7 +1530,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, } // If it was found, set the suffix. if (*loc || *imp) { - suffix = ""; + suffix.clear(); } } else { std::string mcUpper = cmSystemTools::UpperCase(*mci); @@ -1577,7 +1577,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, // configurations and no exact match. if (!*loc && !*imp) { // The suffix computed above is not useful. - suffix = ""; + suffix.clear(); // Look for a configuration-less location. This may be set by // manually-written code. diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index cc93b03..dcaa493 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -33,11 +33,11 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv, // build an arg list for TryCompile and extract the runArgs, std::vector<std::string> tryCompile; - this->CompileResultVariable = ""; - this->RunResultVariable = ""; - this->OutputVariable = ""; - this->RunOutputVariable = ""; - this->CompileOutputVariable = ""; + this->CompileResultVariable.clear(); + this->RunResultVariable.clear(); + this->OutputVariable.clear(); + this->RunOutputVariable.clear(); + this->CompileOutputVariable.clear(); std::string runArgs; unsigned int i; diff --git a/Source/cmVS10LinkFlagTable.h b/Source/cmVS10LinkFlagTable.h index c30ea9a..6a0313a 100644 --- a/Source/cmVS10LinkFlagTable.h +++ b/Source/cmVS10LinkFlagTable.h @@ -29,6 +29,8 @@ static cmVS7FlagTable cmVS10LinkFlagTable[] = { { "CreateHotPatchableImage", "FUNCTIONPADMIN:16", "Itanium Image Only", "ItaniumImage", 0 }, + // correct flags for uac should be /MANIFESTUAC, but some projects already + // use this bug to access uac field, so keep these for compatibility { "UACExecutionLevel", "level='asInvoker'", "asInvoker", "AsInvoker", 0 }, { "UACExecutionLevel", "level='highestAvailable'", "highestAvailable", "HighestAvailable", 0 }, @@ -123,8 +125,12 @@ static cmVS7FlagTable cmVS10LinkFlagTable[] = { { "GenerateManifest", "MANIFEST:NO", "", "false", 0 }, { "GenerateManifest", "MANIFEST", "", "true", 0 }, { "AllowIsolation", "ALLOWISOLATION:NO", "", "false", 0 }, + + // correct flags for uac should be /MANIFESTUAC, but some projects already + // use this bug to access uac field, so keep these for compatibility { "UACUIAccess", "uiAccess='false'", "", "false", 0 }, { "UACUIAccess", "uiAccess='true'", "", "true", 0 }, + { "GenerateDebugInformation", "DEBUG", "", "true", cmVS7FlagTable::CaseInsensitive }, { "MapExports", "MAPINFO:EXPORTS", "", "true", 0 }, @@ -162,11 +168,8 @@ static cmVS7FlagTable cmVS10LinkFlagTable[] = { { "LinkDLL", "DLL", "", "true", 0 }, // Bool Properties With Argument - { "EnableUAC", "MANIFESTUAC:NO", "", "false", 0 }, - { "EnableUAC", "MANIFESTUAC:", "", "true", - cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, - { "UACUIAccess", "MANIFESTUAC:", "Enable User Account Control (UAC)", "", - cmVS7FlagTable::UserValueRequired }, + { "EnableUAC", "MANIFESTUAC:", "", "", + cmVS7FlagTable::UserValueRequired | cmVS7FlagTable::SpaceAppendable }, { "GenerateMapFile", "MAP", "", "true", cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, { "MapFileName", "MAP:", "Generate Map File", "", diff --git a/Source/cmVS11LinkFlagTable.h b/Source/cmVS11LinkFlagTable.h index 1b3a046..24ba8fd 100644 --- a/Source/cmVS11LinkFlagTable.h +++ b/Source/cmVS11LinkFlagTable.h @@ -29,6 +29,8 @@ static cmVS7FlagTable cmVS11LinkFlagTable[] = { { "CreateHotPatchableImage", "FUNCTIONPADMIN:16", "Itanium Image Only", "ItaniumImage", 0 }, + // correct flags for uac should be /MANIFESTUAC, but some projects already + // use this bug to access uac field, so keep these for compatibility { "UACExecutionLevel", "level='asInvoker'", "asInvoker", "AsInvoker", 0 }, { "UACExecutionLevel", "level='highestAvailable'", "highestAvailable", "HighestAvailable", 0 }, @@ -135,8 +137,12 @@ static cmVS7FlagTable cmVS11LinkFlagTable[] = { { "GenerateManifest", "MANIFEST:NO", "", "false", 0 }, { "GenerateManifest", "MANIFEST", "", "true", 0 }, { "AllowIsolation", "ALLOWISOLATION:NO", "", "false", 0 }, + + // correct flags for uac should be /MANIFESTUAC, but some projects already + // use this bug to access uac field, so keep these for compatibility { "UACUIAccess", "uiAccess='false'", "", "false", 0 }, { "UACUIAccess", "uiAccess='true'", "", "true", 0 }, + { "ManifestEmbed", "manifest:embed", "", "true", 0 }, { "GenerateDebugInformation", "DEBUG", "", "true", cmVS7FlagTable::CaseInsensitive }, @@ -179,11 +185,8 @@ static cmVS7FlagTable cmVS11LinkFlagTable[] = { { "LinkDLL", "DLL", "", "true", 0 }, // Bool Properties With Argument - { "EnableUAC", "MANIFESTUAC:NO", "", "false", 0 }, - { "EnableUAC", "MANIFESTUAC:", "", "true", - cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, - { "UACUIAccess", "MANIFESTUAC:", "Enable User Account Control (UAC)", "", - cmVS7FlagTable::UserValueRequired }, + { "EnableUAC", "MANIFESTUAC:", "", "", + cmVS7FlagTable::UserValueRequired | cmVS7FlagTable::SpaceAppendable }, { "GenerateMapFile", "MAP", "", "true", cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, { "MapFileName", "MAP:", "Generate Map File", "", diff --git a/Source/cmVS12LinkFlagTable.h b/Source/cmVS12LinkFlagTable.h index 168c34c..fc667c3 100644 --- a/Source/cmVS12LinkFlagTable.h +++ b/Source/cmVS12LinkFlagTable.h @@ -29,6 +29,8 @@ static cmVS7FlagTable cmVS12LinkFlagTable[] = { { "CreateHotPatchableImage", "FUNCTIONPADMIN:16", "Itanium Image Only", "ItaniumImage", 0 }, + // correct flags for uac should be /MANIFESTUAC, but some projects already + // use this bug to access uac field, so keep these for compatibility { "UACExecutionLevel", "level='asInvoker'", "asInvoker", "AsInvoker", 0 }, { "UACExecutionLevel", "level='highestAvailable'", "highestAvailable", "HighestAvailable", 0 }, @@ -135,8 +137,12 @@ static cmVS7FlagTable cmVS12LinkFlagTable[] = { { "GenerateManifest", "MANIFEST:NO", "", "false", 0 }, { "GenerateManifest", "MANIFEST", "", "true", 0 }, { "AllowIsolation", "ALLOWISOLATION:NO", "", "false", 0 }, + + // correct flags for uac should be /MANIFESTUAC, but some projects already + // use this bug to access uac field, so keep these for compatibility { "UACUIAccess", "uiAccess='false'", "", "false", 0 }, { "UACUIAccess", "uiAccess='true'", "", "true", 0 }, + { "ManifestEmbed", "manifest:embed", "", "true", 0 }, { "GenerateDebugInformation", "DEBUG", "", "true", cmVS7FlagTable::CaseInsensitive }, @@ -179,11 +185,8 @@ static cmVS7FlagTable cmVS12LinkFlagTable[] = { { "LinkDLL", "DLL", "", "true", 0 }, // Bool Properties With Argument - { "EnableUAC", "MANIFESTUAC:NO", "", "false", 0 }, - { "EnableUAC", "MANIFESTUAC:", "", "true", - cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, - { "UACUIAccess", "MANIFESTUAC:", "Enable User Account Control (UAC)", "", - cmVS7FlagTable::UserValueRequired }, + { "EnableUAC", "MANIFESTUAC:", "", "", + cmVS7FlagTable::UserValueRequired | cmVS7FlagTable::SpaceAppendable }, { "GenerateMapFile", "MAP", "", "true", cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, { "MapFileName", "MAP:", "Generate Map File", "", diff --git a/Source/cmVS140LinkFlagTable.h b/Source/cmVS140LinkFlagTable.h index b9a4dc3..7c9452a 100644 --- a/Source/cmVS140LinkFlagTable.h +++ b/Source/cmVS140LinkFlagTable.h @@ -29,6 +29,8 @@ static cmVS7FlagTable cmVS140LinkFlagTable[] = { { "CreateHotPatchableImage", "FUNCTIONPADMIN:16", "Itanium Image Only", "ItaniumImage", 0 }, + // correct flags for uac should be /MANIFESTUAC, but some projects already + // use this bug to access uac field, so keep these for compatibility { "UACExecutionLevel", "level='asInvoker'", "asInvoker", "AsInvoker", 0 }, { "UACExecutionLevel", "level='highestAvailable'", "highestAvailable", "HighestAvailable", 0 }, @@ -148,8 +150,12 @@ static cmVS7FlagTable cmVS140LinkFlagTable[] = { { "GenerateManifest", "MANIFEST:NO", "", "false", 0 }, { "GenerateManifest", "MANIFEST", "", "true", 0 }, { "AllowIsolation", "ALLOWISOLATION:NO", "", "false", 0 }, + + // correct flags for uac should be /MANIFESTUAC, but some projects already + // use this bug to access uac field, so keep these for compatibility { "UACUIAccess", "uiAccess='false'", "", "false", 0 }, { "UACUIAccess", "uiAccess='true'", "", "true", 0 }, + { "ManifestEmbed", "manifest:embed", "", "true", 0 }, { "MapExports", "MAPINFO:EXPORTS", "", "true", 0 }, { "AssemblyDebug", "ASSEMBLYDEBUG:DISABLE", "", "false", 0 }, @@ -190,11 +196,8 @@ static cmVS7FlagTable cmVS140LinkFlagTable[] = { { "LinkDLL", "DLL", "", "true", 0 }, // Bool Properties With Argument - { "EnableUAC", "MANIFESTUAC:NO", "", "false", 0 }, - { "EnableUAC", "MANIFESTUAC:", "", "true", - cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, - { "UACUIAccess", "MANIFESTUAC:", "Enable User Account Control (UAC)", "", - cmVS7FlagTable::UserValueRequired }, + { "EnableUAC", "MANIFESTUAC:", "", "", + cmVS7FlagTable::UserValueRequired | cmVS7FlagTable::SpaceAppendable }, { "GenerateMapFile", "MAP", "", "true", cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, { "MapFileName", "MAP:", "Generate Map File", "", diff --git a/Source/cmVS141LinkFlagTable.h b/Source/cmVS141LinkFlagTable.h index a440ee7..f159f70 100644 --- a/Source/cmVS141LinkFlagTable.h +++ b/Source/cmVS141LinkFlagTable.h @@ -29,6 +29,8 @@ static cmVS7FlagTable cmVS141LinkFlagTable[] = { { "CreateHotPatchableImage", "FUNCTIONPADMIN:16", "Itanium Image Only", "ItaniumImage", 0 }, + // correct flags for uac should be /MANIFESTUAC, but some projects already + // use this bug to access uac field, so keep these for compatibility { "UACExecutionLevel", "level='asInvoker'", "asInvoker", "AsInvoker", 0 }, { "UACExecutionLevel", "level='highestAvailable'", "highestAvailable", "HighestAvailable", 0 }, @@ -150,8 +152,12 @@ static cmVS7FlagTable cmVS141LinkFlagTable[] = { { "GenerateManifest", "MANIFEST:NO", "", "false", 0 }, { "GenerateManifest", "MANIFEST", "", "true", 0 }, { "AllowIsolation", "ALLOWISOLATION:NO", "", "false", 0 }, + + // correct flags for uac should be /MANIFESTUAC, but some projects already + // use this bug to access uac field, so keep these for compatibility { "UACUIAccess", "uiAccess='false'", "", "false", 0 }, { "UACUIAccess", "uiAccess='true'", "", "true", 0 }, + { "ManifestEmbed", "manifest:embed", "", "true", 0 }, { "MapExports", "MAPINFO:EXPORTS", "", "true", 0 }, { "AssemblyDebug", "ASSEMBLYDEBUG:DISABLE", "", "false", 0 }, @@ -192,11 +198,8 @@ static cmVS7FlagTable cmVS141LinkFlagTable[] = { { "LinkDLL", "DLL", "", "true", 0 }, // Bool Properties With Argument - { "EnableUAC", "MANIFESTUAC:NO", "", "false", 0 }, - { "EnableUAC", "MANIFESTUAC:", "", "true", - cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, - { "UACUIAccess", "MANIFESTUAC:", "Enable User Account Control (UAC)", "", - cmVS7FlagTable::UserValueRequired }, + { "EnableUAC", "MANIFESTUAC:", "", "", + cmVS7FlagTable::UserValueRequired | cmVS7FlagTable::SpaceAppendable }, { "GenerateMapFile", "MAP", "", "true", cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, { "MapFileName", "MAP:", "Generate Map File", "", diff --git a/Source/cmVSSetupHelper.cxx b/Source/cmVSSetupHelper.cxx index 7168f26..3c50403 100644 --- a/Source/cmVSSetupHelper.cxx +++ b/Source/cmVSSetupHelper.cxx @@ -218,7 +218,7 @@ bool cmVSSetupAPIHelper::GetVSInstanceInfo( bool cmVSSetupAPIHelper::GetVSInstanceInfo(std::string& vsInstallLocation) { - vsInstallLocation = ""; + vsInstallLocation.clear(); bool isInstalled = this->EnumerateAndChooseVSInstance(); if (isInstalled) { diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index cbc5173..99b9bce 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1612,7 +1612,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) std::string srcDir = this->Makefile->GetCurrentSourceDirectory(); std::string binDir = this->Makefile->GetCurrentBinaryDirectory(); if (fullFileName.find(binDir) != std::string::npos) { - sourceLink = ""; + sourceLink.clear(); } else if (fullFileName.find(srcDir) != std::string::npos) { sourceLink = fullFileName.substr(srcDir.length() + 1); } else { @@ -3260,6 +3260,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( } linkOptions.Parse(flags.c_str()); + linkOptions.FixManifestUACFlags(); if (this->MSTools) { cmGeneratorTarget::ModuleDefinitionInfo const* mdi = diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index 51944fa..b1686be 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -256,6 +256,74 @@ void cmVisualStudioGeneratorOptions::FixCudaCodeGeneration() } } +void cmVisualStudioGeneratorOptions::FixManifestUACFlags() +{ + static const char* ENABLE_UAC = "EnableUAC"; + if (!HasFlag(ENABLE_UAC)) { + return; + } + + const std::string uacFlag = GetFlag(ENABLE_UAC); + std::vector<std::string> subOptions; + cmsys::SystemTools::Split(uacFlag, subOptions, ' '); + if (subOptions.empty()) { + AddFlag(ENABLE_UAC, "true"); + return; + } + + if (subOptions.size() == 1 && subOptions[0] == "NO") { + AddFlag(ENABLE_UAC, "false"); + return; + } + + std::map<std::string, std::string> uacMap; + uacMap["level"] = "UACExecutionLevel"; + uacMap["uiAccess"] = "UACUIAccess"; + + std::map<std::string, std::string> uacExecuteLevelMap; + uacExecuteLevelMap["asInvoker"] = "AsInvoker"; + uacExecuteLevelMap["highestAvailable"] = "HighestAvailable"; + uacExecuteLevelMap["requireAdministrator"] = "RequireAdministrator"; + + for (auto const& subopt : subOptions) { + std::vector<std::string> keyValue; + cmsys::SystemTools::Split(subopt, keyValue, '='); + if (keyValue.size() != 2 || (uacMap.find(keyValue[0]) == uacMap.end())) { + // ignore none key=value option or unknown flags + continue; + } + + if (keyValue[1].front() == '\'' && keyValue[1].back() == '\'') { + keyValue[1] = + keyValue[1].substr(1, std::max<int>(0, keyValue[1].size() - 2)); + } + + if (keyValue[0] == "level") { + if (uacExecuteLevelMap.find(keyValue[1]) == uacExecuteLevelMap.end()) { + // unknown level value + continue; + } + + AddFlag(uacMap[keyValue[0]].c_str(), + uacExecuteLevelMap[keyValue[1]].c_str()); + continue; + } + + if (keyValue[0] == "uiAccess") { + if (keyValue[1] != "true" && keyValue[1] != "false") { + // unknown uiAccess value + continue; + } + AddFlag(uacMap[keyValue[0]].c_str(), keyValue[1].c_str()); + continue; + } + + // unknwon sub option + } + + AddFlag(ENABLE_UAC, "true"); +} + void cmVisualStudioGeneratorOptions::Parse(const char* flags) { // Parse the input string as a windows command line since the string diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h index 8d7942b..7c08a2c 100644 --- a/Source/cmVisualStudioGeneratorOptions.h +++ b/Source/cmVisualStudioGeneratorOptions.h @@ -77,6 +77,8 @@ public: void FixCudaCodeGeneration(); + void FixManifestUACFlags(); + bool IsDebug() const; bool IsWinRt() const; bool IsManaged() const; diff --git a/Source/cmVisualStudioSlnParser.cxx b/Source/cmVisualStudioSlnParser.cxx index 1a32aba..a9acb3f 100644 --- a/Source/cmVisualStudioSlnParser.cxx +++ b/Source/cmVisualStudioSlnParser.cxx @@ -329,7 +329,7 @@ bool cmVisualStudioSlnParser::State::Process( case FileStateIgnore: if (line.GetTag() == this->EndIgnoreTag) { this->Stack.pop(); - this->EndIgnoreTag = ""; + this->EndIgnoreTag.clear(); } break; default: diff --git a/Source/cmVisualStudioWCEPlatformParser.cxx b/Source/cmVisualStudioWCEPlatformParser.cxx index fc64d0f..3b113aa 100644 --- a/Source/cmVisualStudioWCEPlatformParser.cxx +++ b/Source/cmVisualStudioWCEPlatformParser.cxx @@ -56,12 +56,12 @@ void cmVisualStudioWCEPlatformParser::StartElement(const std::string& name, return; } - this->CharacterData = ""; + this->CharacterData.clear(); if (name == "PlatformData") { - this->PlatformName = ""; - this->OSMajorVersion = ""; - this->OSMinorVersion = ""; + this->PlatformName.clear(); + this->OSMajorVersion.clear(); + this->OSMinorVersion.clear(); this->Macros.clear(); } diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 9ffb9f8..e61acb1 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1072,10 +1072,10 @@ void cmake::SetGlobalGenerator(cmGlobalGenerator* gg) // Save the environment variables CXX and CC if (!cmSystemTools::GetEnv("CXX", this->CXXEnvironment)) { - this->CXXEnvironment = ""; + this->CXXEnvironment.clear(); } if (!cmSystemTools::GetEnv("CC", this->CCEnvironment)) { - this->CCEnvironment = ""; + this->CCEnvironment.clear(); } } diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 219a658..a1dfc3e 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -373,7 +373,7 @@ static int do_build(int ac, char const* const* av) hasTarget = true; } else { std::cerr << "'--target' may not be specified more than once.\n\n"; - dir = ""; + dir.clear(); break; } } else if (strcmp(av[i], "--config") == 0) { @@ -401,7 +401,7 @@ static int do_build(int ac, char const* const* av) break; default: std::cerr << "Unknown argument " << av[i] << std::endl; - dir = ""; + dir.clear(); break; } } |