Skip to content
Myr

jv_parse: let decNumberFromString/strtod parse complex nans as a NaN

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Before this patch (when using decNumber), "Nan123" was parsed as a NaN, only if the first n was uppercase.

authored by Emanuele Torre · committed by GitHub · parent dcf9a8e · Browse files · 2 files+6 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+6 added−1 removed

  • tests:+5 added−0 removed
  • other:+1 added−1 removed

2 files+6 added−1 removed

modified:src/jv_parse.c+1 added-1 removed
512 unmodified lines
513 case 't': pattern = "true"; plen = 4; v = jv_true(); break;514 case 'f': pattern = "false"; plen = 5; v = jv_false(); break;515 case 'n':516 // if it starts with 'n', it could be a literal "nan"517 if (p->tokenpos != 3) {517 if (p->tokenbuf[1] == 'u') {518 pattern = "null"; plen = 4; v = jv_null();519 }520 }521 if (pattern) {
390 unmodified lines
modified:tests/jq.test+5 added
1936 unmodified lines
1937tojson | fromjson1938{"a":nan}1939{"a":null}19401941# also "nan with payload" #29851942fromjson | isnan1943"nan1234"1944true194519461947# calling input/0, or debug/0 in a test doesn't crash jq19481949try input catch .1950null
167 unmodified lines