From b27902b8995bb3e003daed6b0811ed746763c68d Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Tue, 10 Nov 2015 13:17:58 -0500 Subject: Revert "Revert "Revert "Revert "Cleanup some numeric code."""" This reverts commit da06e60fb5a095a91c9a4f509466667878624cb3. Cleanup some numeric code. 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/1433513002 . --- fpdfsdk/src/javascript/PublicMethods.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'fpdfsdk/src/javascript/PublicMethods.cpp') diff --git a/fpdfsdk/src/javascript/PublicMethods.cpp b/fpdfsdk/src/javascript/PublicMethods.cpp index 92b47666e2..8e8cb21c60 100644 --- a/fpdfsdk/src/javascript/PublicMethods.cpp +++ b/fpdfsdk/src/javascript/PublicMethods.cpp @@ -6,6 +6,7 @@ #include "PublicMethods.h" +#include "../../../core/include/fxcrt/fx_ext.h" #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. #include "../../include/javascript/IJavaScript.h" #include "Field.h" @@ -116,7 +117,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) { @@ -396,7 +397,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; -- cgit v1.2.3