#if (defined __APPLE__ && defined __MACH__) || defined _WIN32 || defined __CYGWIN__
# ifndef GNULIB_defined_setlocale /* don't override gnulib */
+/* The return type 'const char *' serves the purpose of producing warnings
+ for invalid uses of the value returned from this function. */
# ifdef _INTL_REDIRECT_INLINE
-extern char *libintl_setlocale (int, const char *);
+extern const char *libintl_setlocale (int, const char *);
+# undef setlocale /* Disable #define setlocale(...) ... */
# ifndef __cplusplus
static
# endif
_INTL_FORCE_INLINE
char *setlocale (int __category, const char *__locale)
{
- return libintl_setlocale (__category, __locale);
+# ifdef __cplusplus
+ return const_cast<char *>(libintl_setlocale (__category, __locale));
+# else
+ return (char *) libintl_setlocale (__category, __locale);
+# endif
}
# elif !defined _INTL_NO_DEFINE_MACRO_SETLOCALE
# ifdef _INTL_REDIRECT_MACROS
# undef setlocale
# define setlocale libintl_setlocale
-# endif
+extern const char *setlocale (int, const char *);
+# else /* defined _INTL_REDIRECT_ASM */
+# undef setlocale /* Disable #define setlocale(...) ... */
extern char *setlocale (int, const char *)
_INTL_ASM (libintl_setlocale);
+# endif
# if defined _INTL_REDIRECT_MACROS && defined __cplusplus && !defined _INTL_CXX_NO_CLOBBER_STD_NAMESPACE
namespace std { using ::libintl_setlocale; }
# endif
/* Like setlocale, but accept also locale names in the form ll or ll_CC,
where ll is an ISO 639 language code and CC is an ISO 3166 country code. */
-static char *
+static const char *
setlocale_unixlike (int category, const char *locale)
{
int is_utf8 = (GetACP () == 65001);
locale = "English_United States.65001";
/* First, try setlocale with the original argument unchanged. */
- char *result = setlocale (category, locale);
+ const char *result = setlocale (category, locale);
if (result != NULL)
return result;
# elif defined __ANDROID__
/* Like setlocale, but accept also the locale names "C" and "POSIX". */
-static char *
+static const char *
setlocale_unixlike (int category, const char *locale)
{
- char *result = setlocale_fixed (category, locale);
+ const char *result = setlocale_fixed (category, locale);
if (result == NULL)
switch (category)
{
case LC_MEASUREMENT:
if (locale == NULL
|| streq (locale, "C") || streq (locale, "POSIX"))
- result = (char *) "C";
+ result = "C";
break;
default:
break;
# if LC_MESSAGES == 1729
/* Like setlocale, but support also LC_MESSAGES. */
-static char *
+static const char *
setlocale_single (int category, const char *locale)
{
if (category == LC_MESSAGES)
# endif
SHLIB_EXPORTED
-char *
+const char *
libintl_setlocale (int category, const char *locale)
{
if (locale != NULL && locale[0] == '\0')
};
/* Back up the old locale, in case one of the steps fails. */
- char *saved_locale = setlocale (LC_ALL, NULL);
- if (saved_locale == NULL)
+ const char *old_locale = setlocale (LC_ALL, NULL);
+ if (old_locale == NULL)
return NULL;
- saved_locale = strdup (saved_locale);
+ char *saved_locale = strdup (old_locale);
if (saved_locale == NULL)
return NULL;
/* In the underlying implementation, LC_ALL does not contain
LC_MESSAGES. Therefore we need to handle LC_MESSAGES
separately. */
- char *result;
+ const char *result;
# if defined _WIN32 && ! defined __CYGWIN__
if (strchr (native_locale, '.') != NULL)
{
- char *saved_locale;
-
/* Back up the old locale. */
- saved_locale = setlocale (LC_ALL, NULL);
- if (saved_locale == NULL)
+ const char *old_locale = setlocale (LC_ALL, NULL);
+ if (old_locale == NULL)
return NULL;
- saved_locale = strdup (saved_locale);
+ char *saved_locale = strdup (old_locale);
if (saved_locale == NULL)
return NULL;
"LC_COLLATE=...;LC_CTYPE=...;LC_MONETARY=...;LC_NUMERIC=...;LC_TIME=..."
If necessary, add ";LC_MESSAGES=..." at the end. */
{
- char *name1 = setlocale (LC_ALL, NULL);
- char *name2 = setlocale_single (LC_MESSAGES, NULL);
+ const char *name1 = setlocale (LC_ALL, NULL);
+ const char *name2 = setlocale_single (LC_MESSAGES, NULL);
if (streq (name1, name2))
/* Not a mixed locale. */
return name1;