]> granicus.if.org Git - json-c/commitdiff
Revert part of PR#606 and use isnan/isinf again, but provide macro implementations...
authorEric Haszlakiewicz <erh+git@nimenees.com>
Sat, 16 May 2020 01:29:18 +0000 (01:29 +0000)
committerEric Haszlakiewicz <erh+git@nimenees.com>
Sat, 16 May 2020 01:29:18 +0000 (01:29 +0000)
json_object.c
math_compat.h

index 527cd3106078a89b541f4a166c9831ea475f2b56..04164d059e9e63c5c2a8f235c55fcdc8e3641bd2 100644 (file)
@@ -903,15 +903,11 @@ static int json_object_double_to_json_string_format(struct json_object *jso, str
         * ECMA 262 section 9.8.1 defines
         * how to handle these cases as strings
         */
-#ifdef HAVE_DECL_ISNAN
        if (isnan(jso->o.c_double))
        {
                size = snprintf(buf, sizeof(buf), "NaN");
        }
-       else
-#endif
-#ifdef HAVE_DECL_ISINF
-       if (isinf(jso->o.c_double))
+       else if (isinf(jso->o.c_double))
        {
                if (jso->o.c_double > 0)
                        size = snprintf(buf, sizeof(buf), "Infinity");
@@ -919,7 +915,6 @@ static int json_object_double_to_json_string_format(struct json_object *jso, str
                        size = snprintf(buf, sizeof(buf), "-Infinity");
        }
        else
-#endif
        {
                const char *std_format = "%.17g";
                int format_drops_decimals = 0;
index fdbad4de07817b9794afe5b01f85d2edfffcfc56..2382fe15b30a6f199ad7cda7f2f0b4db3585704f 100644 (file)
@@ -12,6 +12,9 @@
 #ifdef HAVE_DECL__ISNAN
 #include <float.h>
 #define isnan(x) _isnan(x)
+#else
+/* On platforms like AIX and "IBM i" we need to provide our own isnan */
+#define isnan(x) ((x) != (x))
 #endif
 #endif
 
 #ifdef HAVE_DECL__FINITE
 #include <float.h>
 #define isinf(x) (!_finite(x))
+#else
+#include <float.h>
+/* On platforms like AIX and "IBM i" we need to provide our own isinf */
+#define isinf(x) ((x) < -DBL_MAX || (x) > DBL_MAX)
 #endif
 #endif