This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
17 months agoupdate perldelta for 5.37.6
Max Maischein [Sun, 20 Nov 2022 10:12:34 +0000 (11:12 +0100)]
update perldelta for 5.37.6

17 months agoUpdate Module::CoreList for 5.37.6
Max Maischein [Sun, 20 Nov 2022 09:36:10 +0000 (10:36 +0100)]
Update Module::CoreList for 5.37.6

17 months agolocale.c: Don't Safefree temps
Karl Williamson [Sun, 20 Nov 2022 04:01:22 +0000 (21:01 -0700)]
locale.c: Don't Safefree temps

Commit 22392ba2f8a changed the querylocale_foo macros to return a
mortalized copy instead of having to free things explicitly.  This was
done because the various code paths are complicated, and I was noticing
various leaks that would require a bunch of #ifdef's to fix.

That commit meant that all the existing free's of the results needed to
be removed.  This one was overlooked at the time.  Reported in
<f47046d6-7e35-301d-10f-9160b34ca2b6@uwe-dueffert.de>, not in github

17 months agoDevel::PPPort/module3: eliminate the always true warning for the return
Tony Cook [Thu, 17 Nov 2022 22:49:55 +0000 (09:49 +1100)]
Devel::PPPort/module3: eliminate the always true warning for the return

In this case we're testing that the result is always true, and it
happens the compiler realizes that the return value is always true,
even in isolation.

Returning the variable that we've already set to point to
PL_bufptr eliminates the warning.

The compiler is still smart enough to eliminate the comparison
on optimized builds.  Some linter may still complain about it.

17 months agoGvNAME() always returns a true value
Tony Cook [Thu, 17 Nov 2022 03:42:36 +0000 (14:42 +1100)]
GvNAME() always returns a true value

gcc 12 was complaining that GvNAME() always returns a true value,
and that's also true.

Omit such uses in conditions.

17 months agochange HvENAME_HEK() to HvENAME_HEK_NN() where NULLs would crash anyway
Tony Cook [Thu, 17 Nov 2022 03:41:35 +0000 (14:41 +1100)]
change HvENAME_HEK() to HvENAME_HEK_NN() where NULLs would crash anyway

gcc 12 was producing a confusing message complaining that
references to with hek_key[] were beyond the end of the array,
even though a properly HEK has bytes beyond the first we declare.

From experimentation I theorize the confusing message was produced
because HvENAME_HEK() can return a NULL pointer, and the array
pointed to by any NULL pointer is zero length, producing the
array bounds warning we were seeing.

Fixed by changing each hv_(fetch|delete)hek() call to use the
HvENAME_HEK_NN() macro variant, which doesn't include an explicit
NULL return value.

mro_method_changed_in() was a bit special, it evaluated the
hv_fetchhek() before the check for an anonymous stash, so I reordered
the code to take advantage of C99, checking the assertions before we
dereference the stash pointer, checking we have a name before trying
to look it up.

17 months agoonly fully calculate the stash (effective) name where needed
Tony Cook [Thu, 17 Nov 2022 03:30:39 +0000 (14:30 +1100)]
only fully calculate the stash (effective) name where needed

gcc 12 was complaining that evaluating (somehekptr)->hek_key
was always true in many places where HvNAME() or HvENAME() was
being called in boolean context.

Add new macros to check whether the names should be available and
use those instead.

17 months agoclarify that every tag is required to be annotated
Andreas Koenig [Tue, 15 Nov 2022 04:57:13 +0000 (05:57 +0100)]
clarify that every tag is required to be annotated
- while the instructions were already clear at this point, accidents with lightweight (unannotated) tags have happened

17 months agorelax the assertion in SSPTR() and SSPTRt()
Tony Cook [Mon, 14 Nov 2022 03:00:38 +0000 (14:00 +1100)]
relax the assertion in SSPTR() and SSPTRt()

I added assertions in SSPTR() and SSPTRt() to try to ensure the new
SSize_t result from SSNEW*() wouldn't be truncated, but this
was too strict, requiring that the size matched exactly.

Relax this to allow the input offset to be the same or larger than
SSize_t.

Fixes #20504.

17 months agoSkip one test under miniperl
James E Keenan [Fri, 18 Nov 2022 14:39:10 +0000 (14:39 +0000)]
Skip one test under miniperl

threads module not yet available.

For: # https://github.com/Perl/perl5/issues/20524

17 months agodist/Tie-File/t/29a_upcopy.t: double timeout to 10
David Mitchell [Fri, 18 Nov 2022 10:07:24 +0000 (10:07 +0000)]
dist/Tie-File/t/29a_upcopy.t: double timeout to 10

Some of these tests (which involve moving blocks of data around in a
file) are occasionally randomly timing out on some slow smokers.
Double the timeout from 5s to 10s and see if the problem goes away.

17 months agodist/Tie-File/t/29a_upcopy.t add test descriptions
David Mitchell [Fri, 18 Nov 2022 10:05:32 +0000 (10:05 +0000)]
dist/Tie-File/t/29a_upcopy.t add test descriptions

17 months agoGetopt::Long: synch with CPAN version 2.54
Johan Vromans [Fri, 18 Nov 2022 00:02:18 +0000 (00:02 +0000)]
Getopt::Long: synch with CPAN version 2.54

From Changes:

* Fix compatibility with Perl 5.8.

17 months agoGetopt::Long: sync with CPAN version 2.53
Johan Vromans [Thu, 17 Nov 2022 00:19:16 +0000 (00:19 +0000)]
Getopt::Long: sync with CPAN version 2.53

From Changes:

* Improve parsing of float numbers.
  https://rt.cpan.org/Ticket/Display.html?id=133216

* Fix Version/HelpMessage -message argument.
  https://rt.cpan.org/Ticket/Display.html?id=133963

* Added 'starter' method to the callback object. This method returns the
  starter (e.g. '--' or '-') of the option as used by the user.

* Fix problem with Pod::Usage argument in examples/skel2.pl.

* Enhanced option:default spec to octal, hex and binary.

17 months agoFix & test useless-anonymous-subroutine warnings.
Felipe Gasper [Wed, 9 Nov 2022 18:58:12 +0000 (13:58 -0500)]
Fix & test useless-anonymous-subroutine warnings.

Issue #20384: This fixes a breakage from
35458d36d3c9fcf47064e4379e15276057b0bca5 that Devel::WatchVars’s test suite
caught. A test is added to Perl’s own test suite to prevent regressions.

17 months agoFail attempts to pass anonsub to \$ prototype.
Felipe Gasper [Mon, 31 Oct 2022 20:34:11 +0000 (16:34 -0400)]
Fail attempts to pass anonsub to \$ prototype.

Issue #20384

17 months agoParseXS - version bump to 3.48 and test perlxs.pod has the right version
Yves Orton [Tue, 8 Nov 2022 16:44:11 +0000 (17:44 +0100)]
ParseXS - version bump to 3.48 and test perlxs.pod has the right version

The version in the pod has been long wrong. We are on 3.48 now, it was 3.13_01.

17 months agoParseXS - make testing easier
Yves Orton [Mon, 14 Nov 2022 17:46:11 +0000 (18:46 +0100)]
ParseXS - make testing easier

Use warn instead of print STDERR, and provide a way to make
errors trigger a die instead of an exit(1).

Currently the module code is written as though the only way
it will be used is via the xsubpp script, so the library does
annoying things like calling exit() instead of die() to signal
an exception. It also uses print STDERR instead of warn,
which means the test code can't just use a $SIG{__WARN__} hook
to see its warnings, and instead has to include PrimitiveCapture
in the t directory. These two things combine annoyingly in our
test code such that when you break the module you can see tests
exiting early, but with no useful diagnostics as to why.

This patch reworks this to use "warn" instead of print STDERR,
and to provide a way to enable the use of "die" instead of exit.
Thus making debugging failing tests far easier.

17 months agoParseXS - add support for elifdef and elifndef
Yves Orton [Mon, 14 Nov 2022 10:16:40 +0000 (11:16 +0100)]
ParseXS - add support for elifdef and elifndef

The upcoming C++23 and C23 standards add #elifdef, #elifndef.

17 months agoParseXS - allow symbolic alias of default function
Yves Orton [Tue, 8 Nov 2022 17:31:01 +0000 (18:31 +0100)]
ParseXS - allow symbolic alias of default function

Also normalize warnings. It used to be if you created an alias
of the root function (0) no warning would be produced. Now
we will produce a warning, but we also allow symbolic references
to defuse the warning.

17 months agoParseXS - better support for duplicate ALIASes
Yves Orton [Tue, 8 Nov 2022 16:40:09 +0000 (17:40 +0100)]
ParseXS - better support for duplicate ALIASes

Sometimes you *want* to create multiple names for the same
functionality, but doing so with the ALIAS functionality requires
awkward workarounds. This adds a new "symbolic alias" that does
not warn on dupes as creating a dupe is its whole point. For a
symbolic alias the value is the name of an existing alias.

This also cleans up some of the warnings related to aliases so
we distinguish between when a duplicate is truly ignored or
where it overrides a previous value. And deal with a few other
edge cases properly.

17 months agoParseXS - handle #else and #endif without blank line prefixes
Yves Orton [Tue, 8 Nov 2022 14:06:17 +0000 (15:06 +0100)]
ParseXS - handle #else and #endif without blank line prefixes

This patch makes it possible to omit some of the whitespace around
preprocessor directives. It teaches fetch_para() to understand
that a #else or #endif directive that does not end a #if that
was seen in the current "paragraph" should not be parsed as part
of that paragraph. This means that a conditional block that defines
the same sub under different define conditions need not have extra
whitespace after each sub definition.

17 months agoParseXS - sort things that might produce output
Yves Orton [Tue, 8 Nov 2022 13:58:04 +0000 (14:58 +0100)]
ParseXS - sort things that might produce output

Make sure our output is deterministic.

17 months agoconfigure.gnu forwards extra arguments to Configure
Tony Cook [Mon, 14 Nov 2022 00:20:15 +0000 (11:20 +1100)]
configure.gnu forwards extra arguments to Configure

except when it doesn't (the -- arguments)

This came up during discussion of #20502, but is not a fix for it.

17 months agoWhitespace alignment fix in regen/feature.pl
Paul "LeoNerd" Evans [Mon, 14 Nov 2022 15:04:14 +0000 (15:04 +0000)]
Whitespace alignment fix in regen/feature.pl

17 months agoUpdate AUTHORS and .mailmap with my (Mattia Barbon) current address
Mattia Barbon [Mon, 14 Nov 2022 09:13:21 +0000 (10:13 +0100)]
Update AUTHORS and .mailmap with my (Mattia Barbon) current address

17 months agoSvPVutf8_nomg - assign string length to the len parameter
Mattia Barbon [Sun, 13 Nov 2022 22:33:50 +0000 (23:33 +0100)]
SvPVutf8_nomg - assign string length to the len parameter

This is consistent with other SvPV* variants that take a len parameter.

17 months agoutf8::upgrade: Don't coerce undef arg
Karl Williamson [Fri, 28 Oct 2022 14:48:37 +0000 (08:48 -0600)]
utf8::upgrade: Don't coerce undef arg

This fixes GH #20419

17 months agoFigure out I32df, U32uf, etc. in Configure rather than in perl.h
TAKAI Kousuke [Tue, 18 Oct 2022 13:46:11 +0000 (22:46 +0900)]
Figure out I32df, U32uf, etc. in Configure rather than in perl.h

These macros were defined in perl.h using preprocessor conditionals,
but determining wheter I32 is "int" or "long" is pretty hard with
preprocessor, when INTSIZE == LONGSIZE.  The Configure script
should know exact underlying type of I32, so it should be able to
determine whether %d or %ld shall be used to format I32 value
more robustly.

Various pre-configured files, such as uconfig.h, are updated to
align with this.

17 months agoPerl doesn't appear to be included in the ibb any more
Tony Cook [Mon, 14 Nov 2022 00:02:06 +0000 (11:02 +1100)]
Perl doesn't appear to be included in the ibb any more

The "ibb-perl" link prompts for a login, though other links like
"https://hackerone.com/perl" load without a login.

Perl also isn't listed under the ibb project itself at
"https://hackerone.com/ibb?type=team"

17 months agoTie-File: report test timeouts to STDERR
David Mitchell [Sat, 12 Nov 2022 09:16:04 +0000 (09:16 +0000)]
Tie-File: report test timeouts to STDERR

Currently some tests have a 5 second timeout. If this is exceeded,
the test number is output as "not ok", along with "# Timeout" to
STDOUT. Change the latter to output to STDERR along with the test
filename and test number, for easer debugging of smoke logs.

(Really these test files need upgrading to use Test::* but that's a job
for another day and another person....)

17 months agoskip testing .github/README.md if doesn't appear to be a README
Tony Cook [Fri, 11 Nov 2022 04:53:12 +0000 (15:53 +1100)]
skip testing .github/README.md if doesn't appear to be a README

git on windows at least of 2.37.1 does not checkout symbolic links
as symbolic links, leaving them as files containing the filename
linked to.

This meant this test against .github/README.md failed, since it only
contained "../README": nothing that appears to be a copyright message

I considered testing that .github/README.md was a symbolic link
but 8975221916 suggests that it may eventually become more distinct
from the root README file, so instead check its size.

17 months agoregcomp.c - add a PARNO() macro to wrap the ARG() macro
Yves Orton [Fri, 4 Nov 2022 17:18:49 +0000 (18:18 +0100)]
regcomp.c - add a PARNO() macro to wrap the ARG() macro

We used the ARG() macro to access the parno data for the OPEN
and CLOSE regops. This made it difficult to find what needed to
change when the type and size or location of this data in the
node was modified. Replacing this access with a specific macro
makes the code more legible and future proof.

This was actually backported from finding everything that broke
by changing the regnode type for OPEN and CLOSE to 2L and moving
the paren parameter to the 2L slot. We might do something like this
in the future and separating the PARNO() macros from their
implementation will make it easier.

17 months agoregcomp.c - correct comment
Yves Orton [Fri, 4 Nov 2022 17:27:23 +0000 (18:27 +0100)]
regcomp.c - correct comment

17 months agoDevel-PPPort: bump version
Graham Knop [Fri, 4 Nov 2022 04:45:07 +0000 (05:45 +0100)]
Devel-PPPort: bump version

17 months agoDevel-PPPort: fix STMT_START and STMT_END to not warn on clang
Graham Knop [Fri, 4 Nov 2022 04:33:30 +0000 (05:33 +0100)]
Devel-PPPort: fix STMT_START and STMT_END to not warn on clang

Since 7169efc77525df70484a824bff4ceebd1fafc760, perl's core STMT_START
and STMT_END macros no longer try to use brace groups, due to the
warnings they can generate and their very limited usefulness.

That commit also changed Devel::PPPort to remove the use of brace groups
in STMT_START/STMT_END. That led to errors in older perls, so it was
partly reverted in e08ee3cb66f362c4901846a46014cfdfcd60326c. Since then,
various other macros have been improved to properly work with brace
groups enabled or disabled.

We can now remove the brace group using variant of STMT_START/STMT_END,
which will silence the warnings from clang.

17 months agoDevel-PPPort: use inline function for croak_sv without brace groups
Graham Knop [Fri, 4 Nov 2022 04:27:41 +0000 (05:27 +0100)]
Devel-PPPort: use inline function for croak_sv without brace groups

The macro for croak_sv when brace groups are not enabled uses
STMT_START/STMT_END. This works when used as a statement, but would
break if used as part of an expression.

To resolve this, change that macro to use a function. As a static inline
function with a namespaced name, it shouldn't cause problems with
namespace pollution.

17 months agopod/perlhacks.pod - document TEST_ARGS and make win32 perl use it too
Yves Orton [Thu, 3 Nov 2022 18:50:48 +0000 (19:50 +0100)]
pod/perlhacks.pod - document TEST_ARGS and make win32 perl use it too

Win32 has had TEST_SWITCHES and TEST_FILES for ages. Unix has
TEST_ARGS. This extends Win32 to support TEST_ARGS as well. I
havent made the contrary change to the unix code, anyone using
TEST_SWITCHES is already using it on Win32.

17 months agoParseXS - fix todo tests to match the correct filename
Yves Orton [Tue, 8 Nov 2022 13:43:01 +0000 (14:43 +0100)]
ParseXS - fix todo tests to match the correct filename

The original regex was off and showed this test as passing when
it was actually failing, which is what we expect and why the test
is marked as TODO. The test accidentally doubled the extension
expected in the filename, and this patch corrects that mistake.

17 months agoperldelta for 545d499045, 42d0708bf6, a1aa0ce9693, 4f8b3850b207
Tony Cook [Mon, 7 Nov 2022 23:39:44 +0000 (10:39 +1100)]
perldelta for 545d49904542d0708bf6a1aa0ce96934f8b3850b207

17 months agobump $Storable::VERSION
Tony Cook [Mon, 25 Jul 2022 06:53:41 +0000 (16:53 +1000)]
bump $Storable::VERSION

17 months agomake store_hook() handle regular expression objects
Tony Cook [Mon, 25 Jul 2022 04:53:39 +0000 (14:53 +1000)]
make store_hook() handle regular expression objects

Previously this would complain it didn't know the object type
when preparing to call STORABLE_freeze.

17 months agoimprove error reporting by store_hook() on an unknown type
Tony Cook [Tue, 19 Jul 2022 05:58:35 +0000 (15:58 +1000)]
improve error reporting by store_hook() on an unknown type

This produced an opaque message when it was asked to freeze an
object of an unsupported type.  Changes:

- replace the opaque internal object type number with the typical perl name of the
  type ("GLOB" instead of "8")
- include the class of the object being frozen to identify which class needs work
- include name of the function we're trying to call to do the freeze,
  if possible

17 months agoallow porting/corelist.t to be run from root
Yves Orton [Mon, 24 Oct 2022 07:45:55 +0000 (09:45 +0200)]
allow porting/corelist.t to be run from root

17 months agoTest case where different functions are declared
James E Keenan [Mon, 4 Jul 2022 21:02:01 +0000 (21:02 +0000)]
Test case where different functions are declared

In the first sample .xs file supplied for this branch, a function named
'dbh' was declared twice, once inside an 'ifdef', once outside.  This
led me to think that that dual use of the string 'dbh' was the problem
EUPXS was stumbling upon.

However, that appears to be incorrect.  If we supply a second sample .xs
file in which we use two different function names, we still get the
undesired warning.

17 months agoAdd TODO-ed test for duplicate warning
James E Keenan [Mon, 4 Jul 2022 15:12:17 +0000 (15:12 +0000)]
Add TODO-ed test for duplicate warning

17 months agoAdd test file contributed in GH 19661
E. Choroba [Mon, 4 Jul 2022 14:14:19 +0000 (14:14 +0000)]
Add test file contributed in GH 19661

17 months agobuildtoc: Add error check
Karl Williamson [Wed, 2 Nov 2022 19:39:55 +0000 (13:39 -0600)]
buildtoc: Add error check

If something goes wrong, this wouldn't have known it

17 months agoUpdate Data::Dumper synopsis
Elvin Aslanov [Fri, 2 Sep 2022 15:09:18 +0000 (19:09 +0400)]
Update Data::Dumper synopsis

Add `my` to synopsis.

Committer: Data-Dumper: Update $VERSION in POD.  The release date no
longer appears in the POD, so let's remove the comment admonishing us to
update it.

For: https://github.com/Perl/perl5/pull/20224

17 months agoregen/regcomp.pl - add more detail on what the script does and list its inputs properly
Yves Orton [Mon, 12 Sep 2022 09:30:15 +0000 (11:30 +0200)]
regen/regcomp.pl - add more detail on what the script does and list its inputs properly

Previously we were only showing one of the inputs that generates
regnodes.h, now we show all of them. Also add some paragraphs explaining
a bit more detail what the files contain and how we process.

Committer: Small grammatical correction, per
https://github.com/Perl/perl5/pull/20288#discussion_r968344745

17 months agoGenerate opcode.h, opnames.h
Branislav Zahradník [Fri, 4 Nov 2022 18:39:08 +0000 (19:39 +0100)]
Generate opcode.h, opnames.h

17 months agoRefactor opcode.pl - with c99 array init index comments are not necessary
Branislav Zahradník [Mon, 17 Oct 2022 05:43:07 +0000 (07:43 +0200)]
Refactor opcode.pl - with c99 array init index comments are not necessary

17 months agoRefactor opcode.pl - use c99 array initialization (using op enum)
Branislav Zahradník [Sun, 16 Oct 2022 17:59:38 +0000 (19:59 +0200)]
Refactor opcode.pl - use c99 array initialization (using op enum)

17 months agoRefactor opcode.pl - use INIT() macro instead of #ifdef/#endif
Branislav Zahradník [Sun, 16 Oct 2022 16:46:11 +0000 (18:46 +0200)]
Refactor opcode.pl - use INIT() macro instead of #ifdef/#endif

17 months agoRefactor opcode.pl - let INIT() macro to accept expressions with comma(s)
Branislav Zahradník [Sun, 16 Oct 2022 17:48:56 +0000 (19:48 +0200)]
Refactor opcode.pl - let INIT() macro to accept expressions with comma(s)

17 months agoRefactor opcode.pl - B/Op_private.pm - move generator code to function
Branislav Zahradník [Sun, 16 Oct 2022 15:00:51 +0000 (17:00 +0200)]
Refactor opcode.pl - B/Op_private.pm - move generator code to function

17 months agoRefactor opcode.pl - pp_proto.h - move generator code to function
Branislav Zahradník [Sun, 16 Oct 2022 14:11:29 +0000 (16:11 +0200)]
Refactor opcode.pl - pp_proto.h - move generator code to function

17 months agoRefactor opcode.pl - opnames.h - unglobalize output handle
Branislav Zahradník [Sun, 16 Oct 2022 10:51:48 +0000 (12:51 +0200)]
Refactor opcode.pl - opnames.h - unglobalize output handle

17 months agoRefactor opcode.pl - opnames.h - move epilogue into function
Branislav Zahradník [Sun, 16 Oct 2022 10:47:24 +0000 (12:47 +0200)]
Refactor opcode.pl - opnames.h - move epilogue into function

17 months agoRefactor opcode.pl - opnames.h - move opcode predicates into function
Branislav Zahradník [Sun, 16 Oct 2022 10:02:29 +0000 (12:02 +0200)]
Refactor opcode.pl - opnames.h - move opcode predicates into function

17 months agoRefactor opcode.pl - opnames.h - move enum generator into function
Branislav Zahradník [Sun, 16 Oct 2022 09:49:57 +0000 (11:49 +0200)]
Refactor opcode.pl - opnames.h - move enum generator into function

17 months agoRefactor opcode.pl - opcode.h - unglobalize output handle
Branislav Zahradník [Sun, 16 Oct 2022 09:18:04 +0000 (11:18 +0200)]
Refactor opcode.pl - opcode.h - unglobalize output handle

17 months agoRefactor opcode.pl - opcode.h - move PL_opargs into function
Branislav Zahradník [Sun, 16 Oct 2022 09:01:03 +0000 (11:01 +0200)]
Refactor opcode.pl - opcode.h - move PL_opargs into function

17 months agoRefactor opcode.pl - opcode.h - move PL_check into function
Branislav Zahradník [Sun, 16 Oct 2022 07:40:31 +0000 (09:40 +0200)]
Refactor opcode.pl - opcode.h - move PL_check into function

17 months agoRefactor opcode.pl - opcode.h - move PL_ppaddr into function
Branislav Zahradník [Sun, 16 Oct 2022 07:28:17 +0000 (09:28 +0200)]
Refactor opcode.pl - opcode.h - move PL_ppaddr into function

17 months agoRefactor opcode.pl - opcode.h - move opnames into function
Branislav Zahradník [Sun, 16 Oct 2022 06:34:08 +0000 (08:34 +0200)]
Refactor opcode.pl - opcode.h - move opnames into function

17 months agoRefactor opcode.pl - opcode.h - move defines into function
Branislav Zahradník [Sun, 16 Oct 2022 06:31:07 +0000 (08:31 +0200)]
Refactor opcode.pl - opcode.h - move defines into function

17 months agoRefactor opcode.pl - opcode.h - move prologue into function
Branislav Zahradník [Sun, 16 Oct 2022 06:23:11 +0000 (08:23 +0200)]
Refactor opcode.pl - opcode.h - move prologue into function

17 months agoRefactor opcode.pl - required little bit newer perl
Branislav Zahradník [Sun, 16 Oct 2022 06:36:37 +0000 (08:36 +0200)]
Refactor opcode.pl - required little bit newer perl

This is perl5 developer tool, it's safe to expect contributors have
something newer at their disposal.

17 months agoRefactor opcode.pl - untabify
Branislav Zahradník [Fri, 4 Nov 2022 18:07:41 +0000 (19:07 +0100)]
Refactor opcode.pl - untabify

17 months agoMoved unused variable into debug scope
AnFunctionArray [Fri, 4 Nov 2022 15:52:56 +0000 (17:52 +0200)]
Moved unused variable into debug scope

Moved declaration of object p.

For: Issue: https://github.com/Perl/perl5/issues/20485
     p.r.:  https://github.com/Perl/perl5/pull/20486

17 months agoregcomp.c - remove always true condition
Yves Orton [Fri, 4 Nov 2022 08:19:59 +0000 (09:19 +0100)]
regcomp.c - remove always true condition

RX_PRECOMP() has for some time been an expression that
will always be true, thus there is not need to test it.

17 months agoGitHub Actions: switch from ::set-output to $GITHUB_OUTPUT
Graham Knop [Fri, 4 Nov 2022 05:13:03 +0000 (06:13 +0100)]
GitHub Actions: switch from ::set-output to $GITHUB_OUTPUT

The ::set-output command has been deprecated and replaced with the
$GITHUB_OUTPUT environment file. Convert the workflows to use the newer
output mechanism.

Reference: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

17 months agoscope.* - revert and rework SAVECOPWARNINGS change
Yves Orton [Fri, 4 Nov 2022 09:26:11 +0000 (10:26 +0100)]
scope.* - revert and rework SAVECOPWARNINGS change

We can't put PL_compiling or PL_curcop on the save stack as we don't
have a way to ensure they cross threads properly. This showed up as a
win32 t/op/fork.t failure in the thread based fork emulation layer.

This adds a new save type SAVEt_CURCOP_WARNINGS and macro
SAVECURCOPWARNINGS() to complement SAVEt_COMPILER_WARNINGS and
SAVECOMPILEWARNINGS(). By simply hard coding where the pointers should
be restored to we side step the issue of which thread we are in.

Thanks to Graham Knop for help identifying that one of my commits was
responsible.

17 months agoReplaced recppush/regcppop with memcpy
Alexander Nikolov [Thu, 2 Jun 2022 19:01:42 +0000 (12:01 -0700)]
Replaced recppush/regcppop with memcpy

Basically tested with Intel VTune to be increasing the performance of
a perl regex matching program with multiple capture groups and
recursive patterns

[With minor whitespace edits by Yves.]

17 months agoperldelta for 1a2b24d857d
Tony Cook [Wed, 2 Nov 2022 23:06:40 +0000 (10:06 +1100)]
perldelta for 1a2b24d857d

17 months agochange the return value of SSNEW to SSize_t
Tony Cook [Thu, 20 Oct 2022 04:04:51 +0000 (15:04 +1100)]
change the return value of SSNEW to SSize_t

The normal savestack index is an I32, but that counts in ANY
(which are typically the larger of pointer or IV sizes), this
meant is the save stack was large, but still nowhere need it's
limit, the result of SSNEW() could overflow.

So make the result SSize_t and adjust SSPTR() to match.

SSPTR() asserts to ensure the supplied type is the same size as
SSize_t to ensure callers are updated to handle the new limit.

18 months agoop.c: Add a cast to silence -Wsign-compare warning
TAKAI Kousuke [Wed, 26 Oct 2022 14:59:10 +0000 (23:59 +0900)]
op.c: Add a cast to silence -Wsign-compare warning

In 32-bit build (where IV is not wider than U32), comparing
PL_eval_begin_nest_depth and max_nest_iv would generate a warning:

    op.c:10817:42: warning: comparison of integer expressions of different signedness: ‘U32’ {aka ‘long unsigned int’} and ‘IV’ {aka ‘long int’} [-Wsign-compare]
    10817 |             if (PL_eval_begin_nest_depth >= max_nest_iv) {
          |                                          ^~

18 months agore/fold_grind.pl - rework so we don't double compile patterns
Yves Orton [Fri, 28 Oct 2022 21:28:06 +0000 (23:28 +0200)]
re/fold_grind.pl - rework so we don't double compile patterns

We were calling utf8::upgrade() on qr// objects, which works, in
that it stringifies the pattern, and then upgrades the string, and
the string can be used to match against. But it double compiles the
pattern, which is a bit unnecessary. For example

    $pat= qr/\x{DF}/;
    utf8::upgrade($pat); # $pat is now a string!
    "ss"=~/$pat/;        # and now $pat gets compiled again

works, but it does twice the work needed.

This was found by making utf8::upgrade() ignore refs.

18 months agocop.h - get rid of the STRLEN* stuff from cop_warnings
Yves Orton [Tue, 1 Nov 2022 14:31:24 +0000 (15:31 +0100)]
cop.h - get rid of the STRLEN* stuff from cop_warnings

With RCPV strings we can use the RCPV_LEN() macro, and
make this logic a little less weird.

18 months agowarnings.h - length guard cop_warnings bitvector checks
Yves Orton [Tue, 1 Nov 2022 14:03:41 +0000 (15:03 +0100)]
warnings.h - length guard cop_warnings bitvector checks

18 months agoscope.* - more flexible ways to save warning bits
Yves Orton [Tue, 1 Nov 2022 13:22:45 +0000 (14:22 +0100)]
scope.* - more flexible ways to save warning bits

18 months agoperldelta for 01052a1d77a5, a47628b617d1
Tony Cook [Tue, 1 Nov 2022 22:49:25 +0000 (09:49 +1100)]
perldelta for 01052a1d77a5a47628b617d1

18 months agomake win32_readlink() return PrintName instead of SubstituteName
Tony Cook [Thu, 15 Sep 2022 04:40:18 +0000 (14:40 +1000)]
make win32_readlink() return PrintName instead of SubstituteName

While debugging socket stat()ing I noticed that sometimes the
name returned by win32_readlink() was a full pathname rather than
the name that the link was created as.

Changing this to use the PrintName values changed win32_readlink()
to return the create as name, which seems closer to the POSIX
readlink.

18 months agoWin32 stat() didn't handle AF_UNIX socket files
Tony Cook [Tue, 6 Sep 2022 05:01:54 +0000 (15:01 +1000)]
Win32 stat() didn't handle AF_UNIX socket files

Unfortunately both symbolic links and sockets can only be
"statted" by opening with FILE_FLAG_OPEN_REPARSE_POINT which
obviously doesn't follow symbolic links.

So to find if a chain of symbolic links points to a socket,
is a broken chain, or loops, we need to follow the chain
ourselves.

18 months agoduplicate -F switches would overwrite PL_splitstr without freeing
Tony Cook [Mon, 26 Sep 2022 05:13:02 +0000 (15:13 +1000)]
duplicate -F switches would overwrite PL_splitstr without freeing

Of course, it wasn't safe to free it before the previous patch,
but it is now.

18 months agoWe freed PL_splitstr in each thread, allocate it in each thread too
Tony Cook [Mon, 26 Sep 2022 05:03:50 +0000 (15:03 +1000)]
We freed PL_splitstr in each thread, allocate it in each thread too

I also fixed const correctness for PL_splitstr, it was initialized
to " " which required it to be const, but the value is only looked
at when PL_minus_F is true, so it wasn't necessary.

So initialize it to NULL, and duplicate the value in threads.

18 months agot/comp/require.t - add tests for module_true being off
Yves Orton [Tue, 1 Nov 2022 16:58:47 +0000 (17:58 +0100)]
t/comp/require.t - add tests for module_true being off

Or the file being empty, or various other cases. We missed
a case in the earlier work on module_true.

This also includes some tweaks to make the tests pass under strict
if needed.

18 months agot/comp/require.t - add a way to disable the sleep 20
Yves Orton [Tue, 1 Nov 2022 16:57:45 +0000 (17:57 +0100)]
t/comp/require.t - add a way to disable the sleep 20

it makes developing the test script quite annoying.

18 months agot/comp/require.t - test module_true with requiring empty files
Yves Orton [Tue, 1 Nov 2022 16:02:14 +0000 (17:02 +0100)]
t/comp/require.t - test module_true with requiring empty files

18 months agopp_ctl.c - teach module_true how to deal with blocked requires
Yves Orton [Tue, 1 Nov 2022 15:40:37 +0000 (16:40 +0100)]
pp_ctl.c - teach module_true how to deal with blocked requires

If require encounters an @INC hook that blocks the require it
ends up with a STUB node as the optree for the LEAVEEVAL. This was
causing the module_true logic to segfault. Guarding against the
OP_STUB node fixes the problem.

This affected the tests for IO::Socket::SSL. Thanks to Graham
Knopp for the reduced case, and James Keenan for reporting it
in https://github.com/Perl/perl5/issues/20468.

This should fix the problem.

18 months agolocale.c - add comments about PERL_DESTRUCT_LEVEL avoiding "leaks"
Yves Orton [Mon, 31 Oct 2022 21:39:16 +0000 (22:39 +0100)]
locale.c - add comments about PERL_DESTRUCT_LEVEL avoiding "leaks"

Some of the locale data is deliberately not destroyed during shutdown.
Setting PERL_DESTRUCT_LEVEL=2 causes them to be cleaned up. If someone
ends up debugging under the address sanitizer and ends up at this logic
then the comments will help them avoid some frustration.

18 months agoAlso add a STRLEN member to ANY
Paul "LeoNerd" Evans [Mon, 31 Oct 2022 23:34:06 +0000 (23:34 +0000)]
Also add a STRLEN member to ANY

18 months agoAdd Size_t and SSize_t members to ANY
Paul "LeoNerd" Evans [Mon, 31 Oct 2022 23:27:36 +0000 (23:27 +0000)]
Add Size_t and SSize_t members to ANY

18 months agoConvert tabs to whitespaces in union any {} definition
Paul "LeoNerd" Evans [Mon, 31 Oct 2022 23:27:18 +0000 (23:27 +0000)]
Convert tabs to whitespaces in  union any {}  definition

18 months agoop.c - use refcounted pv pointers for cop_warnings
Yves Orton [Mon, 31 Oct 2022 13:41:27 +0000 (14:41 +0100)]
op.c - use refcounted pv pointers for cop_warnings

this allows multiple ops to share the same underlying
warning bit vector. the vectors are not deduped, however
they are efficiently copied and shared.

18 months agoregen/scope_types.pl - add tool to manage the scope type defines
Yves Orton [Mon, 31 Oct 2022 11:22:19 +0000 (12:22 +0100)]
regen/scope_types.pl - add tool to manage the scope type defines

In scope.c and scope.h there are various defines that must be coordinated
with the contents of an array, and comments and ids which might have to be
mass changed manually in some circumstances. As this is error prone this
patch adds a new regen script to ensure it is kept in sync and to make the
process of adding new types trivial. The data that drives the script is
kept in the scripts __DATA__ section.

18 months agoscope_types.h - new header file for scope type data
Yves Orton [Mon, 31 Oct 2022 10:37:27 +0000 (11:37 +0100)]
scope_types.h - new header file for scope type data

Next patch this data will be autogenerated.

18 months agocop.h - add support for refcounted filenames in cops under threads
Yves Orton [Fri, 28 Oct 2022 19:14:23 +0000 (21:14 +0200)]
cop.h - add support for refcounted filenames in cops under threads

We have a weird bifurcation of the cop logic around threads. With
threads we use a char * cop_file member, without it we use a GV * and
replace cop_file with cop_filegv.

The GV * code refcounts filenames and more or less efficiently shares
the filename amongst many opcodes. However under threads we were
simplify copying the filenames into each opcode. This is because in
theory opcodes created in one thread can be destroyed in another. I say
in theory because as far as I know the core code does not actually do
this. But we have tests that you can construct a perl, clone it, and
then destroy the original, and have the copy work just fine, this means
that opcodes constructed in the main thread will be destroyed in the
cloned thread. This in turn means that you can't put SV derived
structures into the op-tree under threads. Which is why we can not use
the GV * stategy under threads.

As such this code adds a new struct/type RCPV, which is a refcounted
string using shared memory. This is implemented in such a way that code
that previously used a char * can continue to do so, as the refcounting
data is located a specific offset before the char * pointer itself.
This also allows the len data to embedded "into" the PV, which allows
us to expose macros to acces the length of what is in theory a null
terminated string.

    struct rcpv {
        UV      refcount;
        STRLEN  len;
        char    pv[1];
    };
    typedef struct rcpv RCPV;

The struct is sized appropriately on creation in rcpv_new() so that the
pv member contains the full string plus a null byte. It then returns a
pointer to the pv member of the struct. Thus the refcount and length and
embedded at a predictable offset in front of the char *, which means we
do not have to change any types for members using this.

We provide three operations: rcpv_new(), rcpv_copy() and rcpv_free(),
which roughly correspond with newSVpv(), SvREFCNT_inc(), SvREFCNT_dec(),
and a handful of macros as well. We also expose SAVERCPVFREE which is
similar to SAVEGENERICSV but operates on pv's constructed with
rcpv_new().

Currently I have not restricted use of this logic to threaded perls. We
simply do not use it in unthreaded perls, but I see no reason we
couldn't normalize the code to use this in both cases, except possibly
that actually the GV case is more efficient.

Note that rcpv_new() does NOT use a hash table to dedup strings. Two
calls to rcpv_new() with the same arguments will produce two distinct
pointers with their own refcount data.

Refcounting the cop_file data was Tony Cook's idea.

18 months agomg.c/perl.c/scope.c - fixup mangled indentation and whitespace
Yves Orton [Mon, 31 Oct 2022 12:47:43 +0000 (13:47 +0100)]
mg.c/perl.c/scope.c - fixup mangled indentation and whitespace

Various code related to set_and_free_cop_warnings was terribly mangled
as far as whitespace goes. This patch cleans it up so it is readable and
correctly indented. Whitespace only changes.