87 lines
2.7 KiB
Diff
87 lines
2.7 KiB
Diff
|
From: =?UTF-8?q?=C3=89rico=20Nogueira?= <erico.erc@gmail.com>
|
||
|
[PATCH] 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
|
||
|
---
|
||
|
glib/gstrfuncs.c | 17 +++++++----------
|
||
|
1 file changed, 7 insertions(+), 10 deletions(-)
|
||
|
|
||
|
diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c
|
||
|
index ea710c7a1..e486251ab 100644
|
||
|
--- a/glib/gstrfuncs.c
|
||
|
+++ b/glib/gstrfuncs.c
|
||
|
@@ -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;
|
||
|
--
|
||
|
2.34.1
|
||
|
|