83159 Commits

Author SHA1 Message Date
Karl Williamson
d9c4e67401 regcharclass.pl: Fix typo in comment 2025-10-12 17:12:49 -06:00
Karl Williamson
9fc9ec2818 Change invlist function names to be legal
This continues the process started in #23592 to change names with
leading underscores to be legal C.  See that p.r. or
4bb3572f7a1c1f3944b7f58b22b6e7a9ef5faba6 for extensive discussion.

This commit simply moves the leading underscore to be trailing
2025-10-12 16:56:21 -06:00
Karl Williamson
63ec64f263 Merge branch 'Assert string ptrs in-bounds' into blead
There are a bunch of functions that are passed pointers to two positions
in a string. These commits allow you to declare these in embed.fnc, and
have an assert like (s < e) generated that is automatically placed in
the PERL_ARGS_ASSERT for the function.  Many entries in embed.fnc are
changed to use this new capability.

This is extended for functions where it should instead be assert(s <= e)
and assert(s <= cur)
2025-10-12 13:58:37 -06:00
Karl Williamson
a02324bb8a embed.fnc: Add EPTRQ constraints
Generally, a pointer to a string upper bound actually is to one beyond
the actual final byte in the string.  This is sanctioned by the C
Standard, and allows you to just subtract the lower bound from it to get
its length, without having to add 1.

But some functions are written to tolerate the upper bound pointer being
set to the actual final byte.  The EPTRQ constraint in embed.fnc is used
for those; the assertion becomes 'l <= u' instead of strictly less-than.

This commit is the first to use this type of constraint, and it applies
it only to those functions whose documentation or behavior clearly
indicate this is expected.

I removed now redundant asserts that were in the functions, and now are
included in the ARGS_ASSERT macros

There's a dozen-ish ones where that isn't true.  And they need to be
investigated further before deciding their disposition.
2025-10-12 13:57:57 -06:00
Karl Williamson
45ea12db26 embed.fnc: Add MPTR constraints
This is the first use of the new MPTR constraint that is used to
generate an assertion that a pointer is somewhere in the middle of a
string.

I removed now redundant asserts that were in the functions, and now are
included in the ARGS_ASSERT macros
2025-10-12 13:57:57 -06:00
Karl Williamson
e18f23d735 embed.fnc: Add ptr assertions for apparently non-problematic
I went through the declarations in embed.fnc and added PTR constraints
for all the ones that looked to have pointers to the beginning and end
of a string.  I then ran the test suite, and reverted any that had
problems.

Then I looked at the code for each one remaining to see if it was
equipped to handle the case where the end == the beginning, and removed
those.

This is the result.  Testing in the field may reveal others that the
test suite missed; we can fix those as they occur.

I removed now redundant asserts that were in the functions, and now are
included in the ARGS_ASSERT macros
2025-10-12 13:57:56 -06:00
Karl Williamson
752f9267bf Try out new asserts in a couple cases
This uses the previous commit's new abilities on a couple of sample
functions, so you can see the changes it makes in two small bites.
2025-10-12 13:57:56 -06:00
Karl Williamson
1628b08aeb regen/embed.pl: Add ability to assert(s < e)
Where s is a pointer into a string, and e is the end of it.
2025-10-12 13:57:56 -06:00
Karl Williamson
c0125f32ec embed.fnc: Comments only
This:

* reorders some comments to make more sense
* makes minor clarifications
* removes comments that no longer make sense
* adds comments about moving ARGS_ASSERT macros to the top of their
  functions when the code around them gets changed anyway.
2025-10-12 13:57:56 -06:00
Karl Williamson
cdd132be41 regen/embed.pl: Comments/white-space
Wrap to fit in 80 column terminal window
2025-10-12 13:57:56 -06:00
Karl Williamson
42c9bbd124 regen/embed.pl: Remove redundant push 2025-10-12 13:57:56 -06:00
Karl Williamson
3a7b25bc8b Move some ARGS_ASSERT macros to function start
Historically the asserts had to be placed after any declarations
because of limitations in the C89 Standard that have been removed in C99
which we are now following.

Placing the assertions at the function beginning is clearer, and stops
any issues with the code below it using a variable prior to its
assertion.
2025-10-12 13:53:12 -06:00
Karl Williamson
43eccc533f embed.fnc: Change NULLOK to NN for several functions
Inspection showed these were wrongly categorized
2025-10-12 13:53:12 -06:00
Karl Williamson
e8829bd6d6 Fix grammar in a comment 2025-10-11 10:54:20 -06:00
Karl Williamson
7a47da9dc1 perlapi: Clarify delimcpy() entry 2025-10-11 10:54:20 -06:00
Richard Leach
4e66795307 Perl_newSVobject - adjusted for the default values
`newSV_type(SVt_PVOBJ)` does the following initialization:
* `ObjectMAXFIELD(sv) = -1;`
* `ObjectFIELDS(sv) = NULL;`

This commit makes two changes to `Perl_newSVobject` reflecting that:

1. There's no need for `Perl_newSVobject` to set either of these fields
if `fieldcount` is zero, so that line is coverted into a DEBUGGING
assert()` and one added for `ObjectMAXFIELD(sv)` for completeness.

2. When `fieldcount` is non-zero, setting `ObjectMAXFIELD(sv)` prior to
the `Newx()` is more likely to result in the compiler realising that
it only needs to do one `ObjectMAXFIELD(sv)` STORE rather than two.
2025-10-10 23:39:56 +01:00
Richard Leach
86ccb03763 perlclass.pod - remove mention of :writer from the TODO section
As noted earlier in the file, this has been implemented and there don't
seem to be any breaking changes planned.
2025-10-10 22:02:10 +01:00
sisyphus
201ee5d599 [Win32] Define I_STDCKDINT and $Config{i_stdckdint} when appropriate.
For context and further info see:
https://github.com/Perl/perl5/pull/23703
2025-10-09 14:39:01 -06:00
Elvin Aslanov
a816864f53 .gitattributes: *.inc recognized as Pawn
Prevent that from happening in GH language stats.

It seems only `Math-BigInt` tests use `*.inc` for Perl code

https://github.com/search?q=repo%3APerl%2Fperl5%20path%3A*.inc&type=code
2025-10-08 17:57:38 -06:00
Karl Williamson
bed34e3c7d perlintern: Consolidate all deprecate() forms
This removes redundancy in the pod, and makes it easier for the reader
to see the similarities and differences between the forms.
2025-10-08 16:47:08 -06:00
Karl Williamson
28873a5238 perlapi: Consolidate the sv_eq and svstr_eq entries
These functions do the same thing, differing in details.  Consolidation
makes perlapi more compact, and makes it easier for the reader to see
the similarities and differences between the functions.

Note that the cryptic sentence "It correctly handles the UTF8 flag" in
the sv_streq entry has been removed.  It turns out that meant that the
code looks at the UTF8ness of each SV, except when 'use bytes' is in
effect.
2025-10-08 16:46:46 -06:00
Paul "LeoNerd" Evans
ef56cbf1eb Move signatures compilation failure tests to t/lib/croak/signatures
It's better to reuse the standard croak test infrastructure, than put
lots of ad-hoc uses of `eval` and assertions on the value of `$@`
afterwards in the regular signatures.t file.
2025-10-08 16:17:10 +01:00
Paul "LeoNerd" Evans
153ee16033 Recognise a # PREAMBLE directive in a t/lib file
This allows a test file to begin with a common pragma line or other
setup code and avoid having to repeat that setup across every individual
test block in the file.
2025-10-08 16:17:10 +01:00
Paul "LeoNerd" Evans
5a425b64b8 Ignore 'compilation failed' line when running t/croak tests
This final line of output is often repeated across many tests, but its
exact details aren't overly interesting from a testing perspective. It's
easier just to ignore it in the output and then not have to rely on
testing it all the time.
2025-10-08 09:59:07 +01:00
Paul "LeoNerd" Evans
a17dbf92aa Indentation/whitespace fixes in t/test.pl
Purely syntax, no change in behaviour
2025-10-08 09:59:07 +01:00
Karl Williamson
af48eb611a Inline hv_common_key_len()
This tiny function is called as an intermediary from several frequently
used macros.
2025-10-07 18:53:56 -06:00
Karl Williamson
b4df6841d0 hv.h: Slight simplification of hv_fetch() macro
I think this is easier to read
2025-10-07 18:53:56 -06:00
Karl Williamson
656be9b021 toke.c: Replace for() with simpler do while()
It is a bit simpler
2025-10-07 11:48:47 -06:00
Karl Williamson
cdde901d86 toke.c: Avoid a loop iteration
By using the output of the first macro, and skipping ahead in the parse
string, we avoid reparsing the same bytes.
2025-10-07 11:48:47 -06:00
Karl Williamson
690e285d14 toke.c: Convert for(;;;) to simpler while()
isSPACE only matches single-byte characters; no need to be concerned
with UTF-8ness
2025-10-07 11:48:47 -06:00
Karl Williamson
526049b8eb toke.c: strlen returns size_t, not int 2025-10-07 11:48:47 -06:00
Karl Williamson
59bca40fd0 S_scan_ident: Convert parameter to bool
All calls to it set it to TRUE or FALSE
2025-10-07 11:48:47 -06:00
Karl Williamson
6ceb5e3137 toke.c: Change name of static function
'uni' commonly is short for Unicode.  Here, it was short for 'unary',
which I found highly confusing.

This also changes the name of a formal parameter to also not be 'uni'
when 'unary' is meant.
2025-10-07 11:48:47 -06:00
Karl Williamson
1b20140b9a toke.c: Convert sizeof() calls to use more mnemonic
The length of a constant literal is STRLENs
The end position of a C array is C_ARRAY_END
The number of elements in a C array is C_ARRAY_LENGTH
2025-10-07 11:48:47 -06:00
Karl Williamson
c3ebe61dd8 toke.c: Change S_scan_ident parameter
Change it from being an array length, to being a pointer to the ending
position of the array.  This makes this function consistent with most of
the others in this file.

It allows us to usually use C_ARRAY_END() to wrap the parameter, which
simplifies some expressions,
2025-10-07 11:48:47 -06:00
Karl Williamson
9f0a1b691f toke.c: Change S_scan_word parameter
Change it from being an array length, to being a pointer to the ending
position of the array.  This makes this function consistent with most of
the others in this file.

It allows us to usually use C_ARRAY_END() to wrap the parameter, which
simplifies some expressions,
2025-10-07 11:48:47 -06:00
Karl Williamson
5b7224a9ee perlapi: Reword sv_numeq entry
This is more compact and, I believe, readable than before
2025-10-07 10:26:21 -06:00
Karl Williamson
5b6ac6112e perlapi: Combine hv_fetch_ent with other hv_fetch entries 2025-10-07 08:21:08 -06:00
Karl Williamson
1d1db97270 test.pl: Always set up (simpler) watchdog END block
This commit removes the existing END blocks that vary depending on the
type of timer being used, and replaces them with a single END block that
always exists, and simply calls watchdog(0).  This already cancels
whatever watchdogs are in place, doing nothing if none are.

Spotted by Tony Cook

Even though a test file should clear every timer before exit, this makes
sure it happens.
2025-10-07 08:20:23 -06:00
Karl Williamson
3533239736 test.pl: Calling watchdog cancels existing ones
This enhances the code to work on cases like:

watchdog(5);
sleep 4;
watchdog(10);
sleep 8;

Prior to this commit, you had to explicitly cancel an existing watchdog
before setting a new one.

As a result of this commit, all possible wathdog variables get undef'd
early.  This makes later undef calls redundant, so they are removed.

Suggested by Tony Cook
2025-10-07 08:20:23 -06:00
Karl Williamson
dcdb676b23 test.pl: Harden watchdog against glitches
Only one type of watchdog timer supposedly can exist.  But I can see the
possibility that a temporary glitch in the system caused a fallback type
to be used.  This commit simply makes sure that when cancelling,
anything out there gets cancelled, instead of assuming there's just one
possibility.
2025-10-07 08:20:23 -06:00
Karl Williamson
c240d36c55 test.pl: Don't assume existing watchdog uses alarm()
The fallback method of setting a watchdog timer is to use alarm().
Prior to this commit, the code presumed that if it wasn't one of the
other possibilities, it must be this one.  This is a valid assumption
currently, but future commits will change that.  Prepare for them with
this commit.
2025-10-07 08:20:23 -06:00
Karl Williamson
abdf59c559 test.pl: Change variable name
The next commit changes things, so that some people may find that after
that, the current name would be misleading or confusing.
2025-10-07 08:20:23 -06:00
Karl Williamson
e19d1bb2f3 test.pl: Try alarm if can't start watchdog on Win/VMS
Prior to this commit, the code gave up immediately if it tried
unsuccessfully to use a watchdog thread.  But the alarm method is still
available.  Drop down to try it.
2025-10-07 08:20:23 -06:00
Karl Williamson
ac78c4bb6c test.pl: Don't use watchdog thread unless safe signals
In the thread documentation, I noticed that unsafe signals preclude
killing threads with a signal.  But this is the normal method for
clearing a watchdog timer under threads.  I doubt that people are
compiling with PERL_OLD_SIGNALS these days, so I didn't check for that,
but it's easy enough to check for the environment variable that does the
same thing at runtime.
2025-10-07 08:20:23 -06:00
Karl Williamson
318cb22148 test.pl: Clarify some comments, ternary, white space
Parenthesize the ternary conditional for clarity

Change some indentation, mostly in preparation for later commits
2025-10-07 08:20:23 -06:00
Branislav Zahradník
412b9d48fc [parser] Decompose barestmt -> bare_statement_yadayada 2025-10-07 15:23:22 +02:00
Branislav Zahradník
37f6bc88dc [parser] Decompose barestmt -> bare_statement_while 2025-10-07 15:23:22 +02:00
Branislav Zahradník
4810f9b72f [parser] Decompose barestmt -> bare_statement_when 2025-10-07 15:23:22 +02:00
Branislav Zahradník
192a22b2ce [parser] Decompose barestmt -> bare_statement_utilize 2025-10-07 15:23:22 +02:00