Skip to content

Commit

Permalink
Revise warnings when locale init has issues
Browse files Browse the repository at this point in the history
Previously, we didn't know the possible locale categories on this
system, so grepped through the environment outputting anything that
begins with 'LC_'.  But now we do know all of them, and can just use
those.
  • Loading branch information
khwilliamson committed May 6, 2023
1 parent 3fc6bd0 commit acbbd1b
Showing 1 changed file with 8 additions and 31 deletions.
39 changes: 8 additions & 31 deletions locale.c
Expand Up @@ -6609,39 +6609,16 @@ S_output_check_environment_warning(pTHX_ const char * const language,
lc_all ? lc_all : "unset",
lc_all ? '"' : ')');

# if defined(USE_ENVIRON_ARRAY)

{
char **e;

/* Look through the environment for any variables of the
* form qr/ ^ LC_ [A-Z]+ = /x, except LC_ALL which was
* already handled above. These are assumed to be locale
* settings. Output them and their values. */
for (e = environ; *e; e++) {
const STRLEN prefix_len = sizeof("LC_") - 1;
STRLEN uppers_len;

if ( strBEGINs(*e, "LC_")
&& ! strBEGINs(*e, "LC_ALL=")
&& (uppers_len = strspn(*e + prefix_len,
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"))
&& ((*e)[prefix_len + uppers_len] == '='))
{
PerlIO_printf(Perl_error_log, "\t%.*s = \"%s\",\n",
(int) (prefix_len + uppers_len), *e,
*e + prefix_len + uppers_len + 1);
}
}
for (unsigned int i = 0; i < LC_ALL_INDEX_; i++) {
const char * value = PerlEnv_getenv(category_names[i]);
PerlIO_printf(Perl_error_log,
"\t%s = %c%s%c,\n",
category_names[i],
value ? '"' : '(',
value ? value : "unset",
value ? '"' : ')');
}

# else

PerlIO_printf(Perl_error_log,
"\t(possibly more locale environment variables)\n");

# endif

PerlIO_printf(Perl_error_log, "\tLANG = %c%s%c\n",
lang ? '"' : '(',
lang ? lang : "unset",
Expand Down

0 comments on commit acbbd1b

Please sign in to comment.