From: Petri Lehtinen Date: Fri, 26 Mar 2010 19:59:53 +0000 (+0200) Subject: Estimate real number underflows with 0.0 X-Git-Tag: v1.2.1~5 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=jansson.git;a=commitdiff_plain;h=bb89a5d4d377f7b6b8c0c9ce3a2698b112447d08 Estimate real number underflows with 0.0 Earlier it was a decoding error. --- diff --git a/src/load.c b/src/load.c index baf3183..649609a 100644 --- a/src/load.c +++ b/src/load.c @@ -483,14 +483,7 @@ static int lex_scan_number(lex_t *lex, char c, json_error_t *error) value = strtod(saved_text, &end); assert(end == saved_text + lex->saved_text.length); - if(value == 0 && errno == ERANGE) { - error_set(error, lex, "real number underflow"); - goto out; - } - - /* Cannot test for +/-HUGE_VAL because the HUGE_VAL constant is - only defined in C99 mode. So let's trust in sole errno. */ - else if(errno == ERANGE) { + if(errno == ERANGE && value != 0) { error_set(error, lex, "real number overflow"); goto out; } diff --git a/test/suites/invalid-strip/real-underflow/error b/test/suites/invalid-strip/real-underflow/error deleted file mode 100644 index 1b65d40..0000000 --- a/test/suites/invalid-strip/real-underflow/error +++ /dev/null @@ -1,2 +0,0 @@ -1 -real number underflow near '123e-10000000' diff --git a/test/suites/invalid/real-underflow/error b/test/suites/invalid/real-underflow/error deleted file mode 100644 index 1b65d40..0000000 --- a/test/suites/invalid/real-underflow/error +++ /dev/null @@ -1,2 +0,0 @@ -1 -real number underflow near '123e-10000000' diff --git a/test/suites/invalid-strip/real-underflow/input b/test/suites/valid-strip/real-underflow/input similarity index 100% rename from test/suites/invalid-strip/real-underflow/input rename to test/suites/valid-strip/real-underflow/input diff --git a/test/suites/valid-strip/real-underflow/output b/test/suites/valid-strip/real-underflow/output new file mode 100644 index 0000000..92df1df --- /dev/null +++ b/test/suites/valid-strip/real-underflow/output @@ -0,0 +1 @@ +[0.0] \ No newline at end of file diff --git a/test/suites/invalid/real-underflow/input b/test/suites/valid/real-underflow/input similarity index 100% rename from test/suites/invalid/real-underflow/input rename to test/suites/valid/real-underflow/input diff --git a/test/suites/valid/real-underflow/output b/test/suites/valid/real-underflow/output new file mode 100644 index 0000000..92df1df --- /dev/null +++ b/test/suites/valid/real-underflow/output @@ -0,0 +1 @@ +[0.0] \ No newline at end of file