diff options
author | Vitaly Stakhovsky <vvs31415@gitlab.org> | 2019-02-20 13:50:00 -0500 |
---|---|---|
committer | Vitaly Stakhovsky <vvs31415@gitlab.org> | 2019-02-20 14:53:39 -0500 |
commit | 4e315e9449735fc0f246c8cc838613693e849296 (patch) | |
tree | 73e74046ff415ed019c23a3433b015f229813c6d | |
parent | b76b83efd37a439e22d1d92af3b98c30e8f9ba97 (diff) | |
download | cmake-4e315e9449735fc0f246c8cc838613693e849296.tar.gz |
cmSystemTools: More functions accept `std::string` params
-rw-r--r-- | Source/CPack/cmCPackGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/CTest/cmCTestBZR.cxx | 2 | ||||
-rw-r--r-- | Source/CTest/cmCTestBuildHandler.cxx | 11 | ||||
-rw-r--r-- | Source/CTest/cmCTestBuildHandler.h | 2 | ||||
-rw-r--r-- | Source/CTest/cmCTestCVS.cxx | 2 | ||||
-rw-r--r-- | Source/CTest/cmCTestConfigureHandler.cxx | 2 | ||||
-rw-r--r-- | Source/CTest/cmCTestCoverageHandler.cxx | 4 | ||||
-rw-r--r-- | Source/CTest/cmCTestGIT.cxx | 2 | ||||
-rw-r--r-- | Source/CTest/cmCTestHG.cxx | 2 | ||||
-rw-r--r-- | Source/CTest/cmCTestMemCheckHandler.cxx | 2 | ||||
-rw-r--r-- | Source/CTest/cmCTestP4.cxx | 5 | ||||
-rw-r--r-- | Source/CTest/cmCTestSVN.cxx | 4 | ||||
-rw-r--r-- | Source/cmCTest.cxx | 2 | ||||
-rw-r--r-- | Source/cmCTest.h | 5 | ||||
-rw-r--r-- | Source/cmComputeLinkInformation.cxx | 2 | ||||
-rw-r--r-- | Source/cmExecProgramCommand.cxx | 2 | ||||
-rw-r--r-- | Source/cmGhsMultiTargetGenerator.cxx | 10 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmSystemTools.cxx | 12 | ||||
-rw-r--r-- | Source/cmSystemTools.h | 8 | ||||
-rw-r--r-- | Source/cmTryRunCommand.cxx | 5 |
22 files changed, 44 insertions, 47 deletions
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 575254e996..127bcf9dd9 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -1255,9 +1255,8 @@ bool cmCPackGenerator::ConfigureFile(const std::string& inName, int cmCPackGenerator::CleanTemporaryDirectory() { - std::string tempInstallDirectoryWithPostfix = + std::string tempInstallDirectory = this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY"); - const char* tempInstallDirectory = tempInstallDirectoryWithPostfix.c_str(); if (cmsys::SystemTools::FileExists(tempInstallDirectory)) { cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Clean temporary : " << tempInstallDirectory << std::endl); diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx index b154caf301..83aeb6408e 100644 --- a/Source/CTest/cmCTestBZR.cxx +++ b/Source/CTest/cmCTestBZR.cxx @@ -365,7 +365,7 @@ bool cmCTestBZR::UpdateImpl() if (opts.empty()) { opts = this->CTest->GetCTestConfiguration("BZRUpdateOptions"); } - std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts); // TODO: if(this->CTest->GetTestModel() == cmCTest::NIGHTLY) diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index c75f4d452d..07bc7e7612 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -418,8 +418,8 @@ int cmCTestBuildHandler::ProcessHandler() int retVal = 0; int res = cmsysProcess_State_Exited; if (!this->CTest->GetShowOnly()) { - res = this->RunMakeCommand(makeCommand.c_str(), &retVal, - buildDirectory.c_str(), 0, ofs); + res = this->RunMakeCommand(makeCommand, &retVal, buildDirectory.c_str(), 0, + ofs); } else { cmCTestOptionalLog(this->CTest, DEBUG, "Build with command: " << makeCommand << std::endl, @@ -766,9 +766,10 @@ void cmCTestBuildHandler::LaunchHelper::WriteScrapeMatchers( } } -int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal, - const char* dir, int timeout, - std::ostream& ofs, Encoding encoding) +int cmCTestBuildHandler::RunMakeCommand(const std::string& command, + int* retVal, const char* dir, + int timeout, std::ostream& ofs, + Encoding encoding) { // First generate the command and arguments std::vector<std::string> args = cmSystemTools::ParseArguments(command); diff --git a/Source/CTest/cmCTestBuildHandler.h b/Source/CTest/cmCTestBuildHandler.h index a9b121b24e..722c590093 100644 --- a/Source/CTest/cmCTestBuildHandler.h +++ b/Source/CTest/cmCTestBuildHandler.h @@ -52,7 +52,7 @@ private: //! Run command specialized for make and configure. Returns process status // and retVal is return value or exception. - int RunMakeCommand(const char* command, int* retVal, const char* dir, + int RunMakeCommand(const std::string& command, int* retVal, const char* dir, int timeout, std::ostream& ofs, Encoding encoding = cmProcessOutput::Auto); diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx index 6e8f73f83c..9c038399e5 100644 --- a/Source/CTest/cmCTestCVS.cxx +++ b/Source/CTest/cmCTestCVS.cxx @@ -78,7 +78,7 @@ bool cmCTestCVS::UpdateImpl() opts = "-dP"; } } - std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts); // Specify the start time for nightly testing. if (this->CTest->GetTestModel() == cmCTest::NIGHTLY) { diff --git a/Source/CTest/cmCTestConfigureHandler.cxx b/Source/CTest/cmCTestConfigureHandler.cxx index 6b7601b6e3..7e93189cde 100644 --- a/Source/CTest/cmCTestConfigureHandler.cxx +++ b/Source/CTest/cmCTestConfigureHandler.cxx @@ -61,7 +61,7 @@ int cmCTestConfigureHandler::ProcessHandler() cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Configure with command: " << cCommand << std::endl, this->Quiet); - res = this->CTest->RunMakeCommand(cCommand.c_str(), output, &retVal, + res = this->CTest->RunMakeCommand(cCommand, output, &retVal, buildDirectory.c_str(), cmDuration::zero(), ofs); diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 4dda9ad9bc..d76bd2a3e4 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -1004,7 +1004,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( static_cast<void>(locale_C); std::vector<std::string> basecovargs = - cmSystemTools::ParseArguments(gcovExtraFlags.c_str()); + cmSystemTools::ParseArguments(gcovExtraFlags); basecovargs.insert(basecovargs.begin(), gcovCommand); basecovargs.emplace_back("-o"); @@ -1377,7 +1377,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage( static_cast<void>(locale_C); std::vector<std::string> covargs = - cmSystemTools::ParseArguments(lcovExtraFlags.c_str()); + cmSystemTools::ParseArguments(lcovExtraFlags); covargs.insert(covargs.begin(), lcovCommand); const std::string command = joinCommandLine(covargs); diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 210abe55ba..11cd005c13 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -162,7 +162,7 @@ bool cmCTestGIT::UpdateByFetchAndReset() if (opts.empty()) { opts = this->CTest->GetCTestConfiguration("GITUpdateOptions"); } - std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts); for (std::string const& arg : args) { git_fetch.push_back(arg.c_str()); } diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx index 6fb99d8642..727c59cc66 100644 --- a/Source/CTest/cmCTestHG.cxx +++ b/Source/CTest/cmCTestHG.cxx @@ -144,7 +144,7 @@ bool cmCTestHG::UpdateImpl() if (opts.empty()) { opts = this->CTest->GetCTestConfiguration("HGUpdateOptions"); } - std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts); for (std::string const& arg : args) { hg_update.push_back(arg.c_str()); } diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 954f5bb108..22c8469266 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -520,7 +520,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() this->CTest->GetCTestConfiguration("ValgrindCommandOptions"); } this->MemoryTesterOptions = - cmSystemTools::ParseArguments(memoryTesterOptions.c_str()); + cmSystemTools::ParseArguments(memoryTesterOptions); this->MemoryTesterOutputFile = this->CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.??.log"; diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index ac4753c87b..315f49855a 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -324,8 +324,7 @@ void cmCTestP4::SetP4Options(std::vector<char const*>& CommandOptions) // The CTEST_P4_OPTIONS variable adds additional Perforce command line // options before the main command std::string opts = this->CTest->GetCTestConfiguration("P4Options"); - std::vector<std::string> args = - cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts); P4Options.insert(P4Options.end(), args.begin(), args.end()); } @@ -501,7 +500,7 @@ bool cmCTestP4::UpdateImpl() if (opts.empty()) { opts = this->CTest->GetCTestConfiguration("P4UpdateOptions"); } - std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts); for (std::string const& arg : args) { p4_sync.push_back(arg.c_str()); } diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx index 3bf66ca23f..b7a4e4c114 100644 --- a/Source/CTest/cmCTestSVN.cxx +++ b/Source/CTest/cmCTestSVN.cxx @@ -242,7 +242,7 @@ bool cmCTestSVN::UpdateImpl() if (opts.empty()) { opts = this->CTest->GetCTestConfiguration("SVNUpdateOptions"); } - std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts); // Specify the start time for nightly testing. if (this->CTest->GetTestModel() == cmCTest::NIGHTLY) { @@ -277,7 +277,7 @@ bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters, std::string userOptions = this->CTest->GetCTestConfiguration("SVNOptions"); std::vector<std::string> parsedUserOptions = - cmSystemTools::ParseArguments(userOptions.c_str()); + cmSystemTools::ParseArguments(userOptions); for (std::string const& opt : parsedUserOptions) { args.push_back(opt.c_str()); } diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index ba2fe6c9b5..c77bb97ea3 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1009,7 +1009,7 @@ int cmCTest::GetTestModelFromString(const char* str) //###################################################################### //###################################################################### -int cmCTest::RunMakeCommand(const char* command, std::string& output, +int cmCTest::RunMakeCommand(const std::string& command, std::string& output, int* retVal, const char* dir, cmDuration timeout, std::ostream& ofs, Encoding encoding) { diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 7dbf4d536a..a765fedec9 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -280,8 +280,9 @@ public: * Run command specialized for make and configure. Returns process status * and retVal is return value or exception. */ - int RunMakeCommand(const char* command, std::string& output, int* retVal, - const char* dir, cmDuration timeout, std::ostream& ofs, + int RunMakeCommand(const std::string& command, std::string& output, + int* retVal, const char* dir, cmDuration timeout, + std::ostream& ofs, Encoding encoding = cmProcessOutput::Auto); /** Return the current tag */ diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 3d61665fd3..eef93f80e7 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1266,7 +1266,7 @@ void cmComputeLinkInformation::AddFrameworkItem(std::string const& item) void cmComputeLinkInformation::AddDirectoryItem(std::string const& item) { if (this->Makefile->IsOn("APPLE") && - cmSystemTools::IsPathToFramework(item.c_str())) { + cmSystemTools::IsPathToFramework(item)) { this->AddFrameworkItem(item); } else { this->DropDirectoryItem(item); diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx index 75a7786a43..f4a9a9e9ed 100644 --- a/Source/cmExecProgramCommand.cxx +++ b/Source/cmExecProgramCommand.cxx @@ -67,7 +67,7 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args, std::string command; if (!arguments.empty()) { - command = cmSystemTools::ConvertToRunCommandPath(args[0].c_str()); + command = cmSystemTools::ConvertToRunCommandPath(args[0]); command += " "; command += arguments; } else { diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index c63e01a490..9f8f12b96d 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -210,7 +210,7 @@ void cmGhsMultiTargetGenerator::WriteCompilerFlags(std::ostream& fout, if (flagsByLangI != this->FlagsByLanguage.end()) { if (!flagsByLangI->second.empty()) { std::vector<std::string> ghsCompFlags = - cmSystemTools::ParseArguments(flagsByLangI->second.c_str()); + cmSystemTools::ParseArguments(flagsByLangI->second); for (auto& f : ghsCompFlags) { fout << " " << f << std::endl; } @@ -265,16 +265,14 @@ void cmGhsMultiTargetGenerator::WriteTargetLinkLine(std::ostream& fout, frameworkPath, linkPath, this->GeneratorTarget); // write out link options - std::vector<std::string> lopts = - cmSystemTools::ParseArguments(linkFlags.c_str()); + std::vector<std::string> lopts = cmSystemTools::ParseArguments(linkFlags); for (auto& l : lopts) { fout << " " << l << std::endl; } // write out link search paths // must be quoted for paths that contain spaces - std::vector<std::string> lpath = - cmSystemTools::ParseArguments(linkPath.c_str()); + std::vector<std::string> lpath = cmSystemTools::ParseArguments(linkPath); for (auto& l : lpath) { fout << " -L\"" << l << "\"" << std::endl; } @@ -284,7 +282,7 @@ void cmGhsMultiTargetGenerator::WriteTargetLinkLine(std::ostream& fout, std::string cbd = this->LocalGenerator->GetCurrentBinaryDirectory(); std::vector<std::string> llibs = - cmSystemTools::ParseArguments(linkLibraries.c_str()); + cmSystemTools::ParseArguments(linkLibraries); for (auto& l : llibs) { if (l.compare(0, 2, "-l") == 0) { fout << " \"" << l << "\"" << std::endl; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index fa0ffcc611..3a5658909e 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2200,7 +2200,7 @@ cmGeneratorTarget* cmGlobalGenerator::FindGeneratorTarget( bool cmGlobalGenerator::NameResolvesToFramework( const std::string& libname) const { - if (cmSystemTools::IsPathToFramework(libname.c_str())) { + if (cmSystemTools::IsPathToFramework(libname)) { return true; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 83931659d7..1921e30cf5 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -776,7 +776,7 @@ std::string cmLocalGenerator::GetIncludeFlags( #endif for (std::string const& i : includes) { if (fwSearchFlag && *fwSearchFlag && this->Makefile->IsOn("APPLE") && - cmSystemTools::IsPathToFramework(i.c_str())) { + cmSystemTools::IsPathToFramework(i)) { std::string frameworkDir = i; frameworkDir += "/../"; frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index f0e8077e7f..28a65643cc 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -571,13 +571,14 @@ std::vector<std::string> cmSystemTools::HandleResponseFile( return arg_full; } -std::vector<std::string> cmSystemTools::ParseArguments(const char* command) +std::vector<std::string> cmSystemTools::ParseArguments(const std::string& cmd) { std::vector<std::string> args; std::string arg; bool win_path = false; + const char* command = cmd.c_str(); if (command[0] && command[1] && ((command[0] != '/' && command[1] == ':' && command[2] == '\\') || (command[0] == '\"' && command[1] != '/' && command[2] == ':' && @@ -878,8 +879,7 @@ bool cmSystemTools::RunSingleCommand(const std::string& command, outputflag = OUTPUT_NONE; } - std::vector<std::string> args = - cmSystemTools::ParseArguments(command.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(command); if (args.empty()) { return false; @@ -1411,7 +1411,7 @@ void cmSystemTools::ConvertToOutputSlashes(std::string& path) #endif } -std::string cmSystemTools::ConvertToRunCommandPath(const char* path) +std::string cmSystemTools::ConvertToRunCommandPath(const std::string& path) { #if defined(_WIN32) && !defined(__CYGWIN__) return cmSystemTools::ConvertToWindowsOutputPath(path); @@ -1614,7 +1614,7 @@ void cmSystemTools::EnableVSConsoleOutput() #endif } -bool cmSystemTools::IsPathToFramework(const char* path) +bool cmSystemTools::IsPathToFramework(const std::string& path) { return (cmSystemTools::FileIsFullPath(path) && cmHasLiteralSuffix(path, ".framework")); @@ -3005,7 +3005,7 @@ bool cmSystemTools::CheckRPath(std::string const& file, #endif } -bool cmSystemTools::RepeatedRemoveDirectory(const char* dir) +bool cmSystemTools::RepeatedRemoveDirectory(const std::string& dir) { // Windows sometimes locks files temporarily so try a few times. for (int i = 0; i < 10; ++i) { diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 82e4f01f8d..60e8c1807d 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -141,7 +141,7 @@ public: ///! Return true if value is NOTFOUND or ends in -NOTFOUND. static bool IsNOTFOUND(const char* value); ///! Return true if the path is a framework - static bool IsPathToFramework(const char* value); + static bool IsPathToFramework(const std::string& value); static bool DoesFileExistWithExtensions( const std::string& name, const std::vector<std::string>& sourceExts); @@ -242,7 +242,7 @@ public: /** * Parse arguments out of a single string command */ - static std::vector<std::string> ParseArguments(const char* command); + static std::vector<std::string> ParseArguments(const std::string& command); /** Parse arguments out of a windows command line string. */ static void ParseWindowsCommandLine(const char* command, @@ -353,7 +353,7 @@ public: // ConvertToRunCommandPath does not use s_ForceUnixPaths and should // be used when RunCommand is called from cmake, because the // running cmake needs paths to be in its format - static std::string ConvertToRunCommandPath(const char* path); + static std::string ConvertToRunCommandPath(const std::string& path); /** compute the relative path from local to remote. local must be a directory. remote can be a file or a directory. @@ -488,7 +488,7 @@ public: static bool CheckRPath(std::string const& file, std::string const& newRPath); /** Remove a directory; repeat a few times in case of locked files. */ - static bool RepeatedRemoveDirectory(const char* dir); + static bool RepeatedRemoveDirectory(const std::string& dir); /** Tokenize a string */ static std::vector<std::string> tokenize(const std::string& str, diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index d863339666..da34bca723 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -173,7 +173,7 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs, std::vector<std::string> emulatorWithArgs; cmSystemTools::ExpandListArgument(emulator, emulatorWithArgs); finalCommand += - cmSystemTools::ConvertToRunCommandPath(emulatorWithArgs[0].c_str()); + cmSystemTools::ConvertToRunCommandPath(emulatorWithArgs[0]); finalCommand += " "; for (std::string const& arg : cmMakeRange(emulatorWithArgs).advance(1)) { finalCommand += "\""; @@ -182,8 +182,7 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs, finalCommand += " "; } } - finalCommand += - cmSystemTools::ConvertToRunCommandPath(this->OutputFile.c_str()); + finalCommand += cmSystemTools::ConvertToRunCommandPath(this->OutputFile); if (!runArgs.empty()) { finalCommand += runArgs; } |