Estimate real number underflows with 0.0
authorPetri Lehtinen <petri@digip.org>
Fri, 26 Mar 2010 19:59:53 +0000 (21:59 +0200)
committerPetri Lehtinen <petri@digip.org>
Fri, 26 Mar 2010 19:59:56 +0000 (21:59 +0200)
Earlier it was a decoding error.

src/load.c
test/suites/invalid-strip/real-underflow/error [deleted file]
test/suites/invalid/real-underflow/error [deleted file]
test/suites/valid-strip/real-underflow/input [moved from test/suites/invalid-strip/real-underflow/input with 100% similarity]
test/suites/valid-strip/real-underflow/output [new file with mode: 0644]
test/suites/valid/real-underflow/input [moved from test/suites/invalid/real-underflow/input with 100% similarity]
test/suites/valid/real-underflow/output [new file with mode: 0644]

index baf3183..649609a 100644 (file)
@@ -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 (file)
index 1b65d40..0000000
+++ /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 (file)
index 1b65d40..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-1
-real number underflow near '123e-10000000'
diff --git a/test/suites/valid-strip/real-underflow/output b/test/suites/valid-strip/real-underflow/output
new file mode 100644 (file)
index 0000000..92df1df
--- /dev/null
@@ -0,0 +1 @@
+[0.0]
\ No newline at end of file
diff --git a/test/suites/valid/real-underflow/output b/test/suites/valid/real-underflow/output
new file mode 100644 (file)
index 0000000..92df1df
--- /dev/null
@@ -0,0 +1 @@
+[0.0]
\ No newline at end of file