mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-10-07 04:02:23 +03:00
KWSys 2026-02-06 (3d72d062)
Code extracted from:
https://gitlab.kitware.com/utils/kwsys.git
at commit 3d72d06204c97f124fc9a56fc3e6e077ebdf0862 (master).
Upstream Shortlog
-----------------
Brad King (2):
9551db0a SystemTools: Fix argument type in tolower/toupper calls
44f37675 Process: Fix process tree termination on NetBSD
This commit is contained in:
1 parent
115d2eaaa2
commit
f7607963a5
4 files changed
+36
-12
No files matched your search
@@ -162,7 +162,7 @@ std::string Glob::PatternToRegex(std::string const& pattern,
|
||||
// On case-insensitive systems file names are converted to lower
|
||||
// case before matching.
|
||||
if (!preserve_case) {
|
||||
ch = tolower(ch);
|
||||
ch = tolower(static_cast<unsigned char>(ch));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
+2
-1
@@ -2502,7 +2502,8 @@ static pid_t kwsysProcessFork(kwsysProcess* cp,
|
||||
corresponding parsing format string. The parsing format should
|
||||
have two integers to store: the pid and then the ppid. */
|
||||
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
|
||||
defined(__OpenBSD__) || defined(__GLIBC__) || defined(__GNU__)
|
||||
defined(__NetBSD__) || defined(__OpenBSD__) || defined(__GLIBC__) || \
|
||||
defined(__GNU__)
|
||||
# define KWSYSPE_PS_COMMAND "ps axo pid,ppid"
|
||||
# define KWSYSPE_PS_FORMAT "%d %d\n"
|
||||
#elif defined(__sun) && (defined(__SVR4) || defined(__svr4__)) /* Solaris */
|
||||
|
||||
+18
-10
@@ -320,7 +320,8 @@ inline char const* Getcwd(char* buf, unsigned int len)
|
||||
if (nlen < len) {
|
||||
// make sure the drive letter is capital
|
||||
if (nlen > 1 && buf[1] == ':') {
|
||||
buf[0] = toupper(buf[0]);
|
||||
buf[0] =
|
||||
static_cast<char>(toupper(static_cast<unsigned char>(buf[0])));
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
@@ -552,7 +553,8 @@ std::string SystemToolsStatic::GetCasePathName(std::string const& pathIn)
|
||||
casePath = path_components[idx++];
|
||||
// make sure drive letter is always upper case
|
||||
if (casePath.size() > 1 && casePath[1] == ':') {
|
||||
casePath[0] = toupper(casePath[0]);
|
||||
casePath[0] = static_cast<std::string::value_type>(
|
||||
toupper(static_cast<unsigned char>(casePath[0])));
|
||||
}
|
||||
char const* sep = "";
|
||||
|
||||
@@ -1656,9 +1658,11 @@ std::string SystemTools::Capitalized(std::string const& s)
|
||||
return n;
|
||||
}
|
||||
n.resize(s.size());
|
||||
n[0] = static_cast<std::string::value_type>(toupper(s[0]));
|
||||
n[0] = static_cast<std::string::value_type>(
|
||||
toupper(static_cast<unsigned char>(s[0])));
|
||||
for (size_t i = 1; i < s.size(); i++) {
|
||||
n[i] = static_cast<std::string::value_type>(tolower(s[i]));
|
||||
n[i] = static_cast<std::string::value_type>(
|
||||
tolower(static_cast<unsigned char>(s[i])));
|
||||
}
|
||||
return n;
|
||||
}
|
||||
@@ -1677,7 +1681,8 @@ std::string SystemTools::CapitalizedWords(std::string const& s)
|
||||
if (isalpha(s[i]) && (i == 0 || isspace(s[i - 1])))
|
||||
#endif
|
||||
{
|
||||
n[i] = static_cast<std::string::value_type>(toupper(s[i]));
|
||||
n[i] = static_cast<std::string::value_type>(
|
||||
toupper(static_cast<unsigned char>(s[i])));
|
||||
}
|
||||
}
|
||||
return n;
|
||||
@@ -1697,7 +1702,8 @@ std::string SystemTools::UnCapitalizedWords(std::string const& s)
|
||||
if (isalpha(s[i]) && (i == 0 || isspace(s[i - 1])))
|
||||
#endif
|
||||
{
|
||||
n[i] = static_cast<std::string::value_type>(tolower(s[i]));
|
||||
n[i] = static_cast<std::string::value_type>(
|
||||
tolower(static_cast<unsigned char>(s[i])));
|
||||
}
|
||||
}
|
||||
return n;
|
||||
@@ -1768,7 +1774,8 @@ std::string SystemTools::LowerCase(std::string const& s)
|
||||
std::string n;
|
||||
n.resize(s.size());
|
||||
for (size_t i = 0; i < s.size(); i++) {
|
||||
n[i] = static_cast<std::string::value_type>(tolower(s[i]));
|
||||
n[i] = static_cast<std::string::value_type>(
|
||||
tolower(static_cast<unsigned char>(s[i])));
|
||||
}
|
||||
return n;
|
||||
}
|
||||
@@ -1779,7 +1786,8 @@ std::string SystemTools::UpperCase(std::string const& s)
|
||||
std::string n;
|
||||
n.resize(s.size());
|
||||
for (size_t i = 0; i < s.size(); i++) {
|
||||
n[i] = static_cast<std::string::value_type>(toupper(s[i]));
|
||||
n[i] = static_cast<std::string::value_type>(
|
||||
toupper(static_cast<unsigned char>(s[i])));
|
||||
}
|
||||
return n;
|
||||
}
|
||||
@@ -2743,8 +2751,8 @@ int SystemTools::Strucmp(char const* l, char const* r)
|
||||
int lc;
|
||||
int rc;
|
||||
do {
|
||||
lc = tolower(*l++);
|
||||
rc = tolower(*r++);
|
||||
lc = tolower(static_cast<unsigned char>(*l++));
|
||||
rc = tolower(static_cast<unsigned char>(*r++));
|
||||
} while (lc == rc && lc);
|
||||
return lc - rc;
|
||||
}
|
||||
|
||||
@@ -534,6 +534,21 @@ static bool CheckStringOperations()
|
||||
{
|
||||
bool res = true;
|
||||
|
||||
// Case conversion should only affect ASCII bytes.
|
||||
// Test using a UTF-8 Copyright Symbol because its leading byte
|
||||
// is transformed by MSVC's tolower in a US-ASCII locale.
|
||||
static std::string const sampleUTF8 = "y\xC2\xA9Z"; // Copyright Symbol
|
||||
if (kwsys::SystemTools::LowerCase(sampleUTF8) != "y\xC2\xA9z") {
|
||||
std::cerr << "Problem with LowerCase " << '"' << sampleUTF8 << '"'
|
||||
<< std::endl;
|
||||
res = false;
|
||||
}
|
||||
if (kwsys::SystemTools::UpperCase(sampleUTF8) != "Y\xC2\xA9Z") {
|
||||
std::cerr << "Problem with UpperCase " << '"' << sampleUTF8 << '"'
|
||||
<< std::endl;
|
||||
res = false;
|
||||
}
|
||||
|
||||
std::string test = "mary had a little lamb.";
|
||||
if (kwsys::SystemTools::CapitalizedWords(test) !=
|
||||
"Mary Had A Little Lamb.") {
|
||||
|
||||
Reference in new issue
Block a user