summaryrefslogtreecommitdiff
path: root/core/src/fxcodec/codec
diff options
context:
space:
mode:
authordan sinclair <dsinclair@chromium.org>2015-11-10 13:33:04 -0500
committerdan sinclair <dsinclair@chromium.org>2015-11-10 13:33:04 -0500
commit0569ab0b11b723d9bca4ddd642b0cf8828c4bdd1 (patch)
treed0f6ba295574785c773536be7b5526680ed60f04 /core/src/fxcodec/codec
parente6e16954f0cdc324849fca9da883be8f131b3834 (diff)
downloadpdfium-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/fxcodec/codec')
-rw-r--r--core/src/fxcodec/codec/fx_codec.cpp49
1 files changed, 22 insertions, 27 deletions
diff --git a/core/src/fxcodec/codec/fx_codec.cpp b/core/src/fxcodec/codec/fx_codec.cpp
index 51a1f5d55c..bfa5befce4 100644
--- a/core/src/fxcodec/codec/fx_codec.cpp
+++ b/core/src/fxcodec/codec/fx_codec.cpp
@@ -1,4 +1,3 @@
-
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,7 +9,6 @@
#include <cmath>
#include "codec_int.h"
-#include "core/include/fxcrt/fx_ext.h"
#include "core/include/fxcrt/fx_safe_types.h"
#include "third_party/base/logging.h"
@@ -149,20 +147,6 @@ FX_BOOL CCodec_BasicModule::RunLengthEncode(const uint8_t* src_buf,
FX_DWORD& dest_size) {
return FALSE;
}
-
-#define EXPONENT_DETECT(ptr) \
- for (;; ptr++) { \
- if (!std::isdigit(*ptr)) { \
- if (endptr) \
- *endptr = (char*)ptr; \
- break; \
- } else { \
- exp_ret *= 10; \
- exp_ret += FXSYS_toDecimalDigit(*ptr); \
- continue; \
- } \
- }
-
extern "C" double FXstrtod(const char* nptr, char** endptr) {
double ret = 0.0;
const char* ptr = nptr;
@@ -173,20 +157,20 @@ extern "C" double FXstrtod(const char* nptr, char** endptr) {
return 0.0;
}
for (;; ptr++) {
- if (!e_number && !e_point && (*ptr == '\t' || *ptr == ' '))
+ if (!e_number && !e_point && (*ptr == '\t' || *ptr == ' ')) {
continue;
-
- if (std::isdigit(*ptr)) {
- if (!e_number)
+ }
+ if (*ptr >= '0' && *ptr <= '9') {
+ if (!e_number) {
e_number = 1;
-
+ }
if (!e_point) {
ret *= 10;
- ret += FXSYS_toDecimalDigit(*ptr);
+ ret += (*ptr - '0');
} else {
fra_count++;
fra_ret *= 10;
- fra_ret += FXSYS_toDecimalDigit(*ptr);
+ fra_ret += (*ptr - '0');
}
continue;
}
@@ -204,17 +188,29 @@ extern "C" double FXstrtod(const char* nptr, char** endptr) {
}
}
if (e_number && (*ptr == 'e' || *ptr == 'E')) {
+#define EXPONENT_DETECT(ptr) \
+ for (;; ptr++) { \
+ if (*ptr < '0' || *ptr > '9') { \
+ if (endptr) \
+ *endptr = (char*)ptr; \
+ break; \
+ } else { \
+ exp_ret *= 10; \
+ exp_ret += (*ptr - '0'); \
+ continue; \
+ } \
+ }
exp_ptr = ptr++;
if (*ptr == '+' || *ptr == '-') {
exp_sig = (*ptr++ == '+') ? 1 : -1;
- if (!std::isdigit(*ptr)) {
+ if (*ptr < '0' || *ptr > '9') {
if (endptr) {
*endptr = (char*)exp_ptr;
}
break;
}
EXPONENT_DETECT(ptr);
- } else if (std::isdigit(*ptr)) {
+ } else if (*ptr >= '0' && *ptr <= '9') {
EXPONENT_DETECT(ptr);
} else {
if (endptr) {
@@ -222,6 +218,7 @@ extern "C" double FXstrtod(const char* nptr, char** endptr) {
}
break;
}
+#undef EXPONENT_DETECT
break;
}
if (ptr != nptr && !e_number) {
@@ -250,8 +247,6 @@ extern "C" double FXstrtod(const char* nptr, char** endptr) {
}
return is_negative ? -ret : ret;
}
-#undef EXPONENT_DETECT
-
FX_BOOL CCodec_BasicModule::A85Encode(const uint8_t* src_buf,
FX_DWORD src_size,
uint8_t*& dest_buf,