jv_parse: let decNumberFromString/strtod parse complex nans as a NaN
Before this patch (when using decNumber), "Nan123" was parsed as a NaN, only if the first n was uppercase.
This commit is contained in:
1 parent
dcf9a8e580
commit
c5fd64ba97
2 files changed
+6
-1
No files matched your search
+1
-1
@@ -514,7 +514,7 @@ static pfunc check_literal(struct jv_parser* p) {
|
|||||||
case 'f': pattern = "false"; plen = 5; v = jv_false(); break;
|
case 'f': pattern = "false"; plen = 5; v = jv_false(); break;
|
||||||
case 'n':
|
case 'n':
|
||||||
// if it starts with 'n', it could be a literal "nan"
|
// if it starts with 'n', it could be a literal "nan"
|
||||||
if (p->tokenpos != 3) {
|
if (p->tokenbuf[1] == 'u') {
|
||||||
pattern = "null"; plen = 4; v = jv_null();
|
pattern = "null"; plen = 4; v = jv_null();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1938,6 +1938,11 @@ tojson | fromjson
|
|||||||
{"a":nan}
|
{"a":nan}
|
||||||
{"a":null}
|
{"a":null}
|
||||||
|
|
||||||
|
# also "nan with payload" #2985
|
||||||
|
fromjson | isnan
|
||||||
|
"nan1234"
|
||||||
|
true
|
||||||
|
|
||||||
|
|
||||||
# calling input/0, or debug/0 in a test doesn't crash jq
|
# calling input/0, or debug/0 in a test doesn't crash jq
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user