From 735eda96cf24349d10b160c8f5bd363b73d8aba1 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Mon, 12 Mar 2018 15:44:36 +0000 Subject: Remove all usages of FXSYS_iswASCIIalpha Instances are either replaced with FXSYS_iswalpha, which calls out to the ICU library to do the proper Unicode operations, or have been converted to a isascii && isalpha pair, if ASCII alpha is actually what was wanted. BUG=pdfium:1035 Change-Id: I971ff639ee1ff818ad08793a1900a8bcbb0a3e04 Reviewed-on: https://pdfium-review.googlesource.com/28450 Reviewed-by: dsinclair Commit-Queue: Ryan Harrison --- core/fpdftext/cpdf_textpage.cpp | 2 +- core/fxcrt/css/cfx_cssselector.cpp | 2 +- core/fxcrt/css/cfx_csssyntaxparser.cpp | 3 ++- core/fxcrt/fx_extension.h | 4 ++-- fxjs/cjs_publicmethods.cpp | 2 +- fxjs/cjs_util.cpp | 2 +- xfa/fgas/crt/cfgas_formatstring.cpp | 8 ++++---- xfa/fxfa/fm2js/cxfa_fmlexer.cpp | 2 +- 8 files changed, 13 insertions(+), 12 deletions(-) diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp index 7541dae6a7..e712549ceb 100644 --- a/core/fpdftext/cpdf_textpage.cpp +++ b/core/fpdftext/cpdf_textpage.cpp @@ -1210,7 +1210,7 @@ bool CPDF_TextPage::IsHyphen(wchar_t curChar) const { if ((iter + 1) != curText.rend()) { iter++; - if (FXSYS_iswASCIIalpha(*iter) && FXSYS_iswalnum(curChar)) + if (FXSYS_iswalpha(*iter) && FXSYS_iswalnum(curChar)) return true; } diff --git a/core/fxcrt/css/cfx_cssselector.cpp b/core/fxcrt/css/cfx_cssselector.cpp index 8a22b12287..510114f2e5 100644 --- a/core/fxcrt/css/cfx_cssselector.cpp +++ b/core/fxcrt/css/cfx_cssselector.cpp @@ -67,7 +67,7 @@ std::unique_ptr CFX_CSSSelector::FromString( std::unique_ptr pFirst = nullptr; for (psz = pStart; psz < pEnd;) { wchar_t wch = *psz; - if (FXSYS_iswASCIIalpha(wch) || wch == '*') { + if ((isascii(wch) && isalpha(wch)) || wch == '*') { int32_t iNameLen = wch == '*' ? 1 : GetCSSNameLen(psz, pEnd); auto p = pdfium::MakeUnique(CFX_CSSSelectorType::Element, psz, iNameLen, true); diff --git a/core/fxcrt/css/cfx_csssyntaxparser.cpp b/core/fxcrt/css/cfx_csssyntaxparser.cpp index fea951f1ec..97586dc59f 100644 --- a/core/fxcrt/css/cfx_csssyntaxparser.cpp +++ b/core/fxcrt/css/cfx_csssyntaxparser.cpp @@ -18,7 +18,8 @@ namespace { bool IsSelectorStart(wchar_t wch) { - return wch == '.' || wch == '#' || wch == '*' || FXSYS_iswASCIIalpha(wch); + return wch == '.' || wch == '#' || wch == '*' || + (isascii(wch) && isalpha(wch)); } } // namespace diff --git a/core/fxcrt/fx_extension.h b/core/fxcrt/fx_extension.h index bd0ac8b303..fd7b78afdb 100644 --- a/core/fxcrt/fx_extension.h +++ b/core/fxcrt/fx_extension.h @@ -42,8 +42,8 @@ inline int32_t FXSYS_toASCIIupper(int32_t ch) { return ch < 'a' || ch > 'z' ? ch : (ch - 0x20); } -inline bool FXSYS_iswASCIIalpha(wchar_t wch) { - return FXSYS_isASCIIupper(wch) || FXSYS_isASCIIlower(wch); +inline bool FXSYS_iswalpha(wchar_t c) { + return u_isalpha(c); } inline bool FXSYS_iswalnum(wchar_t c) { diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp index 81a84d286b..ea4ea713d8 100644 --- a/fxjs/cjs_publicmethods.cpp +++ b/fxjs/cjs_publicmethods.cpp @@ -283,7 +283,7 @@ bool CJS_PublicMethods::MaskSatisfied(wchar_t c_Change, wchar_t c_Mask) { case L'9': return !!std::iswdigit(c_Change); case L'A': - return FXSYS_iswASCIIalpha(c_Change); + return isascii(c_Change) && isalpha(c_Change); case L'O': return isascii(c_Change) && isalnum(c_Change); case L'X': diff --git a/fxjs/cjs_util.cpp b/fxjs/cjs_util.cpp index d73c238488..25d4590259 100644 --- a/fxjs/cjs_util.cpp +++ b/fxjs/cjs_util.cpp @@ -322,7 +322,7 @@ WideString CJS_Util::printx(const WideString& wsFormat, } break; case 'A': { if (iSourceIdx < wsSource.GetLength()) { - if (FXSYS_iswASCIIalpha(wsSource[iSourceIdx])) { + if (isascii(wsSource[iSourceIdx]) && isalpha(wsSource[iSourceIdx])) { wsResult += TranslateCase(wsSource[iSourceIdx], eCaseMode); ++iFormatIdx; } diff --git a/xfa/fgas/crt/cfgas_formatstring.cpp b/xfa/fgas/crt/cfgas_formatstring.cpp index e4185b83c9..d7273d0e4a 100644 --- a/xfa/fgas/crt/cfgas_formatstring.cpp +++ b/xfa/fgas/crt/cfgas_formatstring.cpp @@ -1096,7 +1096,7 @@ bool CFGAS_FormatString::ParseText(const WideString& wsSrcText, break; } case 'A': - if (FXSYS_iswASCIIalpha(pStrText[iText])) { + if (FXSYS_iswalpha(pStrText[iText])) { *wsValue += pStrText[iText]; iText++; } @@ -1110,7 +1110,7 @@ bool CFGAS_FormatString::ParseText(const WideString& wsSrcText, case 'O': case '0': if (FXSYS_isDecimalDigit(pStrText[iText]) || - FXSYS_iswASCIIalpha(pStrText[iText])) { + FXSYS_iswalpha(pStrText[iText])) { *wsValue += pStrText[iText]; iText++; } @@ -1815,7 +1815,7 @@ bool CFGAS_FormatString::FormatText(const WideString& wsSrcText, break; } case 'A': - if (iText >= iLenText || !FXSYS_iswASCIIalpha(pStrText[iText])) + if (iText >= iLenText || !FXSYS_iswalpha(pStrText[iText])) return false; *wsOutput += pStrText[iText++]; @@ -1831,7 +1831,7 @@ bool CFGAS_FormatString::FormatText(const WideString& wsSrcText, case 'O': case '0': if (iText >= iLenText || (!FXSYS_isDecimalDigit(pStrText[iText]) && - !FXSYS_iswASCIIalpha(pStrText[iText]))) { + !FXSYS_iswalpha(pStrText[iText]))) { return false; } *wsOutput += pStrText[iText++]; diff --git a/xfa/fxfa/fm2js/cxfa_fmlexer.cpp b/xfa/fxfa/fm2js/cxfa_fmlexer.cpp index 4dc8788a1a..3559fb7aeb 100644 --- a/xfa/fxfa/fm2js/cxfa_fmlexer.cpp +++ b/xfa/fxfa/fm2js/cxfa_fmlexer.cpp @@ -306,7 +306,7 @@ CXFA_FMToken CXFA_FMLexer::AdvanceForNumber() { wchar_t* end = nullptr; if (m_cursor) wcstod(const_cast(m_cursor), &end); - if (!end || FXSYS_iswASCIIalpha(*end)) { + if (!end || FXSYS_iswalpha(*end)) { RaiseError(); return CXFA_FMToken(); } -- cgit v1.2.3