[gtk-doc] gtkdoc-scangobj: serialise doubles and floats always with a decimal dot
- From: Stefan Kost <stefkost src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-doc] gtkdoc-scangobj: serialise doubles and floats always with a decimal dot
- Date: Mon, 4 Oct 2010 09:08:45 +0000 (UTC)
commit 280c2d0654be3f39bd357c1dee9919ef1c34be21
Author: Tim-Philipp Müller <tim muller collabora co uk>
Date: Mon Oct 4 12:08:47 2010 +0300
gtkdoc-scangobj: serialise doubles and floats always with a decimal dot
Make sure floats and double property values are output with a decimal dot (and
not e.g. a comma) irrespective of the current locale. g_ascii_formatd() is used
here instead of g_ascii_dtostr() because we want nice human-readable numbers and
do not need the exact same bit representation when deserialising.
Other parts of gtk-doc may need fixing as well to make sure to always
deserialise floats and doubles in C locale.
gtkdoc-scangobj.in | 23 +++++++++++++++++++----
1 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/gtkdoc-scangobj.in b/gtkdoc-scangobj.in
index 1977ed2..3e9a212 100644
--- a/gtkdoc-scangobj.in
+++ b/gtkdoc-scangobj.in
@@ -1028,8 +1028,13 @@ describe_double_constant (gdouble value)
desc = g_strdup ("G_MINFLOAT");
else if (GTKDOC_COMPARE_FLOAT (value, -G_MAXFLOAT))
desc = g_strdup ("-G_MAXFLOAT");
- else
- desc = g_strdup_printf ("%lg", value);
+ else{
+ /* make sure floats are output with a decimal dot irrespective of
+ * current locale. Use formatd since we want human-readable numbers
+ * and do not need the exact same bit representation when deserialising */
+ desc = g_malloc0 (G_ASCII_DTOSTR_BUF_SIZE);
+ g_ascii_formatd (desc, G_ASCII_DTOSTR_BUF_SIZE, "%g", value);
+ }
return desc;
}
@@ -1446,13 +1451,23 @@ describe_default (GParamSpec *spec)
{
GParamSpecFloat *pspec = G_PARAM_SPEC_FLOAT (spec);
- desc = g_strdup_printf ("%g", pspec->default_value);
+ /* make sure floats are output with a decimal dot irrespective of
+ * current locale. Use formatd since we want human-readable numbers
+ * and do not need the exact same bit representation when deserialising */
+ desc = g_malloc0 (G_ASCII_DTOSTR_BUF_SIZE);
+ g_ascii_formatd (desc, G_ASCII_DTOSTR_BUF_SIZE, "%g",
+ pspec->default_value);
}
else if (G_IS_PARAM_SPEC_DOUBLE (spec))
{
GParamSpecDouble *pspec = G_PARAM_SPEC_DOUBLE (spec);
- desc = g_strdup_printf ("%lg", pspec->default_value);
+ /* make sure floats are output with a decimal dot irrespective of
+ * current locale. Use formatd since we want human-readable numbers
+ * and do not need the exact same bit representation when deserialising */
+ desc = g_malloc0 (G_ASCII_DTOSTR_BUF_SIZE);
+ g_ascii_formatd (desc, G_ASCII_DTOSTR_BUF_SIZE, "%g",
+ pspec->default_value);
}
else if (G_IS_PARAM_SPEC_STRING (spec))
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]