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

[Perl/perl5] 5a04f3: sv.c: Move some initialization inside #ifdef

From:
Karl Williamson via perl5-changes
Date:
August 10, 2022 00:06
Subject:
[Perl/perl5] 5a04f3: sv.c: Move some initialization inside #ifdef
Message ID:
Perl/perl5/push/refs/heads/blead/264fad-582368@github.com
  Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: 5a04f3b4c979ee336196947f81e2ee3414df0067
      https://github.com/Perl/perl5/commit/5a04f3b4c979ee336196947f81e2ee3414df0067
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-09 (Tue, 09 Aug 2022)

  Changed paths:
    M sv.c

  Log Message:
  -----------
  sv.c: Move some initialization inside #ifdef

If not using the feature, don't need to initialize it.


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

  Changed paths:
    M intrpvar.h

  Log Message:
  -----------
  intrpvar.h: Fix when certain locale symbols get defined

Certain interpreter variables are needed only in certain Configurations.
This commit removes some that aren't needed everywhere to be generated
only where they are needed, and generates some that weren't being used
that are or will be needed everywhere by follow-up commits.


  Commit: 7b5ca0e3b094ba6744a4213a3ab14de057fbfec6
      https://github.com/Perl/perl5/commit/7b5ca0e3b094ba6744a4213a3ab14de057fbfec6
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-09 (Tue, 09 Aug 2022)

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

  Log Message:
  -----------
  Temporarily skip on Windows

The next commits will expose an existing Windows bug which will get
fixed in a later set of commits


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

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

  Log Message:
  -----------
  Make two locale PL_ strings const char*

This adds some compile safety to these.


  Commit: 82e2ef274609fbe3e9e3a0c11bab9b6ef9b3d959
      https://github.com/Perl/perl5/commit/82e2ef274609fbe3e9e3a0c11bab9b6ef9b3d959
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-09 (Tue, 09 Aug 2022)

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

  Log Message:
  -----------
  Reorder some locale functions in embed.fnc

This allows the removal of some #ifdefs, and makes things easier to read


  Commit: 32899cfbfbeefbe5023d40fcf4ed4420752f9b20
      https://github.com/Perl/perl5/commit/32899cfbfbeefbe5023d40fcf4ed4420752f9b20
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-09 (Tue, 09 Aug 2022)

  Changed paths:
    M embed.fnc
    M embed.h
    M embedvar.h
    M intrpvar.h
    M locale.c
    M perl.c
    M proto.h
    M sv.c

  Log Message:
  -----------
  locale.c: Generalize stdize_locale()

This function is rewritten to handle LC_ALL, and to make it easier to
add new checks.

There is also a change, which I think is an improvement, in that everything
starting with a \n is trimmed, instead of just a trailing \n.

A couple of calls to stdize_locale() are removed, as they are redundant,
because they are called only as a result of Perl_setlocale() being
called, and that ends up calling stdize_locale always, early on.

The call to savepv() is also moved in a couple cases to after the result
is known to not be NULL

I originally had such a new check in mind, but it turned out that doing
it here didn't solve the problem, so this commit has been amended
(before ever being pushed) to not include that.
chomped.


  Commit: 50ffb02bd2b94a3e1ca31fc74825149050e13940
      https://github.com/Perl/perl5/commit/50ffb02bd2b94a3e1ca31fc74825149050e13940
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-09 (Tue, 09 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Refactor some derived #defines

The _c suffix is supposed to mean the category is known at compile time.
In some configurations this does not matter, and so I had named things
carelessly, so this might be confusing.  This commit fixes that.


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

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Use setlocale() for init, not P2008

We have found bugs in the POSIX 2008 libc implementations on various
platforms.  This code, which does the initialization of locale handling
has always been very conservative, expecting possible failures due to
bugs in it or the libc implementations, and backing out if necessary to
a crippled, but workable state, if something goes wrong.

I think we should use the oldest, most stable locale implementation in
these circumstances


  Commit: 57eeab0b3f388c00cfe0396591f603825b2a4707
      https://github.com/Perl/perl5/commit/57eeab0b3f388c00cfe0396591f603825b2a4707
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-09 (Tue, 09 Aug 2022)

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

  Log Message:
  -----------
  setlocale_failure_panic_i now used more generally

This function was #ifdef'd out of being defined to silence a compiler
warning in some configurations.  It's about to be used more generally,
so needs to be generally accessible


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

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

  Log Message:
  -----------
  locale.c: Split aggregate LC_ALL from emulate_setlocale

This splits into a separate function the code necessary in some
Configurations to calculate LC_ALL from a potentially disparate
aggregate of categories having different locales.

This is being done just for readability, as this extensive code in the
middle of something else distracts from the main point.

A goto is hence replaced by a recursive call.  This commit intends to do
the minimal changes involved in making this a function.  The next commit
will make some revisions.


  Commit: 0998f1fdef4e86ac499c438d50eeed02082bddff
      https://github.com/Perl/perl5/commit/0998f1fdef4e86ac499c438d50eeed02082bddff
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-09 (Tue, 09 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Avoid loop; panic on unexpected condition.

If we can't change to the locale to C, something is seriously wrong; no
sense trying to soldier on.

And, instead of a loop, set all the categories to C in a single call
(which actually doesn't expand to a loop)


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

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Comments; move declarations to use point

Now that we are using C99, we can move declarations so that it makes
more sense.


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

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

  Log Message:
  -----------
  locale.c: Change internal variable name

The new name better reflects its purpose, so is less confusing


  Commit: 74a90e54e037da4ed3d60a7fa673fe972a1aea69
      https://github.com/Perl/perl5/commit/74a90e54e037da4ed3d60a7fa673fe972a1aea69
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-09 (Tue, 09 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Clean up handling of a glibc bug

This commit moves all mention of this bug to just the code that requires
it, and inlines a macro, making it easier to comprehend


  Commit: 11d8dd19b41b7297a5fdb734e1abe796035ec7a9
      https://github.com/Perl/perl5/commit/11d8dd19b41b7297a5fdb734e1abe796035ec7a9
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-09 (Tue, 09 Aug 2022)

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

  Log Message:
  -----------
  locale.c: Split ancillary from S_emulate_setlocale

This takes the code to update LC_ALL, used only in some Configurations,
out of the main line, making the main line more readable.

It also allows the removal of temporary code added a few commits back


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

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: locale "" can be disparate

Setting a locale "" means to get the value from environment variables.
These can set locale categories to different locales, and this needs to
be handled.  The logic before this commit only handled the disparate
case when the locale wasn't ""; but this was compensated for elsewhere.
A future commit will remove that compensation.


  Commit: 9444acab0fa8be151c488e30e8956f53a3cbd981
      https://github.com/Perl/perl5/commit/9444acab0fa8be151c488e30e8956f53a3cbd981
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-09 (Tue, 09 Aug 2022)

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

  Log Message:
  -----------
  Split off setting locale to "" from S_emulate_setlocale

This is done for readability, to move the special casing of setting a
locale to the empty string (hence getting it from the environment) out
of the main line code.


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

  Changed paths:
    M sv.c

  Log Message:
  -----------
  sv.c: Duplicate more variables during cloning

These locale-related ones should be getting initialized in the new
thread, but be certain.


  Commit: 827a4a051afa67d6b91304bc64744af3072038aa
      https://github.com/Perl/perl5/commit/827a4a051afa67d6b91304bc64744af3072038aa
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-09 (Tue, 09 Aug 2022)

  Changed paths:
    M embed.fnc
    M embed.h
    M embedvar.h
    M intrpvar.h
    M locale.c
    M makedef.pl
    M perl.c
    M proto.h
    M sv.c

  Log Message:
  -----------
  locale.c: Add fcn to hide edge case undefined behavior

The POSIX 2008 API has an edge case in that the result of most of the
functions when called with a global (as opposed to a per-thread) locale
is undefined.

The duplocale() function is the exception which will create a per-thread
locale containing the values copied from the global one.

This commit just calls duplocale, if needed, and the caller need not
concern itself with this possibility


  Commit: 1a63cba7a2a638223fb5a5ffdf6718c59ec4b4c4
      https://github.com/Perl/perl5/commit/1a63cba7a2a638223fb5a5ffdf6718c59ec4b4c4
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-09 (Tue, 09 Aug 2022)

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

  Log Message:
  -----------
  locale.c: Add DEBUGGING information

These functions are called as expansions of macros.  It may be useful to
know where in the file the macro occurred.


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

  Changed paths:
    M locale.c

  Log Message:
  -----------
  Don't discard locale info in starting P2008

The program is started in the global locale, and then is converted to
the POSIX 2008 per-thread locale API.  This is accomplished by adding a
duplocale of the global locale.  Prior to this commit the startup
locale was discarded.  It really should be the foundation for the 2008
locales.

And, as a defensive measure, if a locale change fails that otherwise
would have started per-thread locales, we set up our stored information
(that may never have been initialized) to the global locale information


  Commit: 20ad7b235ac5e0dd0076a77c2d8c59f9b73110ad
      https://github.com/Perl/perl5/commit/20ad7b235ac5e0dd0076a77c2d8c59f9b73110ad
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-09 (Tue, 09 Aug 2022)

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

  Log Message:
  -----------
  Add a common locale panic macro and functions

This will make sure that all the necessary clean up gets done.


  Commit: 0494a7e2c2af12c9e359461b2c1d072f58e2f5bd
      https://github.com/Perl/perl5/commit/0494a7e2c2af12c9e359461b2c1d072f58e2f5bd
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-09 (Tue, 09 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Use DEBUG_(PRE|POST_)STMTS to save/restore errno

Instead of explicitly saving the errno around debugging statements, the
more general mechanism is used.


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

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Move DEBUG location info

This commit takes advantage of the mechanism to add common DEBUGGING
code to print the __FILE__ and __LINE__ of every debugging statement.
This allows those to be removed from each statement, and have them
implicitly added.

This make things consistent, and easier to read and add new statements.


  Commit: 6fad488018a8b96f412ac0e987d34f524cf0bc15
      https://github.com/Perl/perl5/commit/6fad488018a8b96f412ac0e987d34f524cf0bc15
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-09 (Tue, 09 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Change outlier call to use macro

This is the only occurrence of this in the program.  Change to match
everywhere else, so that people don't wonder if something special might
be going on.


  Commit: 0d17a9c874054353494839eb7d7c55d1acc0e7f4
      https://github.com/Perl/perl5/commit/0d17a9c874054353494839eb7d7c55d1acc0e7f4
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-09 (Tue, 09 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: newlocale() can't handle disparate locales

This is a follow on commit to d92b203c3251254039d9cb3b314646b5e894c21c.
querylocale() isn't required by Standards to handle LC_ALL, and it often
doesn't when the underlying locales aren't all set to the same thing.
That commit fixed that.

Overlooked by that commit was that newlocale() also doesn't necessarily
handle LC_ALL input of disparate locales.  This commit changes to use the
same mechanism to deal with this situation that is already in place for
non-querylocale() systems


  Commit: 66a28734f9b468c01710ae9c15b1a7bbfef04ee0
      https://github.com/Perl/perl5/commit/66a28734f9b468c01710ae9c15b1a7bbfef04ee0
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-09 (Tue, 09 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Mv declarations closer to use in function

This clarifies the underlying object.  This commit also adds one bit of
information to a debugging statement

This changes also to print the entry locale under DEBUGGING upon entry
to the top of the function


  Commit: 19e550d7feff0e915e0f181add94aebe4e22c38b
      https://github.com/Perl/perl5/commit/19e550d7feff0e915e0f181add94aebe4e22c38b
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-09 (Tue, 09 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Don't waste time executing a no-op

If we're trying to change the locale to what it already is, that's a
no-op.  This skips that work.  As noted in the comments, this also led
to subtle bugs with newlocale() trying to free the basis operand, and
giving bad results.


  Commit: 947b444cf66f17cb2c1db85542cf34afe4311a81
      https://github.com/Perl/perl5/commit/947b444cf66f17cb2c1db85542cf34afe4311a81
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-09 (Tue, 09 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: panic if shouldn't-happen events do

If any of these cases occur, something is so wrong with the system that
we shouldn't continue.


  Commit: 43c2ca2c447c15e8e75118bee581d6d97a37f5af
      https://github.com/Perl/perl5/commit/43c2ca2c447c15e8e75118bee581d6d97a37f5af
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-09 (Tue, 09 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Make sure newlocale() doesn't destroy arg

newlocale() takes as one of its arguments, a starting locale.  It can
free that argument's space it if chooses.  I think the instances of this
happening have been already been fixed, but this commit makes it clear
that it won't destroy the wrong things.


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

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Rmv unnecessary variable

Changes in this function mean this value has already been calculated
and saved under a different name.


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

  Changed paths:
    M locale.c
    M perl.h

  Log Message:
  -----------
  Swap the ordering of two locale category indices

Perl internally uses a mapping of locale category values into a
consecutive sequence of indices starting at 0.  These are used as
indexes into arrays.  The reason is that the category numbers are
opaque, vary by platform, aren't necessarily sequential, and hence are
hard to make table driven code for.

This commit makes the LC_CTYPE index 0, and LC_NUMERIC equal to 1;
swapping them.  The reason is to cause LC_CTYPE to get done first in the
many loops through the categories.  The UTF8ness of categories is an
often needed value, and most of the time the categories will have the
same locale.  LC_CTYPE is needed to calculate the UTF8ness, then by doing
it first and caching the result, the other categories likely
automatically will use the same value, without having to recalculate.


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

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Change assert() into STATIC_ASSERT()


  Commit: 3b30ed2b88690ee598bd63c0062488a50037ab39
      https://github.com/Perl/perl5/commit/3b30ed2b88690ee598bd63c0062488a50037ab39
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-09 (Tue, 09 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Add check that strxfrm didn't fail

The code failed to take into account that strxfrm() can fail for reasons
besides buffer length.  It does not return errors, and the only way to
check is to set errno to 0 beforehand, and check that it is still 0
afterwards.


  Commit: 58236863a5f7af6b81dab8284edf709c4cbc9e54
      https://github.com/Perl/perl5/commit/58236863a5f7af6b81dab8284edf709c4cbc9e54
  Author: Karl Williamson <khw@cpan.org>
  Date:   2022-08-09 (Tue, 09 Aug 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Print code point in hex, not decimal

Hex is the more familiar form


Compare: https://github.com/Perl/perl5/compare/264fadfa2d42...58236863a5f7



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