mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
Merge branch 'upstream-KWSys' into update-kwsys
# By KWSys Upstream * upstream-KWSys: KWSys 2024-02-15 (aad06964)
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user