Merge pull request #90 from remicollet/issue-strict

in strick mode, number must not start with 0
diff --git a/json_inttypes.h b/json_inttypes.h
index 2f84ade..bfe1060 100644
--- a/json_inttypes.h
+++ b/json_inttypes.h
@@ -4,7 +4,7 @@
 
 #include "json_config.h"
 
-#if defined(_MSC_VER) && _MSC_VER < 1700
+#if defined(_MSC_VER) && _MSC_VER =< 1700
 
 /* Anything less than Visual Studio C++ 10 is missing stdint.h and inttypes.h */
 typedef __int32 int32_t;
diff --git a/json_object.c b/json_object.c
index f2b5ce0..e12c440 100644
--- a/json_object.c
+++ b/json_object.c
@@ -16,6 +16,7 @@
 #include <stdlib.h>
 #include <stddef.h>
 #include <string.h>
+#include <math.h>
 
 #include "debug.h"
 #include "printbuf.h"
@@ -37,6 +38,13 @@
   char* strndup(const char* str, size_t n);
 #endif /* !HAVE_STRNDUP */
 
+#if !defined(HAVE_SNPRINTF) && defined(_MSC_VER)
+  /* MSC has the version as _snprintf */
+# define snprintf _snprintf
+#elif !defined(HAVE_SNPRINTF)
+# error You do not have snprintf on your system.
+#endif /* HAVE_SNPRINTF */
+
 // Don't define this.  It's not thread-safe.
 /* #define REFCOUNT_DEBUG 1 */
 
@@ -561,8 +569,19 @@
 {
   char buf[128], *p, *q;
   int size;
+  /* Although JSON RFC does not support
+     NaN or Infinity as numeric values
+     ECMA 262 section 9.8.1 defines
+     how to handle these cases as strings */
+  if(isnan(jso->o.c_double))
+    size = snprintf(buf, 128, "NaN");
+  else if(isinf(jso->o.c_double) == 1)
+    size = snprintf(buf, 128, "Infinity");
+  else if(isinf(jso->o.c_double) == -1)
+    size = snprintf(buf, 128, "-Infinity");
+  else
+    size = snprintf(buf, 128, "%f", jso->o.c_double);
 
-  size = snprintf(buf, 128, "%f", jso->o.c_double);
   p = strchr(buf, ',');
   if (p) {
     *p = '.';
diff --git a/json_util.c b/json_util.c
index 111fa01..d62d54e 100644
--- a/json_util.c
+++ b/json_util.c
@@ -159,14 +159,15 @@
 static void sscanf_is_broken_test()
 {
 	int64_t num64;
+	int ret_errno, is_int64_min, ret_errno2, is_int64_max;
 
 	(void)sscanf(" -01234567890123456789012345", "%" SCNd64, &num64);
-	int ret_errno = errno;
-	int is_int64_min = (num64 == INT64_MIN);
+	ret_errno = errno;
+	is_int64_min = (num64 == INT64_MIN);
 
 	(void)sscanf(" 01234567890123456789012345", "%" SCNd64, &num64);
-	int ret_errno2 = errno;
-	int is_int64_max = (num64 == INT64_MAX);
+	ret_errno2 = errno;
+	is_int64_max = (num64 == INT64_MAX);
 
 	if (ret_errno != ERANGE || !is_int64_min ||
 	    ret_errno2 != ERANGE || !is_int64_max)