From 0569ab0b11b723d9bca4ddd642b0cf8828c4bdd1 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Tue, 10 Nov 2015 13:33:04 -0500 Subject: Revert x4 "Cleanup some numeric code." This reverts commit b27902b8995bb3e003daed6b0811ed746763c68d. 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. TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1432973003 . --- fpdfsdk/src/fsdk_baseannot.cpp | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'fpdfsdk/src/fsdk_baseannot.cpp') diff --git a/fpdfsdk/src/fsdk_baseannot.cpp b/fpdfsdk/src/fsdk_baseannot.cpp index 1ccac9275a..52f34fae8e 100644 --- a/fpdfsdk/src/fsdk_baseannot.cpp +++ b/fpdfsdk/src/fsdk_baseannot.cpp @@ -4,7 +4,6 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "../../core/include/fxcrt/fx_ext.h" #include "../include/fsdk_define.h" #include "../include/fsdk_mgr.h" #include "../include/fsdk_baseannot.h" @@ -217,9 +216,12 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString( int i = 0; int j, k; FX_CHAR ch; - while (i < strLength && !std::isdigit(dtStr[i])) - ++i; - + while (i < strLength) { + ch = dtStr[i]; + if (ch >= '0' && ch <= '9') + break; + i++; + } if (i >= strLength) return *this; @@ -227,9 +229,9 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString( k = 0; while (i < strLength && j < 4) { ch = dtStr[i]; - k = k * 10 + FXSYS_toDecimalDigit(ch); + k = k * 10 + ch - '0'; j++; - if (!std::isdigit(ch)) + if (ch < '0' || ch > '9') break; i++; } @@ -241,9 +243,9 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString( k = 0; while (i < strLength && j < 2) { ch = dtStr[i]; - k = k * 10 + FXSYS_toDecimalDigit(ch); + k = k * 10 + ch - '0'; j++; - if (!std::isdigit(ch)) + if (ch < '0' || ch > '9') break; i++; } @@ -255,9 +257,9 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString( k = 0; while (i < strLength && j < 2) { ch = dtStr[i]; - k = k * 10 + FXSYS_toDecimalDigit(ch); + k = k * 10 + ch - '0'; j++; - if (!std::isdigit(ch)) + if (ch < '0' || ch > '9') break; i++; } @@ -269,9 +271,9 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString( k = 0; while (i < strLength && j < 2) { ch = dtStr[i]; - k = k * 10 + FXSYS_toDecimalDigit(ch); + k = k * 10 + ch - '0'; j++; - if (!std::isdigit(ch)) + if (ch < '0' || ch > '9') break; i++; } @@ -283,9 +285,9 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString( k = 0; while (i < strLength && j < 2) { ch = dtStr[i]; - k = k * 10 + FXSYS_toDecimalDigit(ch); + k = k * 10 + ch - '0'; j++; - if (!std::isdigit(ch)) + if (ch < '0' || ch > '9') break; i++; } @@ -297,9 +299,9 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString( k = 0; while (i < strLength && j < 2) { ch = dtStr[i]; - k = k * 10 + FXSYS_toDecimalDigit(ch); + k = k * 10 + ch - '0'; j++; - if (!std::isdigit(ch)) + if (ch < '0' || ch > '9') break; i++; } @@ -318,9 +320,9 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString( k = 0; while (i < strLength && j < 2) { ch = dtStr[i]; - k = k * 10 + FXSYS_toDecimalDigit(ch); + k = k * 10 + ch - '0'; j++; - if (!std::isdigit(ch)) + if (ch < '0' || ch > '9') break; i++; } @@ -335,9 +337,9 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString( k = 0; while (i < strLength && j < 2) { ch = dtStr[i]; - k = k * 10 + FXSYS_toDecimalDigit(ch); + k = k * 10 + ch - '0'; j++; - if (!std::isdigit(ch)) + if (ch < '0' || ch > '9') break; i++; } -- cgit v1.2.3