Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Unified Diff: fpdfsdk/src/fsdk_baseannot.cpp

Issue 1449873003: Reland "Cleanup some numeric code."" (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix windows build Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/src/fxcrt/fx_xml_parser.cpp ('k') | fpdfsdk/src/javascript/PublicMethods.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/src/fsdk_baseannot.cpp
diff --git a/fpdfsdk/src/fsdk_baseannot.cpp b/fpdfsdk/src/fsdk_baseannot.cpp
index f6ead75f9fd73685a0d67cc62dd8866a57c2918a..8cd3df97c0fca00e9104322037e32058fe72838e 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++;
}
« no previous file with comments | « core/src/fxcrt/fx_xml_parser.cpp ('k') | fpdfsdk/src/javascript/PublicMethods.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698