Merge branch 'wip/smcv/bug3418-newlocale-errno' into 'main'

strfuncs: Don't let get_C_locale() clobber errno

Closes #3418

See merge request GNOME/glib!4170
This commit is contained in:
Simon McVittie 2024-07-26 15:41:26 +00:00
commit 4b1ee1f738

View File

@ -689,12 +689,14 @@ g_ascii_strtod (const gchar *nptr,
gchar **endptr)
{
#if defined(USE_XLOCALE) && defined(HAVE_STRTOD_L)
locale_t c_locale;
g_return_val_if_fail (nptr != NULL, 0);
c_locale = get_C_locale ();
errno = 0;
return strtod_l (nptr, endptr, get_C_locale ());
return strtod_l (nptr, endptr, c_locale);
#else
@ -1176,7 +1178,10 @@ g_ascii_strtoull (const gchar *nptr,
guint base)
{
#if defined(USE_XLOCALE) && defined(HAVE_STRTOULL_L)
return strtoull_l (nptr, endptr, base, get_C_locale ());
locale_t c_locale = get_C_locale ();
errno = 0;
return strtoull_l (nptr, endptr, base, c_locale);
#else
gboolean negative;
guint64 result;
@ -1224,7 +1229,10 @@ g_ascii_strtoll (const gchar *nptr,
guint base)
{
#if defined(USE_XLOCALE) && defined(HAVE_STRTOLL_L)
return strtoll_l (nptr, endptr, base, get_C_locale ());
locale_t c_locale = get_C_locale ();
errno = 0;
return strtoll_l (nptr, endptr, base, c_locale);
#else
gboolean negative;
guint64 result;