summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2018-03-13 15:16:00 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-03-13 15:16:00 +0000
commit7a1aa5f659110e99950b00b6b326b41436872635 (patch)
tree16d89f9e2fc865b1a7a7727190938ad8499551e5
parent0c6b98182403868334b4dfe4852caa4d0e2ba272 (diff)
downloadpdfium-chromium/3370.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>
-rw-r--r--core/fxcrt/bytestring.cpp4
-rw-r--r--core/fxcrt/fx_extension.cpp8
-rw-r--r--core/fxcrt/fx_extension.h16
-rw-r--r--core/fxcrt/fx_system.cpp16
-rw-r--r--core/fxge/android/cfpf_skiafontmgr.cpp4
-rw-r--r--fpdfsdk/pwl/cpwl_list_impl.cpp3
-rw-r--r--fxjs/cfxjse_formcalc_context.cpp2
-rw-r--r--fxjs/cjs_util.cpp4
8 files changed, 28 insertions, 29 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;
}
diff --git a/fpdfsdk/pwl/cpwl_list_impl.cpp b/fpdfsdk/pwl/cpwl_list_impl.cpp
index 561ef1b9f9..8795a67bcd 100644
--- a/fpdfsdk/pwl/cpwl_list_impl.cpp
+++ b/fpdfsdk/pwl/cpwl_list_impl.cpp
@@ -608,8 +608,7 @@ int32_t CPWL_ListCtrl::FindNext(int32_t nIndex, wchar_t nChar) const {
nCircleIndex = 0;
if (Item* pListItem = m_ListItems[nCircleIndex].get()) {
- if (FXSYS_toASCIIupper(pListItem->GetFirstChar()) ==
- FXSYS_toASCIIupper(nChar))
+ if (FXSYS_towupper(pListItem->GetFirstChar()) == FXSYS_towupper(nChar))
return nCircleIndex;
}
}
diff --git a/fxjs/cfxjse_formcalc_context.cpp b/fxjs/cfxjse_formcalc_context.cpp
index 14053c8d33..4157c29426 100644
--- a/fxjs/cfxjse_formcalc_context.cpp
+++ b/fxjs/cfxjse_formcalc_context.cpp
@@ -1892,7 +1892,7 @@ bool CFXJSE_FormCalcContext::IsIsoTimeFormat(const char* pData,
iIndex += kSubSecondLength;
}
- if (iIndex < iLength && FXSYS_toASCIIlower(pData[iIndex]) == 'z')
+ if (iIndex < iLength && FXSYS_towlower(pData[iIndex]) == 'z')
return true;
int32_t iSign = 1;
diff --git a/fxjs/cjs_util.cpp b/fxjs/cjs_util.cpp
index 25d4590259..883d022006 100644
--- a/fxjs/cjs_util.cpp
+++ b/fxjs/cjs_util.cpp
@@ -264,9 +264,9 @@ CJS_Return CJS_Util::printx(CJS_Runtime* pRuntime,
enum CaseMode { kPreserveCase, kUpperCase, kLowerCase };
static wchar_t TranslateCase(wchar_t input, CaseMode eMode) {
- if (eMode == kLowerCase && FXSYS_isASCIIupper(input))
+ if (eMode == kLowerCase && FXSYS_iswupper(input))
return input | 0x20;
- if (eMode == kUpperCase && FXSYS_isASCIIlower(input))
+ if (eMode == kUpperCase && FXSYS_iswlower(input))
return input & ~0x20;
return input;
}