summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/javascript
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2015-11-03 14:54:35 -0500
committerDan Sinclair <dsinclair@chromium.org>2015-11-03 14:54:35 -0500
commite0e922db5fb77df9a5a9cc802096f484ed21da1c (patch)
treed6b3da42c1a28ec150c5cb9fe6b00d8f6af099d5 /fpdfsdk/src/javascript
parentc9e76c09b9e7901823ac52a3705da235bd2abe24 (diff)
downloadpdfium-e0e922db5fb77df9a5a9cc802096f484ed21da1c.tar.xz
Revert "Revert "Cleanup some numeric code.""
This reverts commit 23d576f0b498bd4f37ef2175916223a2e5ea0324. 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/1405253007 .
Diffstat (limited to 'fpdfsdk/src/javascript')
-rw-r--r--fpdfsdk/src/javascript/PublicMethods.cpp5
-rw-r--r--fpdfsdk/src/javascript/util.cpp7
2 files changed, 7 insertions, 5 deletions
diff --git a/fpdfsdk/src/javascript/PublicMethods.cpp b/fpdfsdk/src/javascript/PublicMethods.cpp
index e898214cd8..7ede42db13 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_toDecimalDigit(c);
nSkip = i - nStart + 1;
if (nSkip >= nMaxStep)
break;
diff --git a/fpdfsdk/src/javascript/util.cpp b/fpdfsdk/src/javascript/util.cpp
index 14e15c1b6f..fc94a0e393 100644
--- a/fpdfsdk/src/javascript/util.cpp
+++ b/fpdfsdk/src/javascript/util.cpp
@@ -6,6 +6,7 @@
#include "util.h"
+#include "../../../core/include/fxcrt/fx_ext.h"
#include "../../include/javascript/IJavaScript.h"
#include "JS_Context.h"
#include "JS_Define.h"
@@ -425,7 +426,7 @@ void util::printx(const std::string& cFormat,
break;
case 'X': {
while (itSource < iSize) {
- if ((cSource[itSource] >= '0' && cSource[itSource] <= '9') ||
+ if (std::isdigit(cSource[itSource]) ||
(cSource[itSource] >= 'a' && cSource[itSource] <= 'z') ||
(cSource[itSource] >= 'A' && cSource[itSource] <= 'Z')) {
cPurpose += cSource[itSource];
@@ -450,7 +451,7 @@ void util::printx(const std::string& cFormat,
} break;
case '9': {
while (itSource < iSize) {
- if (cSource[itSource] >= '0' && cSource[itSource] <= '9') {
+ if (std::isdigit(cSource[itSource])) {
cPurpose += cSource[itSource];
itSource++;
break;
@@ -531,7 +532,7 @@ int64_t FX_atoi64(const char* nptr) {
total = 0;
while (isdigit(c)) {
- total = 10 * total + (c - '0'); /* accumulate digit */
+ total = 10 * total + FXSYS_toDecimalDigit(c); /* accumulate digit */
c = (int)(unsigned char)*nptr++; /* get next char */
}