diff options
author | Tim-Philipp Müller <tim.muller@collabora.co.uk> | 2010-07-23 16:46:10 +0100 |
---|---|---|
committer | Tim-Philipp Müller <tim.muller@collabora.co.uk> | 2010-07-23 16:46:10 +0100 |
commit | 1c3225c7cffafbcfdf711ed33c69e6e1f974745d (patch) | |
tree | acfaa8c13f0f128d593491a76f871e49c84270bf | |
parent | f1dae75a1e567c6726be4c77db5c682e951178c2 (diff) |
gstdoc-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.
-rwxr-xr-x | gstdoc-scangobj | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/gstdoc-scangobj b/gstdoc-scangobj index f1d031b..cc1e294 100755 --- a/gstdoc-scangobj +++ b/gstdoc-scangobj @@ -1216,8 +1216,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; } @@ -1583,13 +1588,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)) { |