diff options
author | dan sinclair <dsinclair@chromium.org> | 2015-11-10 13:33:04 -0500 |
---|---|---|
committer | dan sinclair <dsinclair@chromium.org> | 2015-11-10 13:33:04 -0500 |
commit | 0569ab0b11b723d9bca4ddd642b0cf8828c4bdd1 (patch) | |
tree | d0f6ba295574785c773536be7b5526680ed60f04 /fpdfsdk/src/javascript | |
parent | e6e16954f0cdc324849fca9da883be8f131b3834 (diff) | |
download | pdfium-0569ab0b11b723d9bca4ddd642b0cf8828c4bdd1.tar.xz |
Revert x4 "Cleanup some numeric code."
This reverts commit b27902b8995bb3e003daed6b0811ed746763c68d.
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.
TBR=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1432973003 .
Diffstat (limited to 'fpdfsdk/src/javascript')
-rw-r--r-- | fpdfsdk/src/javascript/PublicMethods.cpp | 5 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/util.cpp | 7 |
2 files changed, 5 insertions, 7 deletions
diff --git a/fpdfsdk/src/javascript/PublicMethods.cpp b/fpdfsdk/src/javascript/PublicMethods.cpp index 8e8cb21c60..92b47666e2 100644 --- a/fpdfsdk/src/javascript/PublicMethods.cpp +++ b/fpdfsdk/src/javascript/PublicMethods.cpp @@ -6,7 +6,6 @@ #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" @@ -117,7 +116,7 @@ FX_BOOL CJS_PublicMethods::IsDigit(wchar_t ch) { } FX_BOOL CJS_PublicMethods::IsDigit(char ch) { - return std::isdigit(ch); + return (ch >= '0' && ch <= '9'); } FX_BOOL CJS_PublicMethods::IsAlphabetic(wchar_t ch) { @@ -397,7 +396,7 @@ int CJS_PublicMethods::ParseStringInteger(const CFX_WideString& string, FX_WCHAR c = string.GetAt(i); if (IsDigit((wchar_t)c)) { - nRet = nRet * 10 + FXSYS_toDecimalDigitWide(c); + nRet = nRet * 10 + (c - '0'); nSkip = i - nStart + 1; if (nSkip >= nMaxStep) break; diff --git a/fpdfsdk/src/javascript/util.cpp b/fpdfsdk/src/javascript/util.cpp index fc94a0e393..14e15c1b6f 100644 --- a/fpdfsdk/src/javascript/util.cpp +++ b/fpdfsdk/src/javascript/util.cpp @@ -6,7 +6,6 @@ #include "util.h" -#include "../../../core/include/fxcrt/fx_ext.h" #include "../../include/javascript/IJavaScript.h" #include "JS_Context.h" #include "JS_Define.h" @@ -426,7 +425,7 @@ void util::printx(const std::string& cFormat, break; case 'X': { while (itSource < iSize) { - if (std::isdigit(cSource[itSource]) || + if ((cSource[itSource] >= '0' && cSource[itSource] <= '9') || (cSource[itSource] >= 'a' && cSource[itSource] <= 'z') || (cSource[itSource] >= 'A' && cSource[itSource] <= 'Z')) { cPurpose += cSource[itSource]; @@ -451,7 +450,7 @@ void util::printx(const std::string& cFormat, } break; case '9': { while (itSource < iSize) { - if (std::isdigit(cSource[itSource])) { + if (cSource[itSource] >= '0' && cSource[itSource] <= '9') { cPurpose += cSource[itSource]; itSource++; break; @@ -532,7 +531,7 @@ int64_t FX_atoi64(const char* nptr) { total = 0; while (isdigit(c)) { - total = 10 * total + FXSYS_toDecimalDigit(c); /* accumulate digit */ + total = 10 * total + (c - '0'); /* accumulate digit */ c = (int)(unsigned char)*nptr++; /* get next char */ } |