Skip to content

Commit

Permalink
Merge branch 'upstream-KWSys' into update-kwsys
Browse files Browse the repository at this point in the history
# By KWSys Upstream
* upstream-KWSys:
  KWSys 2024-11-30 (dfbcd769)
  • Loading branch information
bradking committed Dec 9, 2024
2 parents 95fdd25 + 464940d commit c188c7f
Show file tree
Hide file tree
Showing 11 changed files with 252 additions and 411 deletions.
14 changes: 3 additions & 11 deletions Modules/ThirdParty/KWSys/src/KWSys/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -410,14 +410,6 @@ if(KWSYS_USE_DynamicLoader)
endif()

if(KWSYS_USE_SystemTools)
if (NOT DEFINED KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP)
set(KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP 1)
endif ()
if (KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP)
set(KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP 1)
else ()
set(KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP 0)
endif ()
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_SETENV
"Checking whether CXX compiler has setenv" DIRECT)
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_UNSETENV
Expand Down Expand Up @@ -692,7 +684,7 @@ foreach(c IN LISTS KWSYS_CLASSES)

# Configure the header for this class.
configure_file(${PROJECT_SOURCE_DIR}/${c}.hxx.in ${KWSYS_HEADER_DIR}/${c}.hxx
@ONLY IMMEDIATE)
@ONLY)
set(KWSYS_CXX_SRCS ${KWSYS_CXX_SRCS} ${KWSYS_HEADER_DIR}/${c}.hxx)

# Create an install target for the header.
Expand All @@ -707,7 +699,7 @@ endforeach()
foreach(h IN LISTS KWSYS_H_FILES)
# Configure the header into the given directory.
configure_file(${PROJECT_SOURCE_DIR}/${h}.h.in ${KWSYS_HEADER_DIR}/${h}.h
@ONLY IMMEDIATE)
@ONLY)
set(KWSYS_C_SRCS ${KWSYS_C_SRCS} ${KWSYS_HEADER_DIR}/${h}.h)

# Create an install target for the header.
Expand All @@ -722,7 +714,7 @@ endforeach()
foreach(h IN LISTS KWSYS_HXX_FILES)
# Configure the header into the given directory.
configure_file(${PROJECT_SOURCE_DIR}/${h}.hxx.in ${KWSYS_HEADER_DIR}/${h}.hxx
@ONLY IMMEDIATE)
@ONLY)
set(KWSYS_CXX_SRCS ${KWSYS_CXX_SRCS} ${KWSYS_HEADER_DIR}/${h}.hxx)

# Create an install target for the header.
Expand Down
5 changes: 0 additions & 5 deletions Modules/ThirdParty/KWSys/src/KWSys/Configure.hxx.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
/* Whether <ext/stdio_filebuf.h> is available. */
#define @KWSYS_NAMESPACE@_CXX_HAS_EXT_STDIO_FILEBUF_H \
@KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H@
/* Whether the translation map is available or not. */
#define @KWSYS_NAMESPACE@_SYSTEMTOOLS_USE_TRANSLATION_MAP \
@KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP@

#if defined(__SUNPRO_CC) && __SUNPRO_CC > 0x5130 && defined(__has_attribute)
# define @KWSYS_NAMESPACE@_has_cpp_attribute(x) __has_attribute(x)
Expand Down Expand Up @@ -58,8 +55,6 @@
# define KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H \
@KWSYS_NAMESPACE@_CXX_HAS_EXT_STDIO_FILEBUF_H
# define KWSYS_FALLTHROUGH @KWSYS_NAMESPACE@_FALLTHROUGH
# define KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP \
@KWSYS_NAMESPACE@_SYSTEMTOOLS_USE_TRANSLATION_MAP
#endif

#endif
8 changes: 4 additions & 4 deletions Modules/ThirdParty/KWSys/src/KWSys/Directory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ Status Directory::Load(std::string const& name, std::string* errorMessage)
DIR* dir = opendir(name.c_str());

if (!dir) {
if (errorMessage != nullptr) {
if (errorMessage) {
*errorMessage = std::string(strerror(errno));
}
return Status::POSIX_errno();
Expand All @@ -303,7 +303,7 @@ Status Directory::Load(std::string const& name, std::string* errorMessage)
this->Internal->Files.emplace_back(d->d_name);
}
if (errno != 0) {
if (errorMessage != nullptr) {
if (errorMessage) {
*errorMessage = std::string(strerror(errno));
}
return Status::POSIX_errno();
Expand All @@ -321,7 +321,7 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name,
DIR* dir = opendir(name.c_str());

if (!dir) {
if (errorMessage != nullptr) {
if (errorMessage) {
*errorMessage = std::string(strerror(errno));
}
return 0;
Expand All @@ -332,7 +332,7 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name,
count++;
}
if (errno != 0) {
if (errorMessage != nullptr) {
if (errorMessage) {
*errorMessage = std::string(strerror(errno));
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion Modules/ThirdParty/KWSys/src/KWSys/ProcessUNIX.c
Original file line number Diff line number Diff line change
Expand Up @@ -2541,7 +2541,7 @@ static void kwsysProcessKill(pid_t process_id)
/* Kill all children if we can find them. */
#if defined(__linux__) || defined(__CYGWIN__)
/* First try using the /proc filesystem. */
if ((procdir = opendir("/proc")) != NULL) {
if ((procdir = opendir("/proc"))) {
# if defined(MAXPATHLEN)
char fname[MAXPATHLEN];
# elif defined(PATH_MAX)
Expand Down
4 changes: 2 additions & 2 deletions Modules/ThirdParty/KWSys/src/KWSys/ProcessWin32.c
Original file line number Diff line number Diff line change
Expand Up @@ -666,14 +666,14 @@ int kwsysProcess_SetWorkingDirectory(kwsysProcess* cp, const char* dir)
if (dir && dir[0]) {
wchar_t* wdir = kwsysEncoding_DupToWide(dir);
/* We must convert the working directory to a full path. */
DWORD length = GetFullPathNameW(wdir, 0, 0, 0);
DWORD length = GetFullPathNameW(wdir, 0, NULL, NULL);
if (length > 0) {
wchar_t* work_dir = malloc(length * sizeof(wchar_t));
if (!work_dir) {
free(wdir);
return 0;
}
if (!GetFullPathNameW(wdir, length, work_dir, 0)) {
if (!GetFullPathNameW(wdir, length, work_dir, NULL)) {
free(work_dir);
free(wdir);
return 0;
Expand Down
56 changes: 28 additions & 28 deletions Modules/ThirdParty/KWSys/src/KWSys/RegularExpression.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ RegularExpression::RegularExpression(const RegularExpression& rxp)
// Copy pointers into last successful "find" operation
this->regmatch = rxp.regmatch;
this->regmust = rxp.regmust; // Copy field
if (rxp.regmust != nullptr) {
if (rxp.regmust) {
char* dum = rxp.program;
ind = 0;
while (dum != rxp.regmust) {
Expand Down Expand Up @@ -81,7 +81,7 @@ RegularExpression& RegularExpression::operator=(const RegularExpression& rxp)
// Copy pointers into last successful "find" operation
this->regmatch = rxp.regmatch;
this->regmust = rxp.regmust; // Copy field
if (rxp.regmust != nullptr) {
if (rxp.regmust) {
char* dum = rxp.program;
ind = 0;
while (dum != rxp.regmust) {
Expand Down Expand Up @@ -339,7 +339,7 @@ bool RegularExpression::compile(const char* exp)
const char* longest;
int flags;

if (exp == nullptr) {
if (!exp) {
// RAISE Error, SYM(RegularExpression), SYM(No_Expr),
printf("RegularExpression::compile(): No expression supplied.\n");
return false;
Expand Down Expand Up @@ -372,7 +372,7 @@ bool RegularExpression::compile(const char* exp)
this->program = new char[comp.regsize];
this->progsize = static_cast<int>(comp.regsize);

if (this->program == nullptr) {
if (!this->program) {
// RAISE Error, SYM(RegularExpression), SYM(Out_Of_Memory),
printf("RegularExpression::compile(): Out of memory.\n");
return false;
Expand Down Expand Up @@ -415,7 +415,7 @@ bool RegularExpression::compile(const char* exp)
if (flags & SPSTART) {
longest = nullptr;
size_t len = 0;
for (; scan != nullptr; scan = regnext(scan))
for (; scan; scan = regnext(scan))
if (OP(scan) == EXACTLY && strlen(OPERAND(scan)) >= len) {
longest = OPERAND(scan);
len = strlen(OPERAND(scan));
Expand Down Expand Up @@ -461,9 +461,9 @@ char* RegExpCompile::reg(int paren, int* flagp)

// Pick up the branches, linking them together.
br = regbranch(&flags);
if (br == nullptr)
if (!br)
return (nullptr);
if (ret != nullptr)
if (ret)
regtail(ret, br); // OPEN -> first.
else
ret = br;
Expand All @@ -473,7 +473,7 @@ char* RegExpCompile::reg(int paren, int* flagp)
while (*regparse == '|') {
regparse++;
br = regbranch(&flags);
if (br == nullptr)
if (!br)
return (nullptr);
regtail(ret, br); // BRANCH -> BRANCH.
if (!(flags & HASWIDTH))
Expand All @@ -486,7 +486,7 @@ char* RegExpCompile::reg(int paren, int* flagp)
regtail(ret, ender);

// Hook the tails of the branches to the closing node.
for (br = ret; br != nullptr; br = regnext(br))
for (br = ret; br; br = regnext(br))
regoptail(br, ender);

// Check for proper termination.
Expand Down Expand Up @@ -527,16 +527,16 @@ char* RegExpCompile::regbranch(int* flagp)
chain = nullptr;
while (*regparse != '\0' && *regparse != '|' && *regparse != ')') {
latest = regpiece(&flags);
if (latest == nullptr)
if (!latest)
return (nullptr);
*flagp |= flags & HASWIDTH;
if (chain == nullptr) // First piece.
if (!chain) // First piece.
*flagp |= flags & SPSTART;
else
regtail(chain, latest);
chain = latest;
}
if (chain == nullptr) // Loop ran zero times.
if (!chain) // Loop ran zero times.
regnode(NOTHING);

return (ret);
Expand All @@ -559,7 +559,7 @@ char* RegExpCompile::regpiece(int* flagp)
int flags;

ret = regatom(&flags);
if (ret == nullptr)
if (!ret)
return (nullptr);

op = *regparse;
Expand Down Expand Up @@ -678,7 +678,7 @@ char* RegExpCompile::regatom(int* flagp)
} break;
case '(':
ret = reg(1, &flags);
if (ret == nullptr)
if (!ret)
return (nullptr);
*flagp |= flags & (HASWIDTH | SPSTART);
break;
Expand Down Expand Up @@ -812,7 +812,7 @@ void RegExpCompile::regtail(char* p, const char* val)
scan = p;
for (;;) {
temp = regnext(scan);
if (temp == nullptr)
if (!temp)
break;
scan = temp;
}
Expand All @@ -831,7 +831,7 @@ void RegExpCompile::regtail(char* p, const char* val)
void RegExpCompile::regoptail(char* p, const char* val)
{
// "Operandless" and "op != BRANCH" are synonymous in practice.
if (p == nullptr || p == regdummyptr || OP(p) != BRANCH)
if (!p || p == regdummyptr || OP(p) != BRANCH)
return;
regtail(OPERAND(p), val);
}
Expand Down Expand Up @@ -881,14 +881,14 @@ bool RegularExpression::find(char const* string,
}

// If there is a "must appear" string, look for it.
if (this->regmust != nullptr) {
if (this->regmust) {
s = string;
while ((s = strchr(s, this->regmust[0])) != nullptr) {
while ((s = strchr(s, this->regmust[0]))) {
if (strncmp(s, this->regmust, this->regmlen) == 0)
break; // Found it.
s++;
}
if (s == nullptr) // Not present.
if (!s) // Not present.
return false;
}

Expand All @@ -906,7 +906,7 @@ bool RegularExpression::find(char const* string,
s = string;
if (this->regstart != '\0')
// We know what char it must start with.
while ((s = strchr(s, this->regstart)) != nullptr) {
while ((s = strchr(s, this->regstart))) {
if (regFind.regtry(s, rmatch.startp, rmatch.endp, this->program))
return true;
s++;
Expand Down Expand Up @@ -969,7 +969,7 @@ int RegExpFind::regmatch(const char* prog)

scan = prog;

while (scan != nullptr) {
while (scan) {

next = regnext(scan);

Expand Down Expand Up @@ -1001,12 +1001,12 @@ int RegExpFind::regmatch(const char* prog)
reginput += len;
} break;
case ANYOF:
if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) == nullptr)
if (*reginput == '\0' || !strchr(OPERAND(scan), *reginput))
return (0);
reginput++;
break;
case ANYBUT:
if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) != nullptr)
if (*reginput == '\0' || strchr(OPERAND(scan), *reginput))
return (0);
reginput++;
break;
Expand Down Expand Up @@ -1058,7 +1058,7 @@ int RegExpFind::regmatch(const char* prog)
// Don't set startp if some later invocation of the
// same parentheses already has.
//
if (regstartp[no] == nullptr)
if (!regstartp[no])
regstartp[no] = save;
return (1);
} else
Expand Down Expand Up @@ -1109,7 +1109,7 @@ int RegExpFind::regmatch(const char* prog)
// Don't set endp if some later invocation of the
// same parentheses already has.
//
if (regendp[no] == nullptr)
if (!regendp[no])
regendp[no] = save;
return (1);
} else
Expand All @@ -1129,7 +1129,7 @@ int RegExpFind::regmatch(const char* prog)
return (1);
reginput = save;
scan = regnext(scan);
} while (scan != nullptr && OP(scan) == BRANCH);
} while (scan && OP(scan) == BRANCH);
return (0);
// NOTREACHED
}
Expand Down Expand Up @@ -1207,13 +1207,13 @@ int RegExpFind::regrepeat(const char* p)
}
break;
case ANYOF:
while (*scan != '\0' && strchr(opnd, *scan) != nullptr) {
while (*scan != '\0' && strchr(opnd, *scan)) {
count++;
scan++;
}
break;
case ANYBUT:
while (*scan != '\0' && strchr(opnd, *scan) == nullptr) {
while (*scan != '\0' && !strchr(opnd, *scan)) {
count++;
scan++;
}
Expand Down
6 changes: 3 additions & 3 deletions Modules/ThirdParty/KWSys/src/KWSys/RegularExpression.hxx.in
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ inline RegularExpressionMatch::RegularExpressionMatch()
*/
inline bool RegularExpressionMatch::isValid() const
{
return (this->startp[0] != nullptr);
return (this->startp[0]);
}

/**
Expand Down Expand Up @@ -140,7 +140,7 @@ inline std::string::size_type RegularExpressionMatch::end(int n) const
*/
inline std::string RegularExpressionMatch::match(int n) const
{
if (this->startp[n] == nullptr) {
if (!this->startp[n]) {
return std::string();
} else {
return std::string(
Expand Down Expand Up @@ -551,7 +551,7 @@ inline bool RegularExpression::operator!=(const RegularExpression& r) const
*/
inline bool RegularExpression::is_valid() const
{
return (this->program != nullptr);
return (this->program);
}

inline void RegularExpression::set_invalid()
Expand Down
Loading

0 comments on commit c188c7f

Please sign in to comment.