mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-08 18:36:17 +01:00
gstrfuncs: don't require nonstandard functions for USE_XLOCALE.
Make it so USE_XLOCALE is set whenever newlocale() and uselocale() are available. This way, we can still use the _g_snprintf() path for some functions, and also use the *_l functions when they are available. newlocale(3) are uselocale(3) part of POSIX 2008, while the *_l functions being used are nonstandard glibc extensions. Gating all the locale functionality behind them meant we were using fallbacks on non glibc platforms unnecessarily. Further changes to this code could add fallback for the non _l suffixed number parsing functions, but that might be unnecessary complexity. Fixes #2553
This commit is contained in:
parent
e3e3c02bd2
commit
4b2f342a22
@ -317,11 +317,8 @@ static const guint16 ascii_table_data[256] = {
|
||||
|
||||
const guint16 * const g_ascii_table = ascii_table_data;
|
||||
|
||||
#if defined (HAVE_NEWLOCALE) && \
|
||||
defined (HAVE_USELOCALE) && \
|
||||
defined (HAVE_STRTOD_L) && \
|
||||
defined (HAVE_STRTOULL_L) && \
|
||||
defined (HAVE_STRTOLL_L)
|
||||
#if defined(HAVE_NEWLOCALE) && \
|
||||
defined(HAVE_USELOCALE)
|
||||
#define USE_XLOCALE 1
|
||||
#endif
|
||||
|
||||
@ -731,7 +728,7 @@ gdouble
|
||||
g_ascii_strtod (const gchar *nptr,
|
||||
gchar **endptr)
|
||||
{
|
||||
#ifdef USE_XLOCALE
|
||||
#if defined(USE_XLOCALE) && defined(HAVE_STRTOD_L)
|
||||
|
||||
g_return_val_if_fail (nptr != NULL, 0);
|
||||
|
||||
@ -1044,7 +1041,7 @@ g_ascii_formatd (gchar *buffer,
|
||||
#define TOUPPER(c) (ISLOWER (c) ? (c) - 'a' + 'A' : (c))
|
||||
#define TOLOWER(c) (ISUPPER (c) ? (c) - 'A' + 'a' : (c))
|
||||
|
||||
#ifndef USE_XLOCALE
|
||||
#if !defined(USE_XLOCALE) || !defined(HAVE_STRTOULL_L) || !defined(HAVE_STRTOLL_L)
|
||||
|
||||
static guint64
|
||||
g_parse_long_long (const gchar *nptr,
|
||||
@ -1169,7 +1166,7 @@ g_parse_long_long (const gchar *nptr,
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif /* !USE_XLOCALE */
|
||||
#endif /* !defined(USE_XLOCALE) || !defined(HAVE_STRTOULL_L) || !defined(HAVE_STRTOLL_L) */
|
||||
|
||||
/**
|
||||
* g_ascii_strtoull:
|
||||
@ -1210,7 +1207,7 @@ g_ascii_strtoull (const gchar *nptr,
|
||||
gchar **endptr,
|
||||
guint base)
|
||||
{
|
||||
#ifdef USE_XLOCALE
|
||||
#if defined(USE_XLOCALE) && defined(HAVE_STRTOULL_L)
|
||||
return strtoull_l (nptr, endptr, base, get_C_locale ());
|
||||
#else
|
||||
gboolean negative;
|
||||
@ -1257,7 +1254,7 @@ g_ascii_strtoll (const gchar *nptr,
|
||||
gchar **endptr,
|
||||
guint base)
|
||||
{
|
||||
#ifdef USE_XLOCALE
|
||||
#if defined(USE_XLOCALE) && defined(HAVE_STRTOLL_L)
|
||||
return strtoll_l (nptr, endptr, base, get_C_locale ());
|
||||
#else
|
||||
gboolean negative;
|
||||
|
Loading…
Reference in New Issue
Block a user