mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-02-25 07:41:07 +01:00
stricter float parsing
fixes `test/jsonchecker/fail31.json` (issue #113)
This commit is contained in:
parent
e0bfb45000
commit
c1441ef5e0
@ -381,11 +381,24 @@ bool Reader::readCppStyleComment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Reader::readNumber() {
|
void Reader::readNumber() {
|
||||||
while (current_ != end_) {
|
const char *p = current_;
|
||||||
if (!(*current_ >= '0' && *current_ <= '9') &&
|
char c = '0'; // stopgap for already consumed character
|
||||||
!in(*current_, '.', 'e', 'E', '+', '-'))
|
// integral part
|
||||||
break;
|
while (c >= '0' && c <= '9')
|
||||||
++current_;
|
c = (current_ = p) < end_ ? *p++ : 0;
|
||||||
|
// fractional part
|
||||||
|
if (c == '.') {
|
||||||
|
c = (current_ = p) < end_ ? *p++ : 0;
|
||||||
|
while (c >= '0' && c <= '9')
|
||||||
|
c = (current_ = p) < end_ ? *p++ : 0;
|
||||||
|
}
|
||||||
|
// exponential part
|
||||||
|
if (c == 'e' || c == 'E') {
|
||||||
|
c = (current_ = p) < end_ ? *p++ : 0;
|
||||||
|
if (c == '+' || c == '-')
|
||||||
|
c = (current_ = p) < end_ ? *p++ : 0;
|
||||||
|
while (c >= '0' && c <= '9')
|
||||||
|
c = (current_ = p) < end_ ? *p++ : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user