mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-03 04:21:13 +00:00
Parser now correctly reads floats in scientific notation.
Change-Id: I7abb14a4b6c596674d6aff2b9de6e63603c0d2dc Tested: on Windows and Linux.
This commit is contained in:
@@ -200,6 +200,13 @@ void Parser::Next() {
|
||||
if (*cursor_ == '.') {
|
||||
cursor_++;
|
||||
while (isdigit(static_cast<unsigned char>(*cursor_))) cursor_++;
|
||||
// See if this float has a scientific notation suffix. Both JSON
|
||||
// and C++ (through strtod() we use) have the same format:
|
||||
if (*cursor_ == 'e' || *cursor_ == 'E') {
|
||||
cursor_++;
|
||||
if (*cursor_ == '+' || *cursor_ == '-') cursor_++;
|
||||
while (isdigit(static_cast<unsigned char>(*cursor_))) cursor_++;
|
||||
}
|
||||
token_ = kTokenFloatConstant;
|
||||
} else {
|
||||
token_ = kTokenIntegerConstant;
|
||||
|
||||
Reference in New Issue
Block a user