setlocale_unixlike (int category, const char *locale)
{
int is_utf8 = (GetACP () == 65001);
- char *result;
- char llCC_buf[64];
- char ll_buf[64];
- char CC_buf[64];
/* The native Windows implementation of setlocale understands the special
locale name "C", but not "POSIX". Therefore map "POSIX" to "C". */
locale = "English_United States.65001";
/* First, try setlocale with the original argument unchanged. */
- result = setlocale (category, locale);
+ char *result = setlocale (category, locale);
if (result != NULL)
return result;
/* Otherwise, assume the argument is in the form
language[_territory][.codeset][@modifier]
and try to map it using the tables. */
+ char llCC_buf[64];
if (strlen (locale) < sizeof (llCC_buf))
{
/* Second try: Remove the codeset part. */
if (territory_end == NULL)
territory_end = territory_start + strlen (territory_start);
+ char ll_buf[64];
memcpy (ll_buf, llCC_buf, underscore - llCC_buf);
strcpy (ll_buf + (underscore - llCC_buf), territory_end);
+ char CC_buf[64];
memcpy (CC_buf, territory_start, territory_end - territory_start);
CC_buf[territory_end - territory_start] = '\0';
langcmp (const char *locale1, const char *locale2)
{
size_t locale1_len;
- size_t locale2_len;
- int cmp;
-
{
const char *locale1_end = strchr (locale1, '_');
if (locale1_end != NULL)
else
locale1_len = strlen (locale1);
}
+ size_t locale2_len;
{
const char *locale2_end = strchr (locale2, '_');
if (locale2_end != NULL)
locale2_len = strlen (locale2);
}
+ int cmp;
if (locale1_len < locale2_len)
{
cmp = memcmp (locale1, locale2, locale1_len);
LC_MONETARY,
LC_MESSAGES
};
- char *saved_locale;
- const char *base_name;
- unsigned int i;
/* Back up the old locale, in case one of the steps fails. */
- saved_locale = setlocale (LC_ALL, NULL);
+ char *saved_locale = setlocale (LC_ALL, NULL);
if (saved_locale == NULL)
return NULL;
saved_locale = strdup (saved_locale);
/* Set LC_CTYPE category. Set all other categories (except possibly
LC_MESSAGES) to the same value in the same call; this is likely to
save calls. */
- base_name =
+ const char *base_name =
gl_locale_name_environ (LC_CTYPE, category_to_name (LC_CTYPE));
if (base_name == NULL)
base_name = gl_locale_name_default ();
+ unsigned int i;
if (setlocale_unixlike (LC_ALL, base_name) != NULL)
{
/* LC_CTYPE category already set. */
for (; i < countof (categories); i++)
{
int cat = categories[i];
- const char *name;
-
- name = gl_locale_name_environ (cat, category_to_name (cat));
+ const char *name =
+ gl_locale_name_environ (cat, category_to_name (cat));
if (name == NULL)
name = gl_locale_name_default ();