mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-23 14:48:19 -05:00
Merge branch 'upstream-KWSys' into update-kwsys
# By KWSys Upstream * upstream-KWSys: KWSys 2024-09-03 (9c5f00b7)
This commit is contained in:
@@ -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();
|
||||
@@ -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();
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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));
|
||||
@@ -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;
|
||||
@@ -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))
|
||||
@@ -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.
|
||||
@@ -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);
|
||||
@@ -559,7 +559,7 @@ char* RegExpCompile::regpiece(int* flagp)
|
||||
int flags;
|
||||
|
||||
ret = regatom(&flags);
|
||||
if (ret == nullptr)
|
||||
if (!ret)
|
||||
return (nullptr);
|
||||
|
||||
op = *regparse;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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++;
|
||||
@@ -969,7 +969,7 @@ int RegExpFind::regmatch(const char* prog)
|
||||
|
||||
scan = prog;
|
||||
|
||||
while (scan != nullptr) {
|
||||
while (scan) {
|
||||
|
||||
next = regnext(scan);
|
||||
|
||||
@@ -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;
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
}
|
||||
@@ -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++;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ inline RegularExpressionMatch::RegularExpressionMatch()
|
||||
*/
|
||||
inline bool RegularExpressionMatch::isValid() const
|
||||
{
|
||||
return (this->startp[0] != nullptr);
|
||||
return (this->startp[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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(
|
||||
@@ -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()
|
||||
|
||||
@@ -874,7 +874,7 @@ int LoadLines(FILE* file, std::vector<std::string>& lines)
|
||||
char buf[bufSize] = { '\0' };
|
||||
while (!feof(file) && !ferror(file)) {
|
||||
errno = 0;
|
||||
if (fgets(buf, bufSize, file) == nullptr) {
|
||||
if (!fgets(buf, bufSize, file)) {
|
||||
if (ferror(file) && (errno == EINTR)) {
|
||||
clearerr(file);
|
||||
}
|
||||
@@ -900,7 +900,7 @@ int LoadLines(FILE* file, std::vector<std::string>& lines)
|
||||
int LoadLines(const char* fileName, std::vector<std::string>& lines)
|
||||
{
|
||||
FILE* file = fopen(fileName, "r");
|
||||
if (file == nullptr) {
|
||||
if (!file) {
|
||||
return 0;
|
||||
}
|
||||
int nRead = LoadLines(file, lines);
|
||||
@@ -938,7 +938,7 @@ int GetFieldsFromFile(const char* fileName, const char** fieldNames, T* values)
|
||||
return -1;
|
||||
}
|
||||
int i = 0;
|
||||
while (fieldNames[i] != nullptr) {
|
||||
while (fieldNames[i]) {
|
||||
int ierr = NameValue(fields, fieldNames[i], values[i]);
|
||||
if (ierr) {
|
||||
return -(i + 2);
|
||||
@@ -970,7 +970,7 @@ int GetFieldsFromCommand(const char* command, const char** fieldNames,
|
||||
T* values)
|
||||
{
|
||||
FILE* file = popen(command, "r");
|
||||
if (file == nullptr) {
|
||||
if (!file) {
|
||||
return -1;
|
||||
}
|
||||
std::vector<std::string> fields;
|
||||
@@ -980,7 +980,7 @@ int GetFieldsFromCommand(const char* command, const char** fieldNames,
|
||||
return -1;
|
||||
}
|
||||
int i = 0;
|
||||
while (fieldNames[i] != nullptr) {
|
||||
while (fieldNames[i]) {
|
||||
int ierr = NameValue(fields, fieldNames[i], values[i]);
|
||||
if (ierr) {
|
||||
return -(i + 2);
|
||||
@@ -1016,7 +1016,7 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo,
|
||||
break;
|
||||
|
||||
case SIGFPE:
|
||||
oss << "Caught SIGFPE at " << (sigInfo->si_addr == nullptr ? "0x" : "")
|
||||
oss << "Caught SIGFPE at " << (sigInfo->si_addr ? "" : "0x")
|
||||
<< sigInfo->si_addr << " ";
|
||||
switch (sigInfo->si_code) {
|
||||
# if defined(FPE_INTDIV)
|
||||
@@ -1064,7 +1064,7 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo,
|
||||
break;
|
||||
|
||||
case SIGSEGV:
|
||||
oss << "Caught SIGSEGV at " << (sigInfo->si_addr == nullptr ? "0x" : "")
|
||||
oss << "Caught SIGSEGV at " << (sigInfo->si_addr ? "" : "0x")
|
||||
<< sigInfo->si_addr << " ";
|
||||
switch (sigInfo->si_code) {
|
||||
case SEGV_MAPERR:
|
||||
@@ -1082,7 +1082,7 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo,
|
||||
break;
|
||||
|
||||
case SIGBUS:
|
||||
oss << "Caught SIGBUS at " << (sigInfo->si_addr == nullptr ? "0x" : "")
|
||||
oss << "Caught SIGBUS at " << (sigInfo->si_addr ? "" : "0x")
|
||||
<< sigInfo->si_addr << " ";
|
||||
switch (sigInfo->si_code) {
|
||||
case BUS_ADRALN:
|
||||
@@ -1122,7 +1122,7 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo,
|
||||
break;
|
||||
|
||||
case SIGILL:
|
||||
oss << "Caught SIGILL at " << (sigInfo->si_addr == nullptr ? "0x" : "")
|
||||
oss << "Caught SIGILL at " << (sigInfo->si_addr ? "" : "0x")
|
||||
<< sigInfo->si_addr << " ";
|
||||
switch (sigInfo->si_code) {
|
||||
case ILL_ILLOPC:
|
||||
@@ -1659,7 +1659,7 @@ int SystemInformationImplementation::GetFullyQualifiedDomainName(
|
||||
return -2;
|
||||
}
|
||||
|
||||
for (ifa = ifas; ifa != nullptr; ifa = ifa->ifa_next) {
|
||||
for (ifa = ifas; ifa; ifa = ifa->ifa_next) {
|
||||
int fam = ifa->ifa_addr ? ifa->ifa_addr->sa_family : -1;
|
||||
// Skip Loopback interfaces
|
||||
if (((fam == AF_INET) || (fam == AF_INET6)) &&
|
||||
@@ -3886,7 +3886,7 @@ long long SystemInformationImplementation::GetProcMemoryUsed()
|
||||
std::ostringstream oss;
|
||||
oss << "ps -o rss= -p " << pid;
|
||||
FILE* file = popen(oss.str().c_str(), "r");
|
||||
if (file == nullptr) {
|
||||
if (!file) {
|
||||
return -1;
|
||||
}
|
||||
oss.str("");
|
||||
|
||||
@@ -268,7 +268,7 @@ static inline char* realpath(const char* path, char* resolved_path)
|
||||
snprintf(resolved_path, maxlen, "%s", path);
|
||||
BPath normalized(resolved_path, nullptr, true);
|
||||
const char* resolved = normalized.Path();
|
||||
if (resolved != nullptr) // nullptr == No such file.
|
||||
if (resolved) // nullptr == No such file.
|
||||
{
|
||||
if (snprintf(resolved_path, maxlen, "%s", resolved) < maxlen) {
|
||||
return resolved_path;
|
||||
@@ -798,7 +798,7 @@ bool SystemTools::HasEnv(const char* key)
|
||||
#else
|
||||
const char* v = getenv(key);
|
||||
#endif
|
||||
return v != nullptr;
|
||||
return v;
|
||||
}
|
||||
|
||||
bool SystemTools::HasEnv(const std::string& key)
|
||||
@@ -1167,7 +1167,7 @@ static DWORD SystemToolsMakeRegistryMode(DWORD mode,
|
||||
// only add the modes when on a system that supports Wow64.
|
||||
static FARPROC wow64p =
|
||||
GetProcAddress(GetModuleHandleW(L"kernel32"), "IsWow64Process");
|
||||
if (wow64p == nullptr) {
|
||||
if (!wow64p) {
|
||||
return mode;
|
||||
}
|
||||
|
||||
@@ -3394,7 +3394,7 @@ Status SystemTools::ReadSymlink(std::string const& newName,
|
||||
// terminated by an empty string (0-0). We need the third string.
|
||||
size_t destLen;
|
||||
substituteNameData = GetAppExecLink(data, destLen);
|
||||
if (substituteNameData == nullptr || destLen == 0) {
|
||||
if (!substituteNameData || destLen == 0) {
|
||||
return Status::Windows(ERROR_SYMLINK_NOT_SUPPORTED);
|
||||
}
|
||||
substituteNameLength = static_cast<USHORT>(destLen);
|
||||
|
||||
Reference in New Issue
Block a user