mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-28 10:07:13 +02:00
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
This commit is contained in:
@@ -673,12 +673,16 @@ g_strtod (const gchar *nptr,
|
|||||||
* you can reliably detect overflow and underflow.
|
* you can reliably detect overflow and underflow.
|
||||||
*
|
*
|
||||||
* Return value: the #gdouble value.
|
* Return value: the #gdouble value.
|
||||||
**/
|
*/
|
||||||
gdouble
|
gdouble
|
||||||
g_ascii_strtod (const gchar *nptr,
|
g_ascii_strtod (const gchar *nptr,
|
||||||
gchar **endptr)
|
gchar **endptr)
|
||||||
{
|
{
|
||||||
|
g_return_val_if_fail (nptr != NULL, 0);
|
||||||
|
|
||||||
#ifdef HAVE_STRTOD_L
|
#ifdef HAVE_STRTOD_L
|
||||||
|
errno = 0;
|
||||||
|
|
||||||
return strtod_l (nptr, endptr, get_C_locale ());
|
return strtod_l (nptr, endptr, get_C_locale ());
|
||||||
#else
|
#else
|
||||||
gchar *fail_pos;
|
gchar *fail_pos;
|
||||||
@@ -690,8 +694,6 @@ g_ascii_strtod (const gchar *nptr,
|
|||||||
const char *end = NULL; /* Silence gcc */
|
const char *end = NULL; /* Silence gcc */
|
||||||
int strtod_errno;
|
int strtod_errno;
|
||||||
|
|
||||||
g_return_val_if_fail (nptr != NULL, 0);
|
|
||||||
|
|
||||||
fail_pos = NULL;
|
fail_pos = NULL;
|
||||||
|
|
||||||
locale_data = localeconv ();
|
locale_data = localeconv ();
|
||||||
|
Reference in New Issue
Block a user