diff options
author | Christopher James Lahey <clahey@ximian.com> | 2001-10-06 22:23:10 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2001-10-06 22:23:10 +0800 |
commit | 8c8bf81c61d4da00bfd529f92a394f59a1b1f5b7 (patch) | |
tree | 1649c82449d745844f044061c8137e88e100d6d1 /e-util/e-xml-utils.c | |
parent | 9e805a243e4cbee3dedf0275c69528717e0e3aeb (diff) | |
download | gsoc2013-evolution-8c8bf81c61d4da00bfd529f92a394f59a1b1f5b7.tar.gz gsoc2013-evolution-8c8bf81c61d4da00bfd529f92a394f59a1b1f5b7.tar.zst gsoc2013-evolution-8c8bf81c61d4da00bfd529f92a394f59a1b1f5b7.zip |
New function that parses a string as a double either in the C locale or
2001-10-06 Christopher James Lahey <clahey@ximian.com>
* gal/util/e-util.c, gal/util/e-util.h (e_flexible_strtod): New
function that parses a string as a double either in the C locale
or the current locale.
(e_ascii_dtostr): New function that saves a double as a string as
it would be saved in the C locale.
* gal/util/e-xml-utils.c
(e_xml_get_double_prop_by_name_with_default): Use
e_flexible_strtod here.
(e_xml_set_double_prop_by_name): Use e_ascii_dtostr here.
svn path=/trunk/; revision=13479
Diffstat (limited to 'e-util/e-xml-utils.c')
-rw-r--r-- | e-util/e-xml-utils.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/e-util/e-xml-utils.c b/e-util/e-xml-utils.c index 1285b5ce75..6ff68c5904 100644 --- a/e-util/e-xml-utils.c +++ b/e-util/e-xml-utils.c @@ -30,6 +30,7 @@ #include <gnome-xml/parser.h> #include <gnome-xml/xmlmemory.h> #include "gal/util/e-i18n.h" +#include "gal/util/e-util.h" xmlNode * e_xml_get_child_by_name (const xmlNode *parent, const xmlChar *child_name) @@ -329,7 +330,7 @@ e_xml_get_double_prop_by_name_with_default (const xmlNode *parent, const xmlChar prop = xmlGetProp ((xmlNode *) parent, prop_name); if (prop != NULL) { - (void) sscanf (prop, "%lf", &ret_val); + ret_val = e_flexible_strtod (prop, NULL); xmlFree (prop); } return ret_val; @@ -338,18 +339,17 @@ e_xml_get_double_prop_by_name_with_default (const xmlNode *parent, const xmlChar void e_xml_set_double_prop_by_name(xmlNode *parent, const xmlChar *prop_name, gdouble value) { - gchar *valuestr; + char buffer[E_ASCII_DTOSTR_BUF_SIZE]; g_return_if_fail (parent != NULL); g_return_if_fail (prop_name != NULL); if (fabs (value) < 1e9 && fabs (value) > 1e-5) { - valuestr = g_strdup_printf ("%f", value); + e_ascii_dtostr (buffer, sizeof (buffer), "%.17f", value); } else { - valuestr = g_strdup_printf ("%.*g", DBL_DIG, value); + e_ascii_dtostr (buffer, sizeof (buffer), "%.17g", value); } - xmlSetProp (parent, prop_name, valuestr); - g_free (valuestr); + xmlSetProp (parent, prop_name, buffer); } gchar * |