develooper Front page | perl.perl5.changes | Postings from August 2022

[Perl/perl5] 72c16d: loc_tools: Create function, refactor

From:
Karl Williamson via perl5-changes
Date:
August 10, 2022 17:22
Subject:
[Perl/perl5] 72c16d: loc_tools: Create function, refactor
Message ID:
Perl/perl5/push/refs/heads/smoke-me/khw-locale4/8e565e-2d0e20@github.com
  Branch: refs/heads/smoke-me/khw-locale4
  Home:   https://github.com/Perl/perl5
  Commit: 72c16d3b9bb9a8652c46e9386cb64ae60d94378b
      https://github.com/Perl/perl5/commit/72c16d3b9bb9a8652c46e9386cb64ae60d94378b
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M t/loc_tools.pl

  Log Message:
  -----------
  loc_tools: Create function, refactor

category_excluded() is a better name for what the current name
'is_category_valid" does.  And it turns out that we need to use this
function on (those few) systems that don't have LC_CTYPE to avoid
executing code that depends on LC_CTYPE.

And we do need an improved is_category_valid() for other checks.


  Commit: 61896cbde456b6b22cf8491bbc58bb71a761da2f
      https://github.com/Perl/perl5/commit/61896cbde456b6b22cf8491bbc58bb71a761da2f
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M t/loc_tools.pl

  Log Message:
  -----------
  loc_tools.pl: Move code in file

This is for future commits to call after it is defined


  Commit: 2beaee1b8a9711e347046c46b43c5f91df063616
      https://github.com/Perl/perl5/commit/2beaee1b8a9711e347046c46b43c5f91df063616
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M t/loc_tools.pl

  Log Message:
  -----------
  t/loc_tools.pl: Print better failing test numbers

This test module is 'required' from other perl test files.  If it
encounters an error, it doesn't know how to report it.  What it does is
call fail() if available, and a home-grown one otherwise.  Prior to this
commit the home-grown version just made all tests number 0.  This commit
changes that to make them sequentially numbered from a very high
starting one, so as not to interfere with the outer calls.


  Commit: 9ff37908fe83f8016a783f3a600559822ce2d35a
      https://github.com/Perl/perl5/commit/9ff37908fe83f8016a783f3a600559822ce2d35a
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M t/loc_tools.pl

  Log Message:
  -----------
  t/loc_tools.pl: Refactor _trylocale()

This function is used to see if a locale actually works on the current
platform.  I was not fully aware of the glitches if a category is in one
locale, and LC_CTYPE is in another.  This makes sure they are both the
same; and this results in some simplification.


  Commit: 547c2c43c1aeb98cc80dc55eadd87b645900cf41
      https://github.com/Perl/perl5/commit/547c2c43c1aeb98cc80dc55eadd87b645900cf41
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M t/loc_tools.pl

  Log Message:
  -----------
  t/loc_tools.pl: Fail earlier

Move the code that returns failure into the loop, so won't keep
iterating if failure is going to happen anyway.


  Commit: bb921aa31788dfd0dbc3c19cea5e4ce8295d6bb5
      https://github.com/Perl/perl5/commit/bb921aa31788dfd0dbc3c19cea5e4ce8295d6bb5
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M t/loc_tools.pl

  Log Message:
  -----------
  t/loc_tools.pl: Add checks

This verifies that we can restore a locale that we were previously in,
and makes sure that we don't stay in a locale that doesn't work well.
Doing so has led to crashes.


  Commit: 4e85aea22a49b640080e685aabd1d8a2fc0cd6d6
      https://github.com/Perl/perl5/commit/4e85aea22a49b640080e685aabd1d8a2fc0cd6d6
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M t/loc_tools.pl

  Log Message:
  -----------
  t/loc_tools.pl: Don't allow commas in locale names

This was a problem in some buggy Windows versions.  This addition keeps
locales with this bug from being tested.


  Commit: 9da158cf26266ddc9fcdbd5c47c98260afb291aa
      https://github.com/Perl/perl5/commit/9da158cf26266ddc9fcdbd5c47c98260afb291aa
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M t/loc_tools.pl

  Log Message:
  -----------
  t/loc_tools.pl: Check for unsupported locales

This commit causes us not to view unsupported locales as legitimate for
testing.  Core dumps occurred on some platforms without this.

It looks for a diagnostic that the next commit in this series will
generate.


  Commit: 18e0d2a534d231259ed5a6f1f15bafaa72b10a12
      https://github.com/Perl/perl5/commit/18e0d2a534d231259ed5a6f1f15bafaa72b10a12
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M t/loc_tools.pl

  Log Message:
  -----------
  t/loc_tools.pl: White-space only


  Commit: 3105d23e598fc5fae4c4583cf0501423e2d065a4
      https://github.com/Perl/perl5/commit/3105d23e598fc5fae4c4583cf0501423e2d065a4
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M t/loc_tools.pl

  Log Message:
  -----------
  t/loc_tools.pl: Turn off warnings in a timely manner

It doesn't matter much, but some warnings might be output by doing the
'use locale' before turning off warnings.


  Commit: b97310cfefb7853af3ecad82433236f501f63bee
      https://github.com/Perl/perl5/commit/b97310cfefb7853af3ecad82433236f501f63bee
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M embed.fnc
    M embed.h
    M locale.c
    M proto.h

  Log Message:
  -----------
  locale.c: querylocale return mortalized copy

It is too easy to forget to savepv() the return of these macros, leading
to hard-to-diagnose bugs.  Head those off at the pass by always making a
copy that gets freed by the system.


  Commit: 5c0a95df218625640a724f14b663d0e130b79e26
      https://github.com/Perl/perl5/commit/5c0a95df218625640a724f14b663d0e130b79e26
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  Initialize PL_numeric_name, PL_collation_name

Having these initialized to the C locale aoids some otherwise required
conditionals.


  Commit: 10030a54aeea9eddd20f2df3d8bdd2a4c314fb5b
      https://github.com/Perl/perl5/commit/10030a54aeea9eddd20f2df3d8bdd2a4c314fb5b
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Silence some compiler warnings if no LC_ALL


  Commit: ec453182d037dbe0d186fe5f2953bd86480dcc6d
      https://github.com/Perl/perl5/commit/ec453182d037dbe0d186fe5f2953bd86480dcc6d
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Don't change locale if already there

Changing the locale is cheap for some categories, but expensive for
others.  Changing LC_COLLATE is most expensive, requiring recalculation
of the collation transformation mapping.

This commit checks that we aren't already in the desired locale before
changing locales. and does nothing if no change is needed.


  Commit: 584238acc542dc417960382c2a8ffced3d5b9b6b
      https://github.com/Perl/perl5/commit/584238acc542dc417960382c2a8ffced3d5b9b6b
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M embed.fnc
    M embed.h
    M locale.c
    M proto.h

  Log Message:
  -----------
  locale.c: Separate out two Win fcns from a larger one

This makes the larger one easier to understand, and prepares for
possible independent calls to the two, which are potentially useful on
their own.


  Commit: bef6ee45ce497974d5cd787f1d4cc983950799ad
      https://github.com/Perl/perl5/commit/bef6ee45ce497974d5cd787f1d4cc983950799ad
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M embed.fnc
    M embed.h
    M ext/POSIX/POSIX.xs
    M ext/POSIX/lib/POSIX.pm
    M locale.c
    M proto.h

  Log Message:
  -----------
  Move code from POSIX.xs to locale.c

This avoids duplicated logic.


  Commit: cb4bd6b5d7aca4e3624a947d734366c66c5ce9e9
      https://github.com/Perl/perl5/commit/cb4bd6b5d7aca4e3624a947d734366c66c5ce9e9
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Reorder cases in a switch

This moves handling the CODESET to the end, as future commits will make
its handling more complicated.  The cases are now ordered so the
simplest (based on the direction of future commits) are first


  Commit: caa2c371c0840e7a50fdaa45f2e2c0667bea5cc1
      https://github.com/Perl/perl5/commit/caa2c371c0840e7a50fdaa45f2e2c0667bea5cc1
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Make statics of repeated string constants

These strings are (or soon will be) used in multiple places; so have
just one definition for them.


  Commit: cf06fe5cb6fa5a8f86841d740bf0d09014925cbe
      https://github.com/Perl/perl5/commit/cf06fe5cb6fa5a8f86841d740bf0d09014925cbe
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Add two #defines

This makes sure that we handle having any variant of nl_langinfo() or
localeconv().


  Commit: 221f89bf612dc3812b4b6672ffbb37317b39d713
      https://github.com/Perl/perl5/commit/221f89bf612dc3812b4b6672ffbb37317b39d713
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M embed.fnc
    M embed.h
    M locale.c
    M proto.h

  Log Message:
  -----------
  locale.c: Return defaults for uncomputable langinfo items

Return the values from the C locale for nl_langinfo() items that aren't
computable on this platform.  If the platform has nl_langinfo(), then
all of them are computable, but if not, some can't be computed, and
others can be, but only if there are alternative methods available on
the platform.

As part of this commit, S_my_nl_langinfo() and S_save_to_buffer() are no
longer used when USE_LOCALE is not defined, so don't compile them.


  Commit: 941c1bd31bfaadac461748c7c4cb08207752487d
      https://github.com/Perl/perl5/commit/941c1bd31bfaadac461748c7c4cb08207752487d
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Rmv reimplementation of my_strftime()

Prior to this commit, there was a near duplicate copy of the code from
util.c that implements my_strftime().  This was done because the util.c
version zaps the wday field, which made it incompatible.

But it dawned on me that if the arbitrary date we use to do our
calculations were such that it was for a year in which the wday field
gets zapped to the value we want it to be, then the util.c version
automatically works.  This happens in years when January 1 falls on a
Sunday.


  Commit: eef6d69c476e6dfdc12c8564358ed27764ef038d
      https://github.com/Perl/perl5/commit/eef6d69c476e6dfdc12c8564358ed27764ef038d
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: White-space only

Align with previous commit and properly indent some preprocessor
directives


  Commit: a1c252825a3e24b346310a810202dfb74670c54d
      https://github.com/Perl/perl5/commit/a1c252825a3e24b346310a810202dfb74670c54d
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M embed.fnc
    M embed.h
    M locale.c
    M proto.h

  Log Message:
  -----------
  locale.c: Shorten static function name

The extra syllable(s) are unnecessary noise


  Commit: 2ed32732fabb3ddf2d77594ac348c26580caeb66
      https://github.com/Perl/perl5/commit/2ed32732fabb3ddf2d77594ac348c26580caeb66
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M embed.fnc
    M locale.c
    M proto.h

  Log Message:
  -----------
  locale.c: Extend a static function

This will allow it to be used in situations where the buffer it controls
is single use, and we don't need to keep track of the size for future
calls.


  Commit: c588ab30b872ee066687a1a1f7020dc706af50ad
      https://github.com/Perl/perl5/commit/c588ab30b872ee066687a1a1f7020dc706af50ad
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Use typedef to simplify

This allows some preprocessor conditionals to be removed


  Commit: 03af3e6b21fb508c919a79bf95fdbbc6425bd442
      https://github.com/Perl/perl5/commit/03af3e6b21fb508c919a79bf95fdbbc6425bd442
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Rmv redundant cBOOL()

strEQ and && already return booleans


  Commit: e30c62f3e78b15f3ae6670c4f51f84ebce4c0fa1
      https://github.com/Perl/perl5/commit/e30c62f3e78b15f3ae6670c4f51f84ebce4c0fa1
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Fix currency symbol derivation

On platforms without nl_langinfo(), we derive the currency symbol from
localeconv().  The symbol must be tweaked to conform to nl_langinfo()
standards.  Prior to this commit, it guessed at how to tweak a rare
circumstance.  I found evidence this guess was wrong, so looked around,
and copied the way cygwin does it.

This also no longer returns just an empty string in certain cases.
nl_langinfo() itself doesn't, so conform to that.


  Commit: fae7c3a328598da861deb3b3be7b6659e0689aa6
      https://github.com/Perl/perl5/commit/fae7c3a328598da861deb3b3be7b6659e0689aa6
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Don't add CP to Windows code page names

The actual name appears to be just the number for purposes of
nl_langinfo()-ish things.


  Commit: 2cbf6f3a682ede467b5589b9785533465130c17f
      https://github.com/Perl/perl5/commit/2cbf6f3a682ede467b5589b9785533465130c17f
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M embed.fnc
    M locale.c
    M proto.h

  Log Message:
  -----------
  locale.c: Don't ask a static fcn to be inlined

It's too complicated to really be inlined, and the compiler can figure
things out itself given it is a static function


  Commit: 14c05917b1e871ab626c3e6b27679f40729c1425
      https://github.com/Perl/perl5/commit/14c05917b1e871ab626c3e6b27679f40729c1425
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M embed.fnc
    M proto.h

  Log Message:
  -----------
  S_save_to_buffer() allow ignoring return value

Future commits will want to use this, while discarding the return value.


  Commit: 8b81e5089dc446573e9bafe5c118e79381f4c9c9
      https://github.com/Perl/perl5/commit/8b81e5089dc446573e9bafe5c118e79381f4c9c9
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M embed.fnc
    M locale.c
    M proto.h

  Log Message:
  -----------
  locale.c: Rmv no longer used param from static fnc

Previous commits have gotten rid of this parameter to S_save_to_buffer


  Commit: 47b414d571b8299fc102a6bf7243661a71f3d1d6
      https://github.com/Perl/perl5/commit/47b414d571b8299fc102a6bf7243661a71f3d1d6
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Don't read off buffer end

In some configurations, under the exact set of input it would have been
possible to read past the buffer end.  This commit adds a conditional to
prevent that.


  Commit: 23bfc6c4f25d4266b9a2808ac2212b3c28f1c257
      https://github.com/Perl/perl5/commit/23bfc6c4f25d4266b9a2808ac2212b3c28f1c257
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Fix Windows bug with broken localeconv()

localeconv() was broken on Windows until VS 2015.  As a workaround, this
was using my_snprintf() to find what the decimal point character is,
trying to avoid our workaround for localeconv(), which has a (slight)
chance of a race condition.

The problem is that my_snprintf() might not end up calling snprintf at
all; I didn't trace all possibilities in Windows.  So it doesn't make
for a reliable sentinel.

This commit now specifically uses libc snprintf(), and if it fails, drops
down to try localeconv().

It also changes things so that if localeconv() is not present at all or
usable on the platform, to use this snprintf method.


  Commit: 8928541deb728d4cb2685f5e86494274b3c5c10e
      https://github.com/Perl/perl5/commit/8928541deb728d4cb2685f5e86494274b3c5c10e
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Use a scratch buf; instead of reusing old

This is in preparation for the next commit


  Commit: 541e209aa5df2f8cdc2ec2028a4a6a70442e2ff1
      https://github.com/Perl/perl5/commit/541e209aa5df2f8cdc2ec2028a4a6a70442e2ff1
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M intrpvar.h
    M locale.c

  Log Message:
  -----------
  locale: make PL_langinfo_buf const *

The previous commit allows this change to be made.


  Commit: fb0f2da3b38d0ca1d02ac42b553f667d43b97086
      https://github.com/Perl/perl5/commit/fb0f2da3b38d0ca1d02ac42b553f667d43b97086
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M embed.fnc
    M embed.h
    M proto.h

  Log Message:
  -----------
  embed.fnc: Also check for NL_LANGINFO_L

The preprocessor directives were only flooking for plain nl_langinfo().
It's quite unlikely that a platform will have the '_l' version without
also having the plain one.  But this makes sure.


  Commit: 26e0e8ddba18e91c5c37870ae8b824ab3d6362f9
      https://github.com/Perl/perl5/commit/26e0e8ddba18e91c5c37870ae8b824ab3d6362f9
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M embed.fnc
    M embed.h
    M locale.c
    M proto.h

  Log Message:
  -----------
  locale.c: Make static fcn reentrant

This makes my_langinfo() reentrant by adding parameters specifying where
to store the result.

This prepares for future commits, and fixes some minor bugs for XS
writers, in that the claim was that the buffer in calling
Perl_langinfo() was safe from getting zapped until the next call to it
in the same thread.  It turns out there were cases where, because of
internal calls, the buffer did get zapped.


  Commit: c69e5c4a0ab240ba11a6a9c07ae5a68327323d25
      https://github.com/Perl/perl5/commit/c69e5c4a0ab240ba11a6a9c07ae5a68327323d25
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: langinfo: Use Windows fcn to find CODESET

There is a Windows function, available for quite a long time, that will
return the current code page.  Use this for the nl_langinfo() CODESET,
as that libc function isn't implemented on Windows.


  Commit: 898660ee09e911f412ce78dc2ddad976d1993209
      https://github.com/Perl/perl5/commit/898660ee09e911f412ce78dc2ddad976d1993209
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M embed.fnc
    M embed.h
    M locale.c
    M proto.h

  Log Message:
  -----------
  locale.c: Add static fcn to analyze locale name codeset

It determines if the name indicates it is UTF-8 or not.  There are
several variant spellings in use, and this hides that from the the
callers.

It won't be actually used until the next commit


  Commit: aca23c63988b77c40e8f63e3ff0a5fd71af5fd83
      https://github.com/Perl/perl5/commit/aca23c63988b77c40e8f63e3ff0a5fd71af5fd83
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M ext/I18N-Langinfo/Langinfo.pm
    M locale.c

  Log Message:
  -----------
  locale.c: Improve non-nl_langinfo() CODESET calc

Prior to this commit, on non-Windows platforms that don't have a
nl_langinfo() libc function, the code completely punted computation of
the CODESET item.  I have not been able to figure out how to do this,
even going to the locale definition files on disk (which may vary
anyway), but we can do a lot better than punting.

This commit adds three checks:

1) If the locale name is C or POSIX, we know the codeset

2) We can detect if a locale is UTF-8.  If it is, that is the codeset.
Many modern locales are of this ilk.

3) Failing that, some locales have the codeset appear in the name,
following a dot.

It isn't perfect, but it's a lot better than completely punting.


  Commit: 5f462ba6c30d38a5e97fcff3a0d04d96e19fd086
      https://github.com/Perl/perl5/commit/5f462ba6c30d38a5e97fcff3a0d04d96e19fd086
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M embed.fnc
    M locale.c
    M proto.h

  Log Message:
  -----------
  Add toggle_locale() fcns

These are designed to temporarily switch the locale for a cateogry
around some operation that needs it to be different than the current
one.  They will be used in the next commit.

These will eventually replace the more unwieldy
_is_cur_LC_category_utf8() function, which toggles as a side effect


  Commit: df368fe57ac00bcce13721e1975b2cfc9dcece43
      https://github.com/Perl/perl5/commit/df368fe57ac00bcce13721e1975b2cfc9dcece43
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M embed.fnc
    M embed.h
    M locale.c
    M proto.h

  Log Message:
  -----------
  New signature for static fcn my_langinfo()

This commit changes the calling sequence for my_langinfo to add the
desired locale, and the locale category of the desired item.

This allows the function to be able to return the desired value for any
locale, avoiding some locale changes that would happen until this
commit, and hiding the need for locale changes from outside functions,
though a couple continue to do so to avoid potential multiple changes.


  Commit: 8ba9b4d7a6c10730ab97cab31af5f946c762d5d4
      https://github.com/Perl/perl5/commit/8ba9b4d7a6c10730ab97cab31af5f946c762d5d4
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.: Need CTYPE to match other category for nl_langinfo

nl_langinfo knows about various components of locales that are supposed
to be defined for every locale, such as a string for a Yes/No response
or the name of a month in a particular language.  These are associated
with various locale categories.  In the examples cited, the month names
are in the LC_TIME category, and the responses in the LC_MESSAGES one.
But (perhaps because these are text strings), some platforms require the
LC_CTYPE locale to be the same as the other locale.  cygwin is an
example.  Rather than try to figure out which platform require this, and
which do not, it is a simple matter to just LC_CTYPE at the same time as
the other category


  Commit: a37702a0eea6e6386e8601897ec5ab8d683ee007
      https://github.com/Perl/perl5/commit/a37702a0eea6e6386e8601897ec5ab8d683ee007
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M embed.fnc
    M embed.h
    M locale.c
    M proto.h

  Log Message:
  -----------
  locale.c: Add is_locale_utf8()

Previous commits have added the infrastructure to be able to determine
if a locale is UTF-8.  This will prove useful, and this commit adds
a function to encapsulate this information, and uses it in a couple of
places, with more to come in future commits.

This uses as a final fallback, mbtowc(), supposed to be available in
C99.  Future commits will add heuristics when that function isn't
available or is known to be unreliable on a particular system.


  Commit: 5e5dbbd167bd564d2688dffc3a10452b31d4ffe4
      https://github.com/Perl/perl5/commit/5e5dbbd167bd564d2688dffc3a10452b31d4ffe4
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M embed.fnc
    M embed.h
    M locale.c
    M perl.h
    M proto.h
    M utf8.h

  Log Message:
  -----------
  locale.c: Add fcn for UTF8ness determination

get_locale_string_utf8ness_i() will determine if the string it is passed
in the locale it is passed is to be treated as UTF-8, or not.


  Commit: 78c052f5443909264cbf49a24fbfc1b259b1d18a
      https://github.com/Perl/perl5/commit/78c052f5443909264cbf49a24fbfc1b259b1d18a
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M embed.fnc
    M embed.h
    M ext/POSIX/POSIX.xs
    M locale.c
    M proto.h

  Log Message:
  -----------
  XXX perldelta Move POSIX::localeconv() logic to locale.c

The code currently in POSIX.xs is moved to locale.c, and reworked some
to fit in that scheme, and the logic for the workaround for the Windows
broken localeconv() is made more robust.

This is in preparation for the next commit which will use this logic
instead of (imperfectly) duplicating it.

This also creates Perl_localeconv() for direct XS calls of this
functionality.


  Commit: 4632e732f8053f1ea026b999d5f89e177fd1f9c3
      https://github.com/Perl/perl5/commit/4632e732f8053f1ea026b999d5f89e177fd1f9c3
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: localeconv() unconditional NUMERIC toggle

It is possible to lockout changing the LC_NUMERIC locale.  This is done
in some printf cases where a recursive call could get the radix
character wrong.  But localeconv(), which could be called during this
recursion on some platforms, toggles the locale briefly, without
affecting the surrounding calls; so it can do the toggle
unconditionally.

The previous commit merely moved the functionality of localeconv() from
POSIX.xs to locale.c.  This commit expands upon that.


  Commit: 78eb83b736d6453ceb062c8fa7c083e6f4e8cd08
      https://github.com/Perl/perl5/commit/78eb83b736d6453ceb062c8fa7c083e6f4e8cd08
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M embed.fnc
    M embed.h
    M locale.c
    M proto.h

  Log Message:
  -----------
  locale.c: Collapse duplicate logic into one instance

A previous commit move the logic for localeconv() into locale.c.  This
commit takes advantage of that to use it instead of repeating the logic.

Notably, this commit removes the inconsistent duplicate logic that had
been used to deal with the Windows broken localeconv() bug.


  Commit: b1ec0d10f5707c80565213bc1914526cc9ece418
      https://github.com/Perl/perl5/commit/b1ec0d10f5707c80565213bc1914526cc9ece418
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Add branch prediction, comments


  Commit: c23411d34f1bea4aa915353850ed5c81cd7dfc93
      https://github.com/Perl/perl5/commit/c23411d34f1bea4aa915353850ed5c81cd7dfc93
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M embed.fnc
    M embed.h
    M ext/POSIX/POSIX.xs
    M locale.c
    M proto.h

  Log Message:
  -----------
  XXXdelta Add my_strftime8()

This is like plain my_strftime(), but additionally returns an indication
of the UTF-8ness of the returned string


  Commit: fc10ac7c89f5549d1e16133af24846467d47c315
      https://github.com/Perl/perl5/commit/fc10ac7c89f5549d1e16133af24846467d47c315
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M embed.fnc
    M embed.h
    M locale.c
    M proto.h

  Log Message:
  -----------
  locale.c: Add utf8ness return param to static fcn

my_langinfo_i() now will additionally return the UTF-8ness of the
returned string.


  Commit: fdf50d1f6fe33e9b3058b38e914d8b6dfcb284b1
      https://github.com/Perl/perl5/commit/fdf50d1f6fe33e9b3058b38e914d8b6dfcb284b1
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M embed.fnc
    M ext/I18N-Langinfo/Langinfo.xs
    M locale.c
    M proto.h

  Log Message:
  -----------
  XXXdelta Add Perl_langinfo8()

This is like Perl_langinfo() but additionally returns information about
the UTF-8ness of the returned string.


  Commit: f36872166eee2f4c57aacf37e4997ccae73655d3
      https://github.com/Perl/perl5/commit/f36872166eee2f4c57aacf37e4997ccae73655d3
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M lib/locale.t

  Log Message:
  -----------
  lib/locale.t: Use I18N::Langinfo, not POSIX::localeconv()

Now that Langinfo is ported to every box, it requires less work than
localeconv(), and offers more choices.  This commit changes to use it,
and for more info when debugging, gets some additional info from it,
while avoiding some calls when not debugging


  Commit: e09854b5d7273b3f93d797a0c9488f66503ac17a
      https://github.com/Perl/perl5/commit/e09854b5d7273b3f93d797a0c9488f66503ac17a
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M lib/locale_threads.t

  Log Message:
  -----------
  locale_threads.t: Use I18N::Langinfo, not POSIX::localeconv()

The former is always present; the latter might not be


  Commit: 2ad141cbc70df5770e02a986b8f31a6f7e4938dc
      https://github.com/Perl/perl5/commit/2ad141cbc70df5770e02a986b8f31a6f7e4938dc
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Add fallbacks if no mbtowc()

This add heuristics that work well for non-English locales to determine
if a locale is UTF-8 or not when mbtowc() isn't available.  It would be
a very rare compiler that didn't have that these days, but this covers
that case as best as I have been able to figure out.


  Commit: 2d0e205decaec70e20acd6a7d724474f5fd6a178
      https://github.com/Perl/perl5/commit/2d0e205decaec70e20acd6a7d724474f5fd6a178
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-10 (Wed, 10 Aug 2022)

  Changed paths:
    M ext/I18N-Langinfo/t/Langinfo.t

  Log Message:
  -----------
  Revert "XXX Temporarily skip on Windows"

This should now be fixed by intervening commits


Compare: https://github.com/Perl/perl5/compare/8e565e96ee3e...2d0e205decae



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About