diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2015-11-16 13:09:00 -0500 |
---|---|---|
committer | Dan Sinclair <dsinclair@chromium.org> | 2015-11-16 13:09:00 -0500 |
commit | 10cfea1fdafc8fcf1edd60bc783e9db9ef6229c0 (patch) | |
tree | 3cd1bc8e6a6b33391ea8ad83388a07ca4974f40b /fpdfsdk/src/javascript/PublicMethods.cpp | |
parent | ec441e67745054ece5e3d736b60fffa2f7f8d20c (diff) | |
download | pdfium-10cfea1fdafc8fcf1edd60bc783e9db9ef6229c0.tar.xz |
Merge to XFA: Reland "Cleanup some numeric code.""
This reverts commit 0569ab0b11b723d9bca4ddd642b0cf8828c4bdd1.
This changes the various comparisons of char >= '0' && char <= '9' and
char < '0' || char > '9' to use std::isdigit checks. It also cleans up
a handful of hex to digit conversions to call one common method.
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1449873003 .
(cherry picked from commit 3f148915d12f54a946a0c0bf526162b79c39d650)
Review URL: https://codereview.chromium.org/1452673002 .
Diffstat (limited to 'fpdfsdk/src/javascript/PublicMethods.cpp')
-rw-r--r-- | fpdfsdk/src/javascript/PublicMethods.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/fpdfsdk/src/javascript/PublicMethods.cpp b/fpdfsdk/src/javascript/PublicMethods.cpp index 454085069e..75327dd631 100644 --- a/fpdfsdk/src/javascript/PublicMethods.cpp +++ b/fpdfsdk/src/javascript/PublicMethods.cpp @@ -14,6 +14,7 @@ #include "JS_Runtime.h" #include "JS_Value.h" #include "color.h" +#include "core/include/fxcrt/fx_ext.h" #include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment. #include "fpdfsdk/include/javascript/IJavaScript.h" #include "resource.h" @@ -108,7 +109,7 @@ FX_BOOL CJS_PublicMethods::IsDigit(wchar_t ch) { } FX_BOOL CJS_PublicMethods::IsDigit(char ch) { - return (ch >= '0' && ch <= '9'); + return std::isdigit(ch); } FX_BOOL CJS_PublicMethods::IsAlphabetic(wchar_t ch) { @@ -388,7 +389,7 @@ int CJS_PublicMethods::ParseStringInteger(const CFX_WideString& string, FX_WCHAR c = string.GetAt(i); if (IsDigit((wchar_t)c)) { - nRet = nRet * 10 + (c - '0'); + nRet = nRet * 10 + FXSYS_toDecimalDigitWide(c); nSkip = i - nStart + 1; if (nSkip >= nMaxStep) break; |