Simplify things by storing integer values only as int64_t's internally, and
 omit the range check during parsing since we already have the checks when
 accessing the value. There is no longer a json_type_int64, only json_type_int.
Fix some problems with parsing 0 and -0 values, and add a couple of tests.
Fix some minor compile issues on HPUX environments.


git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@60 327403b1-1117-474d-bef2-5cb71233fd97
diff --git a/json_object.c b/json_object.c
index c2b6fe2..2b6dad4 100644
--- a/json_object.c
+++ b/json_object.c
@@ -43,7 +43,6 @@
   "object",
   "array",
   "string",
-  "int64",
 };
 #endif /* REFCOUNT_DEBUG */
 
@@ -306,8 +305,6 @@
   case json_type_boolean:
     return jso->o.c_boolean;
   case json_type_int:
-    return (jso->o.c_int != 0);
-  case json_type_int64:
     return (jso->o.c_int64 != 0);
   case json_type_double:
     return (jso->o.c_double != 0);
@@ -324,10 +321,6 @@
 static int json_object_int_to_json_string(struct json_object* jso,
 					  struct printbuf *pb)
 {
-  return sprintbuf(pb, "%d", jso->o.c_int);
-}
-
-static int json_object_int64_to_json_string(struct json_object* jso, struct printbuf *pb) {
   return sprintbuf(pb, "%"PRId64, jso->o.c_int64);
 }
 
@@ -336,7 +329,7 @@
   struct json_object *jso = json_object_new(json_type_int);
   if(!jso) return NULL;
   jso->_to_json_string = &json_object_int_to_json_string;
-  jso->o.c_int = i;
+  jso->o.c_int64 = i;
   return jso;
 }
 
@@ -355,13 +348,11 @@
 	 */
 	if (json_parse_int64(jso->o.c_string, &cint64) != 0)
 		return 0; /* whoops, it didn't work. */
-	o_type = json_type_int64;
+	o_type = json_type_int;
   }
 
   switch(jso->o_type) {
   case json_type_int:
-    return jso->o.c_int;
-  case json_type_int64:
 	/* Make sure we return the correct values for out of range numbers. */
 	if (cint64 <= INT32_MIN)
 		return INT32_MIN;
@@ -380,9 +371,9 @@
 
 struct json_object* json_object_new_int64(int64_t i)
 {
-  struct json_object *jso = json_object_new(json_type_int64);
+  struct json_object *jso = json_object_new(json_type_int);
   if(!jso) return NULL;
-  jso->_to_json_string = &json_object_int64_to_json_string;
+  jso->_to_json_string = &json_object_int_to_json_string;
   jso->o.c_int64 = i;
   return jso;
 }
@@ -394,8 +385,6 @@
   if(!jso) return 0;
   switch(jso->o_type) {
   case json_type_int:
-    return (int64_t)jso->o.c_int;
-  case json_type_int64:
     return jso->o.c_int64;
   case json_type_double:
     return (int64_t)jso->o.c_double;
@@ -435,8 +424,6 @@
   case json_type_double:
     return jso->o.c_double;
   case json_type_int:
-    return jso->o.c_int;
-  case json_type_int64:
     return jso->o.c_int64;
   case json_type_boolean:
     return jso->o.c_boolean;