summaryrefslogtreecommitdiff
path: root/gtkdoc-scangobj.in
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim.muller@collabora.co.uk>2010-10-04 12:08:47 +0300
committerStefan Kost <ensonic@users.sf.net>2010-10-04 12:08:47 +0300
commit280c2d0654be3f39bd357c1dee9919ef1c34be21 (patch)
treedbc0e5f6743d7409a4d20cd4da4c2505802057b0 /gtkdoc-scangobj.in
parent8688e1d689d498f541d0f64ca141b503c9620837 (diff)
downloadgtk-doc-280c2d0654be3f39bd357c1dee9919ef1c34be21.tar.gz
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.
Diffstat (limited to 'gtkdoc-scangobj.in')
-rw-r--r--gtkdoc-scangobj.in23
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))
{