summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fsdk_baseannot.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2015-11-16 12:28:39 -0500
committerDan Sinclair <dsinclair@chromium.org>2015-11-16 12:28:39 -0500
commit3f148915d12f54a946a0c0bf526162b79c39d650 (patch)
tree17a95f27c8a6a07356b68ac41b5fbcc0f2358ab9 /fpdfsdk/src/fsdk_baseannot.cpp
parent76c6d639f46c37ba955569f507201eb3f1b613fc (diff)
downloadpdfium-chromium/2567.tar.xz
Reland "Cleanup some numeric code.""chromium/2567
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 .
Diffstat (limited to 'fpdfsdk/src/fsdk_baseannot.cpp')
-rw-r--r--fpdfsdk/src/fsdk_baseannot.cpp42
1 files changed, 20 insertions, 22 deletions
diff --git a/fpdfsdk/src/fsdk_baseannot.cpp b/fpdfsdk/src/fsdk_baseannot.cpp
index f6ead75f9f..8cd3df97c0 100644
--- a/fpdfsdk/src/fsdk_baseannot.cpp
+++ b/fpdfsdk/src/fsdk_baseannot.cpp
@@ -4,6 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include "core/include/fxcrt/fx_ext.h"
#include "fpdfsdk/include/fsdk_baseannot.h"
#include "fpdfsdk/include/fsdk_define.h"
#include "fpdfsdk/include/fsdk_mgr.h"
@@ -216,12 +217,9 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString(
int i = 0;
int j, k;
FX_CHAR ch;
- while (i < strLength) {
- ch = dtStr[i];
- if (ch >= '0' && ch <= '9')
- break;
- i++;
- }
+ while (i < strLength && !std::isdigit(dtStr[i]))
+ ++i;
+
if (i >= strLength)
return *this;
@@ -229,9 +227,9 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString(
k = 0;
while (i < strLength && j < 4) {
ch = dtStr[i];
- k = k * 10 + ch - '0';
+ k = k * 10 + FXSYS_toDecimalDigit(ch);
j++;
- if (ch < '0' || ch > '9')
+ if (!std::isdigit(ch))
break;
i++;
}
@@ -243,9 +241,9 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString(
k = 0;
while (i < strLength && j < 2) {
ch = dtStr[i];
- k = k * 10 + ch - '0';
+ k = k * 10 + FXSYS_toDecimalDigit(ch);
j++;
- if (ch < '0' || ch > '9')
+ if (!std::isdigit(ch))
break;
i++;
}
@@ -257,9 +255,9 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString(
k = 0;
while (i < strLength && j < 2) {
ch = dtStr[i];
- k = k * 10 + ch - '0';
+ k = k * 10 + FXSYS_toDecimalDigit(ch);
j++;
- if (ch < '0' || ch > '9')
+ if (!std::isdigit(ch))
break;
i++;
}
@@ -271,9 +269,9 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString(
k = 0;
while (i < strLength && j < 2) {
ch = dtStr[i];
- k = k * 10 + ch - '0';
+ k = k * 10 + FXSYS_toDecimalDigit(ch);
j++;
- if (ch < '0' || ch > '9')
+ if (!std::isdigit(ch))
break;
i++;
}
@@ -285,9 +283,9 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString(
k = 0;
while (i < strLength && j < 2) {
ch = dtStr[i];
- k = k * 10 + ch - '0';
+ k = k * 10 + FXSYS_toDecimalDigit(ch);
j++;
- if (ch < '0' || ch > '9')
+ if (!std::isdigit(ch))
break;
i++;
}
@@ -299,9 +297,9 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString(
k = 0;
while (i < strLength && j < 2) {
ch = dtStr[i];
- k = k * 10 + ch - '0';
+ k = k * 10 + FXSYS_toDecimalDigit(ch);
j++;
- if (ch < '0' || ch > '9')
+ if (!std::isdigit(ch))
break;
i++;
}
@@ -320,9 +318,9 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString(
k = 0;
while (i < strLength && j < 2) {
ch = dtStr[i];
- k = k * 10 + ch - '0';
+ k = k * 10 + FXSYS_toDecimalDigit(ch);
j++;
- if (ch < '0' || ch > '9')
+ if (!std::isdigit(ch))
break;
i++;
}
@@ -337,9 +335,9 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString(
k = 0;
while (i < strLength && j < 2) {
ch = dtStr[i];
- k = k * 10 + ch - '0';
+ k = k * 10 + FXSYS_toDecimalDigit(ch);
j++;
- if (ch < '0' || ch > '9')
+ if (!std::isdigit(ch))
break;
i++;
}