summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2011-10-21 14:57:47 -0400
committerMatthias Clasen <mclasen@redhat.com>2011-10-21 15:00:14 -0400
commite52437982c4dd1c88459f3eed0d8ad1dc167c0eb (patch)
tree8fac2c002c251ed52473f7bc938924e7f01e7fe8
parent848df03e16e190eddf1ee63733d85f687b65bdf9 (diff)
Make g_ascii_strtod behave as documented
The docs explicitly state that we reset errno, so lets do that, even if we just wrap strtod_l. Also move the argument check out of the ifdef. https://bugzilla.gnome.org/show_bug.cgi?id=662398
-rw-r--r--glib/gstrfuncs.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c
index b9b4cab64..01ca71842 100644
--- a/glib/gstrfuncs.c
+++ b/glib/gstrfuncs.c
@@ -673,12 +673,16 @@ g_strtod (const gchar *nptr,
* you can reliably detect overflow and underflow.
*
* Return value: the #gdouble value.
- **/
+ */
gdouble
g_ascii_strtod (const gchar *nptr,
gchar **endptr)
{
+ g_return_val_if_fail (nptr != NULL, 0);
+
#ifdef HAVE_STRTOD_L
+ errno = 0;
+
return strtod_l (nptr, endptr, get_C_locale ());
#else
gchar *fail_pos;
@@ -690,8 +694,6 @@ g_ascii_strtod (const gchar *nptr,
const char *end = NULL; /* Silence gcc */
int strtod_errno;
- g_return_val_if_fail (nptr != NULL, 0);
-
fail_pos = NULL;
locale_data = localeconv ();