diff options
author | dan sinclair <dsinclair@chromium.org> | 2015-11-10 13:33:04 -0500 |
---|---|---|
committer | dan sinclair <dsinclair@chromium.org> | 2015-11-10 13:33:04 -0500 |
commit | 0569ab0b11b723d9bca4ddd642b0cf8828c4bdd1 (patch) | |
tree | d0f6ba295574785c773536be7b5526680ed60f04 /core/src/fxcrt/fx_basic_util.cpp | |
parent | e6e16954f0cdc324849fca9da883be8f131b3834 (diff) | |
download | pdfium-0569ab0b11b723d9bca4ddd642b0cf8828c4bdd1.tar.xz |
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 .
Diffstat (limited to 'core/src/fxcrt/fx_basic_util.cpp')
-rw-r--r-- | core/src/fxcrt/fx_basic_util.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/core/src/fxcrt/fx_basic_util.cpp b/core/src/fxcrt/fx_basic_util.cpp index b4c7064da2..3e9d6169cd 100644 --- a/core/src/fxcrt/fx_basic_util.cpp +++ b/core/src/fxcrt/fx_basic_util.cpp @@ -5,9 +5,6 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "core/include/fxcrt/fx_basic.h" -#include "core/include/fxcrt/fx_ext.h" - -#include <cctype> #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ #include <sys/types.h> @@ -105,11 +102,14 @@ void FX_atonum(const CFX_ByteStringC& strc, FX_BOOL& bInteger, void* pData) { bNegative = TRUE; cc++; } - while (cc < len && std::isdigit(str[cc])) { - // TODO(dsinclair): This is not the right way to handle overflow. - integer = integer * 10 + FXSYS_toDecimalDigit(str[cc]); - if (integer < 0) + while (cc < len) { + if (str[cc] < '0' || str[cc] > '9') { break; + } + integer = integer * 10 + str[cc] - '0'; + if (integer < 0) { + break; + } cc++; } if (bNegative) { @@ -146,7 +146,7 @@ FX_FLOAT FX_atof(const CFX_ByteStringC& strc) { if (str[cc] == '.') { break; } - value = value * 10 + FXSYS_toDecimalDigit(str[cc]); + value = value * 10 + str[cc] - '0'; cc++; } static const FX_FLOAT fraction_scales[] = { @@ -157,7 +157,7 @@ FX_FLOAT FX_atof(const CFX_ByteStringC& strc) { if (cc < len && str[cc] == '.') { cc++; while (cc < len) { - value += fraction_scales[scale] * FXSYS_toDecimalDigit(str[cc]); + value += fraction_scales[scale] * (str[cc] - '0'); scale++; if (scale == sizeof fraction_scales / sizeof(FX_FLOAT)) { break; |