Add extern "C" to definitions of four win32_ functions

This makes them match their declarations in perlhost.h, which fixes linker
errors when linking perl5XX.dll in a C++ build with VC.
[perl #114658] Fix line numbers at the end of string eval

$ perl -e 'eval "{;"; print $@'
Missing right curly or square bracket at (eval 1) line 1, at end of line
syntax error at (eval 1) line 1, at EOF
$ perl -e 'eval "{"; print $@'
Missing right curly or square bracket at (eval 1) line 2, at end of line
syntax error at (eval 1) line 2, at EOF

Notice how the line number goes up when there is no semicolon.

What happens is that eval tacks "\n;" on to the end of the string if
it does not already end with a semicolon.

I actually changed this in blead in commit 11076590 to tack "\n;"
on to the end all the time, to make eval "q;;" and
eval "return #comment;" work.

This caused the line number to increase for eval "{;".

This commit fixes both examples above by modifying S_incline to
account for the "\n;" at the end of a string eval.

Existing tests had to be modified, as they were testing for the wrong
line number.
fix C++ builds broken by cdc4a174060

In commit cdc4a174060 static noreturn function, on a C++ build, (specific
example, GCC ) got a post preprocessor prototype of
"extern "C" static void S_fn_doesnt_return(". GCC generates a compile error
if "extern "C"" and static used together. Plain C build were not affected.

This commit fixed the problem by creating 2 new static exclusive macros, so
extern "C" does not wind up on statics in a C++ build. The macros allow
enough flexibility so any compiler/platform that needs a noreturn
declaration specifier instead of a noreturn function attribute can have
one.
stop Win32 VC miniperl from exporting functions

miniperl.exe does not load XS modules. It has no reason to export anything.
About 130 things are exported by VC Win32 miniperl. 90% of them are
the win32_* functions. All but a couple Perl_* exports are gone in the
exporting miniperl. See perl #115216 for the full list of accidentally
exported items. Also stop trying to find Win32CORE's boot function in
Perl_init_os_extras through the export table. It is not exported and not
in the miniperl image and GetProcAddress will never return not NULL. By
removing this GetProcAddress call, miniperl stops importing GetProcAddress
from kernel32 and a tiny bit startup time by miniperl during the full
perl build process. By removing the exports the compiler is free to use
more random (not cdecl) calling conventions and/or optimizing away code
than before. Also by removing the export entries, and the GetProcAddress
import, RO strings are removed from the miniperl image. This commit only
affects the VC miniperl. The Mingw miniperl remains unmodified except
for not trying to load Win32CORE through the export table and some of the
.c files being compiled with PERL_IS_MINIPERL when previously they were
not.
Fix indentation after a19baa613c
regexec.c: Fix EXACT node handling in regrepeat()

Commit b40a2c17551b484a78122be98db5dc06bb4614d5 introduced a bug in
handling EXACT nodes when the pattern is in UTF-8.  This cleans that up.
regcomp.c: Optimize EXACTFish nodes without folds to EXACT

Often, case folding will be applied to the entire regular expression
(such as by using "/i"), but there will be components in it that are the
same, folded or not.  These components could be represented as EXACT
nodes with no loss of information.  The regex optimizer is then able to
apply more optimizations to them than it could otherwise, and pattern
matching will execute faster.

This commit turns any EXACTFish node (except those under locale rules,
whose folding rules are not known until runtime)) that contains entirely
unfoldable characters into the equivalent EXACT node.

This optimization brings up the idea of possibly splitting an EXACTFish
node that contains a sufficiently long contiguous string of non-folding
characters into the portions that have folding and the portions that
don't.  That might or might not be beneficial; I'm not undertaking the
experiments to check that out.
regen/mk_PL_charclass.pl: Add bit for if character folds

This takes the existing mktables-generated table that lists all
characters that participate in any way in a fold, and creates a bit for
it in l1_char_class_tab.h
handy.h: Add macro which returns if a char is folding

This adds a macro for regcomp.c to use to determine if a Latin1 range
character participates in any folds
regcomp.c: Use more precise definition of folding chars

Previously, in the Latin1 range, whether a character is alphabetic or
not has served as a surrogate for if the character participates in
folds, as it is a superset of the folding class, with two characters
which are alpha but not folding: the masculine and feminine ordinal
indicators.  But we have plenty of bits available in the bit array for
Latin1 character classifications, so this commit makes the definition
precise.
perldelta for [perl #114982]
Simplify the fix for bug #41530

We don’t need to upgrade the target string and redo the pattern match
if the replacement is in utf8.  We can simply convert during concate-
nation, using the more recently added SV_CATUTF8 and SV_CATBYTES flags
to sv_catpvn_flags.

This should make things faster, too, as sv_catpvn_flags does not need
to allocate extra SVs or string buffers.

This happened to trigger an existing COW bug, causing test failures.
SvIsCOW and sv_force_normal_flags were being called on TARG before
get-magic.  So a magical scalar returning a COW could have that COW
modified in place.

I added a test for something I nearly broke.
pp_hot.c:pp_subst: add comment
Define RXf_SPLIT and RXf_SKIPWHITE as 0

They are on longer used in core, and we need room for more flags.

The only CPAN modules that use them check whether RXf_SPLIT is set
(which no longer happens) before setting RXf_SKIPWHITE (which is
ignored).
RXf_MODIFIES_VARS

regcomp.c sets this new flag whenever regops that could modify
$REGMARK or $REGERROR have been seen.  pp_subst will use this
to tell whether it should repeatedly stringify the replacement.
[perl #49190] Stringify repl repeatedly in s///g

pm_runtime in op.c examines the rhs of s/// to see whether it is safe
to execute that set of ops just once.  If it sees a match var or an
expression with side effects, it creates a pp_substcont op, which
results in the rhs being executed multiple times.

If the rhs seems constant enough, pp_subst does the substitution in a
tight loop.

This unfortunately causes s/a/$a/ to fail if *a has been aliased to
*1.  Furthermore, $REGMARK and $REGERROR did not count as match vars.

pp_subst actually has two separate loops.  One of them modifies the
target in place.  The other appends to a new scalar and then copies it
back to the target.  The first loop is used if it seems safe.

This commit makes $REGMARK, $REGERROR and aliases to match vars work=
when the replacement consists solely of the variable.

It does this by setting PL_curpm before stringifying the replacement,
so that $1 et al. see the right pattern.  It also stringifies the
variable for each iteration of the second loop, so that $1 and
$REGMARK update.

The first loop, which requires the rhs to be constant, is skipped if
the regexp contains the special backtracking control verbs that mod-
ify $REGMARK and $REGERROR.
Remove PMf_MAYBE_CONST

It was added in ce862d02d but has never been used.
Don’t taint return value of s///e based on replacement

According to the comments about how taint works above pp_subst in
pp_hot.c, the return value of s/// should not be tainted based on
the taintedness of the replacement.  That makes sense, because the
replacement does not affect how many iterations there were.  (The
return value is the number of iterations).

It only applies, however, to the cases where the ‘constant replace-
ment’ optimisation applies.

That means /e taints its return value:

$ perl5.16.0 -MDevel::Peek -Te '$_ = "abcd"; $x = s//$^X/; Dump $x'
SV = PVMG(0x822ff4) at 0x824dc0
  REFCNT = 1
  FLAGS = (pIOK)
  IV = 1
  NV = 0
  PV = 0
$ perl5.16.0 -MDevel::Peek -Te '$_ = "abcd"; $x = s//$^X/e; Dump $x'
SV = PVMG(0x823010) at 0x824dc0
  REFCNT = 1
  FLAGS = (GMG,SMG,pIOK)
  IV = 1
  NV = 0
  PV = 0
  MAGIC = 0x201940
    MG_VIRTUAL = &PL_vtbl_taint
    MG_TYPE = PERL_MAGIC_taint(t)
    MG_LEN = 1

The number pushed on to the stack was becoming tainted due to the set-
ting of PL_tainted.  PL_tainted is assigned to and the return value
explicitly tainted if appropriate shortly after the mPUSHi (which
implies sv_setiv, which taints when PL_tainted is true), so setting
PL_tainted to 0 just before the mPUSHi is safe.
[perl #49190] Don’t prematurely optimise s/foo/bar$baz/

$baz could be aliased to a package variable, so we do need to recon-
catenate for every iteration of s///g.  For s/// without /g, only one
more op will be executed, so the speed difference is negligible.

The only cases we can optimise in terms of skipping the evaluation of
the ops on the rhs (by eliminating the substconst op) are s//constant/
and s//$single_variable/.  Anything more complicated causes bugs.

A recent commit made s/foo/$bar/g re-stringify $bar for each iteration
(though without having to reevaluate the ops that return $bar).  So we
no longer have to special-case match vars at compile time.

This means that s/foo/bar$baz/g will be slower (and less buggy), but
s/foo/$1/g will be faster.

This also caused an existing taint but in pp_subst to surface.  If
get-magic turns off taint on a replacement string, it should not be
considered tainted.  So the taint check on the replacement should come
*after* the stringification.  This applies to the constant replacement
optimisation.  pp_substcont was already doing this correctly.
perl5180delta: B::Generate is fixed