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.
This commit is contained in:
Tomas Halman authored and Nico Williams committed 2022-05-26 16:02:10 -05:00
1 parent 174db0f935
commit c4d39c4d22
2 files changed
+6

No files matched your search

+1
View File
@@ -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;
+5
View File
@@ -841,3 +841,8 @@ true
{"foo": 42}
{"foo": 43}
.[]|tonumber?
["1", "hello", "3", 4]
1
3
4