Browse Source

Merge branch 'upstream-KWSys' into update-kwsys

# By KWSys Upstream
* upstream-KWSys:
  KWSys 2026-02-08 (29120a5d)
Brad King 2 weeks ago
parent
commit
bc89442828
2 changed files with 13 additions and 26 deletions
  1. 9 18
      Source/kwsys/SystemTools.cxx
  2. 4 8
      Source/kwsys/SystemTools.hxx.in

+ 9 - 18
Source/kwsys/SystemTools.cxx

@@ -27,6 +27,7 @@
 #include KWSYS_HEADER(Encoding.hxx)
 
 #include <algorithm>
+#include <cctype>
 #include <fstream>
 #include <iostream>
 #include <set>
@@ -1768,28 +1769,18 @@ char* SystemTools::AppendStrings(char const* str1, char const* str2,
   return newstr;
 }
 
-// Return a lower case string
-std::string SystemTools::LowerCase(std::string const& s)
+std::string SystemTools::LowerCase(std::string 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(static_cast<unsigned char>(s[i])));
-  }
-  return n;
+  std::transform(s.begin(), s.end(), s.begin(),
+                 [](unsigned char c) { return std::tolower(c); });
+  return s;
 }
 
-// Return a lower case string
-std::string SystemTools::UpperCase(std::string const& s)
+std::string SystemTools::UpperCase(std::string 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(static_cast<unsigned char>(s[i])));
-  }
-  return n;
+  std::transform(s.begin(), s.end(), s.begin(),
+                 [](unsigned char c) { return std::toupper(c); });
+  return s;
 }
 
 // Count char in string

+ 4 - 8
Source/kwsys/SystemTools.hxx.in

@@ -133,15 +133,11 @@ public:
    */
   static std::string UnCapitalizedWords(std::string const&);
 
-  /**
-   * Return a lower case string
-   */
-  static std::string LowerCase(std::string const&);
+  /** Return a lower-case string.  */
+  static std::string LowerCase(std::string);
 
-  /**
-   * Return a lower case string
-   */
-  static std::string UpperCase(std::string const&);
+  /** Return an upper-case string.  */
+  static std::string UpperCase(std::string);
 
   /**
    * Count char in string