[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: json-glib: doubles serialization does not works



2012/1/10 Adam D. Barratt wrote:
>If the bug is critical, I'm surprised that no-one appears to have filed
>it in the BTS by now.

Maybe there are just too few apps in Squeeze that utilizes serialization functionality of json-glib.

>Could you provide a little more information about
>which upstream version the fix was included in, and applications which
>are affected?

I noticed this problem while testing new versions of my game (Mokomaze [1]) on Squeeze. I use json-glib to store user settings. The fix is from official GNOME GIT source code repository. It was committed on March 18th 2010 and version 0.10.4 of the library was released on March 19th 2010 [2].

Absolutely the same bug was fixed in Ubuntu Maverick. The bug report [3] contains detailed description of the problem, a proper fix [4] for the package and even a test app [5].

>If you'd like to have a fix for the issue considered for an update in
>stable, please prepare a fixed package and send a debdiff to
>debian-release for consideration.

I have tried to do it - the diff is attached to this message.

[1] https://github.com/Sektor/mokomaze
[2] http://ftp.gnome.org/pub/GNOME/sources/json-glib/0.10/json-glib-0.10.4.changes
[3] https://bugs.launchpad.net/ubuntu/+source/json-glib/+bug/756426
[4] http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/maverick/json-glib/maverick-proposed/diff/10
[5] https://bugs.launchpad.net/ubuntu/+source/json-glib/+bug/756426/+attachment/2092102/+files/lp756426-test-double.c

--
Anton

=== modified file 'debian/changelog'
--- debian/changelog    2010-01-10 23:59:10 +0000
+++ debian/changelog    2012-01-11 01:30:45 +0000
@@ -1,3 +1,10 @@
+json-glib (0.10.2-2squeeze1) stable; urgency=low
+
+  * debian/patches/01_use_g_format_for_g_ascii_formatd.patch:
+    - Add upstream patch to fix serialization of doubles
+
+ -- Anton Olkhovik <ant007h@gmail.com>  Wed, 11 Jan 2012 01:30:45 +0400
+
 json-glib (0.10.2-2) unstable; urgency=low
 
   * Enable GObject introspection

=== added directory 'debian/patches'
=== added file 'debian/patches/01_use_g_format_for_g_ascii_formatd.patch'
--- debian/patches/01_use_g_format_for_g_ascii_formatd.patch    1970-01-01 00:00:00 +0000
+++ debian/patches/01_use_g_format_for_g_ascii_formatd.patch    2012-01-11 01:30:45 +0000
@@ -0,0 +1,29 @@
+From f622ee8d8ba54ddea6fbb7311a905ffab7842e8d Mon Sep 17 00:00:00 2001
+From: Emmanuele Bassi <ebassi@linux.intel.com>
+Date: Thu, 18 Mar 2010 17:05:57 +0000
+Subject: generator: Use %g format for g_ascii_formatd()
+
+I should read the documentation for the functions I use:
+
+  Converts a gdouble to a string, using the '.' as decimal point. To
+  format the number you pass in a printf()-style format string. Allowed
+  conversion specifiers are 'e', 'E', 'f', 'F', 'g' and 'G'.
+                -- from g_ascii_formatd() in GLib's API reference
+
+Epic reading fail.
+---
+diff --git a/json-glib/json-generator.c b/json-glib/json-generator.c
+index bad239b..c77830e 100644
+--- a/json-glib/json-generator.c
++++ b/json-glib/json-generator.c
+@@ -309,7 +309,7 @@ dump_value (JsonGenerator *generator,
+       {
+         gchar buf[65];
+
+-        g_ascii_formatd (buf, 65, "%d", g_value_get_double (&value));
++        g_ascii_formatd (buf, 65, "%g", g_value_get_double (&value));
+         g_string_append (buffer, buf);
+       }
+       break;
+--
+cgit v0.9.0.2

=== added file 'debian/patches/series'
--- debian/patches/series    1970-01-01 00:00:00 +0000
+++ debian/patches/series    2012-01-11 01:30:45 +0000
@@ -0,0 +1,1 @@
+01_use_g_format_for_g_ascii_formatd.patch


Reply to: