diff options
author | Lei Zhang <thestig@chromium.org> | 2017-04-20 21:41:36 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-04-21 04:53:07 +0000 |
commit | e247ec47b75d45d16298e4e11ba68745b9ebe3eb (patch) | |
tree | e121024f171c04c928459b258b8cae1c1b9d0b56 /core/fxcrt | |
parent | 1badb85e5c3a4b4cd42ca1a2b223d6b3bc67cc4a (diff) | |
download | pdfium-e247ec47b75d45d16298e4e11ba68745b9ebe3eb.tar.xz |
Replace FXSYS_iswdigit with std::iswdigit.
Replace other one-off implementations as well.
Change-Id: I2878f3fae479c12b7de5234ee3a26477d602d14d
Reviewed-on: https://pdfium-review.googlesource.com/4398
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxcrt')
-rw-r--r-- | core/fxcrt/cfx_widestring.cpp | 1 | ||||
-rw-r--r-- | core/fxcrt/fx_extension.cpp | 16 | ||||
-rw-r--r-- | core/fxcrt/fx_extension.h | 6 | ||||
-rw-r--r-- | core/fxcrt/xml/cfx_xmlsyntaxparser.cpp | 12 |
4 files changed, 16 insertions, 19 deletions
diff --git a/core/fxcrt/cfx_widestring.cpp b/core/fxcrt/cfx_widestring.cpp index 2b98ce59a4..8cd4de6edd 100644 --- a/core/fxcrt/cfx_widestring.cpp +++ b/core/fxcrt/cfx_widestring.cpp @@ -10,6 +10,7 @@ #include <algorithm> #include <cctype> +#include <cwctype> #include "core/fxcrt/cfx_string_pool_template.h" #include "core/fxcrt/fx_basic.h" diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp index 47bd937ff8..209584b68d 100644 --- a/core/fxcrt/fx_extension.cpp +++ b/core/fxcrt/fx_extension.cpp @@ -6,6 +6,8 @@ #include "core/fxcrt/fx_extension.h" +#include <cwctype> + #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ #include <wincrypt.h> #else @@ -67,11 +69,10 @@ float FXSYS_wcstof(const wchar_t* pwsStr, int32_t iLength, int32_t* pUsedLen) { float fValue = 0.0f; while (iUsedLen < iLength) { wchar_t wch = pwsStr[iUsedLen]; - if (wch >= L'0' && wch <= L'9') - fValue = fValue * 10.0f + (wch - L'0'); - else + if (!std::iswdigit(wch)) break; + fValue = fValue * 10.0f + (wch - L'0'); iUsedLen++; } @@ -79,12 +80,11 @@ float FXSYS_wcstof(const wchar_t* pwsStr, int32_t iLength, int32_t* pUsedLen) { float fPrecise = 0.1f; while (++iUsedLen < iLength) { wchar_t wch = pwsStr[iUsedLen]; - if (wch >= L'0' && wch <= L'9') { - fValue += (wch - L'0') * fPrecise; - fPrecise *= 0.1f; - } else { + if (!std::iswdigit(wch)) break; - } + + fValue += (wch - L'0') * fPrecise; + fPrecise *= 0.1f; } } if (pUsedLen) diff --git a/core/fxcrt/fx_extension.h b/core/fxcrt/fx_extension.h index e9d16786a9..00604fb22c 100644 --- a/core/fxcrt/fx_extension.h +++ b/core/fxcrt/fx_extension.h @@ -41,12 +41,8 @@ inline bool FXSYS_iswalpha(wchar_t wch) { return (wch >= L'A' && wch <= L'Z') || (wch >= L'a' && wch <= L'z'); } -inline bool FXSYS_iswdigit(wchar_t wch) { - return wch >= L'0' && wch <= L'9'; -} - inline bool FXSYS_iswalnum(wchar_t wch) { - return FXSYS_iswalpha(wch) || FXSYS_iswdigit(wch); + return FXSYS_iswalpha(wch) || std::iswdigit(wch); } inline bool FXSYS_iswspace(wchar_t c) { diff --git a/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp b/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp index ac3f1b5c5d..e3d690f5ab 100644 --- a/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp +++ b/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp @@ -7,6 +7,7 @@ #include "core/fxcrt/xml/cfx_xmlsyntaxparser.h" #include <algorithm> +#include <cwctype> #include <iterator> #include "core/fxcrt/fx_extension.h" @@ -633,20 +634,19 @@ void CFX_XMLSyntaxParser::ParseTextChar(wchar_t character) { if (iLen > 1 && csEntity[1] == L'x') { for (int32_t i = 2; i < iLen; i++) { w = csEntity[i]; - if (w >= L'0' && w <= L'9') { + if (std::iswdigit(w)) ch = (ch << 4) + w - L'0'; - } else if (w >= L'A' && w <= L'F') { + else if (w >= L'A' && w <= L'F') ch = (ch << 4) + w - 55; - } else if (w >= L'a' && w <= L'f') { + else if (w >= L'a' && w <= L'f') ch = (ch << 4) + w - 87; - } else { + else break; - } } } else { for (int32_t i = 1; i < iLen; i++) { w = csEntity[i]; - if (w < L'0' || w > L'9') + if (!std::iswdigit(w)) break; ch = ch * 10 + w - L'0'; } |