This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
3 months agonew perldelta blead
Graham Knop [Sun, 21 Jan 2024 18:15:17 +0000 (19:15 +0100)]
new perldelta

3 months agoAdd file existence test for Porting/makerel
Max Maischein [Sat, 20 Jan 2024 13:41:26 +0000 (14:41 +0100)]
Add file existence test for Porting/makerel

This came up in the release of 5.39.7. Previously autodie.pm had been
upgraded, which removed the file touch_me from the Perl distribution.
The name touch_me was still mentioned in Porting/makerel , but this
only became apparent when makerel was used to actually build a tarball.

This test crudely parses the list of filenames from Porting/makerel
and checks that all the files referenced there exist.

3 months agoClean up perldelta.pod
Max Maischein [Sat, 20 Jan 2024 13:19:24 +0000 (14:19 +0100)]
Clean up perldelta.pod

3 months agoUpdate Module::CoreList for 5.39.8
Max Maischein [Sat, 20 Jan 2024 13:14:52 +0000 (14:14 +0100)]
Update Module::CoreList for 5.39.8

3 months agoBump the Perl version in various places for 5.39.8
Max Maischein [Sat, 20 Jan 2024 13:05:38 +0000 (14:05 +0100)]
Bump the Perl version in various places for 5.39.8

3 months agoTick off release 5.39.7
Max Maischein [Sat, 20 Jan 2024 12:59:04 +0000 (13:59 +0100)]
Tick off release 5.39.7

3 months agoAdd 5.39.7 epigraph
Max Maischein [Sat, 20 Jan 2024 12:57:24 +0000 (13:57 +0100)]
Add 5.39.7 epigraph

3 months agoNote Windows installation issues
Max Maischein [Sat, 20 Jan 2024 12:04:47 +0000 (13:04 +0100)]
Note Windows installation issues

3 months agoautodie v2.37 removed the touch_me file
Max Maischein [Sat, 20 Jan 2024 11:04:43 +0000 (12:04 +0100)]
autodie v2.37 removed the touch_me file

3 months agoAdd new release to perlhist v5.39.7
Max Maischein [Sat, 20 Jan 2024 10:37:33 +0000 (11:37 +0100)]
Add new release to perlhist

3 months agoUpdate Perldelta for 5.39.7
Max Maischein [Sat, 20 Jan 2024 10:35:28 +0000 (11:35 +0100)]
Update Perldelta for 5.39.7

3 months agoUpdate Module::CoreList for 5.39.7
Max Maischein [Sat, 20 Jan 2024 10:12:04 +0000 (11:12 +0100)]
Update Module::CoreList for 5.39.7

3 months agoBump the perl version in various places for 5.39.7
Max Maischein [Sat, 20 Jan 2024 10:03:45 +0000 (11:03 +0100)]
Bump the perl version in various places for 5.39.7

3 months ago`README`: Bump copyright year
Elvin Aslanov [Sun, 14 Jan 2024 14:40:11 +0000 (15:40 +0100)]
`README`: Bump copyright year

It's 2024 now, so update ©️ to reflect that.

Update `perl.c` too because `copyright.t`
fails without it.

3 months agonostdio.h: Properly indent #nested lines
Karl Williamson [Thu, 18 Jan 2024 21:23:33 +0000 (14:23 -0700)]
nostdio.h: Properly indent #nested lines

3 months agoChange some USE_ITHREADS to USE_THREADS
Karl Williamson [Mon, 15 Jan 2024 15:59:15 +0000 (08:59 -0700)]
Change some USE_ITHREADS to USE_THREADS

These are where the underlying implementation should not matter.

3 months agoHandle Linux extra locale categories
Karl Williamson [Tue, 16 Jan 2024 20:12:53 +0000 (13:12 -0700)]
Handle Linux extra locale categories

Linux has six locale categories that aren't in the POSIX standard.  This
commit enables their use.  For example there is meta data about a
locale, and information about how telephone numbers are formatted for
it.

On non-Linux boxes, you can now request them as well, but you will get
stub values, as if the locale were C.

3 months agoAdd locale-related #macro for simplification
Karl Williamson [Mon, 15 Jan 2024 14:39:01 +0000 (07:39 -0700)]
Add locale-related #macro for simplification

This conditionally defines a macro in perl_langinfo.h that leads
currently to just a single simplification in the code, dealing with
platforms that don't have LC_MESSAGES, such as Windows.  But the next
commit will use it more extensively

3 months agolocale.c: Prepare for SV not always being PV
Karl Williamson [Mon, 15 Jan 2024 15:12:56 +0000 (08:12 -0700)]
locale.c: Prepare for SV not always being PV

Prior to two commits hence, these SVs always contained PVs.  But it will
change so sometimes they can be numbers.  The SvPVX shortcuts need to be
changed to SvPV_nolen instead.

3 months agonostdio.h: Fix comment
Karl Williamson [Thu, 18 Jan 2024 21:22:20 +0000 (14:22 -0700)]
nostdio.h: Fix comment

This #endif didn't end the conditional the comment said it did

3 months agoLanginfo: Improve pod about CRNCYSTR
Karl Williamson [Wed, 17 Jan 2024 00:48:58 +0000 (17:48 -0700)]
Langinfo: Improve pod about CRNCYSTR

This adds detail about the Standard-mandated character that is prefixed
to the returned currency string.

3 months agoAdd some locale tests to APItest
Karl Williamson [Tue, 16 Jan 2024 00:22:08 +0000 (17:22 -0700)]
Add some locale tests to APItest

3 months agolocale.c: Remove unnecessary Perl_form() call
Karl Williamson [Tue, 16 Jan 2024 03:45:22 +0000 (20:45 -0700)]
locale.c: Remove unnecessary Perl_form() call

There is nothing to format here; just a constant string.

3 months agoLanginfo.t; Add comment
Karl Williamson [Mon, 15 Jan 2024 14:16:48 +0000 (07:16 -0700)]
Langinfo.t; Add comment

3 months agolocale.c: Don't compile unreachable code
Karl Williamson [Tue, 16 Jan 2024 16:48:28 +0000 (09:48 -0700)]
locale.c: Don't compile unreachable code

The switch statement affected by this commit has numerous case:
statements within it.  Prior to this commit, if any of them was
required, all would be compiled.  But in many Configurations only a
portion of them are required.  Skip the others.

This takes advantage of the fact that an undefined preprocessor macro
evaluates to 0 (false) when used in an #if conditional.  In this
case, #foo_AVAIL is often undefined, so evaluates to false.
(Although locale_table.h could be changed to always define it to
'false', should it become necessary.)

3 months agolib/locale.t: Add more debug output
Karl Williamson [Tue, 16 Jan 2024 18:02:03 +0000 (11:02 -0700)]
lib/locale.t: Add more debug output

This file tries out every locale it can find on the system.  And, in
debug mode, outputs information about each locale, in addition to the
testing.

This commit adds at least one bit of information from every possible
information type.  So, for example, it displays the name of the first
month of the year (but not the rest of the months), the name of the
first day of the week (but not the rest), etc.

This enables someone to get a good idea what a locale is like.

3 months agolib/locale.t: Use a list for display item source
Karl Williamson [Tue, 16 Jan 2024 17:23:35 +0000 (10:23 -0700)]
lib/locale.t: Use a list for display item source

This file displays some items related to the current locale;
haphazardly.  This commit creates a list that is then used instead of
individual statements.  It then becomes easy to add items to display

3 months agolib/locale.t: Reorder a list
Karl Williamson [Tue, 16 Jan 2024 19:02:18 +0000 (12:02 -0700)]
lib/locale.t: Reorder a list

This is to make the next commits have fewer differences

3 months agowin32/GNUmakefile: enable warnings for gcc
Tony Cook [Mon, 15 Jan 2024 04:26:23 +0000 (15:26 +1100)]
win32/GNUmakefile: enable warnings for gcc

Warnings are already enabled for MSVC, so enable them for GCC too.

-Wformat is disabled since the default "__printf__" format checker
doesn't understand the C99-isms like "%zd", resulting in many spurious
warnings.  The __gnu_printf__ checker does understand them, but it
doesn't understand the Windows specific "%I64d" and similar formats.

3 months agoloc_tools: Generally return at least C locale
Karl Williamson [Mon, 15 Jan 2024 16:14:05 +0000 (09:14 -0700)]
loc_tools: Generally return at least C locale

If a category exists on the system, but we are supposed to keep it in
the C locale, it still is testable as C or POSIX.

Prior to this commit, it wasn't considered testable, and as a result
tests in our suite were wrongly skipped.

3 months agoPerl_amagic_call(): don't assume non-NULL PL_op
David Mitchell [Tue, 16 Jan 2024 09:44:14 +0000 (09:44 +0000)]
Perl_amagic_call(): don't assume non-NULL PL_op

This line in Perl_amagic_call():

    U8 gimme = (force_scalar || PL_op->op_type == OP_MULTICONCAT)

relies on either PL_op always being non-null, or for the times that
PL_op is null, that force_scalar always ends up being true.

As it happens, qr// with constant overloading calls Perl_amagic_call()
with a null PL_op, but also with method=string_amg, which happens to set
force_scalar.

Add a check for PL_op being non-null, partly to future-proof the code,
but mainly to shut up Coverity, which rightly pointed out that some new
code added by me with v5.39.6-107-g547324acdb *does* check for PL_op
being non-null earlier in the function, and if there's one thing
Coverity can't abide, it's inconsistency.

3 months agolocale.c: Use strtod over snprintf for radix determination
Karl Williamson [Sun, 26 Nov 2023 19:44:46 +0000 (12:44 -0700)]
locale.c: Use strtod over snprintf for radix determination

I have been a little leery of parsing a formatted number to look for the
radix character, which is what has been done with snprintf on MingW.  It
just seems brittle; it's possible (if unlikely) for the output to be
right-to-left, for example.

And then I saw cases where snprintf always used a dot on MingW; and the
Windows documentation makes no mention of the possibility of another
radix character.  Experimentation by Tony Cook showed that it could
output a comma instead; and the dots I was getting were probably cockpit
errors.

But almost all locales in the world use either a dot or a comma, and I
think it better to start with a string "1,5" or "1.5" and see which
strtod() parses correctly.  We then don't have to ourselves parse, but
see how strtod parses known strings by looking at what it calculates as
the value.  In a dot locale, for example, "1,5" will not yield anything
like 1.5.

Should we encounter a locale not using either a dot nor a comma, the
code drops down to call localeconv() to return the actual character
string.  On platforms where using localeconv() isn't known to have a
race (MSVC since VS2015, for example), the code previously always used
localeconv(), because of my leeriness about parsing an unknown string.

But now strtod is used, being less buggy and faster than localeconv; and
less brittle thant snprintf.

This change also avoids the malloc that the snprintf() version required.

3 months agolocale.c: Rmv extraneous statement
Karl Williamson [Mon, 15 Jan 2024 04:57:28 +0000 (21:57 -0700)]
locale.c: Rmv extraneous statement

Since 60e050beb2e45ebd7ead7f1bf93f845b23c474b5, this isn't necessary.

Spotted by Tony Cook

3 months agoReturn C values if localeconv() not available
Karl Williamson [Mon, 25 Dec 2023 18:50:17 +0000 (11:50 -0700)]
Return C values if localeconv() not available

localeconv() is a C89 function.  But the existing code handled the case
if it isn't available anyway by returning an empty hash if
POSIX::localeconv() is called.  Prior commits have made it actually
easier to instead return the hash populated with the values that the C
locale has, which is more desirable than the current state.  And that is
what this commit does.

There are reasons that localeconv() might not be available.  We recently
had a case where Configure didn't catch its existence.  And it still is
broken on MingW, and until recently on older Windows releases that we
now no longer support.  Workarounds were developed for those cases, but
there may be other platforms where it ends up broken without a
workaround, and this code handles them better and more simply than
before this commit.

3 months agoAdd API function sv_langinfo()
Karl Williamson [Mon, 15 Jan 2024 03:37:10 +0000 (20:37 -0700)]
Add API function sv_langinfo()

This performs the same task as Perl_langinfo8(), but returns an SV.
This is typically more convenient for the caller.

It turns out that nl_langinfo() has some weird returns that aren't yet
exposed by perl, but future commits will.  An SV makes these easier to
cope with.

3 months agoperlapi: Emphasize that setpv() doesn't change the UTF-8 flag
Karl Williamson [Thu, 11 Jan 2024 20:08:44 +0000 (13:08 -0700)]
perlapi: Emphasize that setpv() doesn't change the UTF-8 flag

I keep getting tripped up by this.

3 months agoConfigure: Handle case of no localeconv() found
Karl Williamson [Sat, 6 Jan 2024 22:20:02 +0000 (15:20 -0700)]
Configure: Handle case of no localeconv() found

If not found, there certainly won't be a subset of its returns

3 months agoLanginfo.pm: Change list init indents; sort order
Karl Williamson [Sat, 13 Jan 2024 21:34:30 +0000 (14:34 -0700)]
Langinfo.pm: Change list init indents; sort order

10 should come after 9

3 months agolocale.c: White space only
Karl Williamson [Sat, 13 Jan 2024 20:57:26 +0000 (13:57 -0700)]
locale.c: White space only

3 months agoUnmatched {} in C file generated by Configure issue#21730 m-hilgendorf
H.Merijn Brand [Mon, 15 Jan 2024 14:38:51 +0000 (15:38 +0100)]
Unmatched {} in C file generated by Configure issue#21730 m-hilgendorf

3 months agolocale.c: Skip an intermediate copy
Karl Williamson [Thu, 11 Jan 2024 01:17:23 +0000 (18:17 -0700)]
locale.c: Skip an intermediate copy

This commit takes advantage of the previous ones to pass the desired SV
directly to the langinfo() function, rather than getting a string and
then putting it into the SV

3 months agolocale.c: Avoid extra copying in langinfo
Karl Williamson [Wed, 10 Jan 2024 17:23:24 +0000 (10:23 -0700)]
locale.c: Avoid extra copying in langinfo

The functions that are the interface to libc nl_langinfo() have two
masters.  One is for internal use in the file to get a result that is to
be used and discarded immediately.  The other is to external callers who
may want to keep the result around for a while.

Historically this was done by having the functions both return a value,
and place it into a malloc'd buffer.

Sometimes the result is trivial, and needs to be copied to the buffer.
Other times, other functions are called that return a buffer themselves,
and for which the return value must be extracted from.  In other words,
sometimes it is more convenient to have a simple value; and sometimes it
is more convenient to have a buffer.

Previous commits have paved the way for this one, which knows which
vehicle the desired result should be returned in.

In S_emulate_langinfo(), the most convenient vehicle is used for the
calculation, and just before returning, if the caller wants that one, it
is done; but if the caller wants the other one, the result must be
coerced into that vehicle.

3 months agolocale.c: Change to use SVs for buffers for langinfo()
Karl Williamson [Thu, 11 Jan 2024 01:49:45 +0000 (18:49 -0700)]
locale.c: Change to use SVs for buffers for langinfo()

Prior to this commit, the code implementing the langinfo interface used
malloc'd buffers to store results in.

However, I discovered that perl has never implemented one langinfo item
properly, because its documentation is misleading.  And that item is not
a standard C string, but instead contains embedded NUL characters.

I started to implement an extension to the existing buffer interface to
handle that.  But then I realized it would need the equivalent of SvCUR
and SvLEN.

And then, I realized that the glibc extensions to nl_langinfo() return
values that are better interpreted as UVs than PVs.

To cope with all that, my implementation would be starting to smell like
perl's already-existing SV implementation.

So this commit changes to use SVs behind the scenes.

This presents some advantages here and in the next commit, due to the
maturity of the perl SV code.  The same SV can be reused for scratch
with potential for PV stealing, COW, fewer mallocs, etc.  The explicit
freeing of that SV can be delayed until global destruction.

3 months agolocale.c: Add langinfo_i()
Karl Williamson [Thu, 11 Jan 2024 01:45:31 +0000 (18:45 -0700)]
locale.c: Add langinfo_i()

This is just a small extension of langinfo_c(), allowing another place
in the code to use this interface.

3 months agolocale.c: Remove params from langinfo_c()
Karl Williamson [Tue, 9 Jan 2024 15:53:49 +0000 (08:53 -0700)]
locale.c: Remove params from langinfo_c()

The second parameter removed here is always NULL

The first parameter removed here is now always '&scratch_buffer', as
previous commits have changed the name to.

This commit now removes the ability to pass anything else to the
langinfo_c() macro.  This would normally be brittle, but a couple of
commits down the line will resolve that.

3 months agolocale.c: Use same function interface throughout file
Karl Williamson [Tue, 9 Jan 2024 15:30:12 +0000 (08:30 -0700)]
locale.c: Use same function interface throughout file

S_langinfo_sv_i() is passed a buffer to use, and also returns a value.
This commit changes all calls to it that don't stem from an external
caller to it to only look at the returned value, and to ignore the
buffer (which should have an identical value).  This is in preparation
for future commits which will avoid having a duplicated value.

3 months agolocale.c: Rename variable
Karl Williamson [Tue, 9 Jan 2024 15:38:11 +0000 (08:38 -0700)]
locale.c: Rename variable

This makes all calls to this function use variables with the same name
uniformly througout the file.  This is in preparation for the next
commits.

3 months agolocale.c: Rename static function
Karl Williamson [Tue, 9 Jan 2024 14:59:59 +0000 (07:59 -0700)]
locale.c: Rename static function

This is in preparation for a future commit which will change its
parameter types

3 months agolocale.c: Rename macro
Karl Williamson [Tue, 9 Jan 2024 14:38:00 +0000 (07:38 -0700)]
locale.c: Rename macro

I got tired of typing the prefix 'my_' and there is no good reason since
there is no symbol that differs only in that.

3 months agolocale.c: Use an SV instead of a PV in one place
Karl Williamson [Tue, 9 Jan 2024 03:07:41 +0000 (20:07 -0700)]
locale.c: Use an SV instead of a PV in one place

This was creating a temporary PV; the commit changes to use a mortal SV.
This is in preparation for a future commit where the SV can be passed in
by a caller, and there will be fewer wasted mallocs and frees.

3 months agolocale.c: Change name and API of static function
Karl Williamson [Mon, 8 Jan 2024 21:14:52 +0000 (14:14 -0700)]
locale.c: Change name and API of static function

This now is passed a pointer to the value that may need to be
overridden, and returns a bool (ignored for the time being) as to
whether it changed it or not.

This is in preparation for a future commit.

3 months agolocale.c: Add/clarify some comments
Karl Williamson [Mon, 18 Dec 2023 14:22:31 +0000 (07:22 -0700)]
locale.c: Add/clarify some comments

3 months agolocale.c: Move a small block of code
Karl Williamson [Tue, 9 Jan 2024 16:10:58 +0000 (09:10 -0700)]
locale.c: Move a small block of code

This moves this conditional and function call to when the locale is
still toggled.  Prior to this change, it is possible that we would have
to re-toggle within the function call.

The extra indentation will make sense in a future commit

3 months agolocale.c: Indent a couple statements
Karl Williamson [Tue, 9 Jan 2024 19:21:41 +0000 (12:21 -0700)]
locale.c: Indent a couple statements

This will allow them to vertically align with code added in a future
commit

3 months agolocale.c: Refactor use of Perl_form
Karl Williamson [Wed, 10 Jan 2024 16:24:47 +0000 (09:24 -0700)]
locale.c: Refactor use of Perl_form

This commit creates #define's for the format to use in that function
call.  This will make a future commit easier.

3 months agolocale.c: Move some langinfo emulation code
Karl Williamson [Wed, 10 Jan 2024 04:03:32 +0000 (21:03 -0700)]
locale.c: Move some langinfo emulation code

Some paths through this section of code don't require the result to be
saved to a buffer.  Move the code so to avoid that unnecessary work.

The result is indented an extra amount to prepare for a future commit.

3 months agoS_my_langinfo_i: Always return both a buffer and a value
Karl Williamson [Tue, 9 Jan 2024 14:12:08 +0000 (07:12 -0700)]
S_my_langinfo_i: Always return both a buffer and a value

This function returns a value, and also copies that value into a buffer.
Certain rare Configurations failed to fill in the buffer in some
circumstances.

This commit fixes bugs on those Configurations, and is the first step in
the next several commits in not doing unnecessary copies, which will
obsolete this commit.

3 months agot/re/charset: spell the locale when setlocale() fails
Дилян Палаузов [Sat, 13 Jan 2024 11:35:51 +0000 (12:35 +0100)]
t/re/charset: spell the locale when setlocale() fails

Closes https://github.com/Perl/perl5/issues/21805

3 months agodilyanpalauzov is now a Perl author
Karl Williamson [Sat, 13 Jan 2024 20:47:12 +0000 (13:47 -0700)]
dilyanpalauzov is now a Perl author

3 months ago[doc] Minor spelling issues in C file comments
rwp0 [Thu, 11 Jan 2024 01:08:32 +0000 (02:08 +0100)]
[doc] Minor spelling issues in C file comments

Correct duplicate words and convert links
to HTTPS where supported

3 months agoUpdate Exporter version number to 0.78
Max Maischein [Fri, 12 Jan 2024 09:22:14 +0000 (10:22 +0100)]
Update Exporter version number to 0.78

This was released to CPAN with changes from the blead Makefile.PL
( via 04528e741d17821b6c5e65bfb24935e912d182d3 )
under a new version number but the version number bump was not
done in bleadperl.

Found via

  ./perl Porting/core-cpan-diff -d Exporter

after editing the version number in Porting/Maintainers.pl to 5.78.

Applied via

  ./perl Porting/core-cpan-diff -d Exporter -r | patch -p0

3 months agoCorrect Locale::Maketext version number in Maintainers.pl to 1.33
Max Maischein [Fri, 12 Jan 2024 09:15:11 +0000 (10:15 +0100)]
Correct Locale::Maketext version number in Maintainers.pl to 1.33

... also update the Changes file to the 1.33 version. No other differences
found via

  ./perl Porting/core-cpan-diff -d Locale::Maketext

Diff applied via

    ./perl Porting/core-cpan-diff -d Locale::Maketext -r | patch -p0

3 months agoUpdate IO version number in Porting/Maintainers.pl
Max Maischein [Fri, 12 Jan 2024 09:08:09 +0000 (10:08 +0100)]
Update IO version number in Porting/Maintainers.pl

The code is 1.55 but the version number in Maintainers.pl was at 1.51

Checking that the stuff is identical was done with

./perl Porting/core-cpan-diff -d IO

3 months agocpan/Math-BigInt-FastCalc - Update to version 0.5018
Max Maischein [Thu, 11 Jan 2024 19:24:37 +0000 (20:24 +0100)]
cpan/Math-BigInt-FastCalc - Update to version 0.5018

0.5018 2024-01-06

 * Sync test files with Math-BigInt.

3 months agocpan/Math-BigInt - Update to version 2.003002
Max Maischein [Thu, 11 Jan 2024 19:23:34 +0000 (20:23 +0100)]
cpan/Math-BigInt - Update to version 2.003002

2.003002 2024-01-05

 * Improved interaction between Math::BigInt and the backend libraries.

 * Much faster versions of _ilog2() and _clog2() implemented in the
   Math::BigInt::Calc backend library. This should speed up bilog2() and
   bclog2() in Math::BigInt when "Calc" is used as the backend liberary.

3 months agocpan/Pod-Checker - Update to version 1.76
Max Maischein [Tue, 9 Jan 2024 19:34:44 +0000 (20:34 +0100)]
cpan/Pod-Checker - Update to version 1.76

 Version 1.76
 + CPAN#149267: "OK" message should go to STDOUT, not STDERR
 + CPAN#150660: podchecker -quiet does not print "OK" message

 21-May-2022           Marek Rouchal                        <marekr@cpan.org>

3 months agolocale.c: Change S_emulate_langinfo formal arg type
Karl Williamson [Wed, 10 Jan 2024 13:45:49 +0000 (06:45 -0700)]
locale.c: Change S_emulate_langinfo formal arg type

The type of this parameter changed recently from an enum to an int,
and embed.fnc was updated, but not the actual function definition.

No compilers except the OpenBSD one complained so far.

Fixes GH #21811

3 months agoRemove full stops from POD headings
Dagfinn Ilmari Mannsåker [Wed, 10 Jan 2024 17:58:58 +0000 (17:58 +0000)]
Remove full stops from POD headings

Headings are not sentences and should not have a trailing full stop
unless the last word is an abbreviation or as part of an ellipsis.

3 months agolocale.c Use macro to avoid conditionals
Karl Williamson [Wed, 6 Dec 2023 13:44:36 +0000 (06:44 -0700)]
locale.c Use macro to avoid conditionals

We know at compile time what these conditionals always evaluate to.  Use
a macro to replace the confitional with nothing when its always going to
be true.  (The section of code doesn't even get compiled when its going
to always be false.)

3 months agoFix blead not compiling with -DNO_LOCALE
Karl Williamson [Tue, 9 Jan 2024 19:10:17 +0000 (12:10 -0700)]
Fix blead not compiling with -DNO_LOCALE

This recently introduced failure was due to yet another problem with my
doing a 'rebase -i'.  embed.fnc nowadays gets re-sorted as part of the
build process, and I need to manually verify each time that the new
ordering didn't screw anything up.  Anyway, this function declaration
got placed in the wrong bucket of #ifdefs in embed.fnc.  This commit
fixes that.

3 months agoperldelta for 11c545feea
Tony Cook [Wed, 10 Jan 2024 22:41:19 +0000 (09:41 +1100)]
perldelta for 11c545feea

3 months agoXSUB.h: use Stack_off_t for AX and items
Tony Cook [Wed, 10 Jan 2024 00:48:27 +0000 (11:48 +1100)]
XSUB.h: use Stack_off_t for AX and items

I hadn't expected code to be taking pointers or references to AX,
which turned out to be wrong, so make them Stack_off_t.

This allows XS::Framework or similar code to build with a default
build of perl, but it will still fail to build if perl is built
with -DPERL_STACK_OFFSET_SSIZET, which can only be fixed by updating
XS::Framework to use Stack_off_t itself.

Fixes #21782

3 months agoperlapi: Rmv obsolete advice regarding Perl_langinfo
Karl Williamson [Sun, 31 Dec 2023 14:41:06 +0000 (07:41 -0700)]
perlapi: Rmv obsolete advice regarding Perl_langinfo

The header files have long been adjusted so that the programmer doesn't
have to concern themselves with this bookkeeping.

3 months agolocale.c: Use macros to avoid some #ifdef's
Karl Williamson [Sat, 30 Dec 2023 15:09:58 +0000 (08:09 -0700)]
locale.c: Use macros to avoid some #ifdef's

This #defines these macros once depending on the Configuration to be
either no-ops, or the appropriate expansion.  Then in the code just the
macros instead of #ifdef's.

3 months agoRenée and Max swapped their release dates/versions
Max Maischein [Tue, 9 Jan 2024 18:06:00 +0000 (19:06 +0100)]
Renée and Max swapped their release dates/versions

3 months ago[MERGE] handle/optimise some ops in void context
David Mitchell [Tue, 9 Jan 2024 13:10:10 +0000 (13:10 +0000)]
[MERGE] handle/optimise some ops in void context

This branch:

Fixes a couple of ops which weren't getting their context set correctly.
This doesn't make any change to the correct operation of those ops (they
don't change their behaviour based on context), but could allow for
future optimisations.

Skips a couple of portmanteau OP optimisations ({padv,elemfast}_store) in
non-void context. This allows those two be ops to be slightly faster in void
context (which is overwhelmingly how they are likely to be used(*)), and
falls back to the old separate padsv/sassign op pair otherwise.

Updates a few other ops to handle void context slightly more efficiently.

(*) Tony Cook profiled the test suite: 83.7% of calls to
pp_padsv_store()s were in void context and 99.9% of
aelemfastlex_store()s.

3 months agopp_push, pp_unshift: don't push TARG in void cxt
David Mitchell [Thu, 21 Dec 2023 19:22:45 +0000 (19:22 +0000)]
pp_push, pp_unshift: don't push TARG in void cxt

3 months agopp_undef(): optimise for void return
David Mitchell [Sat, 16 Dec 2023 18:53:41 +0000 (18:53 +0000)]
pp_undef(): optimise for void return

This function is typically called in void context; don't push a result
in void context which will will only be immediately popped again by the
following nextstate or unstack op. On PERL_RC_STACK builds, this
also avoids ++ing and --ing the return value's ref count.

In unknown context it just assumes non-void, rather than incurring the
cost of determining the caller's context.

3 months agopp_print() optimise for void return
David Mitchell [Sat, 16 Dec 2023 18:20:50 +0000 (18:20 +0000)]
pp_print() optimise for void return

This function is often called in void context; don't push a result
in void context which will will only be immediately popped again by the
following nextstate or unstack op. On PERL_RC_STACK builds, this
also avoids ++ing and --ing the return value's ref count.

In unknown context it just assumes non-void, rather than incurring the
cost of determining the caller's context.

3 months agopp_sassign: make return more efficient.
David Mitchell [Fri, 15 Dec 2023 23:32:08 +0000 (23:32 +0000)]
pp_sassign: make return more efficient.

Currently scalar assign effectively always pops the original two
arguments, then pushes the result.

This commit makes it so that

1) in void context (the most usual), it just pops 2 and skips pushing 1.

2) In scalar context, it still logically pops 2 and pushes 1, but since
the return value is also the original left arg, just shuffle that
argument around on the stack rather than messing around with its
reference count in the meantime. The right arg is still freed.

To make it so that *PL_stack_sp remains equal to left, a couple of
non-hot codepaths which break this rule now update the stack to keep
things consistent.

3 months agoOP_AELEMFASTLEX_STORE: only in void context
David Mitchell [Fri, 15 Dec 2023 22:21:12 +0000 (22:21 +0000)]
OP_AELEMFASTLEX_STORE: only in void context

For the optimisation which converts $lex[N] = expr into an
OP_AELEMFASTLEX_STORE op, only optimise if the scalar assign is in VOID
context.

(See the previous commit for a very similar change to OP_PADSV_STORE.)

This allows us to stop pp_aelemfastlex_store() from uselessly pushing the
result onto the stack, only to be immediately popped again by the
following nextstate or unstack op. This becomes more important on
PERL_RC_STACK builds, as each push or pop involves manipulating the SV's
reference count.

I'm working on the assumption that scalar/list/unknown cxt lexical
array element assigns are rare enough that not optimising them is less
of a loss than optimising the void case. So:

    $lex[0] = ....;             # void:    now even faster
    $other = $lex[0] = ...;     # scalar:  now slow again
    foo($lex[0] = ..., ....);   # list:    now slow again

    sub {
        ....
        $lex[0] = ...;          # unknown: now slow again
    }

3 months agoOP_PADSV_STORE: only in void context
David Mitchell [Fri, 15 Dec 2023 21:55:04 +0000 (21:55 +0000)]
OP_PADSV_STORE: only in void context

For the optimisation which converts $lex  = expr into an OP_PADSV_STORE
op, only optimise if the scalar assign is in VOID context.

This allows us to stop pp_padsv_store() from uselessly pushing the
result onto the stack, only to be immediately popped again by the
following nextstate or unstack op. This becomes more important on
PERL_RC_STACK builds, as each push or pop involves manipulating the SV's
reference count.

I'm working on the assumption that scalar/list/unknown cxt lexical
assigns are rare enough that not optimising them is less of a loss than
optimising the void case. So:

    $lex = ....;             # void:    now even faster
    $other = $lex = ...;     # scalar:  now slow again
    foo($lex = ..., ....);   # list:    now slow again

    sub {
        ....
        $lex = ...;          # unknown: now slow again
    }

3 months agoGive OPpTARGET_MY ops real context
David Mitchell [Mon, 18 Dec 2023 21:50:24 +0000 (21:50 +0000)]
Give OPpTARGET_MY ops real context

Perl has an optimisation whereby an op which returns the RHS of a scalar
assignment to a lexical, and which would normally store its result in
a PADTMP, instead skips the following PADSV and SASSIGN ops and assigns
to the lexical directly, instead of to the PADTMP. For example in

    $lex = $a + $b;

the ops (in execution-order) would be changed from

    add[t5] sK/2
    gvsv[*lex] s
    sassign vKS/2
    nextstate(main 2 -e:1) v:{

to

    add[$lex:1,2] sK/TARGMY,2
    nextstate(main 2 -e:1) v:{

However, note that although that the add op is now essentially called in
void context, it is still marked as being in scalar context. This commit
changes it to be be marked as void, i.e.

    add[$lex:1,2] vK/TARGMY,2

The main reason for this is to allow for future optimisations in
functions like pp_add(), which will be able to skip pushing the result
onto the stack in in void context. It just so happens that scalar
assignments to lexical vars are typically in void context.

However, since this is a visible change from the perspective of modules
which examine ops or optrees, I'll leave doing any optimisations until
later, in case this commit needs to be reverted.

The main things this commit had to fix up following the change were:
- still call overload methods in scalar context, even though the op is
  now marked as void;
- not issuing "useless use of add in void context" style warnings on
  such ops;
- making pp_push and pp_unshift still set TARG in void context

No matter whether the op's context is marked as scalar or as void, some
parts of perl will misunderstand, and will need to be special-cased
(since the op is really both, depending on your perspective). So this
commit changes the burden of the special-casing code to be in the
non-hot code paths, like during complication or when calling out to an
overload method.

3 months agoset context in 'state' expressions
David Mitchell [Sat, 16 Dec 2023 14:23:27 +0000 (14:23 +0000)]
set context in 'state' expressions

The ops associated with a state variable declaration and initial
assignment weren't getting their context (GIMME) assigned.

Background:

    state $x = ...;

gets compiled to something similar to

    if (first_time)
        $x = ...;
    else
        $x;

Except that the 'if' is performed by an OP_ONCE logop, which checks and
updates a flag in the pad, and branches to op_next or op_other as
appropriate.

During compilation, the context of the state expression wasn't being
passed on to the children of the OP_ONCE. So the assignment (optimised
into a padsv_store) and the padsv were left as UNKNOWN rather than VOID
or SCALAR as appropriate, as in these two examples:

    state $x = 1;         # should be void
    $y = (state $x = 1);  # should be scalar

This commit fixes that. Note that at the moment it makes no practical
difference, since the padsv/padsv_store ops  don't currently change
their behaviour based on context, but that might change.

3 months agoadd Concise tests for state var assignment
David Mitchell [Sat, 16 Dec 2023 13:51:09 +0000 (13:51 +0000)]
add Concise tests for state var assignment

Add tests for

    state $x = 1;
    my $y = state $x = 1;

to check what context is allocated to the various ops. At the moment it
is actually wrong in places, and this commit captures that wrongness.
The next commit will fix this, and those diffs to the tests added in this
commit will help make it clear what has changed.

3 months agolocale.c: Add clarifying comment
Karl Williamson [Thu, 28 Dec 2023 19:09:57 +0000 (12:09 -0700)]
locale.c: Add clarifying comment

3 months agolocale.c: Can now call my_langinfo_i() in all circumstances
Karl Williamson [Thu, 28 Dec 2023 19:50:04 +0000 (12:50 -0700)]
locale.c: Can now call my_langinfo_i() in all circumstances

Prior to this commit, the caller had to know if the category in question
was being ignored in this Configuration.  Now, that is transparent.

3 months agolocale.c: Extract code into a separate function
Karl Williamson [Thu, 28 Dec 2023 16:49:49 +0000 (09:49 -0700)]
locale.c: Extract code into a separate function

This new function does not have to be compiled in all Configurations,
and placing it separately removes some #ifdefs, and allows its absence
to be more transparent from its callers.

3 months agolocale.c: langinfo: Better handle unknown input item
Karl Williamson [Tue, 2 Jan 2024 00:41:37 +0000 (17:41 -0700)]
locale.c: langinfo: Better handle unknown input item

On systems with <langinfo.h>, the 'item' parameter here must be a member
of an enum.  If it isn't something we recognize, it's a real problem.

On other systems any int can be passed, and it could just be that the
caller got a wrong value.  For these, we don't know if it is a perl
error or a user error, so just set EINVAL and return failure

3 months agolocale.c: No strftime() implies empty formats
Karl Williamson [Thu, 28 Dec 2023 16:24:51 +0000 (09:24 -0700)]
locale.c: No strftime() implies empty formats

When returning an nl_langinfo() format when we are emulating
nl_langinfo() when there is no strftime() on the system, return an
empty format.  A non-empty return is useless.

3 months agolocale.c: Consolidate handling of remaining TIME items
Karl Williamson [Thu, 28 Dec 2023 16:23:57 +0000 (09:23 -0700)]
locale.c: Consolidate handling of remaining TIME items

Without nl_langinfo(), some Configurations handled these nl_langinfo()
items associated with the LC_TIME category in Perl_langinfo8(), and some
Configurations in emulate_langinfo().  This commit consolidates all the
handling to emulate_langinfo().

3 months agolocale.c: Remove redundant handling of the AM_PM format
Karl Williamson [Thu, 28 Dec 2023 16:16:59 +0000 (09:16 -0700)]
locale.c: Remove redundant handling of the AM_PM format

This format is identical whether or not LC_TIME is usable on this
platform or not.  Previously, it was actually handled in two functions,
emulate_langinfo() when LC_TIME is usable, and Perl_langinfo8() when
not.  Previous commits have enabled the format handling in
emulate_langinfo() to be returned instead of having separate cases,
depending on LC_TIME's availability.  That means the handling of this
format in Perl_langinfo8() is redundant and this commit removes it.

3 months agolocale.c: Consolidate handling of ERA format langinfo items
Karl Williamson [Thu, 28 Dec 2023 15:36:52 +0000 (08:36 -0700)]
locale.c: Consolidate handling of ERA format langinfo items

Without nl_langinfo(), some Configurations handled these nl_langinfo()
items associated with the LC_TIME category in Perl_langinfo8(), and some
Configurations in emulate_langinfo().  This commit consolidates all the
handling to emulate_langinfo().

3 months agolocale.c: Consolidate handling of ALT_DIGITS langinfo item
Karl Williamson [Thu, 28 Dec 2023 15:58:22 +0000 (08:58 -0700)]
locale.c: Consolidate handling of ALT_DIGITS langinfo item

Without nl_langinfo(), some Configurations handled this nl_langinfo()
item associated with the LC_TIME category in Perl_langinfo8(), and some
Configurations in emulate_langinfo().  This commit consolidates all the
handling to emulate_langinfo().

3 months agolocale.c: Move handling of ERA langinfo item
Karl Williamson [Thu, 28 Dec 2023 07:04:37 +0000 (00:04 -0700)]
locale.c: Move handling of ERA langinfo item

This commit moves the handling of the ERA langinfo item to
emulate_langinfo() away from Perl_langinfo8().

3 months agolocale.c: Consolidate handling of AM/PM langinfo items
Karl Williamson [Thu, 28 Dec 2023 06:20:06 +0000 (23:20 -0700)]
locale.c: Consolidate handling of AM/PM langinfo items

Without nl_langinfo(), some Configurations handled these nl_langinfo()
items associated with the LC_TIME category in Perl_langinfo8(), and some
Configurations in emulate_langinfo().  This commit consolidates all the
handling to emulate_langinfo().

3 months agolocale.c: Consolidate handling of MON langinfo items
Karl Williamson [Thu, 28 Dec 2023 06:13:41 +0000 (23:13 -0700)]
locale.c: Consolidate handling of MON langinfo items

Without nl_langinfo(), some Configurations handled these nl_langinfo()
items associated with the LC_TIME category in Perl_langinfo8(), and some
Configurations in emulate_langinfo().  This commit consolidates all the
handling to emulate_langinfo().

3 months agolocale.c: Consolidate handling of ABMON langinfo items
Karl Williamson [Thu, 28 Dec 2023 04:45:52 +0000 (21:45 -0700)]
locale.c: Consolidate handling of ABMON langinfo items

Without nl_langinfo(), some Configurations handled these nl_langinfo()
items associated with the LC_TIME category in Perl_langinfo8(), and some
Configurations in emulate_langinfo().  This commit consolidates all the
handling to emulate_langinfo().

3 months agolocale.c: Consolidate handling of DAY langinfo items
Karl Williamson [Thu, 28 Dec 2023 04:36:52 +0000 (21:36 -0700)]
locale.c: Consolidate handling of DAY langinfo items

Without nl_langinfo(), some Configurations handled these nl_langinfo()
items associated with the LC_TIME category in Perl_langinfo8(), and some
Configurations in emulate_langinfo().  This commit consolidates all the
handling to emulate_langinfo().

3 months agolocale.c: Consolidate handling of ABDAY langinfo items
Karl Williamson [Tue, 2 Jan 2024 01:53:20 +0000 (18:53 -0700)]
locale.c: Consolidate handling of ABDAY langinfo items

Without nl_langinfo(), some Configurations handled these nl_langinfo()
items associated with the LC_TIME category in Perl_langinfo8(), and some
Configurations in emulate_langinfo().  This commit consolidates all the
handling to emulate_langinfo().