This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add -Accflags=-DLIBC_HANDLES_MISMATCHED_CTYPE
authorKarl Williamson <khw@cpan.org>
Sun, 3 Dec 2023 17:00:54 +0000 (10:00 -0700)
committerKarl Williamson <khw@cpan.org>
Wed, 13 Dec 2023 16:03:53 +0000 (09:03 -0700)
commit66e51f4311b414e65046505f0e708cd0be00a5d7
treee1e55d0bedf1a6505a09af407d2f9892fcfcb536
parentc97221f5af93a24091393dbdaa7c2191dc0eaffb
Add -Accflags=-DLIBC_HANDLES_MISMATCHED_CTYPE

Consider the name of a month in some language, Chinese for example.  If
LC_TIME has been set to a Chinese locale, strftime() can be used to
generate the Chinese month name for any given date, by using the
%B format.  But also suppose that LC_CTYPE is set to, say, "C".
The return from strftime() on many platforms will be mojibake given that
no Chinese month name is composed of just ASCII characters.  Perl
handles this for you by automatically toggling LC_CTYPE to whatever
LC_TIME is during the execution of strftime(), and afterwards restoring
it to its prior value.  But the strftime() (and similar functions) in
some libc implementations already do this toggle, meaning perl's action
is redundant.

This commit adds the ability for you to tell perl that a libc does this
(by setting this Configure option) and it will skip its syncing LC_CTYPE
and whatever the other locale is.

I propose to turn this on for all platforms as a smoke-me experiment,
and see which ones still yield proper results, and for those, add this
Configuration option to their hints files.

This commit doesn't change perl from syncing LC_CTYPE and LC_COLLATE
for operations related to collation.  It would require more work, and
I'd want to see the results of the experiment first.
locale.c