summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/javascript/util.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2015-11-16 13:09:00 -0500
committerDan Sinclair <dsinclair@chromium.org>2015-11-16 13:09:00 -0500
commit10cfea1fdafc8fcf1edd60bc783e9db9ef6229c0 (patch)
tree3cd1bc8e6a6b33391ea8ad83388a07ca4974f40b /fpdfsdk/src/javascript/util.cpp
parentec441e67745054ece5e3d736b60fffa2f7f8d20c (diff)
downloadpdfium-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/util.cpp')
-rw-r--r--fpdfsdk/src/javascript/util.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/fpdfsdk/src/javascript/util.cpp b/fpdfsdk/src/javascript/util.cpp
index c021ec9e95..30df53ea72 100644
--- a/fpdfsdk/src/javascript/util.cpp
+++ b/fpdfsdk/src/javascript/util.cpp
@@ -13,6 +13,7 @@
#include "JS_Runtime.h"
#include "JS_Value.h"
#include "PublicMethods.h"
+#include "core/include/fxcrt/fx_ext.h"
#include "fpdfsdk/include/javascript/IJavaScript.h"
#include "resource.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 */
}