From c4d39c4d22f2b12225ca1b311708f7e084ad9ff8 Mon Sep 17 00:00:00 2001 From: Tomas Halman Date: Thu, 20 Jan 2022 10:15:50 +0100 Subject: Fix iterration problem for non decimal string When the string transformation to number failed, all following transformation failed too. This happend because status in decNumberFromString function is updated just in error case. Reusing the DEC_CONTEXT that failed before results into error even if the string is valid number. --- src/jv.c | 1 + tests/man.test | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/jv.c b/src/jv.c index 9784b22f..e1fb209f 100644 --- a/src/jv.c +++ b/src/jv.c @@ -612,6 +612,7 @@ static jv jvp_literal_number_new(const char * literal) { n->refcnt = JV_REFCNT_INIT; n->literal_data = NULL; decContext *ctx = DEC_CONTEXT(); + decContextClearStatus(ctx, DEC_Conversion_syntax); decNumberFromString(&n->num_decimal, literal, ctx); n->num_double = NAN; diff --git a/tests/man.test b/tests/man.test index 2a49effe..1c6ff67e 100644 --- a/tests/man.test +++ b/tests/man.test @@ -841,3 +841,8 @@ true {"foo": 42} {"foo": 43} +.[]|tonumber? +["1", "hello", "3", 4] +1 +3 +4 -- cgit v1.2.3