summaryrefslogtreecommitdiff
path: root/json-glib/json-generator.c
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@linux.intel.com>2011-01-10 10:45:39 +0000
committerEmmanuele Bassi <ebassi@linux.intel.com>2011-01-10 10:45:39 +0000
commit02dd77efaa60201f74349c969dc005c8bb092057 (patch)
tree116a1349d8dee60b8b73e1cd12263a6e6b6766b0 /json-glib/json-generator.c
parent3dbab961e675d0684df1121906ae3588d09653e6 (diff)
downloadjson-glib-02dd77efaa60201f74349c969dc005c8bb092057.tar.gz
generator: Use g_ascii_dtostr() to avoid losing precision
The nice format escape for g_ascii_formatd() is not really suited for a serialization format, as it obviously loses precision. https://bugzilla.gnome.org/show_bug.cgi?id=637244
Diffstat (limited to 'json-glib/json-generator.c')
-rw-r--r--json-glib/json-generator.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/json-glib/json-generator.c b/json-glib/json-generator.c
index 22fc6b3..c3bdc9a 100644
--- a/json-glib/json-generator.c
+++ b/json-glib/json-generator.c
@@ -316,10 +316,11 @@ dump_value (JsonGenerator *generator,
case G_TYPE_DOUBLE:
{
- gchar buf[65];
+ gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
- g_ascii_formatd (buf, 65, "%g", g_value_get_double (&value));
- g_string_append (buffer, buf);
+ g_string_append (buffer,
+ g_ascii_dtostr (buf, sizeof (buf),
+ g_value_get_double (&value)));
}
break;