This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
2 years agoperlapi: Fix misspelling
Karl Williamson [Mon, 2 May 2022 20:27:19 +0000 (14:27 -0600)]
perlapi: Fix misspelling

2 years agoautodoc.pl: A source is perlxs.pod
Karl Williamson [Mon, 2 May 2022 19:54:27 +0000 (13:54 -0600)]
autodoc.pl: A source is perlxs.pod

This was meant to be looked at, but wasn't.  It's skipping cpan, dist,
and ext, which it really should be, because we don't have much control
over those.

The comments indicated it expected to get generated files from
lib/ instead, but those wouldn't be in MANIFEST, so weren't getting
looked at.  And it's not a good idea to look for them anyway, as one
could get relicts.  Instead create an exception list of pods that could
have API elements that are documented.

The only current file on that list is what becomes lib/perlxs.pod

2 years agoDocument CvDEPTH
Karl Williamson [Wed, 22 Jul 2020 22:11:48 +0000 (16:11 -0600)]
Document CvDEPTH

2 years agoperlapi: Consolidate entries for Perlio functions
Karl Williamson [Fri, 29 Apr 2022 17:05:00 +0000 (11:05 -0600)]
perlapi: Consolidate entries for Perlio functions

Group all these together to make for a more compact and clear
representation.

2 years agoSort PerlIO entries in pod, embed.fnc
Karl Williamson [Sun, 24 Apr 2022 17:33:19 +0000 (11:33 -0600)]
Sort PerlIO entries in pod, embed.fnc

This has no effect on any code or pod display, but makes it easier to
find them for maintenance, and makes the next commit have a smaller
difference listing

2 years agoMaintainers.pl: comment customized removal criteria
Karl Williamson [Fri, 29 Apr 2022 16:10:42 +0000 (10:10 -0600)]
Maintainers.pl: comment customized removal criteria

2 years agoDocument PERLIO_FUNCS_(DECL|CAST)
Karl Williamson [Thu, 27 Aug 2020 15:28:17 +0000 (09:28 -0600)]
Document PERLIO_FUNCS_(DECL|CAST)

2 years agoupdate const sub docs for stuff that now croaks 19674/head
David Mitchell [Thu, 28 Apr 2022 10:29:04 +0000 (11:29 +0100)]
update const sub docs for stuff that now croaks

GH #19664

Some types of constant sub candidates emitted deprecation warnings
from 5.22 onwards, and croaked from 5.32 onwards. The perlsub docs knew
about the warnings; this commit updates them for the croaks.

At the same time, change the code examples to no longer use the RT
ticket number of the original issue. For one thing, RT numbers are
obsolete, and for another, it was being too cute - setting a variable to
one less than the RT number, then showing that the constant value
hadn't been incremented by the $x++. And using the number for the sub
names. The examples just became noisy with random 5-digit numbers
everywhere.

2 years agolib/experimental.pm is no longer customized
Leon Timmermans [Mon, 25 Apr 2022 22:27:57 +0000 (00:27 +0200)]
lib/experimental.pm is no longer customized

2 years agoperlapi: Document SvPVXtrue
Karl Williamson [Thu, 8 Oct 2020 19:58:48 +0000 (13:58 -0600)]
perlapi: Document SvPVXtrue

2 years agoNote various symbols are documented in perlhacktips
Karl Williamson [Sat, 17 Oct 2020 17:23:27 +0000 (11:23 -0600)]
Note various symbols are documented in perlhacktips

2 years agoperlapi: Rmv duplicate entries
Karl Williamson [Sun, 24 Apr 2022 00:38:13 +0000 (18:38 -0600)]
perlapi: Rmv duplicate entries

These entries that are minor variants of each other were consolidated
into one over-arching entry, but the individual ones were inadvertently
retained, leading to duplicate information.

2 years agoperlembed: Note various symbols are documented here
Karl Williamson [Wed, 7 Oct 2020 23:54:41 +0000 (17:54 -0600)]
perlembed: Note various symbols are documented here

2 years agoPut back the words about no VERSION not undoing feature bundles, which got lost in...
Paul "LeoNerd" Evans [Wed, 20 Apr 2022 23:30:52 +0000 (00:30 +0100)]
Put back the words about no VERSION not undoing feature bundles, which got lost in the earlier reƤrrangement

2 years agoUse signatures in perlunicook example
Paul "LeoNerd" Evans [Wed, 20 Apr 2022 23:26:10 +0000 (00:26 +0100)]
Use signatures in perlunicook example

2 years agouse signature in perlthrtut to further tidy the example, while we're there anyway
Paul "LeoNerd" Evans [Wed, 20 Apr 2022 22:26:08 +0000 (23:26 +0100)]
use signature in perlthrtut to further tidy the example, while we're there anyway

2 years agoPoint directly to L<...|perlfunc/use VERSION> when mentioning the syntax in other...
Paul "LeoNerd" Evans [Wed, 6 Apr 2022 13:01:13 +0000 (14:01 +0100)]
Point directly to L<...|perlfunc/use VERSION> when mentioning the syntax in other docs

2 years agoReplace 'use strict; use warnings;' with 'use VERSION' in docs code examples
Paul "LeoNerd" Evans [Wed, 6 Apr 2022 11:47:26 +0000 (12:47 +0100)]
Replace 'use strict; use warnings;' with 'use VERSION' in docs code examples

2 years agoReplace docs examples of 'use NUMBER' with proper v-strings
Paul "LeoNerd" Evans [Wed, 6 Apr 2022 11:45:07 +0000 (12:45 +0100)]
Replace docs examples of 'use NUMBER' with proper v-strings

2 years agoMore wording in perldsc.pod about 'use VERSION'
Paul "LeoNerd" Evans [Wed, 6 Apr 2022 11:42:13 +0000 (12:42 +0100)]
More wording in perldsc.pod about 'use VERSION'

2 years agoPoint out that 'indirect' is only availble before 'use v5.36'
Paul "LeoNerd" Evans [Wed, 6 Apr 2022 10:48:03 +0000 (11:48 +0100)]
Point out that 'indirect' is only availble before 'use v5.36'

2 years agoAdd some wording about 'use VERSION' to perlstyle.pod
Paul "LeoNerd" Evans [Wed, 6 Apr 2022 10:33:52 +0000 (11:33 +0100)]
Add some wording about 'use VERSION' to perlstyle.pod

2 years agoMention that 'use VERSION' enables strict + warnings + others in perlintro.pod
Paul "LeoNerd" Evans [Mon, 4 Apr 2022 17:59:53 +0000 (18:59 +0100)]
Mention that 'use VERSION' enables strict + warnings + others in perlintro.pod

2 years agoSplit docs for 'use VERSION' into its own section of perlfunc.pod
Paul "LeoNerd" Evans [Wed, 6 Apr 2022 12:43:43 +0000 (13:43 +0100)]
Split docs for 'use VERSION' into its own section of perlfunc.pod

Also add more wording

2 years agoregcomp.c - silence build warning under NO_TAINT_SUPPORT
Yves Orton [Fri, 22 Apr 2022 02:06:35 +0000 (04:06 +0200)]
regcomp.c - silence build warning under NO_TAINT_SUPPORT

The variable 'oldtainted' is unused when NO_TAINT_SUPPORT is defined.
This patch ifdefs it out of the compiled code.

This should resolve GH Issue #19654
See: https://github.com/Perl/perl5/issues/19654

2 years agoRevert "Porting/makerel Make EBCDIC files writable"
Karl Williamson [Wed, 20 Apr 2022 23:53:07 +0000 (17:53 -0600)]
Revert "Porting/makerel Make EBCDIC files writable"

This reverts commit ecef3a65d2c34ab6acbc8d1e8e17f5f41e307729.

This commit stems from an earlier mechanism for creating EBCDIC
releases, but no longer makes sense, leaving all files user-writable.
The intent was to do so just on EBCDIC builds, as at one time all files
were translated into EBCDIC on the destination box.  But nowadays, the
translation is done in makerel itself, before the creation of the tar.

After this commit, files are read-only except for those on the internal
exception list.

Spotted by Steve Hay.

2 years agoregen/mph.pl - make sure the author of _squeeze() has a commit in the log
Ilya Sashcheka [Thu, 21 Apr 2022 05:07:52 +0000 (07:07 +0200)]
regen/mph.pl - make sure the author of _squeeze() has a commit in the log

This commit is actually by the committer, and is intended to ensure that
someone looking for what the author wrote can find it. It took me a while
to get a email address for him or I would have done this in eda35008b17e739922
which is where his work on the _squeeze() split key algorithm was added.
Credit where credit is due and all of that. Thanks Ilya.

2 years agoFix SHA256 digests produced by Porting/makerel on Windows
Steve Hay [Wed, 20 Apr 2022 21:13:21 +0000 (22:13 +0100)]
Fix SHA256 digests produced by Porting/makerel on Windows

2 years agoPrepare Module-CoreList for 5.35.12
Steve Hay [Wed, 20 Apr 2022 21:10:09 +0000 (22:10 +0100)]
Prepare Module-CoreList for 5.35.12

2 years agoBump version for 5.35.12
Steve Hay [Wed, 20 Apr 2022 21:02:58 +0000 (22:02 +0100)]
Bump version for 5.35.12

2 years agoNew perldelta for 5.35.12
Steve Hay [Wed, 20 Apr 2022 20:56:39 +0000 (21:56 +0100)]
New perldelta for 5.35.12

2 years agoTick off release
Steve Hay [Wed, 20 Apr 2022 20:46:59 +0000 (21:46 +0100)]
Tick off release

2 years agoAdd epigraph for 5.35.11
Steve Hay [Wed, 20 Apr 2022 20:46:12 +0000 (21:46 +0100)]
Add epigraph for 5.35.11

2 years agoepigraphs.pod: Correct 5.35.10 version and add link
Steve Hay [Wed, 20 Apr 2022 20:42:32 +0000 (21:42 +0100)]
epigraphs.pod: Correct 5.35.10 version and add link

2 years ago5.35.11 today v5.35.11
Steve Hay [Wed, 20 Apr 2022 18:19:43 +0000 (19:19 +0100)]
5.35.11 today

2 years agoFinalize perldelta
Steve Hay [Wed, 20 Apr 2022 18:16:38 +0000 (19:16 +0100)]
Finalize perldelta

2 years agoUpdate Module-CoreList for 5.35.11
Steve Hay [Wed, 20 Apr 2022 18:11:09 +0000 (19:11 +0100)]
Update Module-CoreList for 5.35.11

2 years agoperldelta - Update for 5.35.11
Steve Hay [Wed, 20 Apr 2022 18:09:06 +0000 (19:09 +0100)]
perldelta - Update for 5.35.11

2 years agoFix typos in perlfunc
Steve Hay [Wed, 20 Apr 2022 17:34:02 +0000 (18:34 +0100)]
Fix typos in perlfunc

2 years agoskip 2 tests if built with DEBUGGING and no taint support
Neil Bowers [Wed, 20 Apr 2022 15:52:27 +0000 (16:52 +0100)]
skip 2 tests if built with DEBUGGING and no taint support

2 years agofixed typo in taint_support comments, shoulda been "with" not "without"
Neil Bowers [Wed, 20 Apr 2022 15:21:37 +0000 (16:21 +0100)]
fixed typo in taint_support comments, shoulda been "with" not "without"

2 years agoFix Porting\updateAUTHORS.pl to not output CRLFs on Windows
Steve Hay [Wed, 20 Apr 2022 13:14:14 +0000 (14:14 +0100)]
Fix Porting\updateAUTHORS.pl to not output CRLFs on Windows

2 years agoAdd/correct/delete notes of CUSTOMIZED files in blead
Steve Hay [Wed, 20 Apr 2022 13:04:34 +0000 (14:04 +0100)]
Add/correct/delete notes of CUSTOMIZED files in blead

2 years agoAdded perldelta entry on support for building a taint-free perl
Neil Bowers [Thu, 17 Mar 2022 09:35:25 +0000 (09:35 +0000)]
Added perldelta entry on support for building a taint-free perl

2 years agoDoc changes to reflect that perl might not support taint
Neil Bowers [Wed, 16 Mar 2022 23:50:01 +0000 (23:50 +0000)]
Doc changes to reflect that perl might not support taint

The central doc change is in perlsec.pod. This not only explains
that you can build a perl that doesn't support taint,
but shows how you can check whether your perl supports taint or not.
The other doc changes are mainly to note that taint might not
be supported, and to refer the reader to perlsec for more details.

2 years agochanges to core module tests to handle perl that doesn't support taint
Neil Bowers [Wed, 16 Mar 2022 23:49:04 +0000 (23:49 +0000)]
changes to core module tests to handle perl that doesn't support taint

2 years agochanges to perl tests to handle perl without taint support
Neil Bowers [Wed, 16 Mar 2022 23:48:22 +0000 (23:48 +0000)]
changes to perl tests to handle perl without taint support

2 years agoAdd Configure question for taint support
Neil Bowers [Wed, 16 Mar 2022 23:43:53 +0000 (23:43 +0000)]
Add Configure question for taint support

This adds a Configure question for whether you want taint support.
It defaults to "yes", so that ./Configure -des will build a perl
which supports taint in the usual way.
If you say "no", then perl is compiled with -DSILENT_NO_TAINT_SUPPORT
so that taint features silently do nothing.

I've submitted a separate pull request on perl/metaconfig,
which adds the underlying metaconfig unit for this question,
which was used to build this Configure script.

2 years agoRevert "dist/PathTools - add missing entries to Changes"
Yves Orton [Wed, 20 Apr 2022 04:52:32 +0000 (06:52 +0200)]
Revert "dist/PathTools - add missing entries to Changes"

This reverts commit 33349b53c2e4df3292c79435e54fc98824e4cba8.

This should have been pushed to a branch not to blead. Fat fingers.
Sorry folks.

2 years agoRevert "mg.c, Cwd.pm - Empty path is the same as "." which is forbidden under taint"
Yves Orton [Wed, 20 Apr 2022 04:44:08 +0000 (06:44 +0200)]
Revert "mg.c, Cwd.pm - Empty path is the same as "." which is forbidden under taint"

This reverts commit 5ede4453c4877110eb5214ff400c173210b101b1.

I messed up and pushed it to blead not to the PR branch I meant to push
it. Thanks to xenu for noticing. This needs a smoke before it should be
applied.

2 years agoNormalize: Use ppport.h
Karl Williamson [Tue, 19 Apr 2022 18:11:48 +0000 (12:11 -0600)]
Normalize: Use ppport.h

This commit changes Unicode::Normalize to use ppport.h.

All modules that convert from UTF-8 should be using the latest ppport.h,
so that they get the latest security checking available, which ppport.h
backports to 6.1.

This commit converts the module to use the utf8_to_uvchr_buf() method of
translation from UTF-8, instead of a method that allows one to pass
flags as to what code points to not accept.  Since the flags parameter
it was passing was zero, this is equivalent to utf8_to_uvchr_buf().

2 years agoSocket: getnameinfo() behaves differently on z/OS
Karl Williamson [Mon, 18 Apr 2022 16:48:23 +0000 (10:48 -0600)]
Socket: getnameinfo() behaves differently on z/OS

POSIX says at least one of the parameters must be non-NULL.  z/OS
requires both to be.

It would be better to have a Configure probe for this, but this is the
first non-conforming OS we have found, and at this stage, there aren't
likely to be any others that Perl might eventually be ported to.  Should
some come along, a probe could be added at that time.

2 years agolibnet: os390 isn't necessarily EBCDIC
Karl Williamson [Fri, 7 Jan 2022 00:37:16 +0000 (17:37 -0700)]
libnet: os390 isn't necessarily EBCDIC

It turns out that z/OS (the new name for os390) can run in ASCII mode.
Therefore the test for EBCDIC must not be based on the OS itself, but
the character set in use.

2 years agopodlators: Fixes for EBCDIC
Karl Williamson [Fri, 9 Jul 2021 01:24:43 +0000 (19:24 -0600)]
podlators: Fixes for EBCDIC

2 years agopodlators: z/OS isn't necessarily EBCDIC
Karl Williamson [Mon, 18 Apr 2022 03:18:30 +0000 (21:18 -0600)]
podlators: z/OS isn't necessarily EBCDIC

(nor is EBCDIC necessarily z/OS).  Fix conditional

2 years agohandy.h: space isn't graph
Karl Williamson [Thu, 7 Apr 2022 18:39:55 +0000 (12:39 -0600)]
handy.h: space isn't graph

2 years agohints/os390.sh: #define os390
Karl Williamson [Fri, 8 Apr 2022 17:00:38 +0000 (11:00 -0600)]
hints/os390.sh: #define os390

This OS has some unique qualities that are hard to test for in
Configure, and aren't likely to go away.

2 years agomg.c, Cwd.pm - Empty path is the same as "." which is forbidden under taint
Yves Orton [Tue, 19 Apr 2022 15:55:40 +0000 (17:55 +0200)]
mg.c, Cwd.pm - Empty path is the same as "." which is forbidden under taint

Having a relative path, including ".", is forbidden under taint. On *nix
an empty PATH or an empty PATH component is equivalent to a PATH of ".",
so they should be forbidden as well.

Note that on Windows the current working directory is ALWAYS checked
first if you try to execute something that does not specify its path,
regardless of the PATH.

I do not know what happens on VMS and I do not have access to a
VMS environment to test. There are totally different codepaths for
VMS as well. This patch does not (or rather should not) change
behavior for VMS.

Note this includes a version bump for all modules in dist/PathTools

2 years agodist/PathTools - add missing entries to Changes
Yves Orton [Wed, 20 Apr 2022 01:44:57 +0000 (03:44 +0200)]
dist/PathTools - add missing entries to Changes

Versions 3.82 through 3.84 were not document in Changes.

2 years agomg.c - move const initialization out of loop
Yves Orton [Tue, 19 Apr 2022 15:43:09 +0000 (17:43 +0200)]
mg.c - move const initialization out of loop

The path_sep is not going to change per iteration of the loop, so just
move it out of the loop.

2 years agoregen/mph.pl - add a validation step to build_split_words()
Yves Orton [Tue, 19 Apr 2022 05:54:55 +0000 (07:54 +0200)]
regen/mph.pl - add a validation step to build_split_words()

Exercise an abundance of caution and validate that the buffer and split
point data returned is fit for pupose.

Includes the output of running regen/mk_invlist.pl.

2 years agoregen/mph.pl & mk_invlists.pl - add the "_squeeze" algorithm to produce smaller blobs
Yves Orton [Sun, 17 Apr 2022 13:00:08 +0000 (15:00 +0200)]
regen/mph.pl & mk_invlists.pl - add the "_squeeze" algorithm to produce smaller blobs

The squeeze algorithm produces smaller blobs, 10-20% depending on how it
is used. With the "randomize_squeeze" option enabled it is slower but
produces 20% smaller blobs than the "_simple" strategy we used to use.
With the "randomize_squeeze" option disabled it is about as fast as
"_simple" but produces about 10% smaller blobs. Regardless "_squeeze"
uses more memory than _simple; quite a bit more currently, although that
is unforced and could be changed if required.

    -blob length: 10548
    +blob length: 8635
    ...
    -data size: 69908 (%67.07)
    +data size: 67995 (%65.23)

So it saves 1913 bytes running with this seed. I happened to get lucky
with the seed, depending on the seed used the blob ended up about 8650
bytes.

This algorithm is originally by Ilya Sashcheka, so I have added him to
the AUTHORS file, but unfortunately I no longer have his email address
as we lost touch. It contains many modifications by me.

2 years agoregen/mph.pl & mk_invlists.pl - convert from sub interfaces to OO interfaces
Yves Orton [Sun, 17 Apr 2022 12:46:44 +0000 (14:46 +0200)]
regen/mph.pl & mk_invlists.pl - convert from sub interfaces to OO interfaces

The old sub based API was passing around an awkward number of arguments
and it was becoming difficult to enhance in certain ways. This patch
changes all the "user servicable" functions into methods, and moves the
configuration defaults into the constructor.

Note, not all the functions have been converted, the core routines with
simple interfaces have not been changed. This is OO for the purpose of
encapsulation not inheritance or overloading.

2 years agoregen/mph.pl - tweaks to generated code, put type on its own line
Yves Orton [Sun, 17 Apr 2022 12:43:00 +0000 (14:43 +0200)]
regen/mph.pl - tweaks to generated code, put type on its own line

All the C code we have puts the type on its own line separate from
the function parameter declaration, so follow that style in our
generated file too.

Also show the generator script in the comment that contains metadata
about the file.

2 years agoregen/mph.pl - use $n instead of @$second_level
Yves Orton [Sun, 17 Apr 2022 12:41:39 +0000 (14:41 +0200)]
regen/mph.pl - use $n instead of @$second_level

Same thing but $n is initialized one line above, so use it.

2 years agoregen/mph.pl - remove bogus defaulting for undef vars
Yves Orton [Sun, 17 Apr 2022 12:07:01 +0000 (14:07 +0200)]
regen/mph.pl - remove bogus defaulting for undef vars

This was some kind of thinko and never made sense, prefix
and suffix should never be undefined.

2 years agoregen/mph.pl - move file open logic to a sub
Yves Orton [Sun, 17 Apr 2022 12:04:24 +0000 (14:04 +0200)]
regen/mph.pl - move file open logic to a sub

this makes all the subs affected support a filehandle or filename

2 years agoregen/mph.pl - whitespace fixups
Yves Orton [Sun, 17 Apr 2022 11:54:14 +0000 (13:54 +0200)]
regen/mph.pl - whitespace fixups

This removes trailing whitespace only. No logic changes here at all.

2 years agoregen/mph.pl - rename $smart_blob to $blob across file
Yves Orton [Sun, 17 Apr 2022 11:52:02 +0000 (13:52 +0200)]
regen/mph.pl - rename $smart_blob to $blob across file

$smart_blob is unhelpfully specific, rename to more generic $blob

2 years agoregen/mph.pl - move split key logic out of make_mph_from_hash
Yves Orton [Sun, 17 Apr 2022 11:40:15 +0000 (13:40 +0200)]
regen/mph.pl - move split key logic out of make_mph_from_hash

The logic of calling build_split_words() twice, once in "normal" mode
and once in "preproces" mode does not belong in regen/mph.pl. So this
patch renames build_split_words() to _build_split_words() and create
a new sub called build_split_words() that implements the "call it
twice" logic.

For consistency the arguments are rearranged as well so the $preprocess
argument is last, as build_split_words() now does not have a $preproces
argument, as only _build_split_words() needs it.

2 years agoregen/mph.pl - fixup wording in comment to be grammatical
Yves Orton [Sun, 17 Apr 2022 11:26:42 +0000 (13:26 +0200)]
regen/mph.pl - fixup wording in comment to be grammatical

The original wording of this paragraph was a bit clumsy and not
grammatically correct. This fixes it.

2 years agoregen/mph.pl - change fnv1a_32() to _fnv1a_32() as it is not public
Yves Orton [Sun, 17 Apr 2022 11:23:32 +0000 (13:23 +0200)]
regen/mph.pl - change fnv1a_32() to _fnv1a_32() as it is not public

This function is not part of the "public" API for this script/package
and might be removed in the future if we needed to, so mark it as
private with a leading underscore.

2 years agoregen/mph.pl - fixup die that is issued if we can't solve this hash
Yves Orton [Sun, 17 Apr 2022 11:18:42 +0000 (13:18 +0200)]
regen/mph.pl - fixup die that is issued if we can't solve this hash

The old code was bit messed up, but I didn't notice because it doesn't
happen with our current data. But in theory it could. It is possible
that fnv1a has a multicollision vulnerability as it is not a secure
hash, so changing the seed wouldn't help. For now we can assume it does
not.

2 years agoregen/mph.pl - Clean up diagnostics logic, allow DEBUG from env.
Yves Orton [Thu, 14 Apr 2022 07:12:20 +0000 (09:12 +0200)]
regen/mph.pl - Clean up diagnostics logic, allow DEBUG from env.

Be silent unless requested to. If DEBUG>1 produce lots of output,
if DEBUG==1 produce some basic information about what is going on.

2 years agoregen/mph.pl - use more efficient logic in build_perfect_hash()
Yves Orton [Thu, 14 Apr 2022 06:26:49 +0000 (08:26 +0200)]
regen/mph.pl - use more efficient logic in build_perfect_hash()

This patch greatly reduces the amount of work we have to do to find a
bucket for keys whose first level hash does not produce any collisions.

We have two cases, those items whose $hash2 is higher than $MAX_SEED2
and those items whose $hash2 is smaller than or equal to $MAX_SEED2.

For the former case we use a similar but streamlined process as we do
for keys whose first level hash produces collisions. For the latter case
we can trivially map the items into any bucket we choose.

2 years agoregen/mph.pl - eliminate the need to use goto
Yves Orton [Thu, 14 Apr 2022 05:01:49 +0000 (07:01 +0200)]
regen/mph.pl - eliminate the need to use goto

The goto is confusing, and has the potential to introduce its own bugs
if future changes are not careful, so get rid of it completely and
break build_perfect_hash() into two subs.

2 years agoregen/mph.pl - change $hash argument to $source_hash
Yves Orton [Thu, 14 Apr 2022 04:51:27 +0000 (06:51 +0200)]
regen/mph.pl - change $hash argument to $source_hash

The term 'hash' is overused in this code, rename the $hash argument
to build_perfect_hash() to $source_hash to disambiguate.

2 years agoregen/mph.pl - move bucket info construction log into a sub
Yves Orton [Thu, 14 Apr 2022 04:29:04 +0000 (06:29 +0200)]
regen/mph.pl - move bucket info construction log into a sub

In a follow up patch this logic will get called from more than one place
so move it to a sub so it can be used easily.

2 years agoregen/mph.pl - bucket info storage: remove 'hash', move 'value' logic
Yves Orton [Thu, 14 Apr 2022 04:18:48 +0000 (06:18 +0200)]
regen/mph.pl - bucket info storage: remove 'hash', move 'value' logic

The 'hash' key is totally unused and unneeded so drop it entirely.

The 'value' key can be stored into the bucket info data elsewhere,
strictly speaking it is not needed for the minimal perfect hash
computations, so move it out so that logic can be changed and
simplified in a future patch.

2 years agoregen/mph.pl - add sanity check for idx and value parameters
Yves Orton [Thu, 14 Apr 2022 04:04:33 +0000 (06:04 +0200)]
regen/mph.pl - add sanity check for idx and value parameters

If either are missing then something has gone badly wrong and we should
stop processing immediately.

2 years agoregen/mph.pl - convert loop to use block form and add comment
Yves Orton [Thu, 14 Apr 2022 04:03:13 +0000 (06:03 +0200)]
regen/mph.pl - convert loop to use block form and add comment

Using the comma operator to separate statments is fine on a one liner,
but so much in a script that is part of perl regen processes. IMO.

2 years agoregen/mph.pl - enable fatal warnings
Yves Orton [Thu, 14 Apr 2022 03:59:20 +0000 (05:59 +0200)]
regen/mph.pl - enable fatal warnings

If this script warns then there is something very wrong and it should be
fixed, so just die immediately. Especially as if it is broken it might
just *spew* warnings, which is annoying.

2 years agoregen/mph.pl - remove unused var
Yves Orton [Thu, 14 Apr 2022 03:58:18 +0000 (05:58 +0200)]
regen/mph.pl - remove unused var

2 years agoregen/mph.pl - perltidy file for style consistency
Yves Orton [Thu, 14 Apr 2022 03:55:15 +0000 (05:55 +0200)]
regen/mph.pl - perltidy file for style consistency

and document the perltidy options used so any future maintainers
can follow the style of the file more easily.

2 years agoregen/mph.pl - remove $max_h check in build_perfect_hash()
Yves Orton [Thu, 14 Apr 2022 03:42:41 +0000 (05:42 +0200)]
regen/mph.pl - remove $max_h check in build_perfect_hash()

Not sure why I put this in to the original code, it is a check that
would be relevant to a PRNG but is not relevant to this use case. So
this patch removes it.

2 years agoregen/mph.pl - specify which fnv we are using
Yves Orton [Thu, 14 Apr 2022 03:38:34 +0000 (05:38 +0200)]
regen/mph.pl - specify which fnv we are using

This documents and specifies which FNV we are using. Since we are using
fnv1a_32() it also replaces the use of $MASK and replaces it with
U32_MAX. fnv1a_32() would never use anything other U32_MAX, even if
$MASK changed, as obviously it is a 32 bit hash function.

2 years agoregen/mph.pl - replace hard coded literal constants
Yves Orton [Thu, 14 Apr 2022 03:18:25 +0000 (05:18 +0200)]
regen/mph.pl - replace hard coded literal constants

This replaces the various hard coded constants with either named
constants, or vars. It also renames FNV_CONST to FNV32_PRIME in the
generated code as that is its proper name.

2 years agoregen/mk_invlists.pl - add a way to dump the keywords hash for review
Yves Orton [Thu, 14 Apr 2022 01:17:40 +0000 (03:17 +0200)]
regen/mk_invlists.pl - add a way to dump the keywords hash for review

This adds a way to tell mk_invlists.pl to dump the keywords hash so it
can be reviewed, or used for testing or whatnot. A user can define the
env var DUMP_KEYWORDS_FILE to be a file name which will be used to save
the keywords hash to. If the env var is not set the file won't get
written to disk.

Includes regenerated output from running regen/mk_invlists.pl to keep
porting/regen.t happy.

2 years agoregen/mk_invlists.pl - move token_name() sub closer to where it is used
Yves Orton [Thu, 14 Apr 2022 01:15:27 +0000 (03:15 +0200)]
regen/mk_invlists.pl - move token_name() sub closer to where it is used

sub token_name() was injected into the middle of totally unrelated logic
that does not use it. token_name() is a wrapper around sanitize_name()
so move it next to that sub.

Also includes the output from running regen/mk_invlists.pl to keep
porting/regen.t happy.

2 years agoregen/mk_invlists.pl - move require to top of file
Yves Orton [Thu, 14 Apr 2022 01:13:05 +0000 (03:13 +0200)]
regen/mk_invlists.pl - move require to top of file

mk_invlists.pl does a lot and takes a while before it gets to the part
where it requires regen/mph.pl, which means that if there are issues in
it they arent discovered until a fair amount of time elapses, which is
frustrating when debugging. Moving the require to the top means the
script dies early and can be fixed.

Includes a regen of uni_keywords.h and friends as this changes a regen
script which causes regen.t to fail if its output is not up to date.

2 years agoregen/mph.pl - handle split data in make_mph_from_hash()
Yves Orton [Wed, 13 Apr 2022 14:58:04 +0000 (16:58 +0200)]
regen/mph.pl - handle split data in make_mph_from_hash()

Doing it in build_perfect_hash() does not make sense, we might want to
use that function to build a hash that does not need to be split.

2 years agoregen/mph.pl - calculate $length_all_keys in make_mph_from_hash()
Yves Orton [Wed, 13 Apr 2022 14:54:07 +0000 (16:54 +0200)]
regen/mph.pl - calculate $length_all_keys in make_mph_from_hash()

Doing it in build_perfect_hash() just results in duplicated logic
between build_split_words() and build_perfect_hash()

2 years agoregen/mph.pl - rename var $b2 to $new_blob in build_split_words()
Yves Orton [Mon, 11 Apr 2022 10:54:12 +0000 (12:54 +0200)]
regen/mph.pl - rename var $b2 to $new_blob in build_split_words()

$new_blob is more descriptive and less confusing.

2 years agoregen/mph.pl - better diags in build_split_words()
Yves Orton [Mon, 11 Apr 2022 10:49:43 +0000 (12:49 +0200)]
regen/mph.pl - better diags in build_split_words()

This also shows how effective the split process compression has been
by computing what percentage the final blob is compared to the worst
case of naively concatenating all the keys together.

2 years agoregen/mph.pl - fix assignment to be consistent with other assignments.
Yves Orton [Mon, 11 Apr 2022 10:47:40 +0000 (12:47 +0200)]
regen/mph.pl - fix assignment to be consistent with other assignments.

This file uses left hugging assignment operators, this was an exception.

2 years agoregen/mph.pl - do a bit less work in build_split_words()
Yves Orton [Mon, 11 Apr 2022 10:42:37 +0000 (12:42 +0200)]
regen/mph.pl - do a bit less work in build_split_words()

We do not need to check the split point of 0 or of the length of the
string as we do not want empty prefixes (the 0 case) and we have already
checked if the entire string is in the blob already in a earlier check
(the length case). This also initializes the $best_prefix to be the full
$key, and the $best_suffix to be the empty string just in case we cannot
find any split point which would result in the variables being
initialized. This prevents unitialized warnings when we track these
variables in the %appended hash.

2 years agoregen/mph.pl - track added bytes while we process/check the blob
Yves Orton [Mon, 11 Apr 2022 10:39:33 +0000 (12:39 +0200)]
regen/mph.pl - track added bytes while we process/check the blob

It is possible that the $blob grows while we validate it, if so
show how much it grew by and produce some diagnostics about it.
We also track how many passes we have done. With this commit it
is only used to make the new diagnostics a bit cleaner, but we will
use it in more diagnostics later.

2 years agoregen/mph.pl - dont null terminate in preprocess stage
Yves Orton [Mon, 11 Apr 2022 10:26:56 +0000 (12:26 +0200)]
regen/mph.pl - dont null terminate in preprocess stage

Removing the null termination allows us to save about 100 bytes
from the final result.

2 years agoregen/mph.pl - dont use $key when dealing with $part of a key
Yves Orton [Mon, 11 Apr 2022 10:20:08 +0000 (12:20 +0200)]
regen/mph.pl - dont use $key when dealing with $part of a key

In build_split_words() $key is used for the main hash, use
$part instead when we are dealing with part of a key (even
if the $part might equal the $key).

2 years agoregen/mph.pl - remove unused arguments from build_split_words()
Yves Orton [Mon, 11 Apr 2022 10:16:19 +0000 (12:16 +0200)]
regen/mph.pl - remove unused arguments from build_split_words()

These were vestigal from a previous implementation, no point in
leaving them in, and they impact debugging.

As part of this it make sense to rename %res to $res in
build_scalar_words() as it makes it easier to make $old_res= $res
when we retry.