From 8ef18e8525107eac8bc00545d8dafb186f96a227 Mon Sep 17 00:00:00 2001 From: Vitaly Stakhovsky Date: Thu, 9 Jul 2020 09:00:00 -0400 Subject: Clean a few string conversions --- Source/CPack/cmCPackGenerator.cxx | 2 +- Source/cmSystemTools.cxx | 2 +- Source/cmXCodeScheme.cxx | 2 +- Source/cmake.cxx | 2 +- Source/cmcmd.cxx | 19 +++++++------------ 5 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index fd81495..c641175 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -829,7 +829,7 @@ int cmCPackGenerator::InstallCMakeProject( * - Because it was already used for component install * in order to put things in subdirs... */ - cmSystemTools::PutEnv(std::string("DESTDIR=") + tempInstallDirectory); + cmSystemTools::PutEnv("DESTDIR=" + tempInstallDirectory); cmCPackLogger(cmCPackLog::LOG_DEBUG, "- Creating directory: '" << dir << "'" << std::endl); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 1e78d36..798c29a 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1213,7 +1213,7 @@ bool cmSystemTools::UnsetEnv(const char* value) { # if !defined(HAVE_UNSETENV) std::string var = cmStrCat(value, '='); - return cmSystemTools::PutEnv(var.c_str()); + return cmSystemTools::PutEnv(var); # else unsetenv(value); return true; diff --git a/Source/cmXCodeScheme.cxx b/Source/cmXCodeScheme.cxx index f4c2f2d..0e3cf08 100644 --- a/Source/cmXCodeScheme.cxx +++ b/Source/cmXCodeScheme.cxx @@ -33,7 +33,7 @@ void cmXCodeScheme::WriteXCodeSharedScheme(const std::string& xcProjDir, // Create shared scheme sub-directory tree // std::string xcodeSchemeDir = cmStrCat(xcProjDir, "/xcshareddata/xcschemes"); - cmSystemTools::MakeDirectory(xcodeSchemeDir.c_str()); + cmSystemTools::MakeDirectory(xcodeSchemeDir); std::string xcodeSchemeFile = cmStrCat(xcodeSchemeDir, '/', this->TargetName, ".xcscheme"); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 638f10e..2656849 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1371,7 +1371,7 @@ struct SaveCacheEntry int cmake::HandleDeleteCacheVariables(const std::string& var) { - std::vector argsSplit = cmExpandedList(std::string(var), true); + std::vector argsSplit = cmExpandedList(var, true); // erase the property to avoid infinite recursion this->State->SetGlobalProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_", ""); if (this->State->GetIsInTryCompile()) { diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 6882fdd..49e8a4f 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -600,8 +600,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args) } cmsys::ifstream fin(args[3].c_str(), std::ios::in | std::ios::binary); if (!fin) { - std::cerr << "could not open object list file: " << args[3].c_str() - << "\n"; + std::cerr << "could not open object list file: " << args[3] << "\n"; return 1; } std::vector files; @@ -624,13 +623,12 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args) } FILE* fout = cmsys::SystemTools::Fopen(args[2], "w+"); if (!fout) { - std::cerr << "could not open output .def file: " << args[2].c_str() - << "\n"; + std::cerr << "could not open output .def file: " << args[2] << "\n"; return 1; } bindexplib deffile; if (args.size() >= 5) { - auto a = args[4]; + std::string const& a = args[4]; if (cmHasLiteralPrefix(a, "--nm=")) { deffile.SetNmPath(a.substr(5)); std::cerr << a.substr(5) << "\n"; @@ -638,7 +636,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args) std::cerr << "unknown argument: " << a << "\n"; } } - for (auto const& file : files) { + for (std::string const& file : files) { std::string const& ext = cmSystemTools::GetFilenameLastExtension(file); if (cmSystemTools::LowerCase(ext) == ".def") { if (!deffile.AddDefinitionFile(file.c_str())) { @@ -1020,7 +1018,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args) // Command to create a symbolic link. Fails on platforms not // supporting them. if (args[1] == "create_symlink" && args.size() == 4) { - const char* destinationFileName = args[3].c_str(); + std::string const& destinationFileName = args[3]; if ((cmSystemTools::FileExists(destinationFileName) || cmSystemTools::FileIsSymlink(destinationFileName)) && !cmSystemTools::RemoveFile(destinationFileName)) { @@ -1377,15 +1375,12 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args) #if defined(_WIN32) && !defined(__CYGWIN__) // Write registry value if (args[1] == "write_regv" && args.size() > 3) { - return cmSystemTools::WriteRegistryValue(args[2].c_str(), - args[3].c_str()) - ? 0 - : 1; + return cmSystemTools::WriteRegistryValue(args[2], args[3]) ? 0 : 1; } // Delete registry value if (args[1] == "delete_regv" && args.size() > 2) { - return cmSystemTools::DeleteRegistryValue(args[2].c_str()) ? 0 : 1; + return cmSystemTools::DeleteRegistryValue(args[2]) ? 0 : 1; } // Remove file -- cgit v0.12