Permalink
Browse files

locale.c: Refactor Ultrix code

Examination shows that this code does nothing unless LC_ALL is defined.
So explicitly test at compile time for that.

Also, two variables don't have to be declared so globally, and by
reducing their scope, by creating a new block we don't have to have
PERL_UNUSED_ARG()s for them
  • Loading branch information...
khwilliamson committed Jan 2, 2018
1 parent 42888ca commit 924bb4f9d71eb2fa87d93e764768edab2b499df0
Showing with 8 additions and 10 deletions.
  1. +8 −10 locale.c
View
@@ -1891,16 +1891,13 @@ Perl_init_i18nl10n(pTHX_ int printwarn)
/* disallow with "" or "0" */
*bad_lang_use_once
&& strNE("0", bad_lang_use_once)))));
bool done = FALSE;
/* setlocale() return vals; not copied so must be looked at immediately */
const char * sl_result[NOMINAL_LC_ALL_INDEX + 1];
/* current locale for given category; should have been copied so aren't
* volatile */
const char * curlocales[NOMINAL_LC_ALL_INDEX + 1];
char * locale_param;
# ifdef WIN32
/* In some systems you can find out the system default locale
@@ -1982,20 +1979,19 @@ Perl_init_i18nl10n(pTHX_ int printwarn)
assert(NOMINAL_LC_ALL_INDEX == LC_ALL_INDEX);
# endif
# endif /* DEBUGGING */
# ifndef LOCALE_ENVIRON_REQUIRED
PERL_UNUSED_VAR(done);
PERL_UNUSED_VAR(locale_param);
# else
# ifdef LOCALE_ENVIRON_REQUIRED
/*
* Ultrix setlocale(..., "") fails if there are no environment
* variables from which to get a locale name.
*/
# ifdef LC_ALL
# ifndef LC_ALL
# error Ultrix without LC_ALL not implemented
# else
{
bool done = FALSE;
if (lang) {
sl_result[LC_ALL_INDEX] = do_setlocale_c(LC_ALL, setlocale_init);
DEBUG_LOCALE_INIT(LC_ALL, setlocale_init, sl_result[LC_ALL_INDEX]);
@@ -2005,6 +2001,7 @@ Perl_init_i18nl10n(pTHX_ int printwarn)
setlocale_failure = TRUE;
}
if (! setlocale_failure) {
const char * locale_param;
for (i = 0; i < LC_ALL_INDEX; i++) {
locale_param = (! done && (lang || PerlEnv_getenv(category_names[i])))
? setlocale_init
@@ -2016,6 +2013,7 @@ Perl_init_i18nl10n(pTHX_ int printwarn)
DEBUG_LOCALE_INIT(categories[i], locale_param, sl_result[i]);
}
}
}
# endif /* LC_ALL */
# endif /* LOCALE_ENVIRON_REQUIRED */

0 comments on commit 924bb4f

Please sign in to comment.