From ab1faaa7f81b7dafe03d546341c6a643a58b3678 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 24 Apr 2017 16:16:49 -0700 Subject: Use fx_extension.h utilities in more places in xfa/ Change-Id: Id58c313aa446ecfa223e5c8edc095586b62a61fa Reviewed-on: https://pdfium-review.googlesource.com/4455 Commit-Queue: dsinclair Reviewed-by: dsinclair --- xfa/fde/css/cfde_cssselector.cpp | 14 ++++---------- xfa/fde/css/cfde_csssyntaxparser.cpp | 4 ++-- xfa/fde/css/cfde_cssvaluelistparser.cpp | 3 +-- 3 files changed, 7 insertions(+), 14 deletions(-) (limited to 'xfa/fde') diff --git a/xfa/fde/css/cfde_cssselector.cpp b/xfa/fde/css/cfde_cssselector.cpp index 6842d58738..c1e9f7f22a 100644 --- a/xfa/fde/css/cfde_cssselector.cpp +++ b/xfa/fde/css/cfde_cssselector.cpp @@ -8,24 +8,18 @@ #include +#include "core/fxcrt/fx_extension.h" #include "third_party/base/ptr_util.h" namespace { -bool IsCSSChar(wchar_t wch) { - return (wch >= 'a' && wch <= 'z') || (wch >= 'A' && wch <= 'Z'); -} - int32_t GetCSSNameLen(const wchar_t* psz, const wchar_t* pEnd) { const wchar_t* pStart = psz; while (psz < pEnd) { wchar_t wch = *psz; - if (IsCSSChar(wch) || (wch >= '0' && wch <= '9') || wch == '_' || - wch == '-') { - ++psz; - } else { + if (!FXSYS_iswalnum(wch) && wch != '_' && wch != '-') break; - } + ++psz; } return psz - pStart; } @@ -73,7 +67,7 @@ std::unique_ptr CFDE_CSSSelector::FromString( std::unique_ptr pFirst = nullptr; for (psz = pStart; psz < pEnd;) { wchar_t wch = *psz; - if (IsCSSChar(wch) || wch == '*') { + if (FXSYS_iswalpha(wch) || wch == '*') { int32_t iNameLen = wch == '*' ? 1 : GetCSSNameLen(psz, pEnd); auto p = pdfium::MakeUnique( FDE_CSSSelectorType::Element, psz, iNameLen, true); diff --git a/xfa/fde/css/cfde_csssyntaxparser.cpp b/xfa/fde/css/cfde_csssyntaxparser.cpp index ac1abcc665..bc861bdd6e 100644 --- a/xfa/fde/css/cfde_csssyntaxparser.cpp +++ b/xfa/fde/css/cfde_csssyntaxparser.cpp @@ -9,14 +9,14 @@ #include #include "core/fxcrt/fx_codepage.h" +#include "core/fxcrt/fx_extension.h" #include "xfa/fde/css/cfde_cssdeclaration.h" #include "xfa/fde/css/fde_cssdatatable.h" namespace { bool IsSelectorStart(wchar_t wch) { - return wch == '.' || wch == '#' || wch == '*' || (wch >= 'a' && wch <= 'z') || - (wch >= 'A' && wch <= 'Z'); + return wch == '.' || wch == '#' || wch == '*' || FXSYS_iswalpha(wch); } } // namespace diff --git a/xfa/fde/css/cfde_cssvaluelistparser.cpp b/xfa/fde/css/cfde_cssvaluelistparser.cpp index 36d5edc3c7..84dc20b328 100644 --- a/xfa/fde/css/cfde_cssvaluelistparser.cpp +++ b/xfa/fde/css/cfde_cssvaluelistparser.cpp @@ -30,8 +30,7 @@ bool CFDE_CSSValueListParser::NextValue(FDE_CSSPrimitiveType& eType, iLength = SkipTo(' ', false, false); if (iLength == 4 || iLength == 7) eType = FDE_CSSPrimitiveType::RGB; - } else if ((wch >= '0' && wch <= '9') || wch == '.' || wch == '-' || - wch == '+') { + } else if (std::iswdigit(wch) || wch == '.' || wch == '-' || wch == '+') { while (m_pCur < m_pEnd && (*m_pCur > ' ' && *m_pCur != m_Separator)) ++m_pCur; -- cgit v1.2.3