This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
17 months agoRespect j8 in HARNESS_OPTIONS
Max Maischein [Sun, 25 Dec 2022 09:49:16 +0000 (10:49 +0100)]
Respect j8 in HARNESS_OPTIONS

4aef61a2fe7a73e9a5551a86cfbaac576e8757c5 broke setting the number
of jobs via the environment variable HARNESS_OPTIONS. This patch
allows re-enables setting the number of jobs via HARNESS_OPTIONS again.

17 months agoloc_tools.pl: Always do normalized locale name check
Karl Williamson [Fri, 25 Nov 2022 22:16:23 +0000 (15:16 -0700)]
loc_tools.pl: Always do normalized locale name check

Because of variances in capitalization and use of dashes, we should only
compare locale names that have been normalized to a common syntax.  This
was the remaining outlier, and caused issues on some platforms.

17 months agoHvNAMEf_QUOTEDPREFIX implies \"%s\"
Paul "LeoNerd" Evans [Sat, 24 Dec 2022 13:28:09 +0000 (13:28 +0000)]
HvNAMEf_QUOTEDPREFIX implies \"%s\"

17 months agoAdd HvNAMEfARG() macro
Paul "LeoNerd" Evans [Sat, 24 Dec 2022 13:13:04 +0000 (13:13 +0000)]
Add HvNAMEfARG() macro

17 months agoregen/regcomp.pl - use regen/HeaderParser to read regnodes.h and etc.
Yves Orton [Fri, 16 Dec 2022 17:34:31 +0000 (18:34 +0100)]
regen/regcomp.pl - use regen/HeaderParser to read regnodes.h and etc.

regen/regcomp.pl reads several header files, using HeaderParser will
harden against line continuations or multiline comments.  The current
code is actually somewhat fragile, and minor changes to the header files
it reads will break it. With this patch such changes would be dealt
with by HeaderParser, which should already do the right thing.

17 months agoregen/feature.pl - use regen/HeaderParser to parse perl.h
Yves Orton [Fri, 16 Dec 2022 17:34:16 +0000 (18:34 +0100)]
regen/feature.pl - use regen/HeaderParser to parse perl.h

Using HeaderParser hardens the code against possible future changes
and ensures if there are any parse bugs they get fixed for all our
regen code.

17 months agoembed.h - make regen after recent changes
Yves Orton [Sat, 17 Dec 2022 15:39:54 +0000 (16:39 +0100)]
embed.h - make regen after recent changes

Note this also tidies embed.fnc as well.

17 months agoregen/embed.pl - switch to using HeaderParser for code generation and etc.
Yves Orton [Fri, 16 Dec 2022 17:31:17 +0000 (18:31 +0100)]
regen/embed.pl - switch to using HeaderParser for code generation and etc.

HeaderParser was designed to replace the old grouping code in embed.pl and
regen/embed_lib.pl, which is used to generate embed.h and proto.h and
embedvar.h

It can handle "elif" in embed.fnc, and produces more consistently structured
and formatted and readable output than the old code. It also has much better
logic to dedupe expressions. Adding or changing a constraint in embed.fnc
should no longer have any "action at a distance" effects on the output for
other functions which were not changed or obviously affected by the change.
The old code assumed that sorting the constraints applying to a given function
definition was acceptable, with the result that "elif" was impossible to
support properly, and creating the problem that adding a new constraint which
sorted into a different position could change a large amount of the
output, making it hard to verify that the change was correct.

The new logic should, once the initial normalization is applied, ensure that any
further changes are minimal.

This patch also includes a new tool regen/normalize_embed.pl which will be run
by make regen, which consistently formats embed.fnc itself, which should make
maintaining the file easier, especially during code splits and reorgs.
Function definitions can be lifted out, moved to the end, with new
constraints, and the `make regen` will put it all back into the correct place
and order.

A number of tools and tests which use embed_lib.pl to load embed.fnc data have
necessarily been changed to use the new HeaderParser based logic.

17 months agoregen/HeaderParser.pm - A module to parse our header files
Yves Orton [Fri, 2 Dec 2022 23:12:07 +0000 (00:12 +0100)]
regen/HeaderParser.pm - A module to parse our header files

Consistent proper header file parsing with an OO interface.

There are various traps and zaps parsing header files, such as line
continuations, and multiline comments acting as a line continuation.
There are also issues that the naive may overlook such as indented
preprocessor directives, and such things.

There are also some specialized tasks which we perform to construct
header files from other header files, such as grouping content under
similar guard clauses together, normalizing guard clauses, and the like.

HeaderParser provides an API to handle these issues. The code which
needs to read header files, or write header files, can use the
HeaderParser to group and normalize the content they are reading or
writing. This also frees the code generators from needing to worry about
indentation, or such artifacts, HeaderParser normalizes it all away.

This patch includes migrating everything to use the new infra, but it
does not include some of the changes that would come with that new
infra, so it would not pass test on THIS commit. Running make regen
should "fix" this, although it is deliberate to make rebasing the
branch easier.

One of the notable changes in this commit is that embed.fnc is now under
control of `make regen` (even though it is an input to `make regen`) and
any changes will be automatically tied by running it, even if those changes
also trigger other changes. HeaderParser sits underneath it all, so there
is no chicken and egg problem that would require running `make regen`
twice, the output of processing the modified embed.fnc would be identical
to the output of processing the original.

fixup

17 months agoembed.fnc - documentation improvements
Yves Orton [Sun, 13 Nov 2022 11:26:23 +0000 (12:26 +0100)]
embed.fnc - documentation improvements

- improve comment about exporting symbols. The explanation was a
  bit scanty and out of date. This expands and updates it to
  modern practice.

- ensure that docs for flags are all single quoted, thus they can
  be easily found with a search in the file.

17 months agomro_core.c - define PERL_IN_MRO_CORE_C as well
Yves Orton [Tue, 15 Nov 2022 20:30:47 +0000 (21:30 +0100)]
mro_core.c - define PERL_IN_MRO_CORE_C as well

Each core file defines a symbol which represents that its in that file.
Sometime where we split or move code around this ends up with a file
claiming to be another file. This is fine, but it should also define
its own file specific define.

Currently this isn't used. But if we ever want to restrict functions
in this file to just this file (eg a static function) we will need this
define.

17 months agoRevert "harness: handle serial/parallel directories mixture"
Yves Orton [Fri, 23 Dec 2022 14:40:45 +0000 (15:40 +0100)]
Revert "harness: handle serial/parallel directories mixture"

This reverts commit 675dd65a692bc6b2423c11af8f0bfbc1c169b603.

17 months agosv.c - add support for HvNAMEf and HvNAMEf_QUOTEDPREFIX formats
Yves Orton [Sun, 18 Dec 2022 17:42:34 +0000 (18:42 +0100)]
sv.c - add support for HvNAMEf and HvNAMEf_QUOTEDPREFIX formats

They are similar to SVf and SVf_QUOTEDPREFIX but take an HV * argument
and use HvNAME() and related macros to extract the string. This is
helpful as it makes constructing error messages from a stash (HV *)
easier. It is the callers responsibility to ensure that the HV is
actually a stash.

17 months agoRevert "Inline strlcat(), strlcpy()"
Yves Orton [Thu, 22 Dec 2022 11:50:46 +0000 (12:50 +0100)]
Revert "Inline strlcat(), strlcpy()"

This reverts commit 5be23dd97e360d19c8abb4c0c534f5d5f9d3691a.

The original patch seems to break DBM.

17 months agoloc_tools.pl: Accept dashless UTF8 besides to 'UTF-8'
Karl Williamson [Fri, 25 Nov 2022 22:14:31 +0000 (15:14 -0700)]
loc_tools.pl: Accept dashless UTF8 besides to 'UTF-8'

The dash is sometimes omitted

17 months agoInline strlcat(), strlcpy()
Karl Williamson [Mon, 19 Dec 2022 14:01:24 +0000 (07:01 -0700)]
Inline strlcat(), strlcpy()

These short functions are reasonably frequently used.

17 months agoInline savepv() and related functions
Karl Williamson [Mon, 19 Dec 2022 13:37:56 +0000 (06:37 -0700)]
Inline savepv() and related functions

These short functions are moved from util.c to inline.h.
savesharedpv() and savesharedpvn() aren't moved because there is a
complication of needing also to move croak_no_mem(), which could be
done, but are these called enough to justify it?

17 months agoharness: handle serial/parallel directories mixture
Karl Williamson [Mon, 19 Dec 2022 17:56:19 +0000 (10:56 -0700)]
harness: handle serial/parallel directories mixture

A few test file directories have some test files that must be executed
serially, while others may be in parallel.  Prior to this commit, all
such were executed serially.

This commit changes to look for and handle such directories.  It makes
the safe assumption that the serial files act as setup for the parallel
ones, so all such must be done first

Here are two cases where this helps.

IO::Compress has a large number of serial test files, then a few that
can be executed in parallel.  It often is the last directory to finish.
And the suite isn't over until each file in it is finished.  Those last
few, prior to this commit, executed one after another, when the other
cores were idle.  Now they can execute in parallel.

Test::Simple has many tests, but just a few that need to execute
serially.  Prior to this commit, they all had to execute serially.

17 months agoharness: Initialize parallel job count to 1 if unspecified
Karl Williamson [Mon, 19 Dec 2022 17:50:45 +0000 (10:50 -0700)]
harness: Initialize parallel job count to 1 if unspecified

This will make a later commit easier

17 months agogv.c - rename amagic_find() to amagic_applies()
Yves Orton [Wed, 21 Dec 2022 12:15:25 +0000 (13:15 +0100)]
gv.c - rename amagic_find() to amagic_applies()

The api for amagic_find() didnt make as much as sense as we thought
at first. Most people will be using this as a predicate, and don't
care about the returned CV, so to simplify things until we can really
think this through the required API this switches it to return
a bool and renames it to amagic_applies(), as in "which amagic_applies
to this sv".

17 months agoBump Module-CoreList version
Chris 'BinGOs' Williams [Wed, 21 Dec 2022 10:41:14 +0000 (10:41 +0000)]
Bump Module-CoreList version

17 months agoPrepare Module::Corelist for 5.37.8
Richard Leach [Wed, 21 Dec 2022 10:34:31 +0000 (10:34 +0000)]
Prepare Module::Corelist for 5.37.8

17 months agoShortest day or longest night?
Chris 'BinGOs' Williams [Wed, 21 Dec 2022 10:10:13 +0000 (10:10 +0000)]
Shortest day or longest night?

17 months agoirc-notifications: use literal blocks
Nicolas R [Tue, 20 Dec 2022 23:44:38 +0000 (16:44 -0700)]
irc-notifications: use literal blocks

17 months agoirc-notifications: advertise merged and closed PRs
Nicolas R [Tue, 20 Dec 2022 23:08:46 +0000 (16:08 -0700)]
irc-notifications: advertise merged and closed PRs

Split merged and closed PR notifications

17 months agoirc-notifications: split notifications
Nicolas R [Tue, 20 Dec 2022 22:51:24 +0000 (15:51 -0700)]
irc-notifications: split notifications

Split notifications between the two channels

Advertise opened and closed Pull Requests to #p5p
and use #p5p-commits for any extra notifications
so we reduce noise to #p5p to its minimum.

Remove body from opened PR and only use title.

17 months agoirc-notifications: update notify-irc
Nicolas R [Tue, 20 Dec 2022 22:41:33 +0000 (15:41 -0700)]
irc-notifications: update notify-irc

Update notify-irc action to v2

17 months agoBump the perl version in various places for 5.37.8
Richard Leach [Tue, 20 Dec 2022 18:21:24 +0000 (18:21 +0000)]
Bump the perl version in various places for 5.37.8

17 months agoNew perldelta for 5.37.8
Richard Leach [Tue, 20 Dec 2022 17:46:31 +0000 (17:46 +0000)]
New perldelta for 5.37.8

17 months agoUpdate release_schedule.pod for 5.37.7
Richard Leach [Tue, 20 Dec 2022 17:35:58 +0000 (17:35 +0000)]
Update release_schedule.pod for 5.37.7

17 months agoUpdate epigraphs.pod for 5.37.7
Richard Leach [Tue, 20 Dec 2022 17:33:53 +0000 (17:33 +0000)]
Update epigraphs.pod for 5.37.7

17 months agoAdd new release to perlhist v5.37.7
Richard Leach [Tue, 20 Dec 2022 13:57:45 +0000 (13:57 +0000)]
Add new release to perlhist

17 months agoUpdate t/porting/customized.dat for 5.37.7
Richard Leach [Tue, 20 Dec 2022 13:51:15 +0000 (13:51 +0000)]
Update t/porting/customized.dat for 5.37.7

17 months agoUpdate perldelta.pod for 5.37.7
Richard Leach [Tue, 20 Dec 2022 13:50:18 +0000 (13:50 +0000)]
Update perldelta.pod for 5.37.7

17 months agoUpdate Module::CoreList for 5.37.7
Richard Leach [Tue, 20 Dec 2022 13:31:24 +0000 (13:31 +0000)]
Update Module::CoreList for 5.37.7

17 months agoAddress GH #20571
Karl Williamson [Sat, 17 Dec 2022 22:35:04 +0000 (15:35 -0700)]
Address GH #20571

The blamed commit, 04de022, exposed a bug in the module itself.  I will
submit a PR to fix it.

But this ticket did tell me that there was a problem with that commit.
It returned a C language value, CHAR_MAX, which doesn't really have a
corresponding concept in Perl.  Instead we use -1 to indicate that a
positive-valued variable is in some abnormal state.  This commit changes
to do that, and documents the changes, which should have been done in
04de022.

17 months agoFix broken API: sync_locale()
Karl Williamson [Sat, 17 Dec 2022 15:34:33 +0000 (08:34 -0700)]
Fix broken API: sync_locale()

This fixes GH #20565.

Lack of tests allowed sync_locale() to get broken until CPAN testing
showed it so.

Basically, I blew it in 9f5a615be674d7663d3b4719849baa1ba3027f5b.  Most
egregiously, I forgot to turn back on when a sync_locale() is executed,
the toggling for locales whose radix character isn't a dot.  And this
needs a way to tell the other code that it needs to recompute things at
this time, since our records don't reflect what happened before the
sync.

17 months agoAdd testing global locale switching; Todo #20565
Karl Williamson [Sat, 17 Dec 2022 15:17:10 +0000 (08:17 -0700)]
Add testing global locale switching; Todo #20565

API switch_to_global_locale() and sync_locale() weren't tested because I
hadn't figured out a way to do so, but @dk showed me the way in his
reproducing case for GH #20565.

17 months agoAPI-test:locale.t: Look for a comma radix locale
Karl Williamson [Sat, 17 Dec 2022 15:12:23 +0000 (08:12 -0700)]
API-test:locale.t: Look for a comma radix locale

Prior to this commit there was code (whose results were ignored) looking
for a locale with a non-dot radix.  This can result in a UTF-8 radix,
which may not display properly without the terminal and file handle
being in sync.  Almost all non-dot locales use a comma, which is
represented the same in UTF-8 as not, so doesn't suffer from the display
problem.  So look specifically for a comma.

The result is still unused, but the next commit will use it.

17 months agolocale.c: Clarifications
Karl Williamson [Fri, 16 Dec 2022 15:19:24 +0000 (08:19 -0700)]
locale.c: Clarifications

This commit adds/improves some comments, changes a variable name, and
adds some parentheses, and moves a declaration (since we now use C99).

17 months agoDefine OP_HELEMEXISTSOR, a handy LOGOP shortcut for HELEM existence tests
Paul "LeoNerd" Evans [Sat, 10 Dec 2022 15:45:10 +0000 (15:45 +0000)]
Define OP_HELEMEXISTSOR, a handy LOGOP shortcut for HELEM existence tests

This op is constructed using an OP_HELEM as the op_first and any scalar
expression as the op_other.

It is roughly equivalent to the following perl code:

  exists $hv{$key} ? $hv{$key} : OTHER

except that the HV and the KEY expression are evaluated only once, and
only one hv_* function is invoked to both test and obtain the value. It
is therefore smaller and more efficient.

Likewise, adding the OPpHELEMEXISTSOR_DELETE flag turns it into the
equivalent of

  exists $hv{$key} ? delete $hv{$key} : OTHER

17 months agolocale.c: No locales imples no UTF-8 ones
Karl Williamson [Mon, 28 Nov 2022 17:51:22 +0000 (10:51 -0700)]
locale.c: No locales imples no UTF-8 ones

If Perl is compiled to not pay attention at all to locales, everything
effectively becomes the C locale, which isn't a UTF-8 one.  So we know
that at compile time.

17 months agoperldelta for 3 upgraded CPAN modules
James E Keenan [Mon, 19 Dec 2022 13:46:27 +0000 (13:46 +0000)]
perldelta for 3 upgraded CPAN modules

17 months agoUpdate experimental to CPAN version 0.030
Leon Timmermans [Mon, 19 Dec 2022 13:34:28 +0000 (13:34 +0000)]
Update experimental to CPAN version 0.030

Adapt to future deprecation of smartmatch

17 months agoharness: When run in ASAP mode, intermix comp/run/cmd
Karl Williamson [Tue, 13 Dec 2022 18:59:48 +0000 (11:59 -0700)]
harness: When run in ASAP mode, intermix comp/run/cmd

Prior to this commit, when run with PERL_TEST_HARNESS_ASAP, there were
three sets of tests run sequentially.  The second set consisted of just
the comp/, run/, and cmd/ directories.  This commit folds those
directories and the third set together, which ekes out a bit more
performance gain.  It was 6% better on my box running ASAN.  And, the
ASAP runs in about 75% of the time as non-ASAP.

There is no change in the non-ASAP operation.

17 months agoharness: Run more parallel tests by execution time order
Karl Williamson [Tue, 13 Dec 2022 18:19:30 +0000 (11:19 -0700)]
harness: Run more parallel tests by execution time order

In the normal mode of operation of t/harness, there are three sets of
tests, where the first set has to completely finish before the second
one starts, which has to completely finish before the third set starts.

The first set is the basic sanity, and quickly completes.  That is
untouched by this commit.

The third set are the tests for mostly non-core modules, including
cpan/, dist/, ext/, and lib/.  These are executed so that the
longest-running ones are started first when parallel testing is
available.  That is also unchanged by this commit.

The second set is what's left over: generally core tests and ones
enabled only on some platforms or by specifying an option, such as
torture tests.  Prior to this commit, these were executed in parallel,
if permitted, but there was no effort to start the longest-running ones
first.  This results in a less than optimum use of the CPU.

The code that orders tests by running time was previously applied to
just the third set of tests.  Prior commits have extracted out that code
into a function.  This commit just uses that function for the tests
in the second set.

In principle, the basic sanity tests could also be run in parallel.
This would be easy to do, but I'm a little leery, and since they are
quick to execute there would not be much gain in doing so.

Comments in the code removed by this commit indicated that the intent
was to execute ext/ and lib/ tests last.  But that hasn't been true for
quite some time, and no one seems to have noticed.  Now that we have a
function to assemble the tests in a given directory, it would be trivial
to change back, but that does lead to a longer wall clock elapsed time.

The PERL_TEST_HARNESS_ASAP environment variable is used to change the
mode of operation so that most of the tests in the second set are
instead moved into the third set.  Only the comp/, run/, and cmd tests
are left in the second set.  That is also unchanged by this commit.

17 months agoharness: Extract code into a function
Karl Williamson [Tue, 13 Dec 2022 18:12:24 +0000 (11:12 -0700)]
harness: Extract code into a function

This is in preparation for it being called from a second place in the
following commit.

The git diff listing shows other code being deleted and added instead of
this extraction, because that has a smaller amount of diffs generated

17 months agoharness: Move comments
Karl Williamson [Tue, 13 Dec 2022 18:06:20 +0000 (11:06 -0700)]
harness: Move comments

This wasn't done in the previous commit in order to minimize the diff
listing

17 months agoharness: Improve handling of serial execution exceptions
Karl Williamson [Tue, 13 Dec 2022 17:54:48 +0000 (10:54 -0700)]
harness: Improve handling of serial execution exceptions

Experience has shown that some directories must be serially executed
even though they have no rules indicating so.  There are currently 2
such directories, hard-coded as such.  This commit turns things into a
hash, removing a grep and moves the check to within an already existing
loop.  If an exception is found, it is deleted from the hash, and at the
end, only the non-matched ones remain, so it is trivial to output that
these weren't found, which indicastes a likely error.

17 months agoharness: Move ARGV, ENV processing earlier
Karl Williamson [Tue, 13 Dec 2022 16:39:22 +0000 (09:39 -0700)]
harness: Move ARGV, ENV processing earlier

This is in preparation for a future commit.

That is the purpose of this commit; however, the git difference listing
instead shows moving the _extract_tests() function later, because that
is the more minimal difference.

17 months agoharness: Simplify
Karl Williamson [Sun, 18 Dec 2022 01:49:39 +0000 (18:49 -0700)]
harness: Simplify

By introducing the hash %map_file_to_dir, we can remove an ugly pattern and
s/// that were used to derive all the directories.

17 months agoharness: Change tabs to spaces
Karl Williamson [Tue, 13 Dec 2022 12:20:14 +0000 (05:20 -0700)]
harness: Change tabs to spaces

17 months agoharness: Don't strip off '../' in path
Karl Williamson [Tue, 13 Dec 2022 04:52:57 +0000 (21:52 -0700)]
harness: Don't strip off '../' in path

This will be useful in future commits

17 months agoharness: Assign names to $_
Karl Williamson [Tue, 13 Dec 2022 04:38:52 +0000 (21:38 -0700)]
harness: Assign names to $_

These are clearer to read, espectially in largish loops.

17 months agoharness: Assign name to $2
Karl Williamson [Tue, 13 Dec 2022 04:26:23 +0000 (21:26 -0700)]
harness: Assign name to $2

It's clearer, and a future commit will destroy $2 before its final use

17 months agoharness: There is a .pl test file: cpan/Term-Cap/test.pl
Karl Williamson [Tue, 13 Dec 2022 03:45:49 +0000 (20:45 -0700)]
harness: There is a .pl test file: cpan/Term-Cap/test.pl

It was handled by using '*' for that directory, but future commits will
want to name individual files in a directory.

17 months agoharness: Extract sort into function
Karl Williamson [Sun, 18 Dec 2022 01:12:55 +0000 (18:12 -0700)]
harness: Extract sort into function

This is in preparation for it being called in other places, in a future
commit.

17 months agoRemove dead VMS code in Cwd::_backtick_pwd
Craig A. Berry [Sun, 18 Dec 2022 14:41:35 +0000 (08:41 -0600)]
Remove dead VMS code in Cwd::_backtick_pwd

The code as written would have had no effect since the value in
$^O is 'VMS' not 'vms' so it's better to remove the confused and
confusing code.

_backtick_pwd is not normally called on VMS because it has its own
set of routines dispatched via the %METHOD_MAP hash.

In the unlikely event that _backtick_pwd got called on VMS, it
would either fail because there is no pwd command, or, if running
under some Unix emulation environment, work just like Unix, and
therefore need no special handling of $ENV{PATH} that is different
from Unix.

17 months agoregcomp_internal.h - remove typedef
Yves Orton [Sun, 18 Dec 2022 10:37:13 +0000 (11:37 +0100)]
regcomp_internal.h - remove typedef

We already typedef scan_data_t in perl.h, we should not do so also
in regcomp_internal.h, we just need to defined struct scan_data_t.

17 months agoUse VMS absolute path to test tainting
Craig A. Berry [Sat, 17 Dec 2022 20:30:56 +0000 (14:30 -0600)]
Use VMS absolute path to test tainting

The '"-T" $arg and some suspect arguments' test has been failing
because it assumed setting $ENV{PATH} to /usr/bin will pass the
absolute path check in mg.c's Perl_magic_setenv, but it doesn't.

Using a VMS absolute path gets it passing.  Ideally we would be using
PL_perllib_sep to figure out whether the list of library paths is in
Unix syntax or VMS syntax, but that's not accessible from Perl, so
we'll have to assume the test is running with native paths in effect.

17 months ago<> to readline documentation updates
Scott Baker [Thu, 3 Nov 2022 17:05:45 +0000 (10:05 -0700)]
<> to readline documentation updates

17 months agoDetect forbidden flow at compiletime of `defer` or `finally`
Paul "LeoNerd" Evans [Wed, 14 Dec 2022 12:24:09 +0000 (12:24 +0000)]
Detect forbidden flow at compiletime of `defer` or `finally`

Using the new `forbid_outofblock_ops()`, many kinds of forbidden control
flow out of a `defer` or `finally` block can be detected statically with
this function by analysing the optree, rather than leaving it until
runtime when the attempt is actually made.

17 months agoAdd `forbid_outofblock_ops()` to op.c
Paul "LeoNerd" Evans [Wed, 14 Dec 2022 12:23:40 +0000 (12:23 +0000)]
Add `forbid_outofblock_ops()` to op.c

Adds a new function to statically detect forbidden control flow out of a
block.

17 months agoFile/Glob.xs: Idempotent setting of PL_opfreehook (fixes GH#20615)
Paul "LeoNerd" Evans [Fri, 16 Dec 2022 23:46:13 +0000 (23:46 +0000)]
File/Glob.xs: Idempotent setting of PL_opfreehook (fixes GH#20615)

17 months agoAdd proto.h as linguist-generated to .gitattributes
Paul "LeoNerd" Evans [Fri, 16 Dec 2022 20:52:45 +0000 (20:52 +0000)]
Add proto.h as linguist-generated to .gitattributes

17 months agoDefine five new operator precedence levels
Paul "LeoNerd" Evans [Thu, 15 Dec 2022 18:31:17 +0000 (18:31 +0000)]
Define five new operator precedence levels

Assignment operators (`==`) were missing, as were both the logical and
the low-precedence shortcutting OR and AND operators (`&&`, `||`,
`and`, `or`)

Also renumbered them around somewhat to even out the spacing. This is
fine during a development cycle.

Also renamed the tokenizer/parser symbol names from "PLUG*OP" to
"PLUGIN_*_OP" for better readability.

17 months agoAdd comment to infix operator precedence enum about when we can/can't change the...
Paul "LeoNerd" Evans [Thu, 15 Dec 2022 17:36:00 +0000 (17:36 +0000)]
Add comment to infix operator precedence enum about when we can/can't change the numbers

17 months agoAdded function amagic_find(sv, method, flags)
Eric Herman [Wed, 9 Nov 2022 08:51:32 +0000 (08:51 +0000)]
Added function amagic_find(sv, method, flags)

Returns the CV pointer to the overloaded method,
which will be needed by join to detect concat magic.

Co-authored-by: Philippe Bruhat (BooK) <book@cpan.org>
17 months agoDocument the meaning of the OPf_SPECIAL flag on the LOOPEX ops
Paul "LeoNerd" Evans [Fri, 16 Dec 2022 10:57:41 +0000 (10:57 +0000)]
Document the meaning of the OPf_SPECIAL flag on the LOOPEX ops

18 months agoperldelta.pod - add note about regex engine decomposition
Yves Orton [Thu, 15 Dec 2022 08:29:08 +0000 (09:29 +0100)]
perldelta.pod - add note about regex engine decomposition

18 months agoWrite an apidoc fragment for wrap_infix_plugin()
Paul "LeoNerd" Evans [Sat, 10 Dec 2022 21:49:56 +0000 (21:49 +0000)]
Write an apidoc fragment for wrap_infix_plugin()

18 months agoToken type `pval` should be a void * pointer
Paul "LeoNerd" Evans [Sat, 10 Dec 2022 22:16:11 +0000 (22:16 +0000)]
Token type `pval` should be a void * pointer

The `pval` field of the token type union is currently only used in one
place; storing the result of the infix operator plugin. Its use here
stores a structure pointer, not a string. The union should define this
field as a `void *` and not a `char *`.

In addition we should not attempt to debug print it as a string because
its value is not valid as one.

18 months agoDo not cast away constness
Bart Van Assche [Mon, 24 Jun 2019 00:04:58 +0000 (17:04 -0700)]
Do not cast away constness

Fix most compiler warnings caused by building Perl extensions with
-Wcast-qual. This is realized by changing the type of multiple T *
arguments into const T * and by changing a few (T *) casts
into (const T *).

18 months agomakedef.pl: Properly define a hash element
Karl Williamson [Thu, 8 Dec 2022 13:50:19 +0000 (06:50 -0700)]
makedef.pl: Properly define a hash element

I had been so used to working lately with C preprocessor directives that
I used the same paradigm in Perl  without noticing.  If 'warnings' had
been on, it would have caught this (the previous commit now turns them
on).

18 months agomakedef.pl: Add 'use warnings'
Karl Williamson [Thu, 8 Dec 2022 13:49:05 +0000 (06:49 -0700)]
makedef.pl: Add 'use warnings'

This would have saved me a bunch of time.

18 months agomakedef.pl: Create $define{WIN32} etc
Karl Williamson [Tue, 6 Dec 2022 15:10:53 +0000 (08:10 -0700)]
makedef.pl: Create $define{WIN32} etc

A portion of makedef.pl must manually be kept in sync with changes to
portions of perl.h.  Prior to this commit, you had to remember
that #ifdef WIN32 from perl.h had to be translated to a completely
different paradigm for use in this file.  This commit fixes that, which
can help prepare the way for future programmatic syncing of the two
files.

18 months agomakedef.pl: Consistently use constant
Karl Williamson [Tue, 6 Dec 2022 14:54:37 +0000 (07:54 -0700)]
makedef.pl: Consistently use constant

This script defines a constant 'PLATFORM', but often uses the rhs of
that constant.  Change to always use the constant.

18 months agoFix warning "implicit declaration of function '_setjmpex'" using MinGW-w64
Tsuyoshi Watanabe [Thu, 18 Aug 2022 16:02:09 +0000 (01:02 +0900)]
Fix warning "implicit declaration of function '_setjmpex'" using MinGW-w64

18 months ago.github - switch to v3 actions
Yves Orton [Fri, 9 Dec 2022 19:12:05 +0000 (20:12 +0100)]
.github - switch to v3 actions

18 months agopod/ - document $INC and INCDIR
Yves Orton [Tue, 6 Dec 2022 11:33:11 +0000 (12:33 +0100)]
pod/ - document $INC and INCDIR

18 months agopp_ctl.c - move logic closer to where it is used
Yves Orton [Fri, 25 Nov 2022 19:39:42 +0000 (20:39 +0100)]
pp_ctl.c - move logic closer to where it is used

No sense doing something that has not effect.

18 months agopp_ctl.c - add support for an INCDIR hook
Yves Orton [Fri, 25 Nov 2022 19:38:04 +0000 (20:38 +0100)]
pp_ctl.c - add support for an INCDIR hook

This hook returns a list of directories for Perl to search.
If it returns an empty list it acts like a no-op (except for the
error message). The return from INCDIR is always stringified,
they are not treated the same as normal @INC entries so no hooks
returning hooks.

18 months agopp_ctl.c - handle objects in @INC a bit more gracefully
Yves Orton [Fri, 25 Nov 2022 19:32:53 +0000 (20:32 +0100)]
pp_ctl.c - handle objects in @INC a bit more gracefully

If an object doesn't have an INC hook then don't call it. Either simply
stringify the ref (think overloads), OR, if it is a blessed coderef,
then just execute it like it was an unblessed coderef.

Also handle when an object is passed as the first argument of the
array form of call. Previously this would throw an exception as the
first argument on the stack when we call_method() would not be
blessed. When this is the scenario we pass in the array as the third
argument to the method.

18 months agopp_ctl.c - support $INC in require_file @INC hook
Yves Orton [Fri, 25 Nov 2022 19:10:05 +0000 (20:10 +0100)]
pp_ctl.c - support $INC in require_file @INC hook

$INC is localized to be the C level index of the loop over the @INC
array. At the end of the hook its value is assigned back to the C level
loop iterator (inc_idx). This allows a hook to control where in the @INC
array the loop should continue, for instance -1 represents "reprocess
from the beginning" (and as a convenience so does undef). This can be
useful if the @INC array is modified by a hook. Normally we would just
"continue along", but this may or may not be the right thing to do, so we
let the user decide.

18 months agopp_ctl.c - require_file: truthful errors and tests: ties are called once
Yves Orton [Fri, 25 Nov 2022 19:05:24 +0000 (20:05 +0100)]
pp_ctl.c - require_file: truthful errors and tests: ties are called once

We need to keep track of what we actually checked. We cannot simply
report the state of @INC at the end of the require, as it might have
changed, possibly several times during the require. This also accounts
for most "silly" stuff that might upset our internal assumptions, for
instance where a tie might report one value to the code doing the
directory check and another in the error message.

We had long standing tests to see that @INC tie elements where called
"once" but they actually tested they were called twice despite claiming
otherwise. This fixes all of those test so that a tied @INC entry is
called exactly once, and whatever it returned the first time is placed
in the error message.

This includes a change to the require error message, so that where it
once said "@INC contains:" it now says "@INC entries checked:". Note
this patch requires parent v0.239 to be available (which was done
in the previous commit).

18 months agopp_ctl.c - eval INC hooks, and rethrow errors with more useful message
Yves Orton [Fri, 25 Nov 2022 18:35:38 +0000 (19:35 +0100)]
pp_ctl.c - eval INC hooks, and rethrow errors with more useful message

When an INC hook blows up debugging what is going on can be
somewhat difficult. This adds some debugging data if the error
message does not seem to be customized.

18 months agopp_ctl.c - refetch @INC from *INC after hook
Yves Orton [Fri, 25 Nov 2022 18:32:29 +0000 (19:32 +0100)]
pp_ctl.c - refetch @INC from *INC after hook

The original value may have been freed by the time the hook
returns, so we have to refetch it immediately after execution.

We also move the declaration into a more minimal scope.

18 months agopp_ctl.c - make ENTER debug data a bit more clear
Yves Orton [Fri, 25 Nov 2022 18:29:38 +0000 (19:29 +0100)]
pp_ctl.c - make ENTER debug data a bit more clear

We will have more than one INC hook in the future.

18 months agopp_ctl.c - rename vars to something more descriptive in require_file()
Yves Orton [Fri, 25 Nov 2022 18:23:51 +0000 (19:23 +0100)]
pp_ctl.c - rename vars to something more descriptive in require_file()

"i" and "ar" is a bit too minimal, and I will be refactoring
this code somewhat in following patches, so this preps it for
future changes.

18 months agot/ - INC hardening tests
Yves Orton [Sat, 26 Nov 2022 10:51:54 +0000 (11:51 +0100)]
t/ - INC hardening tests

These tests are pretty much all marked TODO. In the
following patches we will remove the TODO as we fix
the bug or implement the feature.

18 months agopodcheck.t - make error message less confusing
Yves Orton [Tue, 6 Dec 2022 12:28:43 +0000 (13:28 +0100)]
podcheck.t - make error message less confusing

podcheck.t assumes all non =head text will be indented
at least 4 spaces, but this wasn't explicit in the output
from podcheck for verbatim line length checks.

18 months agoUpdate podlators to CPAN version 5.00
Russ Allbery [Tue, 6 Dec 2022 22:40:57 +0000 (22:40 +0000)]
Update podlators to CPAN version 5.00

5.00 - 2022-11-25: Changes

Drop support for Perl 5.8.  The minimum required version is Perl 5.10.

The default output encoding of Pod::Man on non-EBCDIC systems is now
UTF-8.  The utf8 option (-u or --utf8 to pod2man) is now ignored, since
it is the default.  See the ENCODING section of its documentation for
testing results and further discussion.  (#68741)

Pod::Man now supports an encoding option (-e or --encoding to pod2man),
to change the output encoding to any encoding recognized by Encode, or
the special values groff or roff.  Setting it to roff requests the old
behavior of using character substitutions and *roff escapes to generate
ASCII-only output (the default prior to this version).

Pod::Man now supports the groff output encoding, which replaces all
non-ASCII characters with \[uNNNN] escapes.  This escape was not
supported by the originally *roff implementation, but it is supported
by groff and mandoc and allows proper representation of Unicode
characters.  This output format has no known advantages in portability
over UTF-8 on non-EBCDIC systems.  It is the default output format on
EBCDIC systems, and when the Encode module is not available.  (#73804)

Pod::Man no longer does guesswork transformations that only affected
troff output.  Formatting manual pages with troff is exceptionally
rare, and this magic caused constant maintenance issues.  This means
"--" is no longer changed to an em-dash, strings of capital letters
aren't made a bit smaller, no attempt is made to change double quotes
to paired quotes, and no special formatting is done for C++.  (#132007)

Guesswork (formatting rules based on heuristics intended for Perl
documentation) can now be disabled or selectively enabled in Pod::Man
with the guesswork option (--guessword to pod2man).  (#143668)

Pod::Text now supports an encoding option (-e or --encoding to
pod2text) to force the output encoding, similar to Pod::Man.  The utf8
option (-u or --utf8 to pod2text) is still supported and is equivalent
to setting encoding to UTF-8.

Pod::Text now defaults to UTF-8 encoding if it sees a non-ASCII
character on a non-EBCDIC system and the input encoding is not
specified.  This should fix rendering of E<> escapes of non-ASCII
characters in POD files that don't specify an input encoding, at the
cost of assuming UTF-8 output.  Pod::Text also now commits to an
encoding the first time it outputs a non-ASCII character and sticks
with that encoding for the rest of the file, even if the detected or
declared input encoding changes.  (#102631)

Stop using a PerlIO encoding layer for Pod::Text output and instead
use Encode.  If a PerlIO encoding layer is already set, trust it and do
no encoding.  This fixes encoding problems with output to a string.

Add a coding tag comment to the start of Pod::Man output if the output
encoding is not ASCII.  groff's preconv program and FreeBSD's mandoc
will use this line to determine the input encoding.

Pod::Man now supports a language option (--language to pod2man) that
adds groff language configuration commands to the start of the output.
This is required for proper line breaking of Japanese and Chinese text
when the manual page is not installed in a language-specific directory
so that the man program knows to add that configuration automatically.
Unfortunately, the commands added when this option is used are
groff-specific.  Thanks to zynldyx for the bug report and suggested
fix.

Pod::Man now converts Unicode zero-width spaces (U+200B) to the *roff
escape \:, which indicates a line break point without a space or
hyphen.  (Unfortunately, groff does not honor U+200B itself as a line
break point.)  This escape is not part of the language defined in CSTR
this escape won't cause problems.  (Debian Bug#941980)

Pod::Man and Pod::Text now correctly honor S<> wrapping L<> with an
anchor and URL, and make the space between the anchor and URL
nonbreaking.  (#143768)

Clear the current font before changing fonts in all Pod::Man output,
not just headings.  groff 1.22.4 does not clear bold or italic when
seeing \f(CW font change, which meant bold and italic were extending
farther than they should without this change.  (#143667)

Honor the quotes, lquote, and rquote configuration parameters to
Pod::Man for C<> text inside the special NAME section.  (#143967)

Pod::Man suppresses quote marks around some additional cases of Perl
code in C<> where the intent had been to suppress the quotes but there
were various bugs in the matching regular expressions.  This primarily
affects method calls and negative numbers.

Avoid non-standard *roff escape in the troff accent mark definition for
an acute accent.  \h"..." was used instead of \h'...' as seen in the
other accent mark definitions.  This error appears to have existed
since the first version of Pod::Man.  Thanks, Paul Evans.  (GitHub #14)

Document that nroff adds two spaces after each sentence when reflowing,
and therefore if you want formatted Pod::Man output to consistently
have one space after each sentence, you will have to avoid ending a
sentence at the end of a line in the middle of a paragraph.

Committer: Adjust Porting/Maintainers.pl and Porting/sync-with-cpan to
reflect upstream acceptance of customizations in core distribution.

18 months agoregcomp.c - decompose into smaller files
Yves Orton [Fri, 9 Dec 2022 10:00:17 +0000 (11:00 +0100)]
regcomp.c - decompose into smaller files

This splits a bunch of the subcomponents of the regex engine into
smaller files.

       regcomp_debug.c
       regcomp_internal.h
       regcomp_invlist.c
       regcomp_study.c
       regcomp_trie.c

The only real change besides to the build machine to achieve the split
is to also adds some new defines which can be used in embed.fnc to control
exports without having to enumerate /every/ regex engine file. For
instance all of regcomp*.c defines PERL_IN_REGCOMP_ANY, and this is used
in embed.fnc to manage exports.

18 months agoregex engine - cleanup internal tabs and ws (use -w to ignore)
Yves Orton [Fri, 9 Dec 2022 10:12:45 +0000 (11:12 +0100)]
regex engine - cleanup internal tabs and ws (use -w to ignore)

Having internal tabs causes confusion in diffs and reviews. In the
following patch I will move a lot of code around, creating new files
and they will all be whitespace clean: no trailing whitespace,
tabs expanded to the next tabstop properly, and no trailing empty
lines at the bottom of the file.

This patch prepares for that split, and future splits and changes to
the regex engine by precleaning the main regex engine files with the
same rules.

It should show no changes under '-w'.

18 months agoAdd some apidocs about the PL_infix_plugin variable
Paul "LeoNerd" Evans [Fri, 25 Nov 2022 20:23:23 +0000 (20:23 +0000)]
Add some apidocs about the PL_infix_plugin variable

18 months agoDefine a PL_infix_plugin hook, of a similar style to PL_keyword_plugin
Paul "LeoNerd" Evans [Sun, 27 Nov 2022 15:27:50 +0000 (15:27 +0000)]
Define a PL_infix_plugin hook, of a similar style to PL_keyword_plugin

Runs for identifier-named custom infix operators and sequences of
non-identifier symbol characters.

Defines multiple precedence levels for custom infix operators that fit
alongside exponentiation, multiplication, addition, or relational
comparision operators, as well as a "high" and "low" at either end.

18 months agoSimplify a few callsites with the newPADxVOP() function
Paul "LeoNerd" Evans [Tue, 6 Dec 2022 23:59:21 +0000 (23:59 +0000)]
Simplify a few callsites with the newPADxVOP() function

18 months agoDefine a newPADxVOP() convenience function
Paul "LeoNerd" Evans [Tue, 6 Dec 2022 23:32:48 +0000 (23:32 +0000)]
Define a newPADxVOP() convenience function

This function conveniently sets the ->op_targ field of the returned op,
making it neater to use inline in larger trees of new*OP functions used
to build optree fragments.

This function is implemented as `static inline`, for speed and code-size
reasons.

18 months agoUpdate parent to CPAN version 2.39
Max Maischein [Wed, 7 Dec 2022 22:01:51 +0000 (22:01 +0000)]
Update parent to CPAN version 2.39

From Changes (0.239 2022-12-06):

Harden against changes to require error messages. The '@INC contains'
may change in a future release of perl, this hardens the test to
not be sensitive to the exact words chosen. See:
https://github.com/Perl/perl5/pull/20547

18 months agoutf8_hop forwards Change continuation start behavior
Karl Williamson [Sun, 10 Jul 2022 16:06:17 +0000 (10:06 -0600)]
utf8_hop forwards Change continuation start behavior

Prior to this commit, when hopping forwards, and the initial position to
hop from is a continuation byte, it treats it and each such successive
one as a single character until it gets to a start byte, and switches
into normal mode.

In contrast, in hopping backwards, all the consecutive continuation
bytes are considered to be part of a single character (as they indeed
are).

Thus there is a discrepancy between forward/backwards hopping; and the
forward version seems wrong to me.

This commit removes the discrepancy.  There is no change in behavior if
the starting position is to the beginning of a character.  All calls in
the core except for the API test are of this form.

But, if the initial position is in the middle of a character, it now
moves to the beginning of the next character, subtracting just 1 from
the count of characters to hop (instead of subtracting however many
continuation bytes there are).  This is how I would have expected it to
work all along.

Succinctly, getting to the next character now consumes one hop count, no
matter the direction nor which byte in the character is the starting
position.