summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-02-15 13:37:03 (GMT)
committerBrad King <brad.king@kitware.com>2024-02-15 13:37:03 (GMT)
commitc845da5dfb02a094db4cb47cd505192301669b70 (patch)
treeba0bb5a8356d8852f7f540ac139ed1810be1cd87
parent48388618838e9d99fad9598348785a785f6258d7 (diff)
parente34aa12e6666a58fb3f0cb0ce0411228bbe763af (diff)
downloadCMake-c845da5dfb02a094db4cb47cd505192301669b70.zip
CMake-c845da5dfb02a094db4cb47cd505192301669b70.tar.gz
CMake-c845da5dfb02a094db4cb47cd505192301669b70.tar.bz2
Merge branch 'upstream-KWSys' into update-kwsys
# By KWSys Upstream * upstream-KWSys: KWSys 2024-02-15 (aad06964)
-rw-r--r--Source/kwsys/CommandLineArguments.cxx16
-rw-r--r--Source/kwsys/SystemInformation.cxx2
-rw-r--r--Source/kwsys/SystemTools.cxx34
3 files changed, 19 insertions, 33 deletions
diff --git a/Source/kwsys/CommandLineArguments.cxx b/Source/kwsys/CommandLineArguments.cxx
index 50171dd..61703ad 100644
--- a/Source/kwsys/CommandLineArguments.cxx
+++ b/Source/kwsys/CommandLineArguments.cxx
@@ -132,7 +132,7 @@ bool CommandLineArguments::GetMatchedArguments(
// Does the argument match to any we know about?
for (it = this->Internals->Callbacks.begin();
- it != this->Internals->Callbacks.end(); it++) {
+ it != this->Internals->Callbacks.end(); ++it) {
const CommandLineArguments::Internal::String& parg = it->first;
CommandLineArgumentsCallbackStructure* cs = &it->second;
if (cs->ArgumentType == CommandLineArguments::NO_ARGUMENT ||
@@ -467,7 +467,7 @@ void CommandLineArguments::GenerateHelp()
MapArgs mp;
MapArgs::iterator mpit, smpit;
for (it = this->Internals->Callbacks.begin();
- it != this->Internals->Callbacks.end(); it++) {
+ it != this->Internals->Callbacks.end(); ++it) {
CommandLineArgumentsCallbackStructure* cs = &(it->second);
mpit = mp.find(cs->Help);
if (mpit != mp.end()) {
@@ -478,14 +478,14 @@ void CommandLineArguments::GenerateHelp()
}
}
for (it = this->Internals->Callbacks.begin();
- it != this->Internals->Callbacks.end(); it++) {
+ it != this->Internals->Callbacks.end(); ++it) {
CommandLineArgumentsCallbackStructure* cs = &(it->second);
mpit = mp.find(cs->Help);
if (mpit != mp.end()) {
mpit->second.insert(it->first);
smpit = mp.find(it->first);
CommandLineArguments::Internal::SetOfStrings::iterator sit;
- for (sit = smpit->second.begin(); sit != smpit->second.end(); sit++) {
+ for (sit = smpit->second.begin(); sit != smpit->second.end(); ++sit) {
mpit->second.insert(*sit);
}
mp.erase(smpit);
@@ -496,9 +496,9 @@ void CommandLineArguments::GenerateHelp()
// Find the length of the longest string
CommandLineArguments::Internal::String::size_type maxlen = 0;
- for (mpit = mp.begin(); mpit != mp.end(); mpit++) {
+ for (mpit = mp.begin(); mpit != mp.end(); ++mpit) {
CommandLineArguments::Internal::SetOfStrings::iterator sit;
- for (sit = mpit->second.begin(); sit != mpit->second.end(); sit++) {
+ for (sit = mpit->second.begin(); sit != mpit->second.end(); ++sit) {
CommandLineArguments::Internal::String::size_type clen = sit->size();
switch (this->Internals->Callbacks[*sit].ArgumentType) {
case CommandLineArguments::NO_ARGUMENT:
@@ -524,9 +524,9 @@ void CommandLineArguments::GenerateHelp()
maxlen += 4; // For the space before and after the option
// Print help for each option
- for (mpit = mp.begin(); mpit != mp.end(); mpit++) {
+ for (mpit = mp.begin(); mpit != mp.end(); ++mpit) {
CommandLineArguments::Internal::SetOfStrings::iterator sit;
- for (sit = mpit->second.begin(); sit != mpit->second.end(); sit++) {
+ for (sit = mpit->second.begin(); sit != mpit->second.end(); ++sit) {
str << std::endl;
std::string argument = *sit;
switch (this->Internals->Callbacks[*sit].ArgumentType) {
diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx
index 369ff9a..37526dc 100644
--- a/Source/kwsys/SystemInformation.cxx
+++ b/Source/kwsys/SystemInformation.cxx
@@ -4890,7 +4890,7 @@ std::string SystemInformationImplementation::ParseValueFromKStat(
args.reserve(3 + args_string.size());
args.push_back("kstat");
args.push_back("-p");
- for (auto& i : args_string) {
+ for (const auto& i : args_string) {
args.push_back(i.c_str());
}
args.push_back(nullptr);
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 53b55f6..3f714de 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -2867,9 +2867,8 @@ std::string SystemToolsStatic::FindName(
path.reserve(path.size() + userPaths.size());
path.insert(path.end(), userPaths.begin(), userPaths.end());
// now look for the file
- std::string tryPath;
for (std::string const& p : path) {
- tryPath = p;
+ std::string tryPath = p;
if (tryPath.empty() || tryPath.back() != '/') {
tryPath += '/';
}
@@ -2938,8 +2937,6 @@ std::string SystemTools::FindProgram(const std::string& name,
const std::vector<std::string>& userPaths,
bool no_system_path)
{
- std::string tryPath;
-
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
std::vector<std::string> extensions;
// check to see if the name already has a .xxx at
@@ -2951,7 +2948,7 @@ std::string SystemTools::FindProgram(const std::string& name,
// first try with extensions if the os supports them
for (std::string const& ext : extensions) {
- tryPath = name;
+ std::string tryPath = name;
tryPath += ext;
if (SystemTools::FileIsExecutable(tryPath)) {
return SystemTools::CollapseFullPath(tryPath);
@@ -2988,7 +2985,7 @@ std::string SystemTools::FindProgram(const std::string& name,
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
// first try with extensions
for (std::string const& ext : extensions) {
- tryPath = p;
+ std::string tryPath = p;
tryPath += name;
tryPath += ext;
if (SystemTools::FileIsExecutable(tryPath)) {
@@ -2997,7 +2994,7 @@ std::string SystemTools::FindProgram(const std::string& name,
}
#endif
// now try it without them
- tryPath = p;
+ std::string tryPath = p;
tryPath += name;
if (SystemTools::FileIsExecutable(tryPath)) {
return SystemTools::CollapseFullPath(tryPath);
@@ -3152,16 +3149,13 @@ bool SystemTools::FileIsDirectory(const std::string& inName)
#if defined(_WIN32)
DWORD attr =
GetFileAttributesW(Encoding::ToWindowsExtendedPath(name).c_str());
- if (attr != INVALID_FILE_ATTRIBUTES) {
- return (attr & FILE_ATTRIBUTE_DIRECTORY) != 0;
+ return (attr != INVALID_FILE_ATTRIBUTES) &&
+ (attr & FILE_ATTRIBUTE_DIRECTORY);
#else
struct stat fs;
- if (stat(name, &fs) == 0) {
- return S_ISDIR(fs.st_mode);
+
+ return (stat(name, &fs) == 0) && S_ISDIR(fs.st_mode);
#endif
- } else {
- return false;
- }
}
bool SystemTools::FileIsExecutable(const std::string& inName)
@@ -3226,11 +3220,7 @@ bool SystemTools::FileIsSymlink(const std::string& name)
return FileIsSymlinkWithAttr(path, GetFileAttributesW(path.c_str()));
#else
struct stat fs;
- if (lstat(name.c_str(), &fs) == 0) {
- return S_ISLNK(fs.st_mode);
- } else {
- return false;
- }
+ return (lstat(name.c_str(), &fs) == 0) && S_ISLNK(fs.st_mode);
#endif
}
@@ -3248,11 +3238,7 @@ bool SystemTools::FileIsFIFO(const std::string& name)
return type == FILE_TYPE_PIPE;
#else
struct stat fs;
- if (lstat(name.c_str(), &fs) == 0) {
- return S_ISFIFO(fs.st_mode);
- } else {
- return false;
- }
+ return (lstat(name.c_str(), &fs) == 0) && S_ISFIFO(fs.st_mode);
#endif
}