diff options
Diffstat (limited to 'xfa/fde')
-rw-r--r-- | xfa/fde/css/cfde_cssselector.cpp | 14 | ||||
-rw-r--r-- | xfa/fde/css/cfde_csssyntaxparser.cpp | 4 | ||||
-rw-r--r-- | xfa/fde/css/cfde_cssvaluelistparser.cpp | 3 |
3 files changed, 7 insertions, 14 deletions
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 <utility> +#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> CFDE_CSSSelector::FromString( std::unique_ptr<CFDE_CSSSelector> 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<CFDE_CSSSelector>( 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 <algorithm> #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; |