diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index 6d99360914..994f2b9403 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -233,7 +233,7 @@ int cmCPackArchiveGenerator::InitializeInternal() cmValue newExtensionValue = this->GetOption("CPACK_ARCHIVE_FILE_EXTENSION"); if (!newExtensionValue.IsEmpty()) { std::string newExtension = *newExtensionValue; - if (!cmHasLiteralPrefix(newExtension, ".")) { + if (!cmHasPrefix(newExtension, '.')) { newExtension = cmStrCat('.', newExtension); } cmCPackLogger(cmCPackLog::LOG_DEBUG, diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 1cea240ee5..f9fed6dc09 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -834,7 +834,7 @@ int cmCPackGenerator::InstallCMakeProject( // Make sure that DESTDIR + CPACK_INSTALL_PREFIX directory // exists: // - if (cmHasLiteralPrefix(dir, "/")) { + if (cmHasPrefix(dir, '/')) { dir = tempInstallDirectory + dir; } else { dir = tempInstallDirectory + "/" + dir; diff --git a/Source/CTest/cmParseGTMCoverage.cxx b/Source/CTest/cmParseGTMCoverage.cxx index c7b2092bf1..c11be30fa3 100644 --- a/Source/CTest/cmParseGTMCoverage.cxx +++ b/Source/CTest/cmParseGTMCoverage.cxx @@ -85,7 +85,7 @@ bool cmParseGTMCoverage::ReadMCovFile(char const* file) } // Find the full path to the file bool found = this->FindMumpsFile(routine, filepath); - if (!found && cmHasLiteralSuffix(routine, "%")) { + if (!found && cmHasSuffix(routine, '%')) { routine.erase(0, 1); found = this->FindMumpsFile(routine, filepath); } diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index caa001ab5c..518835923c 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -287,7 +287,7 @@ static bool cmOSXInstall(std::string const& dir, std::string const& tool) static int cmOSXInstall(std::string dir) { - if (!cmHasLiteralSuffix(dir, "/")) { + if (!cmHasSuffix(dir, '/')) { dir += "/"; } return (cmOSXInstall(dir, cmSystemTools::GetCMakeCommand()) && diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 227fe0c306..a51570bc88 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -2531,7 +2531,7 @@ int cmCTest::Run(std::vector const& args) this->Impl->BuildAndTest.TestCommandArgs.emplace_back(args[i]); } } - if (!matched && cmHasLiteralPrefix(arg, "-") && + if (!matched && cmHasPrefix(arg, '-') && !cmHasLiteralPrefix(arg, "--preset")) { cmSystemTools::Error(cmStrCat("Unknown argument: ", arg)); cmSystemTools::Error("Run 'ctest --help' for all supported options."); diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 4d34d66005..b63d2a62b5 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -53,7 +53,7 @@ std::string EvaluateSplitConfigGenex( ++pos; continue; } - if (cmHasLiteralPrefix(cur, ">")) { + if (cmHasPrefix(cur, '>')) { --nestingLevel; if (nestingLevel == 0) { ++pos; diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index c16ea286f9..cbb731bca2 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -1067,7 +1067,7 @@ Json::Value DirectoryObject::DumpInstaller(cmInstallGenerator* gen) installer["destination"] = installDir->GetDestination(this->Config); Json::Value paths = Json::arrayValue; for (std::string const& dir : dirs) { - if (cmHasLiteralSuffix(dir, "/")) { + if (cmHasSuffix(dir, '/')) { paths.append(this->DumpInstallerPath( this->TopSource, dir.substr(0, dir.size() - 1), ".")); } else { diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 8ce713ec54..46bb45efdd 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -2511,7 +2511,7 @@ cm::optional cmcmd_cmake_ninja_depends_fortran( } dir_top_bld = tdi["dir-top-bld"].asString(); - if (!dir_top_bld.empty() && !cmHasLiteralSuffix(dir_top_bld, "/")) { + if (!dir_top_bld.empty() && !cmHasSuffix(dir_top_bld, '/')) { dir_top_bld += '/'; } @@ -2524,7 +2524,7 @@ cm::optional cmcmd_cmake_ninja_depends_fortran( Json::Value const& tdi_module_dir = tdi["module-dir"]; module_dir = tdi_module_dir.asString(); - if (!module_dir.empty() && !cmHasLiteralSuffix(module_dir, "/")) { + if (!module_dir.empty() && !cmHasSuffix(module_dir, '/')) { module_dir += '/'; } @@ -3021,7 +3021,7 @@ int cmcmd_cmake_ninja_dyndep(std::vector::const_iterator argBeg, } std::string module_dir = tdi["module-dir"].asString(); - if (!module_dir.empty() && !cmHasLiteralSuffix(module_dir, "/")) { + if (!module_dir.empty() && !cmHasSuffix(module_dir, '/')) { module_dir += '/'; } std::vector linked_target_dirs; diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 39086f76ae..759806f48e 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -998,7 +998,7 @@ cm::VS::Solution cmGlobalVisualStudioGenerator::CreateSolution( root->MaybeRelativeToCurBinDir(lg->GetCurrentBinaryDirectory()); if (dir == "."_s) { dir.clear(); - } else if (!cmHasLiteralSuffix(dir, "/")) { + } else if (!cmHasSuffix(dir, '/')) { dir += "/"; } diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx index daacea5747..6fb481bd54 100644 --- a/Source/cmLinkLineDeviceComputer.cxx +++ b/Source/cmLinkLineDeviceComputer.cxx @@ -45,7 +45,7 @@ static bool cmLinkItemValidForDevice(std::string const& item) // * '-pthread' => drop // * '-a' => drop // * '-framework Name' (as one string) => drop - return (!cmHasLiteralPrefix(item, "-") || // + return (!cmHasPrefix(item, '-') || // cmHasLiteralPrefix(item, "-l") || // cmHasLiteralPrefix(item, "-L") || // cmHasLiteralPrefix(item, "--library")); diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 4f186a840e..b6cc3a6c86 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -489,7 +489,7 @@ bool RuleNeedsCMD(std::string const& cmd) auto it = std::find_if(args.cbegin(), args.cend(), [](std::string const& arg) -> bool { // FIXME: Detect more windows shell operators. - return cmHasLiteralPrefix(arg, ">"); + return cmHasPrefix(arg, '>'); }); return it != args.cend(); } diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 4e3cee94a7..df3231637d 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -919,7 +919,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( cmOutputConverter::SHELL); if (this->LocalGenerator->IsMinGWMake() && - cmHasLiteralSuffix(targetOutPathCompilePDB, "\\")) { + cmHasSuffix(targetOutPathCompilePDB, '\\')) { // mingw32-make incorrectly interprets 'a\ b c' as 'a b' and 'c' // (but 'a\ b "c"' as 'a\', 'b', and 'c'!). Workaround this by // avoiding a trailing backslash in the argument. diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index ef8dabe0a7..d833bbbfbf 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -456,7 +456,7 @@ std::string cmNinjaTargetGenerator::GetPreprocessedFilePath( { // Choose an extension to compile already-preprocessed source. std::string ppExt = source->GetExtension(); - if (cmHasLiteralPrefix(ppExt, "F")) { + if (cmHasPrefix(ppExt, 'F')) { // Some Fortran compilers automatically enable preprocessing for // upper-case extensions. Since the source is already preprocessed, // use a lower-case extension. diff --git a/Source/cmPackageInfoReader.cxx b/Source/cmPackageInfoReader.cxx index 3c7c9707fa..97a4d0c56b 100644 --- a/Source/cmPackageInfoReader.cxx +++ b/Source/cmPackageInfoReader.cxx @@ -223,7 +223,7 @@ std::vector ReadList(Json::Value const& data, char const* key) std::string NormalizeTargetName(std::string const& name, std::string const& context) { - if (cmHasLiteralPrefix(name, ":")) { + if (cmHasPrefix(name, ':')) { return cmStrCat(context, ':', name); } diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx index 6a34697279..88d171b081 100644 --- a/Source/cmSetCommand.cxx +++ b/Source/cmSetCommand.cxx @@ -81,7 +81,7 @@ bool cmSetCommand(std::vector const& args, // watch for CACHE{} signature if (cmHasLiteralPrefix(variable, "CACHE{") && variable.size() > 7 && - cmHasLiteralSuffix(variable, "}")) { + cmHasSuffix(variable, '}')) { // what is the variable name auto const& varName = variable.substr(6, variable.size() - 7); // VALUE handling diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 971bd3ed05..ee1dba4731 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -642,7 +642,7 @@ std::vector cmSystemTools::HandleResponseFile( { std::vector arg_full; for (std::string const& arg : cmMakeRange(argBeg, argEnd)) { - if (cmHasLiteralPrefix(arg, "@")) { + if (cmHasPrefix(arg, '@')) { cmsys::ifstream responseFile(arg.substr(1).c_str(), std::ios::in); if (!responseFile) { std::string error = cmStrCat("failed to open for reading (", diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index 0d6cb7cb34..2c68392bb2 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -283,7 +283,7 @@ bool cmTargetLinkLibrariesCommand(std::vector const& args, if (cmHasLiteralPrefix(cur, "$<")) { ++genexNesting; ++pos; - } else if (genexNesting > 0 && cmHasLiteralPrefix(cur, ">")) { + } else if (genexNesting > 0 && cmHasPrefix(cur, '>')) { --genexNesting; } } diff --git a/Source/cmTargetPrecompileHeadersCommand.cxx b/Source/cmTargetPrecompileHeadersCommand.cxx index 5a57c06c12..731308993a 100644 --- a/Source/cmTargetPrecompileHeadersCommand.cxx +++ b/Source/cmTargetPrecompileHeadersCommand.cxx @@ -28,7 +28,7 @@ std::vector ConvertToAbsoluteContent( // Use '' and '"foo.h"' includes and absolute paths as-is. // Interpret relative paths with respect to the source directory. // If the path starts in a generator expression, assume it is absolute. - if (cmHasLiteralPrefix(src, "<") || cmHasLiteralPrefix(src, "\"") || + if (cmHasPrefix(src, '<') || cmHasPrefix(src, '"') || cmSystemTools::FileIsFullPath(src) || cmGeneratorExpression::Find(src) == 0) { absoluteSrc = src; diff --git a/Source/cmUnsetCommand.cxx b/Source/cmUnsetCommand.cxx index 117118c190..fdb1b062bb 100644 --- a/Source/cmUnsetCommand.cxx +++ b/Source/cmUnsetCommand.cxx @@ -30,7 +30,7 @@ bool cmUnsetCommand(std::vector const& args, } // unset(CACHE{VAR}) if (cmHasLiteralPrefix(variable, "CACHE{") && variable.size() > 7 && - cmHasLiteralSuffix(variable, "}")) { + cmHasSuffix(variable, '}')) { // get the variable name auto const& varName = variable.substr(6, variable.size() - 7); status.GetMakefile().RemoveCacheDefinition(varName); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 2de27d6ed4..e5f8e684f8 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1483,7 +1483,7 @@ void cmake::SetArgs(std::vector const& args) if (!parsedCorrectly) { cmSystemTools::Error("Run 'cmake --help' for all supported options."); exit(1); - } else if (!matched && cmHasLiteralPrefix(arg, "-")) { + } else if (!matched && cmHasPrefix(arg, '-')) { possibleUnknownArg = arg; } else if (!matched) { bool parsedDirectory = this->SetDirectoriesFromFile(arg); diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 019b366942..09c35c0c96 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -180,7 +180,7 @@ bool cmTarFilesFrom(std::string const& file, std::vector& files) } if (cmHasLiteralPrefix(line, "--add-file=")) { files.push_back(line.substr(11)); - } else if (cmHasLiteralPrefix(line, "-")) { + } else if (cmHasPrefix(line, '-')) { cmSystemTools::Error(cmStrCat("-E tar --files-from='", file, "' file invalid line:\n", line, '\n')); return false; @@ -1084,7 +1084,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args, bool doing_options = true; bool at_least_one_file = false; for (auto const& arg : cmMakeRange(args).advance(2)) { - if (doing_options && cmHasLiteralPrefix(arg, "-")) { + if (doing_options && cmHasPrefix(arg, '-')) { if (arg == "--") { doing_options = false; } @@ -1239,7 +1239,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args, // Destroy console buffers to drop cout/cerr encoding transform. console.reset(); cmCatFile(arg); - } else if (doing_options && cmHasLiteralPrefix(arg, "-")) { + } else if (doing_options && cmHasPrefix(arg, '-')) { if (arg == "--") { doing_options = false; } else { @@ -2416,13 +2416,13 @@ bool cmVSLink::Parse(std::vector::const_iterator argBeg, // Parse our own arguments. std::string intDir; auto arg = argBeg; - while (arg != argEnd && cmHasLiteralPrefix(*arg, "-")) { + while (arg != argEnd && cmHasPrefix(*arg, '-')) { if (*arg == "--") { ++arg; break; } if (*arg == "--manifests") { - for (++arg; arg != argEnd && !cmHasLiteralPrefix(*arg, "-"); ++arg) { + for (++arg; arg != argEnd && !cmHasPrefix(*arg, '-'); ++arg) { this->UserManifests.push_back(*arg); } } else if (cmHasLiteralPrefix(*arg, "--intdir=")) {