3010 Commits

Author SHA1 Message Date
Karl Williamson
274208291b embed.fnc: Change EPTR assert for sv_pos_u2b_foo to gt
These internal functions can handle empty strings, but it aren't called
with those so far, and it is better practice to not call them with an
empty string, so guard against it now.
2026-01-23 12:09:29 -07:00
Karl Williamson
ff31f47a54 embed.fnc: Add string assertions for S_intuit-more
This makes sure the terminating character is a NUL.  This internal
function isn't documented as having that requirement, but that's always
the case in our test suite.  And functions it calls assume there is at
least one character in the input, so the assertion shouldn't be EPTRge,
and the test suite fails if it is EPTRgt.
2026-01-22 07:24:00 -07:00
Karl Williamson
31d13f8ab7 embed.fnc: Add string arg assertions for S_packlist
This function takes a string argument with beginning and ending
positions.  It appears to me that those positions are overwritten
without being examined, but the function does get called with an
apparently empty string, but it actually contains a NUL.
2026-01-22 07:24:00 -07:00
Karl Williamson
c6c2ced1e9 embed.fnc: Add string arg assertions for S_incline
This function is expecting a NUL-terminated C string
2026-01-22 07:24:00 -07:00
Karl Williamson
6a39094910 embed.fnc: Add string args assertions for S_wildcard
The end pointer for this function should always point to the terminating
NUL character of the string.
2026-01-22 07:24:00 -07:00
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
6773f0fb0a embed.fnc: Add comment 2026-01-22 07:24:00 -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
Tony Cook
164f562463 Add some documentation for sv_numcmp_common() 2026-01-22 13:09:21 +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
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
01e16d6bee add sv_numcmp() to the API 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
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
Scott Baker
134107b181 Change Perl_seed() to return a U64 2026-01-20 10:56:48 -07:00
Max Maischein
48b1717bed Bump the perl version in various places for 5.43.7 2026-01-19 19:28:06 +01:00
Karl Williamson
c1becd7fcc numeric.c: Make S_output_nonportable() callable from core
Instead of being internal to this file, changing its name to
Perl_output_nonportable
2026-01-15 09:49:49 -07:00
Karl Williamson
fc3b1a70c0 embed.fnc: Add string assertions for dump_exec_pos
This internal function takes a string argument with beginning and
ending positions.  It is called all the time with an empty string,
2026-01-12 12:49:49 -07:00
Karl Williamson
0a0ad01f4f embed.fnc: Add string assertions for debug_start_match
This internal function takes a string argument with beginning and
ending positions.  It handles the case of an empty string properly.
2026-01-12 12:49:49 -07:00
Karl Williamson
dfd074287b embed.fnc: Change EPTR get_quantifier_value assert to gt
This internal function looks problematic with regard to handling empty
strings, but it isn't ever called with one so far.  Change to catch such
calls that might get added in the future.
2026-01-12 12:49:49 -07:00
Karl Williamson
061aef76b4 embed.fnc: Change EPTR assert for regcurly to gt
This internal function can handle empty strings, but it isn't ever
called with one so far, and it is better practice to not call it with an
empty string
2026-01-12 12:49:49 -07:00
Karl Williamson
2d5fdadd63 embed.fnc: Add string assertions for utf8_hop_forward...
These functions take a string argument with beginning and ending
positions.  They handle the case of an empty string properly, and the
documentation says they handle empty strings.
2026-01-12 12:49:49 -07:00
Karl Williamson
8ca6f48d1a embed.fnc: Add string assertions for grok_numeric_radix
This function takes a string with a beginning and ending pointer.  It
doesn't dereference if the string is empty, and returns the correct
value when empty, and does get called with empty strings.
2026-01-12 12:49:49 -07:00
Karl Williamson
280d4b1d30 embed.fnc: grok_bslash_[ox]: Use EPTR_gt
These two functions examine their input string without checking if it is
zero length.  So, the assertion needs to change.  They aren't ever
called with an empty string.
2026-01-12 12:49:49 -07:00
Karl Williamson
7941a78b40 embed.fnc: Add string asserts for first_symbol,need_utf8:
These can handle empty strings, and are called with them.
2026-01-12 12:49:49 -07:00
Karl Williamson
009870150b embed.fnc: Add string asserts for EPTR for variant_under_utf8_count
It can handle an empty string and is called with empty strings
2026-01-12 12:49:49 -07:00
Karl Williamson
27c12d7b8f embed.fnc: Add EPTR for pos_b2u_midway
This handles an empty string, and is called with that currently a lot
2026-01-12 12:49:49 -07:00
Karl Williamson
57a9a3d8ff embed.fnc: Add string assertions for isSCRIPTRUN
This function is documented to handle empty strings, so EPTRge is
appropriate.
2026-01-12 12:49:49 -07:00
Karl Williamson
46376544f2 embed.fnc: Update comments for macro visibility changes
92dcf59a90bfbb545599098d7043c96abb783ee5 changed newly-created macros to
be affected by the apidoc visibility flags.  This commit updates the
comments in embed.fnc to reflect that.
2026-01-12 10:13:54 -07:00
Karl Williamson
62d42586b1 embed.fnc: Generalize comments to apply beyond functions
This file was originally written to handle functions and the short name
macros that call them.

But its contents have gradually been expanded over the years, without
fully updating the comments to reflect that.

This commit rewords things so that text that refers to more than just
functions is generalized.
2026-01-12 10:13:54 -07:00
Karl Williamson
f6327fd950 embed.fnc: Clarify a couple comments 2026-01-12 10:13:54 -07:00
Karl Williamson
6bd056401c embed.fnc: Make important comment prominent
by moving it to the top of the file and making it SHOUT
2026-01-12 10:13:54 -07:00
Karl Williamson
6639e505e9 embed.fnc: Remove irrelevant comment
This warned about a 5.31 change.  That's long enough ago that people
have gotten used to the new scheme.
2026-01-12 10:13:54 -07:00
Karl Williamson
1001bfec0b embed.fnc: Remove obsolete comment
This hasn't been true since the automatic formatting/sorting of
embed.fnc was instituted in 5.38
2026-01-12 10:13:54 -07:00
Karl Williamson
8a46b02e76 embed.fnc: Remove obsolete comments
These haven't been true since autodoc.pl was changed in 5.38
2026-01-12 10:13:54 -07:00
Karl Williamson
8ae436df76 embed.fnc: Fix misspelling in comment 2026-01-12 10:13:54 -07:00
Karl Williamson
6b6a828b0a Inline Perl_grok_(bin|oct|hex) 2026-01-12 09:42:39 -07:00
Karl Williamson
64b44cde3b Add 'v' flag for embed.fnc/apidoc
An enum constant isn't a macro; it can't be #undef-ined.  This
distinction will matter in a future commit, so create a separate flag
for elements like this.  I suspect this would also apply to other types
of elements, such as struct members, should we eventually need to deal
with those.
2026-01-08 08:58:10 -07:00
Karl Williamson
24c7fb4c21 Convert Perl utf16 to utf8 functions to macros
These functions are hereby removed in favor of calling the plain macros
that already exist
2025-12-27 21:24:47 -07:00
Karl Williamson
d15dd33d87 embed.fnc: Use correct name for formal parameter
The prototype here did not match the actual function
2025-12-24 10:37:48 -07:00
Karl Williamson
acc8ad3a28 embed.fnc: Rename EPTR qualifiers
People found the former names confusing.  This changes to use EPTRgt and
EPTRge that explicitly give the relation that gets used.
2025-12-15 16:57:52 -07:00
Karl Williamson
1c0e0dceeb Three macros are used in perl extensions
They were marked as core-only.
2025-12-10 08:50:19 -07:00
Karl Williamson
9df1c067a9 Remove const char * const return value
A function can't return something of that type, but this has always been
a macro, so this hasn't been caught.
2025-12-10 08:50:19 -07:00
Karl Williamson
3abbf2e1b8 embed.fnc: free_c_backtrace is only Perl_free_c_backtrace 2025-12-10 08:50:19 -07:00
Karl Williamson
838b774823 Move hv_stores() declaration from embed.fnc to hv.h
This is required for the next few commits that start automatically
creating long Perl_name functions for the elements in embed.fnc that are
macros and don't already have them in the source.

Only macros can take a parameter that has to be a literal string, so
don't fit with the next few commits.  This is the only case in embed.fnc
like that, so I'm deferring dealing with it for now.
2025-12-10 08:50:19 -07:00
Karl Williamson
32aaa22eec embed.fnc: Drop Perl_ on do_aexec my_stat my_lstat
These macros are not for external use, so don't need a Perl_ prefix
2025-12-10 08:50:19 -07:00
Karl Williamson
2444829c88 embed.pl: enum and union are like struct in parameters
These keywords all need another word to indicate the parameter type.
Previously only 'struct' was considered to have.

This changed showed an error in one entry embed.fnc, which is also
corrected in this commit.
2025-12-10 08:50:19 -07:00
David Mitchell
343b977ef3 make pregexec() handle zero-length strings again
GH #23903

In embed.fnc, commit v5.43.3-167-g45ea12db26 added SPTR, EPTR parameter
modifiers to (amongst other API functions), Perl_pregexec().

These cause assert constraints to be added to the effect that SPTR <
EPTR (since the latter is supposed to be a pointer to the byte after the
last character in the string).

This falls down for an empty string since in this case pregexec() is
called with strbeg == strend.

This was causing an assert failure in the test suite for
Package-Stash-XS.

The reason it wasn't noticed before is because:

1) pregexec() is a thin wrapper over regexec_flags();

2) The perl core (e.g. pp_match()) calls regexec_flags() rather than
   pregexec();

3) Package::Stash::XS has XS code which calls pregexec() directly rather
   than using CALLREGEXEC() (which would call regexec_flags());

4) In embed.fnc, regexec_flags()'s strend parameter is declared as
   NN rather than EPTR, so it doesn't get the assert added.

So very little code was actually using pregexec().

This commit, for now, changes pregexec()'s strend parameter from EPTR to
EPTRQ, which has the net effect of allowing zero-length strings to be
passed, and thus fixes the CPAN issue.

But longer term, we need to decide: is the general logic for EPTR wrong?
Should the assert be SPTR <= EPTR? And should EPTR be applied to
regexec_flags()'s strend parameter too?
2025-12-04 18:40:52 +00:00