regcomp.c: min len is chars, not bytes

The traditionally-called tricky folds occur because, under /i, a
6-byte/3-character sequence can match a 2-byte/1-character sequence.
The code here has assumed that the delta quantity is measured in bytes
(6-2=4), whereas everywhere else (AFAICT), assumes the measure is to be
in characters (3-2=1).
regen/regcharclass.pl: Add ability for more complex inputs

This adds the capability to get input to this program from another
program, thus allowing essentially arbitrary input.

This will be used in future commits.
regen/regcharclass.pl: Simplify regex

There doesn't need to be a quantifier or capturing on this regex.
Add regen/regcharclass_multi_char_folds.pl

This takes as input the current Unicode character data base, and outputs
lists of the multi-character folds in it, in a form suitable for input
to regen/regcharclass.pl
regen/regcharclass.pl: Generate macros for multi-char fold sequences

These will be used in future commits
regcomp.c: Refactor join_exact() to handle all multi-char folds

join_exact() prior to this commit returned a delta for 3 problematic
sequences showing that the minimum length they match is less than their
nominal length.  It turns out that this is needed for all
multi-character fold sequences; our test suite just did not have the
tests in it to show that.  Tests that do show this will be added in a
future commit, but code elsewhere must be fixed before they pass.
regcomp.c
regexec.c: indent properly and reflow some comments to 80 cols
Fix infinite loop with $tied =~ s/non-utf8/utf8/

Commit 3e462cdc208 fixed bug #41530 (s/non-utf8/utf8/ was not working
properly at all) by upgrading the target and redoing the substitution
if the replacement was utf8 and the target was not.

Commit c95ca9b8cd1 fixed one problem with it calling get-magic too
many times, by checking whether the upgrade caused a string realloca-
tion and only then redoing the substitution.  But it only fixed it
when magic returns a pure ASCII string.

Redoing the substitution meant going back to where the target was
initially stringified and starting again.  That meant calling get-
magic again.

So in those cases where magic returned something other than a UTF8 or
pure ASCII string the substitution restarted and magic would be trig-
gered again, possibly resulting in infinite loops (because it would
have to be upgraded again, resulting a reallocation, and a restart).

This happens with:

• Latin-1 strings
• Copy-on-write non-UTF8 strings
• References that stringify without UTF8

c95ca9b8cd1 also added SvPVX without checking first that it is SvPVX-
able, so a typeglob causes an assertion failure.

It turned out that there were also two other places in pp_subst that
were calling FETCH a second time (the tests I added for the looping/
assertion bugs found this), so I changed them, too.
Add TODO tests for RT#115156
regexec.c: White-space only

Add some spacing for clarity.
regexec.c: Turn test into an assertion

Commit 31c15ce5372b770c3ca899df6cf102f1ed6866ba should have made it so
that the situation of a quantifier {m,n} with m>n never happens.  Remove
the check for it, but replace it with an assertion.
regcomp.c: Slightly relax restriction of SIMPLE nodes

Currently all EXACTish nodes that are SIMPLE must be a single UTF-8
invariant character.  It turns out that the code works not just for
these, but for all Latin1 characters (when the pattern isn't UTF-8)
except the SHARP S under /d folding.

SIMPLE nodes allow for better optimization possibilities, such as CURLY
instead of CURLYM.

There is still a discrepancy in that non-EXACTish nodes that match a
single character, such as the dot (SANY), can be SIMPLE, but EXACTish
nodes have to be just a single byte.
regex: Allow any single char to be SIMPLE

This commit relaxes the previous requirement that an EXACTish node must
contain a single Latin1-range character in order to be considered
SIMPLE.  Now it allows any single character, not just Latin1.

This allows above-Unicode characters to be in optimizations like STAR or
CURLY, instead of having to match with the more complex CURLYM; and it
brings EXACTish nodes in alignment with other SIMPLE nodes, such as
those matching \w or the dot metacharacter, which all along have
supported any code point being SIMPLE
Allow _swash_inversion_hash() to be called in regexec.c

To prevent this very-internal core function from being used by XS
writers, it isn't defined except if the preprocessor indicates it is
compiling certain .c files.  Add regexec.c to the list
Perl_sv_mortalcopy expects a return value.

Courtesy of the OpenVMS C compiler, which said:

SV *
^
%CC-I-MISSINGRETURN, Non-void function "Perl_sv_mortalcopy" does not contain a return statement.
at line number 1206 in file D0:[craig.blead]mathoms.c;1
Merge 2 gv_fetch* calls in Perl_newXS_len_flags

Merge a gv_fetchpvn and a gv_fetchpv. A strlen call is avoided in
gv_fetchpv, and in Perl_newXS_len_flags shorter machine code because 2
different call destinations were merged to 1, and
"GV_ADDMULTI | flags,SVt_PVCV"  arguments are unconditionally executed
and are not in a branch.
PATCH: [perl #114982]: case-insensitive regex bug with UTF8-flagged strings

It turns out that this whole area in regexec.c has never worked
properly, we just didn't have test coverage for it.  Indeed, the portion
that deals with CURLYM had never been updated to include UTF-8!
The failure rate for the new tests added by this commit on the blead
that existed just prior to this commit was 96%.  (4% pass)

This commit refactors the part of regexec.c that deals with quantifiers
and case insensitive matching, and adds comprehensive tests.

Consider a regex of the form A*B.  How do we know how many of A* to
match?  The answer is we don't, until we try B.  But if B begins with
text, we can easily rule out places where the next thing isn't a B.
Only if the next character (following where we are) is the first
character of B, is this a potential match; otherwise it isn't, so there
is no need to even try B.

Code existed to do this, but it was wrong in many ways.  If B can match
case-insensitively under /i, then there may be two or more possible
characters that could begin B.  The previous code assumed there was a
max of two.  It didn't adequately account for the differences between
/a, /d, /l, and /u; and as I mentioned above, in one place it didn't
know that there was such a thing as UTF-8.  Also, it assumed that all
code points can fit into an I32.

To do this right takes quite a bit more intelligence then was there;
and it needs to be done in two different places.  So, this commit
extracts out the code into a single subroutine, heavily modified to
account for the various oversights that were there previously.

The pre-existing infrastructure of fold_grind.t allowed the tests to be
added easily.  I did not add tests for the above-I32 problems, as it
turns out that there are other bugs on these, [perl #115166]
utf8.c: Remove an unnecessary conditional

The unconditional array lookup is clearer, and I suspect faster than
testing for a special case.
regexec.c: Refactor slightly for clarity

This reverses the sense of an if...else, so that the tiny trivial code
is done after the 'if', and the larger, non-trivial part is done in the
else.  This makes it easier to understand.  It also is clear that the
label and goto are no longer needed, if they ever were.
regexec.c: White-space only; comment only; no code changes