summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fsdk_baseannot.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/fsdk_baseannot.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/fsdk_baseannot.cpp')
-rw-r--r--fpdfsdk/src/fsdk_baseannot.cpp44
1 files changed, 21 insertions, 23 deletions
diff --git a/fpdfsdk/src/fsdk_baseannot.cpp b/fpdfsdk/src/fsdk_baseannot.cpp
index 090a50fe62..8b083e3bea 100644
--- a/fpdfsdk/src/fsdk_baseannot.cpp
+++ b/fpdfsdk/src/fsdk_baseannot.cpp
@@ -4,7 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "../include/fpdfxfa/fpdfxfa_doc.h"
+#include "core/include/fxcrt/fx_ext.h"
+#include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h"
#include "fpdfsdk/include/fsdk_baseannot.h"
#include "fpdfsdk/include/fsdk_define.h"
#include "fpdfsdk/include/fsdk_mgr.h"
@@ -217,12 +218,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;
@@ -230,9 +228,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++;
}
@@ -244,9 +242,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++;
}
@@ -258,9 +256,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++;
}
@@ -272,9 +270,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++;
}
@@ -286,9 +284,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++;
}
@@ -300,9 +298,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++;
}
@@ -321,9 +319,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++;
}
@@ -338,9 +336,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++;
}