Commit 1911d984 authored by Paul Wankadia's avatar Paul Wankadia
Browse files

Simplify parse_double_float() in util/pcre.cc.

Change-Id: Ie7e7b3f12f44471d3bed3062420e6dd5e15b1ea7
Reviewed-on: https://code-review.googlesource.com/c/re2/+/47590


Reviewed-by: default avatarPaul Wankadia <junyer@google.com>
Showing with 1 addition and 26 deletions
+1 -26
......@@ -978,32 +978,7 @@ static bool parse_double_float(const char* str, size_t n, bool isfloat,
} else {
r = strtod(buf, &end);
}
if (end != buf + n) {
#ifdef _WIN32
// Microsoft's strtod() doesn't handle inf and nan, so we have to
// handle it explicitly. Speed is not important here because this
// code is only called in unit tests.
bool pos = true;
const char* i = buf;
if ('-' == *i) {
pos = false;
++i;
} else if ('+' == *i) {
++i;
}
if (0 == _stricmp(i, "inf") || 0 == _stricmp(i, "infinity")) {
r = std::numeric_limits<double>::infinity();
if (!pos)
r = -r;
} else if (0 == _stricmp(i, "nan")) {
r = std::numeric_limits<double>::quiet_NaN();
} else {
return false;
}
#else
return false; // Leftover junk
#endif
}
if (end != buf + n) return false; // Leftover junk
if (errno) return false;
if (dest == NULL) return true;
if (isfloat) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment