diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2019-08-01 10:57:18 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2019-08-01 11:33:00 (GMT) |
commit | a693e875db5d0939a316955f513396e533153b6d (patch) | |
tree | e063b89a0bb0d69ce7c3f332d7e03a8efec6421b /Source | |
parent | 33d9a691306956750bffb10be9d0b17a47c0ec0b (diff) | |
download | CMake-a693e875db5d0939a316955f513396e533153b6d.zip CMake-a693e875db5d0939a316955f513396e533153b6d.tar.gz CMake-a693e875db5d0939a316955f513396e533153b6d.tar.bz2 |
Cleanups: Use cmHas{Prefix,Suffix} instead of String{Starts,Ends}With
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CPack/cmCPackGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/CTest/cmCTestCoverageHandler.cxx | 3 | ||||
-rw-r--r-- | Source/CTest/cmCTestLaunch.cxx | 3 | ||||
-rw-r--r-- | Source/CTest/cmParseJacocoCoverage.cxx | 3 | ||||
-rw-r--r-- | Source/cmCTest.cxx | 4 | ||||
-rw-r--r-- | Source/cmCallVisualStudioMacro.cxx | 4 | ||||
-rw-r--r-- | Source/cmExportFileGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmFindProgramCommand.cxx | 3 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 2 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio7Generator.cxx | 9 | ||||
-rw-r--r-- | Source/cmQtAutoMocUic.cxx | 2 | ||||
-rw-r--r-- | Source/cmSourceGroupCommand.cxx | 3 | ||||
-rw-r--r-- | Source/cmVisualStudioSlnParser.cxx | 5 | ||||
-rw-r--r-- | Source/cmake.cxx | 3 |
14 files changed, 29 insertions, 22 deletions
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 512ac7a..3fd124b 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -21,6 +21,7 @@ #include "cmMakefile.h" #include "cmState.h" #include "cmStateSnapshot.h" +#include "cmStringAlgorithms.h" #include "cmVersion.h" #include "cmWorkingDirectory.h" #include "cmXMLSafe.h" @@ -772,7 +773,7 @@ int cmCPackGenerator::InstallCMakeProject( // Make sure that DESTDIR + CPACK_INSTALL_PREFIX directory // exists: // - if (cmSystemTools::StringStartsWith(dir.c_str(), "/")) { + if (cmHasLiteralPrefix(dir, "/")) { dir = tempInstallDirectory + dir; } else { dir = tempInstallDirectory + "/" + dir; diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index f6028c4..54fe612 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -13,6 +13,7 @@ #include "cmParseGTMCoverage.h" #include "cmParseJacocoCoverage.h" #include "cmParsePHPCoverage.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmWorkingDirectory.h" #include "cmXMLWriter.h" @@ -1181,7 +1182,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( // gcov 4.7 can have output lines saying "No executable lines" and // "Removing 'filename.gcov'"... Don't log those as "errors." if (line != "No executable lines" && - !cmSystemTools::StringStartsWith(line.c_str(), "Removing ")) { + !cmHasLiteralPrefix(line, "Removing ")) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output line: [" << line << "]" << std::endl); diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index 237ca82..bbf490e 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -16,6 +16,7 @@ #include "cmProcessOutput.h" #include "cmState.h" #include "cmStateSnapshot.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmXMLWriter.h" #include "cmake.h" @@ -594,7 +595,7 @@ bool cmCTestLaunch::Match(std::string const& line, bool cmCTestLaunch::MatchesFilterPrefix(std::string const& line) const { return !this->OptionFilterPrefix.empty() && - cmSystemTools::StringStartsWith(line, this->OptionFilterPrefix.c_str()); + cmHasPrefix(line, this->OptionFilterPrefix); } int cmCTestLaunch::Main(int argc, const char* const argv[]) diff --git a/Source/CTest/cmParseJacocoCoverage.cxx b/Source/CTest/cmParseJacocoCoverage.cxx index b78142a..5f1e712 100644 --- a/Source/CTest/cmParseJacocoCoverage.cxx +++ b/Source/CTest/cmParseJacocoCoverage.cxx @@ -2,6 +2,7 @@ #include "cmCTest.h" #include "cmCTestCoverageHandler.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmXMLParser.h" @@ -118,7 +119,7 @@ protected: // Check if any of the locations found match our package. for (std::string const& f : files) { std::string dir = cmsys::SystemTools::GetParentDirectory(f); - if (cmsys::SystemTools::StringEndsWith(dir, this->PackageName.c_str())) { + if (cmHasSuffix(dir, this->PackageName)) { cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found package directory for " << fileName << ": " << dir << std::endl, diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 610e9f9..026250d 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1965,7 +1965,7 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, if (this->CheckArgument(arg, "-N", "--show-only")) { this->Impl->ShowOnly = true; } - if (cmSystemTools::StringStartsWith(arg.c_str(), "--show-only=")) { + if (cmHasLiteralPrefix(arg, "--show-only=")) { this->Impl->ShowOnly = true; // Check if a specific format is requested. Defaults to human readable @@ -2227,7 +2227,7 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output) // attempts are simply ignored since previous ctest versions ignore // this too. (As well as many other unknown command line args.) // - if (arg != "-D" && cmSystemTools::StringStartsWith(arg.c_str(), "-D")) { + if (arg != "-D" && cmHasLiteralPrefix(arg, "-D")) { std::string input = arg.substr(2); this->AddVariableDefinition(input); } diff --git a/Source/cmCallVisualStudioMacro.cxx b/Source/cmCallVisualStudioMacro.cxx index f7a2244..9e152ff 100644 --- a/Source/cmCallVisualStudioMacro.cxx +++ b/Source/cmCallVisualStudioMacro.cxx @@ -4,6 +4,7 @@ #include <sstream> +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #if defined(_MSC_VER) @@ -328,8 +329,7 @@ HRESULT FindVisualStudioInstances(const std::string& slnFile, if (SUCCEEDED(hr)) { std::map<std::string, IUnknownPtr>::iterator it; for (it = mrot.begin(); it != mrot.end(); ++it) { - if (cmSystemTools::StringStartsWith(it->first.c_str(), - "!VisualStudio.DTE.")) { + if (cmHasLiteralPrefix(it->first, "!VisualStudio.DTE.")) { IDispatchPtr disp(it->second); if (disp != (IDispatch*)0) { std::string slnName; diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 8fd2947..87f9b4c 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -1209,8 +1209,8 @@ bool cmExportFileGenerator::PopulateExportProperties( targetProperties.GetPropertyValue("EXPORT_PROPERTIES")) { for (auto& prop : cmSystemTools::ExpandedListArgument(exportProperties)) { /* Black list reserved properties */ - if (cmSystemTools::StringStartsWith(prop, "IMPORTED_") || - cmSystemTools::StringStartsWith(prop, "INTERFACE_")) { + if (cmHasLiteralPrefix(prop, "IMPORTED_") || + cmHasLiteralPrefix(prop, "INTERFACE_")) { std::ostringstream e; e << "Target \"" << gte->Target->GetName() << "\" contains property \"" << prop << "\" in EXPORT_PROPERTIES but IMPORTED_* and INTERFACE_* " diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx index 782f746..8fcf1ac 100644 --- a/Source/cmFindProgramCommand.cxx +++ b/Source/cmFindProgramCommand.cxx @@ -4,6 +4,7 @@ #include "cmMakefile.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" class cmExecutionStatus; @@ -71,7 +72,7 @@ struct cmFindProgramHelper bool CheckDirectoryForName(std::string const& path, std::string const& name) { for (std::string const& ext : this->Extensions) { - if (!ext.empty() && cmSystemTools::StringEndsWith(name, ext.c_str())) { + if (!ext.empty() && cmHasSuffix(name, ext)) { continue; } this->TestNameExt = name; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 38f34ac..7340bc2 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4192,7 +4192,7 @@ cmGeneratorTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const if (stripResources) { flags.MacFolder = ""; } - } else if (cmSystemTools::StringStartsWith(location, "Resources/")) { + } else if (cmHasLiteralPrefix(location, "Resources/")) { flags.Type = cmGeneratorTarget::SourceFileTypeDeepResource; if (stripResources) { flags.MacFolder += strlen("Resources/"); diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 8401efb..bead0e3 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -8,7 +8,9 @@ #include "cmMakefile.h" #include "cmMessageType.h" #include "cmState.h" +#include "cmStringAlgorithms.h" #include "cmUuid.h" +#include "cm_string_view.hxx" #include "cmake.h" #include "cmsys/Encoding.hxx" @@ -432,16 +434,15 @@ void cmGlobalVisualStudio7Generator::WriteTargetDepends( void cmGlobalVisualStudio7Generator::WriteFolders(std::ostream& fout) { - const char* prefix = "CMAKE_FOLDER_GUID_"; - const std::string::size_type skip_prefix = strlen(prefix); + cm::string_view const prefix = "CMAKE_FOLDER_GUID_"; std::string guidProjectTypeFolder = "2150E333-8FDC-42A3-9474-1A3956D46DE8"; for (auto const& iter : VisualStudioFolders) { std::string fullName = iter.first; std::string guid = this->GetGUID(fullName); std::replace(fullName.begin(), fullName.end(), '/', '\\'); - if (cmSystemTools::StringStartsWith(fullName.c_str(), prefix)) { - fullName = fullName.substr(skip_prefix); + if (cmHasPrefix(fullName, prefix)) { + fullName = fullName.substr(prefix.size()); } std::string nameOnly = cmSystemTools::GetFilenameName(fullName); diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index 2aefe8f..0801c24 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -1894,7 +1894,7 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) std::list<std::string>::iterator it = includes.begin(); while (it != includes.end()) { std::string const& path = *it; - if (cmSystemTools::StringStartsWith(path, ppath->c_str())) { + if (cmHasPrefix(path, *ppath)) { MocConst_.IncludePaths.push_back(path); it = includes.erase(it); } else { diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx index 04b4d72..ffdd0ce 100644 --- a/Source/cmSourceGroupCommand.cxx +++ b/Source/cmSourceGroupCommand.cxx @@ -9,6 +9,7 @@ #include "cmMakefile.h" #include "cmSourceGroup.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" namespace { @@ -54,7 +55,7 @@ bool rootIsPrefix(const std::string& root, const std::vector<std::string>& files, std::string& error) { for (std::string const& file : files) { - if (!cmSystemTools::StringStartsWith(file, root.c_str())) { + if (!cmHasPrefix(file, root)) { error = "ROOT: " + root + " is not a prefix of file: " + file; return false; } diff --git a/Source/cmVisualStudioSlnParser.cxx b/Source/cmVisualStudioSlnParser.cxx index 9353276..3e7e142 100644 --- a/Source/cmVisualStudioSlnParser.cxx +++ b/Source/cmVisualStudioSlnParser.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmVisualStudioSlnParser.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmVisualStudioSlnData.h" #include "cmsys/FStream.hxx" @@ -192,8 +193,8 @@ bool cmVisualStudioSlnParser::State::Process( assert(!line.IsComment()); switch (this->Stack.top()) { case FileStateStart: - if (!cmSystemTools::StringStartsWith( - line.GetTag().c_str(), "Microsoft Visual Studio Solution File")) { + if (!cmHasLiteralPrefix(line.GetTag(), + "Microsoft Visual Studio Solution File")) { result.SetError(ResultErrorInputStructure, this->GetCurrentLine()); return false; } diff --git a/Source/cmake.cxx b/Source/cmake.cxx index b97152f..309efd3 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2031,8 +2031,7 @@ void cmake::AppendGlobalGeneratorsDocumentation( for (cmGlobalGeneratorFactory* g : this->Generators) { cmDocumentationEntry e; g->GetDocumentation(e); - if (!foundDefaultOne && - cmSystemTools::StringStartsWith(e.Name, defaultName.c_str())) { + if (!foundDefaultOne && cmHasPrefix(e.Name, defaultName)) { e.CustomNamePrefix = '*'; foundDefaultOne = true; } |