Chromium Code Reviews| Index: core/src/fxcodec/codec/fx_codec.cpp |
| diff --git a/core/src/fxcodec/codec/fx_codec.cpp b/core/src/fxcodec/codec/fx_codec.cpp |
| index 46f479e0b11b50441ed2ccc585168ac830838d3f..08b2d2d98535f9401865a91c30edb8e1a6b6f22b 100644 |
| --- a/core/src/fxcodec/codec/fx_codec.cpp |
| +++ b/core/src/fxcodec/codec/fx_codec.cpp |
| @@ -9,6 +9,7 @@ |
| #include <cmath> |
| #include "../../../../third_party/base/logging.h" |
| +#include "../../../include/fxcrt/fx_ext.h" |
| #include "../../../include/fxcrt/fx_safe_types.h" |
| #include "codec_int.h" |
| @@ -147,6 +148,20 @@ FX_BOOL CCodec_BasicModule::RunLengthEncode(const uint8_t* src_buf, |
| FX_DWORD& dest_size) { |
| return FALSE; |
| } |
| + |
| +#define EXPONENT_DETECT(ptr) \ |
|
Tom Sepez
2015/11/04 18:42:45
Later on, you can fix this, too. I'd minimize it
dsinclair
2015/11/04 20:16:24
Acknowledged.
|
| + 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; |
| @@ -157,20 +172,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 (*ptr >= '0' && *ptr <= '9') { |
| - if (!e_number) { |
| + |
| + if (std::isdigit(*ptr)) { |
| + if (!e_number) |
| e_number = 1; |
| - } |
| + |
| if (!e_point) { |
| ret *= 10; |
| - ret += (*ptr - '0'); |
| + ret += FXSYS_toDecimalDigit(*ptr); |
| } else { |
| fra_count++; |
| fra_ret *= 10; |
| - fra_ret += (*ptr - '0'); |
| + fra_ret += FXSYS_toDecimalDigit(*ptr); |
| } |
| continue; |
| } |
| @@ -188,29 +203,17 @@ 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 (*ptr < '0' || *ptr > '9') { |
| + if (!std::isdigit(*ptr)) { |
| if (endptr) { |
| *endptr = (char*)exp_ptr; |
| } |
| break; |
| } |
| EXPONENT_DETECT(ptr); |
| - } else if (*ptr >= '0' && *ptr <= '9') { |
| + } else if (std::isdigit(*ptr)) { |
| EXPONENT_DETECT(ptr); |
| } else { |
| if (endptr) { |
| @@ -218,7 +221,6 @@ extern "C" double FXstrtod(const char* nptr, char** endptr) { |
| } |
| break; |
| } |
| -#undef EXPONENT_DETECT |
| break; |
| } |
| if (ptr != nptr && !e_number) { |
| @@ -247,6 +249,8 @@ 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, |