perl5
perl5 copied to clipboard
Locale fallback cleanup
Cleanup some code in locale.c: Perl_init_i18nl10n
which sets/prints the fallback locale that was used.
Note: this does alter the output of the message slightly, if this is not wanted then that can easily be patched.
Old output:
$ LC_ALL= LANG=C LC_PAPER=aa_BB perl -e1
(...)
perl: warning: Falling back to the standard locale ("C").
New output:
$ LC_ALL= LANG=C LC_PAPER=aa_BB ./perl -e1
(...)
perl: warning: Falling back to a fallback locale (LANG) ("C").
I.e. the output now includes the ENV variable that contains the fallback locale (in the output above: LANG
)
(Suggestions for a better name for trial_locales_struct
are also welcome)
otherwise LGTM
I'm happy to merge this, but will wait if @bram-perl wants to wait for other feedback.
(My experience is that this such feedback is unlikely for this area of the code)
Some feedback on the change of the warning message is still welcome/needed.. That is: is the change acceptable? Or is it a bad idea and should the old message be preserved?
There are two changes in ouptut:
- example 1:
- old:
perl: warning: Falling back to the standard locale ("C").
- new:
perl: warning: Falling back to a fallback locale (LANG) ("C").
- old:
- example 2:
- old:
perl: warning: Falling back to a fallback locale ("en_US").
- new:
perl: warning: Falling back to a fallback locale (LANG) ("en_US").
- old:
Some feedback on the change of the warning message is still welcome/needed.. That is: is the change acceptable? Or is it a bad idea and should the old message be preserved?
There are two changes in ouptut:
* example 1: * old: `perl: warning: Falling back to the standard locale ("C").` * new: `perl: warning: Falling back to a fallback locale (LANG) ("C").` * example 2: * old: `perl: warning: Falling back to a fallback locale ("en_US").` * new: `perl: warning: Falling back to a fallback locale (LANG) ("en_US").`
The proposed new messages do seem awkward, as they contain redundant words. If you're "falling back" from some (presumably intended) locale to another locale, that second locale is a fallback locale by definition.
Based on past experience, changes in warnings or error messages should always be done cautiously, as people tend to write tests to detect them.
The proposed new messages do seem awkward, as they contain redundant words. If you're "falling back" from some (presumably intended) locale to another locale, that second locale is a fallback locale by definition.
That wording has been in place since 2014. Sure it can be changed but that would change the message even more.
Based on past experience, changes in warnings or error messages should always be done cautiously, as people tend to write tests to detect them.
This message is shown when perl is started, not when some code is executed. (it's also completely unrelated to use warnings;
, -w
, ...)
It is possible that people wrote tests for this but I think that is less likely.. (I could be wrong ofc)
To test it they would need to do something like:
my $foo = qx/perl -e1 2>&1/;
if ($foo =~ m/......./) {
....
}
I've updated the output so it behaves exactly the same as before; So there should be no visible change from these commits.
I'll push whenever you've decided there's been a long enough time for suggested names, and change the first commit's message to not have the XXX
Done