[json-glib/json-glib-0-12] generator: Use g_ascii_dtostr() to avoid losing precision
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [json-glib/json-glib-0-12] generator: Use g_ascii_dtostr() to avoid losing precision
- Date: Mon, 10 Jan 2011 11:39:55 +0000 (UTC)
commit 89c2e81e0be5ec7ef53c1b142502a813fcffcc9e
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Mon Jan 10 10:45:39 2011 +0000
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
(cherry picked from commit 02dd77efaa60201f74349c969dc005c8bb092057)
Signed-off-by: Emmanuele Bassi <ebassi linux intel com>
json-glib/json-generator.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/json-glib/json-generator.c b/json-glib/json-generator.c
index 7b41c40..05e15b5 100644
--- a/json-glib/json-generator.c
+++ b/json-glib/json-generator.c
@@ -309,10 +309,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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]