From: Matthias Clasen Date: Thu, 19 Jul 2012 10:32:29 +0000 (-0400) Subject: Be more careful when using xlocale X-Git-Tag: 2.33.8~51 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4c255d4602b4c6f65031588ff30342c36e250567;p=platform%2Fupstream%2Fglib.git Be more careful when using xlocale Bug 680074 shows that we may end up in situations where only some of the xlocale functions we need are available. Rather than trying to find the minimal set of required functions for each use, define a global USE_XLOCALE and only use any xlocale functions if we have a full set. --- diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c index 5d4da1c..9d192a3 100644 --- a/glib/gstrfuncs.c +++ b/glib/gstrfuncs.c @@ -317,7 +317,15 @@ static const guint16 ascii_table_data[256] = { const guint16 * const g_ascii_table = ascii_table_data; -#ifdef HAVE_NEWLOCALE +#if defined (HAVE_NEWLOCALE) && \ + defined (HAVE_USELOCALE) && \ + defined (HAVE_STRTOD_L) && \ + defined (HAVE_STRTOULL_L) && \ + defined (HAVE_STRTOLL_L) +#define USE_XLOCALE 1 +#endif + +#ifdef USE_XLOCALE static locale_t get_C_locale (void) { @@ -683,7 +691,7 @@ gdouble g_ascii_strtod (const gchar *nptr, gchar **endptr) { -#ifdef HAVE_STRTOD_L +#ifdef USE_XLOCALE g_return_val_if_fail (nptr != NULL, 0); @@ -890,7 +898,7 @@ g_ascii_formatd (gchar *buffer, const gchar *format, gdouble d) { -#ifdef HAVE_USELOCALE +#ifdef USE_XLOCALE locale_t old_locale; old_locale = uselocale (get_C_locale ()); @@ -975,7 +983,7 @@ g_ascii_formatd (gchar *buffer, #define TOUPPER(c) (ISLOWER (c) ? (c) - 'a' + 'A' : (c)) #define TOLOWER(c) (ISUPPER (c) ? (c) - 'A' + 'a' : (c)) -#if !defined(HAVE_STRTOLL_L) || !defined(HAVE_STRTOULL_L) +#ifndef USE_XLOCALE static guint64 g_parse_long_long (const gchar *nptr, @@ -1100,7 +1108,7 @@ g_parse_long_long (const gchar *nptr, } return 0; } -#endif +#endif /* !USE_XLOCALE */ /** * g_ascii_strtoull: @@ -1136,7 +1144,7 @@ g_ascii_strtoull (const gchar *nptr, gchar **endptr, guint base) { -#ifdef HAVE_STRTOULL_L +#ifdef USE_XLOCALE return strtoull_l (nptr, endptr, base, get_C_locale ()); #else gboolean negative; @@ -1183,7 +1191,7 @@ g_ascii_strtoll (const gchar *nptr, gchar **endptr, guint base) { -#ifdef HAVE_STRTOLL_L +#ifdef USE_XLOCALE return strtoll_l (nptr, endptr, base, get_C_locale ()); #else gboolean negative;