Em 16-06-2010 09:10, Martin Jansa escreveu:
> On Tue, Jun 15, 2010 at 09:21:48PM +0100, Rui Miguel Silva Seabra wrote:
>> Hi,
>>
>> I'm abandoning libxml2 in favor of json-c for elmdentica (this saves a
>> lot on downloaded data and is easier to parse).
>>
>> For that, I need json-c in the repos.
>>
>> I wrote a recipe... please include it (with whatever fixes you deem
>> necessary).
> 
> With small fixes pushed here:
> http://git.openembedded.org/cgit.cgi/openembedded/commit/?id=7764d0b2511db7890a3bd6a6839a0f59145d0adf
> 
> Building in feed manually, let me know when there is elmdentica SRCREV
> which should depend on it (then it will be pulled to feed automaticaly,
> because of elmdentica DEPENDS).
> 
> Regards,
> 

Hi,

I've found json-c uses plain int for it's integer type, which makes it
unusable when big integers happen to show up (like in Twitter's status
IDs and eventually in identi.ca's).

I don't know how soon there will be a new release of json-c but sent the
attached patch to it's author.

Could, in the meanwhile and so current elmdentica works as expected,
this patch be applied to our json-c package?

Thanks in advance,
Rui
Index: json_object_private.h
===================================================================
--- json_object_private.h       (revision 55)
+++ json_object_private.h       (working copy)
@@ -30,7 +30,7 @@
   union data {
     boolean c_boolean;
     double c_double;
-    int c_int;
+    long long int c_int;
     struct lh_table *c_object;
     struct array_list *c_array;
     char *c_string;
Index: json_object.c
===================================================================
--- json_object.c       (revision 55)
+++ json_object.c       (working copy)
@@ -319,10 +319,10 @@
 static int json_object_int_to_json_string(struct json_object* jso,
                                          struct printbuf *pb)
 {
-  return sprintbuf(pb, "%d", jso->o.c_int);
+  return sprintbuf(pb, "%lld", jso->o.c_int);
 }
 
-struct json_object* json_object_new_int(int i)
+struct json_object* json_object_new_int(long long int i)
 {
   struct json_object *jso = json_object_new(json_type_int);
   if(!jso) return NULL;
@@ -331,20 +331,20 @@
   return jso;
 }
 
-int json_object_get_int(struct json_object *jso)
+long long int json_object_get_int(struct json_object *jso)
 {
-  int cint;
+  long long int cint;
 
   if(!jso) return 0;
   switch(jso->o_type) {
   case json_type_int:
     return jso->o.c_int;
   case json_type_double:
-    return (int)jso->o.c_double;
+    return (long long int)jso->o.c_double;
   case json_type_boolean:
     return jso->o.c_boolean;
   case json_type_string:
-    if(sscanf(jso->o.c_string, "%d", &cint) == 1) return cint;
+    if(sscanf(jso->o.c_string, "%lld", &cint) == 1) return cint;
   default:
     return 0;
   }
Index: json_tokener.c
===================================================================
--- json_tokener.c      (revision 55)
+++ json_tokener.c      (working copy)
@@ -542,9 +542,9 @@
           printbuf_memappend_fast(tok->pb, case_start, case_len);
       }
       {
-        int numi;
+        long long int numi;
         double numd;
-        if(!tok->is_double && sscanf(tok->pb->buf, "%d", &numi) == 1) {
+        if(!tok->is_double && sscanf(tok->pb->buf, "%lld", &numi) == 1) {
           current = json_object_new_int(numi);
         } else if(tok->is_double && sscanf(tok->pb->buf, "%lf", &numd) == 1) {
           current = json_object_new_double(numd);
Index: json_object.h
===================================================================
--- json_object.h       (revision 55)
+++ json_object.h       (working copy)
@@ -252,18 +252,18 @@
  * @param i the integer
  * @returns a json_object of type json_type_int
  */
-extern struct json_object* json_object_new_int(int i);
+extern struct json_object* json_object_new_int(long long int i);
 
-/** Get the int value of a json_object
+/** Get the long long int value of a json_object
  *
  * The type is coerced to a int if the passed object is not a int.
  * double objects will return their integer conversion. Strings will be
  * parsed as an integer. If no conversion exists then 0 is returned.
  *
  * @param obj the json_object instance
- * @returns an int
+ * @returns a long long int
  */
-extern int json_object_get_int(struct json_object *obj);
+extern long long int json_object_get_int(struct json_object *obj);
 
 
 /* double type methods */
Index: ChangeLog
===================================================================
--- ChangeLog   (revision 55)
+++ ChangeLog   (working copy)
@@ -8,6 +8,9 @@
     Brent Miller, bdmiller at yahoo dash inc dot com
   * Correction to comment describing printbuf_memappend in printbuf.h
     Brent Miller, bdmiller at yahoo dash inc dot com
+  * Use long long int instead of plain int for integers (needed for stuff like
+    twitter, which has some long long ints in it's status IDs
+    Rui Miguel Seabra, rms at 1407 dot org
 
 0.9
   * Add README.html README-WIN32.html config.h.win32 to Makefile.am
_______________________________________________
Shr-devel mailing list
[email protected]
http://lists.shr-project.org/mailman/listinfo/shr-devel

Reply via email to