Remove some FXSYS_ functions in favor of std::char_traits<>.

Follow-on CL from an offline discussion about "what is char traits
good for?"

Change-Id: Ief99e97e8337b97bcc6816e3168df9835d95e5f9
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117671
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdftext/cpdf_linkextract.cpp b/core/fpdftext/cpdf_linkextract.cpp
index ab6c395..431b555 100644
--- a/core/fpdftext/cpdf_linkextract.cpp
+++ b/core/fpdftext/cpdf_linkextract.cpp
@@ -6,6 +6,8 @@
 
 #include "core/fpdftext/cpdf_linkextract.h"
 
+#include <wchar.h>
+
 #include <vector>
 
 #include "core/fpdftext/cpdf_textpage.h"
@@ -181,8 +183,8 @@
   static const wchar_t kHttpScheme[] = L"http";
   static const wchar_t kWWWAddrStart[] = L"www.";
 
-  const size_t kHttpSchemeLen = FXSYS_len(kHttpScheme);
-  const size_t kWWWAddrStartLen = FXSYS_len(kWWWAddrStart);
+  const size_t kHttpSchemeLen = wcslen(kHttpScheme);
+  const size_t kWWWAddrStartLen = wcslen(kWWWAddrStart);
 
   WideString str = strBeCheck;
   str.MakeLower();
diff --git a/core/fxcrt/fx_memcpy_wrappers.h b/core/fxcrt/fx_memcpy_wrappers.h
index 2dc8c1c..7751eee 100644
--- a/core/fxcrt/fx_memcpy_wrappers.h
+++ b/core/fxcrt/fx_memcpy_wrappers.h
@@ -58,29 +58,4 @@
   return len ? wmemchr(ptr1, val, len) : nullptr;
 }
 
-// Overloaded functions for C++ templates
-inline size_t FXSYS_len(const char* ptr) {
-  return strlen(ptr);
-}
-
-inline size_t FXSYS_len(const wchar_t* ptr) {
-  return wcslen(ptr);
-}
-
-inline int FXSYS_cmp(const char* ptr1, const char* ptr2, size_t len) {
-  return FXSYS_memcmp(ptr1, ptr2, len);
-}
-
-inline int FXSYS_cmp(const wchar_t* ptr1, const wchar_t* ptr2, size_t len) {
-  return FXSYS_wmemcmp(ptr1, ptr2, len);
-}
-
-inline const char* FXSYS_chr(const char* ptr, char ch, size_t len) {
-  return reinterpret_cast<const char*>(FXSYS_memchr(ptr, ch, len));
-}
-
-inline const wchar_t* FXSYS_chr(const wchar_t* ptr, wchar_t ch, size_t len) {
-  return FXSYS_wmemchr(ptr, ch, len);
-}
-
 #endif  // CORE_FXCRT_FX_MEMCPY_WRAPPERS_H_
diff --git a/core/fxcrt/string_view_template.h b/core/fxcrt/string_view_template.h
index b0e3864..e65ee28 100644
--- a/core/fxcrt/string_view_template.h
+++ b/core/fxcrt/string_view_template.h
@@ -12,6 +12,7 @@
 #include <algorithm>
 #include <iterator>
 #include <optional>
+#include <string>
 #include <type_traits>
 
 #include "core/fxcrt/compiler_specific.h"
@@ -48,7 +49,7 @@
   // NOLINTNEXTLINE(runtime/explicit)
   StringViewTemplate(const CharType* ptr) noexcept
       : m_Span(reinterpret_cast<const UnsignedType*>(ptr),
-               ptr ? FXSYS_len(ptr) : 0) {}
+               ptr ? std::char_traits<CharType>::length(ptr) : 0) {}
 
   constexpr StringViewTemplate(const CharType* ptr, size_t size) noexcept
       : m_Span(reinterpret_cast<const UnsignedType*>(ptr), size) {}
@@ -79,7 +80,8 @@
 
   StringViewTemplate& operator=(const CharType* src) {
     m_Span = pdfium::span<const UnsignedType>(
-        reinterpret_cast<const UnsignedType*>(src), src ? FXSYS_len(src) : 0);
+        reinterpret_cast<const UnsignedType*>(src),
+        src ? std::char_traits<CharType>::length(src) : 0);
     return *this;
   }
 
@@ -196,8 +198,10 @@
   UnsignedType Back() const { return !m_Span.empty() ? m_Span.back() : 0; }
 
   std::optional<size_t> Find(CharType ch) const {
-    const auto* found = reinterpret_cast<const UnsignedType*>(FXSYS_chr(
-        reinterpret_cast<const CharType*>(m_Span.data()), ch, m_Span.size()));
+    const auto* found =
+        reinterpret_cast<const UnsignedType*>(std::char_traits<CharType>::find(
+            reinterpret_cast<const CharType*>(m_Span.data()), m_Span.size(),
+            ch));
 
     return found ? std::optional<size_t>(found - m_Span.data()) : std::nullopt;
   }
@@ -252,18 +256,24 @@
   }
 
   bool operator<(const StringViewTemplate& that) const {
+    const size_t common_size = std::min(m_Span.size(), that.m_Span.size());
     int result =
-        FXSYS_cmp(reinterpret_cast<const CharType*>(m_Span.data()),
-                  reinterpret_cast<const CharType*>(that.m_Span.data()),
-                  std::min(m_Span.size(), that.m_Span.size()));
+        common_size ? std::char_traits<CharType>::compare(
+                          reinterpret_cast<const CharType*>(m_Span.data()),
+                          reinterpret_cast<const CharType*>(that.m_Span.data()),
+                          common_size)
+                    : 0;
     return result < 0 || (result == 0 && m_Span.size() < that.m_Span.size());
   }
 
   bool operator>(const StringViewTemplate& that) const {
+    const size_t common_size = std::min(m_Span.size(), that.m_Span.size());
     int result =
-        FXSYS_cmp(reinterpret_cast<const CharType*>(m_Span.data()),
-                  reinterpret_cast<const CharType*>(that.m_Span.data()),
-                  std::min(m_Span.size(), that.m_Span.size()));
+        common_size ? std::char_traits<CharType>::compare(
+                          reinterpret_cast<const CharType*>(m_Span.data()),
+                          reinterpret_cast<const CharType*>(that.m_Span.data()),
+                          common_size)
+                    : 0;
     return result > 0 || (result == 0 && m_Span.size() > that.m_Span.size());
   }