From 23d576f0b498bd4f37ef2175916223a2e5ea0324 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Thu, 29 Oct 2015 15:08:50 -0400 Subject: Revert "Cleanup some numeric code." This reverts commit 589f7e0a57675efce9810c15a3e9b7c49bf0bc90. Broke the build on Mac, unable to find std::isdigit. TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1428853002 . --- core/src/fxcodec/codec/fx_codec.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to '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 eca6505d12..46f479e0b1 100644 --- a/core/src/fxcodec/codec/fx_codec.cpp +++ b/core/src/fxcodec/codec/fx_codec.cpp @@ -157,13 +157,13 @@ 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 += (*ptr - '0'); @@ -188,29 +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 (!std::isdigit(*ptr)) { \ - if (endptr) \ - *endptr = (char*)ptr; \ - break; \ - } else { \ - exp_ret *= 10; \ - exp_ret += (*ptr - '0'); \ - continue; \ - } \ +#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) { -- cgit v1.2.3