]> granicus.if.org Git - json-c/commitdiff
nan function requires -lm on some platforms; use of NAN is better, if available.
authorMarkus Stenberg <markus.stenberg@iki.fi>
Tue, 18 Mar 2014 14:29:49 +0000 (16:29 +0200)
committerMarkus Stenberg <markus.stenberg@iki.fi>
Tue, 18 Mar 2014 14:29:49 +0000 (16:29 +0200)
json_tokener.c

index 0c800d8f85cfb01d43802b9511cef5f632311612..9862f9ef0729e9c9c3b4077bc2226a9c3bbdf870 100644 (file)
 # error You do not have strncasecmp on your system.
 #endif /* HAVE_STRNCASECMP */
 
+/* Use C99 NAN by default; if not available, nan("") should work too. */
+#ifndef NAN
+#define NAN nan("")
+#endif /* !NAN */
+
 static const char json_null_str[] = "null";
 static const int json_null_str_len = sizeof(json_null_str) - 1;
 static const char json_nan_str[] = "NaN";
@@ -352,7 +357,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
        {
                if (tok->st_pos == json_nan_str_len)
                {
-                       current = json_object_new_double(nan(""));
+                       current = json_object_new_double(NAN);
                        saved_state = json_tokener_state_finish;
                        state = json_tokener_state_eatws;
                        goto redo_char;