diff options
author | Ryan Harrison <rharrison@chromium.org> | 2018-03-13 15:16:00 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-03-13 15:16:00 +0000 |
commit | 7a1aa5f659110e99950b00b6b326b41436872635 (patch) | |
tree | 16d89f9e2fc865b1a7a7727190938ad8499551e5 /core | |
parent | 0c6b98182403868334b4dfe4852caa4d0e2ba272 (diff) | |
download | pdfium-7a1aa5f659110e99950b00b6b326b41436872635.tar.xz |
Remove usage of FXSYS_*ASCIIlower/upper methodschromium/3370
This replaces them with equivalent FXSYS_*wlower/upper methods, which
uses ICU to perform the correct Unicode operations.
BUG=pdfium:1035
Change-Id: I432db5bef9eda71762016b619d93155949d054db
Reviewed-on: https://pdfium-review.googlesource.com/28530
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/fxcrt/bytestring.cpp | 4 | ||||
-rw-r--r-- | core/fxcrt/fx_extension.cpp | 8 | ||||
-rw-r--r-- | core/fxcrt/fx_extension.h | 16 | ||||
-rw-r--r-- | core/fxcrt/fx_system.cpp | 16 | ||||
-rw-r--r-- | core/fxge/android/cfpf_skiafontmgr.cpp | 4 |
5 files changed, 24 insertions, 24 deletions
diff --git a/core/fxcrt/bytestring.cpp b/core/fxcrt/bytestring.cpp index 2a57602692..f5687c591e 100644 --- a/core/fxcrt/bytestring.cpp +++ b/core/fxcrt/bytestring.cpp @@ -344,8 +344,8 @@ bool ByteString::EqualNoCase(const ByteStringView& str) const { const uint8_t* pThat = str.raw_str(); for (size_t i = 0; i < len; i++) { if ((*pThis) != (*pThat)) { - uint8_t bThis = FXSYS_toASCIIlower(*pThis); - uint8_t bThat = FXSYS_toASCIIlower(*pThat); + uint8_t bThis = tolower(*pThis); + uint8_t bThat = tolower(*pThat); if (bThis != bThat) return false; } diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp index 7bfcec6d42..4448a71a9b 100644 --- a/core/fxcrt/fx_extension.cpp +++ b/core/fxcrt/fx_extension.cpp @@ -68,8 +68,8 @@ int32_t FXSYS_wcsnicmp(const wchar_t* s1, const wchar_t* s2, size_t count) { ASSERT(s1 && s2 && count > 0); wchar_t wch1 = 0, wch2 = 0; while (count-- > 0) { - wch1 = static_cast<wchar_t>(FXSYS_toASCIIlower(*s1++)); - wch2 = static_cast<wchar_t>(FXSYS_toASCIIlower(*s2++)); + wch1 = static_cast<wchar_t>(FXSYS_towlower(*s1++)); + wch2 = static_cast<wchar_t>(FXSYS_towlower(*s2++)); if (wch1 != wch2) break; } @@ -80,7 +80,7 @@ uint32_t FX_HashCode_GetA(const ByteStringView& str, bool bIgnoreCase) { uint32_t dwHashCode = 0; if (bIgnoreCase) { for (const auto& c : str) - dwHashCode = 31 * dwHashCode + FXSYS_toASCIIlower(c); + dwHashCode = 31 * dwHashCode + tolower(c); } else { for (const auto& c : str) dwHashCode = 31 * dwHashCode + c; @@ -92,7 +92,7 @@ uint32_t FX_HashCode_GetW(const WideStringView& str, bool bIgnoreCase) { uint32_t dwHashCode = 0; if (bIgnoreCase) { for (const auto& c : str) - dwHashCode = 1313 * dwHashCode + FXSYS_toASCIIlower(c); + dwHashCode = 1313 * dwHashCode + FXSYS_towlower(c); } else { for (const auto& c : str) dwHashCode = 1313 * dwHashCode + c; diff --git a/core/fxcrt/fx_extension.h b/core/fxcrt/fx_extension.h index 8e9d06694f..0f249f89c8 100644 --- a/core/fxcrt/fx_extension.h +++ b/core/fxcrt/fx_extension.h @@ -26,20 +26,20 @@ float FXSYS_wcstof(const wchar_t* pwsStr, wchar_t* FXSYS_wcsncpy(wchar_t* dstStr, const wchar_t* srcStr, size_t count); int32_t FXSYS_wcsnicmp(const wchar_t* s1, const wchar_t* s2, size_t count); -inline bool FXSYS_isASCIIlower(int32_t ch) { - return ch >= 'a' && ch <= 'z'; +inline bool FXSYS_iswlower(int32_t c) { + return u_islower(c); } -inline bool FXSYS_isASCIIupper(int32_t ch) { - return ch >= 'A' && ch <= 'Z'; +inline bool FXSYS_iswupper(int32_t c) { + return u_isupper(c); } -inline int32_t FXSYS_toASCIIlower(int32_t ch) { - return ch < 'A' || ch > 'Z' ? ch : (ch + 0x20); +inline int32_t FXSYS_towlower(wchar_t c) { + return u_tolower(c); } -inline int32_t FXSYS_toASCIIupper(int32_t ch) { - return ch < 'a' || ch > 'z' ? ch : (ch - 0x20); +inline int32_t FXSYS_towupper(wchar_t c) { + return u_toupper(c); } inline bool FXSYS_iswalpha(wchar_t c) { diff --git a/core/fxcrt/fx_system.cpp b/core/fxcrt/fx_system.cpp index 532e83b949..27cbd65f3c 100644 --- a/core/fxcrt/fx_system.cpp +++ b/core/fxcrt/fx_system.cpp @@ -118,7 +118,7 @@ char* FXSYS_strlwr(char* str) { } char* s = str; while (*str) { - *str = FXSYS_toASCIIlower(*str); + *str = tolower(*str); str++; } return s; @@ -129,7 +129,7 @@ char* FXSYS_strupr(char* str) { } char* s = str; while (*str) { - *str = FXSYS_toASCIIupper(*str); + *str = toupper(*str); str++; } return s; @@ -140,7 +140,7 @@ wchar_t* FXSYS_wcslwr(wchar_t* str) { } wchar_t* s = str; while (*str) { - *str = FXSYS_toASCIIlower(*str); + *str = FXSYS_towlower(*str); str++; } return s; @@ -151,7 +151,7 @@ wchar_t* FXSYS_wcsupr(wchar_t* str) { } wchar_t* s = str; while (*str) { - *str = FXSYS_toASCIIupper(*str); + *str = FXSYS_towupper(*str); str++; } return s; @@ -161,8 +161,8 @@ int FXSYS_stricmp(const char* dst, const char* src) { int f; int l; do { - f = FXSYS_toASCIIupper(*dst); - l = FXSYS_toASCIIupper(*src); + f = toupper(*dst); + l = toupper(*src); ++dst; ++src; } while (f && f == l); @@ -173,8 +173,8 @@ int FXSYS_wcsicmp(const wchar_t* dst, const wchar_t* src) { wchar_t f; wchar_t l; do { - f = FXSYS_toASCIIupper(*dst); - l = FXSYS_toASCIIupper(*src); + f = FXSYS_towupper(*dst); + l = FXSYS_towupper(*src); ++dst; ++src; } while (f && f == l); diff --git a/core/fxge/android/cfpf_skiafontmgr.cpp b/core/fxge/android/cfpf_skiafontmgr.cpp index 7413a69884..d44d7d56d2 100644 --- a/core/fxge/android/cfpf_skiafontmgr.cpp +++ b/core/fxge/android/cfpf_skiafontmgr.cpp @@ -97,7 +97,7 @@ uint32_t FPF_GetHashCode_StringA(const char* pStr, int32_t iLength) { const char* pStrEnd = pStr + iLength; uint32_t uHashCode = 0; while (pStr < pStrEnd) - uHashCode = 31 * uHashCode + FXSYS_toASCIIlower(*pStr++); + uHashCode = 31 * uHashCode + tolower(*pStr++); return uHashCode; } @@ -167,7 +167,7 @@ uint32_t FPF_SKIANormalizeFontName(const ByteStringView& bsfamily) { char ch = pBuffer[i]; if (ch == ' ' || ch == '-' || ch == ',') continue; - dwHash = 31 * dwHash + FXSYS_toASCIIlower(ch); + dwHash = 31 * dwHash + tolower(ch); } return dwHash; } |