83733 Commits

Author SHA1 Message Date
Karl Williamson
ea15ca3786 embed.fnc: Add EPTRtermNUL
Some functions take arguments that point to the terminating NUL
character of a string.  This commit adds a way to declare in embed.fnc
that a given argument is of that kind.
2026-01-22 07:24:00 -07:00
Karl Williamson
e3f7e781f3 embed.pl: Save some hash references in variables
This shortens later references
2026-01-22 07:24:00 -07:00
Karl Williamson
4e751d51ff toke.c: Add comment to S_parse-ident 2026-01-22 07:24:00 -07:00
Karl Williamson
6773f0fb0a embed.fnc: Add comment 2026-01-22 07:24:00 -07:00
Karl Williamson
bbc7f9cd1e Standardize .h recursive #include guard names
Some header files in the Perl core have guards to keep a
recursive #include from compiling them again.  This is standard practice
in C coding, and I was surprised at how many headers don't have
it.  These seem to rely on only being included from perl.h, which does
have its own guard.

Most of the guards use a common naming convention.  If the file is named
foo.h, the guard is named 'PERL_FOO_H'.  Often, though, a trailing
underscore is added,  'PERL_FOO_H_', making the convention slightly
fuzzy.  The 'PERL_' is not added if the file 'foo' already includes
'perl' in its name,

Those rules are enough to describe all the guards in the core, except
for the outliers in this commit, plus perl.h.

There are occasions in various Perl scripts that examine our source that
we want to create a pattern that matches the header guard name for a
particular file.  In spite of the slight fuzziness, that's easy using
the above rules, except for the ones in this commit, and perl.h.
It would be better for that code to not have to worry about the
outliers, and since these are arbitrary names, we can just change them
to follow the rules that already apply to most.

This commit changes the names of the outliers so that the only file the
rules don't apply to is perl.h.  Its guard is named H_PERL.  That
spelling is used in Encode, so it's not so easy to change it seamlessly.
I'm willing to live with it continuing to be an outlier for the code I
write.
2026-01-22 07:21:21 -07:00
Karl Williamson
ed5117fa8b grok_infnan: Handle empty input
This public function dereferences its pointer parameter before checking
its validity.
2026-01-22 06:59:32 -07:00
Karl Williamson
cea46623dd op.c: Don't hand-roll is_dup_mode() attributes
This commit adds an entry in embed.fnc for S_is_dup_mode, removing the
assert and __attribute lines in op.c.

The proximal cause for this commit is that I tried compiling with
Perl_assert() enabled, which resulted in a lot of compiler warnings
because of the __attribute__non_null__ line

But I also think it is better to not hand-roll things unless absolutely
necessary.  Changes someone makes to the general scheme are not likely
to be propagated to the hand-rolled items.
2026-01-22 06:58:57 -07:00
Karl Williamson
fb03d6749a regcomp.c: Remove extraneous conditional
This is checking that the argument is an ASCII \w that isn't an
underscore.  But in this range, that is identical to an alphanumeric,
which there is already a macro for, so use that single macro instead of
the two.
2026-01-22 06:57:22 -07:00
Tony Cook
b933ecdd4a add (or improve) SV numeric comparison APIs
A partial fix for #23918
2026-01-22 13:38:54 +11:00
Tony Cook
7c5ddde8c4 add perldelta for sv_numeq fix and other sv_num* additions
modified the sv.c documentation since the perldelta sv_numeq link had
multiple targets.
2026-01-22 13:09:21 +11:00
Tony Cook
164f562463 Add some documentation for sv_numcmp_common() 2026-01-22 13:09:21 +11:00
Tony Cook
b5f41adca0 check the void context fix for sv_numeq too 2026-01-22 13:09:20 +11:00
Tony Cook
1840104512 add SV_FORCE_OVERLOAD to the sv_numcmp() APIs
and add AMGf_force_overload to amagic_call() which does the actual work.
2026-01-22 13:09:20 +11:00
Tony Cook
e11f0edb1a sv_numeq etc: don't do numify overloading with SV_SKIP_OVERLOAD 2026-01-22 13:09:13 +11:00
Tony Cook
c93bd38fcc pp_multiconcat: use the new AMGf_force_scalar
instead of a special case in amagic_call()
2026-01-22 13:07:35 +11:00
Tony Cook
46a4ed5f61 amagic_call: accept a AMGf_force_scalar flag to force scalar context
and use it from the numeric comparison APIs.
2026-01-22 13:07:35 +11:00
Tony Cook
9edfa4656a add tests for void context calls to overloads
Discovered while working on another module, in many amagic_call() will
use the current context when calling the overload sub, but these APIs
might be called in XS code that simply needs a comparison, regardless
of the current OP context.
2026-01-22 13:07:35 +11:00
Tony Cook
2c33801f68 sv_numcmp_common: only call magic once if the SVs are the same
similar to try_amagic_bin()
2026-01-22 13:07:35 +11:00
Tony Cook
747670eba8 add sv_numle(), sv_numlt(), sv_numge(), sv_numgt() APIs
These are all needed because overloading may make them inconsistent
with <=> overloading.
2026-01-22 13:07:35 +11:00
Tony Cook
897c610479 sv_num*: correctly handle "0+" overloaded values
do_ncmp() expects simple SVs and for overloaded SVs will just compare
the SvNV() of each SV, mishandling the case where the 0+ overload
returns a large UV or IV that isn't exactly representable as an NV.

# Conflicts:
#	ext/XS-APItest/t/sv_numeq.t
#	ext/XS-APItest/t/sv_numne.t
#	sv.c
2026-01-22 13:07:34 +11:00
Tony Cook
01e16d6bee add sv_numcmp() to the API 2026-01-22 13:07:34 +11:00
Tony Cook
625a15724a sv_numeq/sv_numne: consolidate the similar documentation
If nothing else putting them together may avoid someone doing
`!sv_numeq(...)`
2026-01-22 13:07:34 +11:00
Tony Cook
22223d7d51 sv.c: extract the common parts of sv_numeq_flags and sv_numne_flags 2026-01-22 13:07:34 +11:00
Tony Cook
53bf030389 add sv_numne() to the API
some refactoring next, since sv_numeq_flags and sv_numne_flags are
similar.

Used a separate test file since putting every sv_num*() variant in the
one file would be ugly

Addresses GH #23918 but isn't a direct fix
2026-01-22 13:07:34 +11:00
Paul "LeoNerd" Evans
da6c78e212 Allow multivariable foreach to use refaliases
As noted by https://github.com/Perl/perl5/issues/24027, while multivar
foreach and refalias foreach have each been available separately for
some time now, it wasn't possible to combine the two until now.

This current implementation does have limits on the number of variables
in total are allowed in a multivariable foreach loop if any are
refaliases (no more than 256), and which ones can be refaliases (none
past the 24th) that are all to do with the way I am abusing the U32
`op_targ` field to store the variable count in the lower 8 bits, and a
bitmask of which vars are refaliases in the upper 24 bits. I decided to
do that as it means I don't have to make the `OP_ITER` op any larger -
such as by expanding it to an UNOP_AUX to give it that extra storage
space. In practice I don't imagine those limits will be a problem for
any practical use-case.

If in a future version we did want to expand on those limits, I think it
would be possible by moving the `refalias_mask` storage to a PV stored
in the UNOP_AUX vector, or somesuch.
2026-01-22 00:07:41 +00:00
Paul "LeoNerd" Evans
091a08d804 More efficient foreach \my $VAR implementation
* Define a new private op constant OPpITER_REFALIAS
 * Presence of this flag on OP_ITER means the iteration var is a
   refalias
 * Throw away the LVREF/REFGEN part of the optree in favour of just
   setting this flag

This change is useful on its own, and also a good stepping-stone towards
being able to implement multiple refalias variables in foreach; as per
  https://github.com/Perl/perl5/issues/24027
2026-01-22 00:07:41 +00:00
Paul "LeoNerd" Evans
e53cc76fc6 Rename perly.y's "list_of_scalars" to "list_of_itervars"
Currently these are all scalar variables, but soon I will add the
ability for iteration variables to be refaliases, so they won't
necessarily all be scalars any more.
2026-01-22 00:07:41 +00:00
Paul "LeoNerd" Evans
ad83cb95d2 Refactor helper function for feature + warnings in op.c
New helper functions to avoid some copy-paste. Also because I'm
otherwise about to add a third copy.
2026-01-22 00:07:41 +00:00
Paul "LeoNerd" Evans
25fad3315b Fix panic() messages in newFOROP() to actually print the right function name 2026-01-22 00:07:41 +00:00
Paul "LeoNerd" Evans
b5e0af402b Unify mg_free_struct() between mg.c and sv.c
Rather than copy-pasted code in two places, define a helper function to
call from both. This also accounts for minor (but currently
inconsequential) differences in behaviour between the two copy-pasted
locations, that seem to have drifted apart over time.
2026-01-21 23:49:41 +00:00
Paul "LeoNerd" Evans
e0275f5f0a Use SvUPGRADE() macro instead of direct call to sv_upgrade()
Adds consistency and avoids a weird cornercase in which due to
non-standard circumstances these SVs are already magical.

These only happen at compile-time so performance hit of performing an
extra SvTYPE() check is not critical.
2026-01-21 12:47:06 +00:00
Scott Baker
76771b2f9a Clean up, simplify, and re-work Perl_seed(). Fixes #2296
DEBUG_U doesn't work? We'll just use a normal comment for now

epoch should be U64
2026-01-20 10:56:48 -07:00
Scott Baker
134107b181 Change Perl_seed() to return a U64 2026-01-20 10:56:48 -07:00
Richard Leach
405e1a98a4 pp_enteriter - skip fits-in-integer check for positive IVs!
`for ( X .. Y ) {}` ranges take values in IV range for X & Y.
(If X & Y are NVs or "look like numbers", the IV values are derived.)

The in-range check is performed on every call to `pp_enteriter` using
`S_outside_integer`, which derives the NV value for X & Y (calling
`sv_upgrade` if X & Y are not SVt_NV or SVt_PVNV+), and performs multiple
checks on the NV values to see if they fit within IV range.

However, if X & Y are `SvIOK_notUV` then the values fit within IV range
by definition and the whole `S_outside_integer` work is unnecessary.
This commit adds a hot branch that checks for `SvIOK_notUV` X & Y with
values `> -1` and skips `S_outside_integer` if the checks are successful.

The `> -1` checks seem like they shouldn't be necessary (again, if it's
an SvIOK_notUV, by definition the value fits in an IV), but are there
to workaround introducing test failures in t/op/range.t. (This attempts
to confirm that test values just below IV_MIN are not accepted in
parsing, but because of NV imprecision, seems to expect some wrong
results. `> -1` is an arbitrary chosen constraint that fits the bill.)

_Gcov_ of a perl build and test_harness run shows this hot branch
predominating:

```
  6056933: 2682:            if (SvIOK_notUV(sv) && SvIVX(sv) > -1 &&
  6048750: 2683:                SvIOK_notUV(right) && SvIVX(right) > -1) {
  6044776: 2684:                cx->cx_type |= CXt_LOOP_LAZYIV;
  6044776: 2685:                cx->blk_loop.state_u.lazyiv.cur = SvIVX(sv);
  6044776: 2686:                cx->blk_loop.state_u.lazyiv.end = SvIVX(right);
  6044776: 2687:                rpp_popfree_2_NN();
        -: 2688:            }
    12157: 2689:            else if (RANGE_IS_NUMERIC(sv,right)) {
    12097: 2690:                cx->cx_type |= CXt_LOOP_LAZYIV;
    24183: 2691:                if (S_outside_integer(aTHX_ sv) ||
    12086: 2692:                    S_outside_integer(aTHX_ right))
       22: 2693:                    DIE(aTHX_ "Range iterator outside integer range");
    12075: 2694:                cx->blk_loop.state_u.lazyiv.cur = SvIV_nomg(sv);
    12075: 2695:                cx->blk_loop.state_u.lazyiv.end = SvIV_nomg(right);
    12075: 2696:                rpp_popfree_2_NN();
        -: 2697:            }
```

perf confirms:
* eliminated calls to `S_outside_integer`, Perl_sv_2nv_flags, `Perl_isinfnan`
* Perl_pp_enteriter also runs slightly faster.
2026-01-20 17:34:31 +00:00
Max Maischein
349bc76fbd Change release managers guide to run the tests in parallel
This makes a difference of 7 minutes per `make test`, so the default
should be to run the tests in parallel. There is one instance of
`make test ; make install` that still exercises the `make test` code
path, for completeness.
2026-01-19 20:25:55 +01:00
Max Maischein
77fd20a561 Prepare Module::Corelist 2026-01-19 20:02:13 +01:00
Max Maischein
d47ea5d4a0 Add URL for Perl 5.43.7 release 2026-01-19 19:29:11 +01:00
Max Maischein
48b1717bed Bump the perl version in various places for 5.43.7 2026-01-19 19:28:06 +01:00
Max Maischein
ca1acb5544 Archive perldelta 5.43.7 2026-01-19 19:21:14 +01:00
Max Maischein
37bc71cdc9 Mark 5.43.7 as released 2026-01-19 19:15:03 +01:00
Max Maischein
6b7fb5cf86 Merge branch 'release-5.43.7' into blead 2026-01-19 19:10:34 +01:00
Max Maischein
87a91cb6b5 Add new release to perlhist v5.43.7 2026-01-19 18:09:32 +01:00
Karl Williamson
7e57931a2b perlio.c: Fix grammar in comment 2026-01-19 10:09:02 -07:00
Max Maischein
963aefadb3 Update perldelta for 5.43.7 2026-01-19 17:46:10 +01:00
Max Maischein
4ea2bfc421 Update Module::CoreList for 5.43.7 2026-01-19 17:23:08 +01:00
Max Maischein
99ce99b7ba Set Module::CoreList version to 20260119
... as we release one day before the 'usual' date
2026-01-19 17:20:29 +01:00
Karl Williamson
06c43a5106 regen.pl: Add comment 2026-01-18 10:26:29 -07:00
Paul "LeoNerd" Evans
5789229d78 Rebuild embed.h last, in case other regen steps wanted to add more things to it
Otherwise, it's possible that later steps add new macros that `embed.pl`
would have wanted to add to its list of things to `#undef`, requiring a
second run of `make regen`.

By running embed.pl last, we ensure this happens in the right order the
first time.
2026-01-16 16:32:14 +00:00
Karl Williamson
fdbbcb462a regexec.c: Change return 0 to NULL
It is better practice to return a pointer when that's what the function
is declared to return
2026-01-15 18:28:15 -07:00
Karl Williamson
7e9ba10fa8 Document (and export) [IU]_(BITS|DIG)
Fixes #24083. Fixes #24084.

In d957e95daa0143d60933d96d6cbfb69eee6d6269 I changed the definitions of
IV_DIG and UV_DIG to depend on IV_BITS and UV_BITS respectively,
creating the latter in perl.h.  These had only visibility to the perl
core.  But I forgot that the _DIG forms were visible everywhere, so the
_BITS forms needed to be as well.

This commit merely documents all of them as public API (which should
have been the case all along anyway), which automatically causes their
visibility to be made everywhere.
2026-01-15 18:15:54 -07:00