This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Don't raise 'poorly supported' locale warning unnecessarily
authorKarl Williamson <khw@cpan.org>
Thu, 18 Dec 2014 20:29:51 +0000 (13:29 -0700)
committerKarl Williamson <khw@cpan.org>
Mon, 29 Dec 2014 20:52:56 +0000 (13:52 -0700)
commit780fcc9fd03dbbd16715e2b6ecd020f9e50b7cc7
treee5f04281794fe574a278cbbe72d4718737c1c482
parenta4525e789871d3846f20d0ea7d2d239c6a21a5a4
Don't raise 'poorly supported' locale warning unnecessarily

Commit 8c6180a91de91a1194f427fc639694f43a903a78 added a warning message
for when Perl determines that the program's underlying locale just
switched into is poorly supported.  At the time it was thought that this
would be an extremely rare occurrence.  However, a bug in HP-UX -
B.11.00/64 causes this message to be raised for the "C" locale.  A
workaround was done that silenced those.  However, before it got fixed,
this message would occur gobs of times executing the test suite.  It was
raised even if the script is not locale-aware, so that the underlying
locale was completely irrelevant.  There is a good prospect that someone
using an older Asian locale as their default would get this message
inappropriately, even if they don't use locales, or switch to a
supported one before using them.

This commit causes the message to be raised only if it actually is
relevant.  When not in the scope of 'use locale', the message is stored,
not raised.  Upon the first locale-dependent operation within a bad
locale, the saved message is raised, and the storage cleared.  I was
able to do this without adding extra branching to the main-line
non-locale execution code.  This was done by adding regnodes which get
jumped to by switch statements, and refactoring some existing C tests so
they exclude non-locale right off the bat.

These changes would have been necessary for another locale warning that
I previously agreed to implement, and which is coming a few commits from
now.

I do not know of any way to add tests in the test suite for this.  It is
in fact rare for modern locales to have these issues.  The way I tested
this was to temporarily change the C code so that all locales are viewed
as defective, and manually note that the warnings came out where
expected, and only where expected.

I chose not to try to output this warning on any POSIX functions called.
I believe that all that are affected are deprecated or scheduled to be
deprecated anyway.  And POSIX is closer to the hardware of the machine.

For convenience, I also don't output the message for some zero-length
pattern matches.  If something is going to be matched, the message will
likely very soon be raised anyway.
embedvar.h
intrpvar.h
locale.c
perl.c
perl.h
pod/perldelta.pod
pod/perldiag.pod
pp.c
regexec.c
sv.c
utf8.c