Skip to content

Commit 7e3f90d

Browse files
kwrobotdzenanz
authored andcommitted
KWSys 2024-03-08 (bc0706e7)
Code extracted from: https://gitlab.kitware.com/utils/kwsys.git at commit bc0706e73e38c043e14223621a6329ed1038095e (master). Upstream Shortlog ----------------- Brad King (1): 3c922475 Convert http URLs to https Christoph Grüninger (3): d3f3c38b Use prefix ++ operators for non-primitive types 9fd52415 Range-for loop with const reference 2310be95 Make variable more local scivision (1): 6624edf2 SystemTools:FileIs{Directory,Executable,FIFO}: refactor for simplicity
1 parent 20e9839 commit 7e3f90d

File tree

8 files changed

+30
-44
lines changed

8 files changed

+30
-44
lines changed

CONTRIBUTING.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ code. It automatically runs ``clang-format`` on the set of source files
3434
for which we enforce style. The script also has options to format only
3535
a subset of files, such as those that are locally modified.
3636

37-
.. _`clang-format`: http://clang.llvm.org/docs/ClangFormat.html
37+
.. _`clang-format`: https://clang.llvm.org/docs/ClangFormat.html
3838
.. _`.clang-format`: .clang-format
3939
.. _`clang-format.bash`: clang-format.bash
4040

CommandLineArguments.cxx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ bool CommandLineArguments::GetMatchedArguments(
132132

133133
// Does the argument match to any we know about?
134134
for (it = this->Internals->Callbacks.begin();
135-
it != this->Internals->Callbacks.end(); it++) {
135+
it != this->Internals->Callbacks.end(); ++it) {
136136
const CommandLineArguments::Internal::String& parg = it->first;
137137
CommandLineArgumentsCallbackStructure* cs = &it->second;
138138
if (cs->ArgumentType == CommandLineArguments::NO_ARGUMENT ||
@@ -467,7 +467,7 @@ void CommandLineArguments::GenerateHelp()
467467
MapArgs mp;
468468
MapArgs::iterator mpit, smpit;
469469
for (it = this->Internals->Callbacks.begin();
470-
it != this->Internals->Callbacks.end(); it++) {
470+
it != this->Internals->Callbacks.end(); ++it) {
471471
CommandLineArgumentsCallbackStructure* cs = &(it->second);
472472
mpit = mp.find(cs->Help);
473473
if (mpit != mp.end()) {
@@ -478,14 +478,14 @@ void CommandLineArguments::GenerateHelp()
478478
}
479479
}
480480
for (it = this->Internals->Callbacks.begin();
481-
it != this->Internals->Callbacks.end(); it++) {
481+
it != this->Internals->Callbacks.end(); ++it) {
482482
CommandLineArgumentsCallbackStructure* cs = &(it->second);
483483
mpit = mp.find(cs->Help);
484484
if (mpit != mp.end()) {
485485
mpit->second.insert(it->first);
486486
smpit = mp.find(it->first);
487487
CommandLineArguments::Internal::SetOfStrings::iterator sit;
488-
for (sit = smpit->second.begin(); sit != smpit->second.end(); sit++) {
488+
for (sit = smpit->second.begin(); sit != smpit->second.end(); ++sit) {
489489
mpit->second.insert(*sit);
490490
}
491491
mp.erase(smpit);
@@ -496,9 +496,9 @@ void CommandLineArguments::GenerateHelp()
496496

497497
// Find the length of the longest string
498498
CommandLineArguments::Internal::String::size_type maxlen = 0;
499-
for (mpit = mp.begin(); mpit != mp.end(); mpit++) {
499+
for (mpit = mp.begin(); mpit != mp.end(); ++mpit) {
500500
CommandLineArguments::Internal::SetOfStrings::iterator sit;
501-
for (sit = mpit->second.begin(); sit != mpit->second.end(); sit++) {
501+
for (sit = mpit->second.begin(); sit != mpit->second.end(); ++sit) {
502502
CommandLineArguments::Internal::String::size_type clen = sit->size();
503503
switch (this->Internals->Callbacks[*sit].ArgumentType) {
504504
case CommandLineArguments::NO_ARGUMENT:
@@ -524,9 +524,9 @@ void CommandLineArguments::GenerateHelp()
524524
maxlen += 4; // For the space before and after the option
525525

526526
// Print help for each option
527-
for (mpit = mp.begin(); mpit != mp.end(); mpit++) {
527+
for (mpit = mp.begin(); mpit != mp.end(); ++mpit) {
528528
CommandLineArguments::Internal::SetOfStrings::iterator sit;
529-
for (sit = mpit->second.begin(); sit != mpit->second.end(); sit++) {
529+
for (sit = mpit->second.begin(); sit != mpit->second.end(); ++sit) {
530530
str << std::endl;
531531
std::string argument = *sit;
532532
switch (this->Internals->Callbacks[*sit].ArgumentType) {

Directory.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name,
269269
# include <string.h>
270270

271271
// PGI with glibc has trouble with dirent and large file support:
272-
// http://www.pgroup.com/userforum/viewtopic.php?
272+
// https://www.pgroup.com/userforum/viewtopic.php?
273273
// p=1992&sid=f16167f51964f1a68fe5041b8eb213b6
274274
// Work around the problem by mapping dirent the same way as readdir.
275275
# if defined(__PGI) && defined(__GLIBC__)

MD5.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
5353
This code implements the MD5 Algorithm defined in RFC 1321, whose
5454
text is available at
55-
http://www.ietf.org/rfc/rfc1321.txt
55+
https://www.ietf.org/rfc/rfc1321.txt
5656
The code is derived from the text of the RFC, including the test suite
5757
(section A.5) but excluding the rest of Appendix A. It does not include
5858
any code or documentation that is identified in the RFC as being

SystemInformation.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
// Consider using these on Win32/Win64 for some of them:
2323
//
2424
// IsProcessorFeaturePresent
25-
// http://msdn.microsoft.com/en-us/library/ms724482(VS.85).aspx
25+
// https://msdn.microsoft.com/en-us/library/ms724482(VS.85).aspx
2626
//
2727
// GetProcessMemoryInfo
28-
// http://msdn.microsoft.com/en-us/library/ms683219(VS.85).aspx
28+
// https://msdn.microsoft.com/en-us/library/ms683219(VS.85).aspx
2929

3030
#include "kwsysPrivate.h"
3131
#include KWSYS_HEADER(SystemInformation.hxx)
@@ -4265,7 +4265,7 @@ bool SystemInformationImplementation::QueryCygwinMemory()
42654265
{
42664266
#ifdef __CYGWIN__
42674267
// _SC_PAGE_SIZE does return the mmap() granularity on Cygwin,
4268-
// see http://cygwin.com/ml/cygwin/2006-06/msg00350.html
4268+
// see https://sourceware.org/legacy-ml/cygwin/2006-06/msg00350.html
42694269
// Therefore just use 4096 as the page size of Windows.
42704270
long m = sysconf(_SC_PHYS_PAGES);
42714271
if (m < 0) {
@@ -4890,7 +4890,7 @@ std::string SystemInformationImplementation::ParseValueFromKStat(
48904890
args.reserve(3 + args_string.size());
48914891
args.push_back("kstat");
48924892
args.push_back("-p");
4893-
for (auto& i : args_string) {
4893+
for (const auto& i : args_string) {
48944894
args.push_back(i.c_str());
48954895
}
48964896
args.push_back(nullptr);

SystemTools.cxx

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2867,9 +2867,8 @@ std::string SystemToolsStatic::FindName(
28672867
path.reserve(path.size() + userPaths.size());
28682868
path.insert(path.end(), userPaths.begin(), userPaths.end());
28692869
// now look for the file
2870-
std::string tryPath;
28712870
for (std::string const& p : path) {
2872-
tryPath = p;
2871+
std::string tryPath = p;
28732872
if (tryPath.empty() || tryPath.back() != '/') {
28742873
tryPath += '/';
28752874
}
@@ -2938,8 +2937,6 @@ std::string SystemTools::FindProgram(const std::string& name,
29382937
const std::vector<std::string>& userPaths,
29392938
bool no_system_path)
29402939
{
2941-
std::string tryPath;
2942-
29432940
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
29442941
std::vector<std::string> extensions;
29452942
// check to see if the name already has a .xxx at
@@ -2951,7 +2948,7 @@ std::string SystemTools::FindProgram(const std::string& name,
29512948

29522949
// first try with extensions if the os supports them
29532950
for (std::string const& ext : extensions) {
2954-
tryPath = name;
2951+
std::string tryPath = name;
29552952
tryPath += ext;
29562953
if (SystemTools::FileIsExecutable(tryPath)) {
29572954
return SystemTools::CollapseFullPath(tryPath);
@@ -2988,7 +2985,7 @@ std::string SystemTools::FindProgram(const std::string& name,
29882985
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
29892986
// first try with extensions
29902987
for (std::string const& ext : extensions) {
2991-
tryPath = p;
2988+
std::string tryPath = p;
29922989
tryPath += name;
29932990
tryPath += ext;
29942991
if (SystemTools::FileIsExecutable(tryPath)) {
@@ -2997,7 +2994,7 @@ std::string SystemTools::FindProgram(const std::string& name,
29972994
}
29982995
#endif
29992996
// now try it without them
3000-
tryPath = p;
2997+
std::string tryPath = p;
30012998
tryPath += name;
30022999
if (SystemTools::FileIsExecutable(tryPath)) {
30033000
return SystemTools::CollapseFullPath(tryPath);
@@ -3152,16 +3149,13 @@ bool SystemTools::FileIsDirectory(const std::string& inName)
31523149
#if defined(_WIN32)
31533150
DWORD attr =
31543151
GetFileAttributesW(Encoding::ToWindowsExtendedPath(name).c_str());
3155-
if (attr != INVALID_FILE_ATTRIBUTES) {
3156-
return (attr & FILE_ATTRIBUTE_DIRECTORY) != 0;
3152+
return (attr != INVALID_FILE_ATTRIBUTES) &&
3153+
(attr & FILE_ATTRIBUTE_DIRECTORY);
31573154
#else
31583155
struct stat fs;
3159-
if (stat(name, &fs) == 0) {
3160-
return S_ISDIR(fs.st_mode);
3156+
3157+
return (stat(name, &fs) == 0) && S_ISDIR(fs.st_mode);
31613158
#endif
3162-
} else {
3163-
return false;
3164-
}
31653159
}
31663160

31673161
bool SystemTools::FileIsExecutable(const std::string& inName)
@@ -3226,11 +3220,7 @@ bool SystemTools::FileIsSymlink(const std::string& name)
32263220
return FileIsSymlinkWithAttr(path, GetFileAttributesW(path.c_str()));
32273221
#else
32283222
struct stat fs;
3229-
if (lstat(name.c_str(), &fs) == 0) {
3230-
return S_ISLNK(fs.st_mode);
3231-
} else {
3232-
return false;
3233-
}
3223+
return (lstat(name.c_str(), &fs) == 0) && S_ISLNK(fs.st_mode);
32343224
#endif
32353225
}
32363226

@@ -3248,11 +3238,7 @@ bool SystemTools::FileIsFIFO(const std::string& name)
32483238
return type == FILE_TYPE_PIPE;
32493239
#else
32503240
struct stat fs;
3251-
if (lstat(name.c_str(), &fs) == 0) {
3252-
return S_ISFIFO(fs.st_mode);
3253-
} else {
3254-
return false;
3255-
}
3241+
return (lstat(name.c_str(), &fs) == 0) && S_ISFIFO(fs.st_mode);
32563242
#endif
32573243
}
32583244

@@ -4889,7 +4875,7 @@ SystemToolsManager::~SystemToolsManager()
48894875

48904876
#if defined(__VMS)
48914877
// On VMS we configure the run time C library to be more UNIX like.
4892-
// http://h71000.www7.hp.com/doc/732final/5763/5763pro_004.html
4878+
// https://h71000.www7.hp.com/doc/732final/5763/5763pro_004.html
48934879
extern "C" int decc$feature_get_index(char* name);
48944880
extern "C" int decc$feature_set_value(int index, int mode, int value);
48954881
static int SetVMSFeature(char* name, int value)

Terminal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ static const char* kwsysTerminalVT100Names[] = { "Eterm",
168168
static int kwsysTerminalStreamIsVT100(FILE* stream, int default_vt100,
169169
int default_tty)
170170
{
171-
/* Force color according to http://bixense.com/clicolors/ convention. */
171+
/* Force color according to https://bixense.com/clicolors/ convention. */
172172
{
173173
const char* clicolor_force = getenv("CLICOLOR_FORCE");
174174
if (clicolor_force && *clicolor_force &&
@@ -177,7 +177,7 @@ static int kwsysTerminalStreamIsVT100(FILE* stream, int default_vt100,
177177
}
178178
}
179179

180-
/* Disable color according to http://bixense.com/clicolors/ convention. */
180+
/* Disable color according to https://bixense.com/clicolors/ convention. */
181181
{
182182
const char* clicolor = getenv("CLICOLOR");
183183
if (clicolor && strcmp(clicolor, "0") == 0) {

testSystemTools.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,12 +1148,12 @@ static bool CheckCopyFileIfDifferent()
11481148
static bool CheckURLParsing()
11491149
{
11501150
bool ret = true;
1151-
std::string url = "http://user:pw@hostname:42/full/url.com";
1151+
std::string url = "https://user:pw@hostname:42/full/url.com";
11521152

11531153
std::string protocol, username, password, hostname, dataport, database;
11541154
kwsys::SystemTools::ParseURL(url, protocol, username, password, hostname,
11551155
dataport, database);
1156-
if (protocol != "http" || username != "user" || password != "pw" ||
1156+
if (protocol != "https" || username != "user" || password != "pw" ||
11571157
hostname != "hostname" || dataport != "42" ||
11581158
database != "full/url.com") {
11591159
std::cerr << "Incorrect URL parsing" << std::endl;

0 commit comments

Comments
 (0)