This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
6 years ago[perl #132854] Allow goto into first arg of bin op
Father Chrysostomos [Sat, 24 Feb 2018 01:59:09 +0000 (17:59 -0800)]
[perl #132854] Allow goto into first arg of bin op

This particular case does not risk any stack corruption, and there is
a CPAN module depending on it working (PerlX::AsyncAwait).

6 years agobetter comments about Carp overload logic
Zefram [Sat, 24 Feb 2018 00:40:13 +0000 (00:40 +0000)]
better comments about Carp overload logic

The comments originally added by commit
c99363aa273278adcad39f32026629b700f9bbc3 for [perl #132828] were unclear
and a bit over-excited.

6 years agoremove spurious _ part of Carp version number
Zefram [Sat, 24 Feb 2018 00:25:15 +0000 (00:25 +0000)]
remove spurious _ part of Carp version number

Commit 4764858cb80e76fdba33cc1b3be8fcdef26df754 unwisely
changed Carp's version number to an underscored one.  Commit
c99363aa273278adcad39f32026629b700f9bbc3 incremented the underscored
part and copied it to Carp::Heavy.  With blead being upstream for Carp,
there is no reason for it to have an underscored version number.

6 years agoperlretut: Clarify metacharacters
Karl Williamson [Wed, 27 Dec 2017 00:20:38 +0000 (17:20 -0700)]
perlretut: Clarify metacharacters

6 years agoEnsure that we don't pick up any "system perl" libraries in @INC.
James E Keenan [Thu, 1 Feb 2018 02:59:21 +0000 (21:59 -0500)]
Ensure that we don't pick up any "system perl" libraries in @INC.

We need a tightly defined @INC which, for this test file, only needs './lib'
so that we can locate the two pragmata and Config.

For: RT # 132795

6 years agoperl #132892: avoid leak by mortalizing temporary copy of pattern
Yves Orton [Fri, 23 Feb 2018 03:13:49 +0000 (04:13 +0100)]
perl #132892: avoid leak by mortalizing temporary copy of pattern

6 years agofix Perl #132828 - dont use overload to bypass overloads
Yves Orton [Sun, 18 Feb 2018 06:29:03 +0000 (07:29 +0100)]
fix Perl #132828 - dont use overload to bypass overloads

the internals don't need overload.pm to be loaded to enable overloads
which means that Carp needs to defend against overload without checking
if overload.pm is loaded either.

One odd thing about this change is that if I remove the "eval" that
wraps the "require" then we fail tests in dist/Carp/t/vivify_stash.t
which defies expectation as the require is never actually executed
from that code.

This patch doesn't have tests yet as it can segfault perl.

6 years agoFix RT #52610: Carp: Do not crash when reading @DB::args
Pali [Wed, 31 Jan 2018 21:43:46 +0000 (22:43 +0100)]
Fix RT #52610: Carp: Do not crash when reading @DB::args

Trying to read values from array @DB::args can lead to perl fatal error
"Bizarre copy of ARRAY in scalar assignment". But missing, incomplete or
possible incorrect value in @DB::args is not a fatal error for Carp.

Carp is primary used for reporting warnings and errors from other
modules, so it should not crash perl when trying to print error message.

This patch safely iterates all elements of @DB::args array via eval { }
block and replace already freed scalars for Carp usage by string
"** argument not available anymore **".

This prevent crashing perl and allows to use Carp module. It it not a
proper fix but rather workaround for Carp module. At least it allows to
safely use Carp.

Patch amended by Yves Orton

6 years agoPATCH: [perl #132900] Blead Breaks CPAN: FELIPE/Crypt-Perl
Karl Williamson [Fri, 23 Feb 2018 04:45:42 +0000 (21:45 -0700)]
PATCH: [perl #132900] Blead Breaks CPAN: FELIPE/Crypt-Perl

The root cause of this was using a 'char' where it should have been
'U8'.  I changed the signatures so that all the related functions take
and return U8's, and the compiler detects what should be cast to/from
char.  The functions all deal with byte bit patterns, so unsigned is the
appropriate declaration.

6 years agoAPItest:locale.t Fix ALT_DIGITS test
Karl Williamson [Thu, 22 Feb 2018 21:21:23 +0000 (14:21 -0700)]
APItest:locale.t Fix ALT_DIGITS test

The value returned for ALT_DIGITS may vary by locale and platform.
Change the  test to only look for a result, as opposed to a particular
result.

This should fix https://rt.perl.org/Ticket/Display.html?id=132879
but I'll leave the ticket open until that is verified.

6 years agot/op/index.t: indent run_tests() sub
David Mitchell [Tue, 20 Feb 2018 17:04:10 +0000 (17:04 +0000)]
t/op/index.t: indent run_tests() sub

(whitespace-only change)

The body of run_tests() had no indentation, meaning people didn't see it
and started adding tests outside the sub (see previous commit)

6 years agot/op/index.t: include all tests within run_tests()
David Mitchell [Tue, 20 Feb 2018 17:01:28 +0000 (17:01 +0000)]
t/op/index.t: include all tests within run_tests()

Some tests were added at the end of the file, outside sub run_tests(),
so weren't being picked up by t/op/index_thr.t.

6 years agoAdd word apparently dropped in documentation.
James E Keenan [Mon, 19 Feb 2018 13:19:22 +0000 (08:19 -0500)]
Add word apparently dropped in documentation.

6 years agoMove note about defective locale on HP-UX to README.hpux
H.Merijn Brand [Tue, 20 Feb 2018 10:55:17 +0000 (11:55 +0100)]
Move note about defective locale on HP-UX to README.hpux

6 years agoS_do_trans_complex(): outdent a block of code
David Mitchell [Tue, 20 Feb 2018 09:54:07 +0000 (09:54 +0000)]
S_do_trans_complex(): outdent a block of code

whitespace-only change left over from my recent tr///c fix work

6 years agofix nit in perl5278delta.pod
David Mitchell [Tue, 20 Feb 2018 09:35:21 +0000 (09:35 +0000)]
fix nit in perl5278delta.pod

RT #132776

The :lvalue sub examples didn't have a valid body for an lvalue sub;
I've replaced the '1' with '...'

6 years agoMerge branch '\N{} handler refactoring ' into blead
Karl Williamson [Tue, 20 Feb 2018 08:38:27 +0000 (01:38 -0700)]
Merge branch '\N{} handler refactoring ' into blead

This series of commits refactors a portion of the \N{} handling in
regcomp.c.  This was done in preparation for allowing m'\N{...}', that
is single quoted patterns containing named characters.  Currently this
is illegal.

The final step to do this is not quite ready to be committed.  It
basically works, but the edge cases need to be looked at and tests
created, and the code freeze is upon us.

Some of the commits in this series are more than a year old, and I was
plagued with problems with rebasing, some of which I only resolved just
now, and decided to get this refactoring in before any more things come
along.  I intend to fix
https://rt.perl.org/Ticket/Display.html?id=132163
during the code freeze, and I've started it out on the refactored code
used here, so it would be extra work to have to use the unrefactored
version.

6 years agoregcomp.c: Refactor some if-elses
Karl Williamson [Sun, 15 Jan 2017 00:55:24 +0000 (17:55 -0700)]
regcomp.c: Refactor some if-elses

if (foo) {
    ...
    return
} else {
    stuff
}

is equivalent to

if (foo) {
    ...
    return
}

stuff

This commit changes the former to the latter, which also means moving
some declarations earlier, and some intialization later, and removing
some no longer valid code.  This will be useful in the next commit.

6 years agoregcomp.c: White space only
Karl Williamson [Thu, 2 Mar 2017 19:15:20 +0000 (12:15 -0700)]
regcomp.c: White space only

This changes the indentation of some code to reflect where it should be
with the addition and subtraction of blocks in the next commits.  And it
reflows to fit in 79 columns, and converts some tabs to spaces.

6 years agoregcomp.c: Simplify expression
Karl Williamson [Thu, 2 Mar 2017 19:14:38 +0000 (12:14 -0700)]
regcomp.c: Simplify expression

The previous commit has made part of this 'if' redundant, so the whole
thing can be simplified.

6 years agoregcomp.c: Re-order branches
Karl Williamson [Thu, 12 Jan 2017 21:59:45 +0000 (14:59 -0700)]
regcomp.c: Re-order branches

This will be useful in a future commit

6 years agoperldelta for performance enhancements
Karl Williamson [Tue, 20 Feb 2018 05:12:49 +0000 (22:12 -0700)]
perldelta for performance enhancements

6 years agoutf8.h: Add in #define for backcompat
Karl Williamson [Mon, 12 Feb 2018 12:53:47 +0000 (05:53 -0700)]
utf8.h: Add in #define for backcompat

This symbol somehow got deleted, and it really shouldn't have been.

This should not go in perldelta, as we don't want people to be using
this ancient symbol who aren't already are.

6 years agolocale.c: Add STATIC_ASSERT
Karl Williamson [Tue, 20 Feb 2018 04:15:21 +0000 (21:15 -0700)]
locale.c: Add STATIC_ASSERT

I tried this in a smoke earlier, and got one failure, and to keep on
going, removed it temporarily.  But many other changes later, I tried
again in a smoke, and it isn't failing.  A legitimate failure of this
assertion would mean reading/writing past a buffer end.

6 years agoperlre: Add note that nested (?>...) are not no-ops
Karl Williamson [Tue, 20 Feb 2018 03:52:29 +0000 (20:52 -0700)]
perlre: Add note that nested (?>...) are not no-ops

6 years agoAdd atomic script runs
Karl Williamson [Tue, 20 Feb 2018 03:40:20 +0000 (20:40 -0700)]
Add atomic script runs

This is an extension to the new script_run feature that is syntactic
sugar for the idiom espected to be most commonly used:

(*sr:(?>...)) can be written as (*asr:...)

6 years agoFix skipping char in (*sr:...) defn
Karl Williamson [Tue, 20 Feb 2018 03:28:19 +0000 (20:28 -0700)]
Fix skipping char in (*sr:...) defn

This was wrongly calling nextchar(), which skipped the next character
wrongly

6 years agot/re/script_run.t: White space only
Karl Williamson [Tue, 20 Feb 2018 03:15:21 +0000 (20:15 -0700)]
t/re/script_run.t: White space only

The previous commit created an outer block around these

6 years agot/re/script_run.t: Tests for 'sr' form of (*script_run:...)
Karl Williamson [Tue, 20 Feb 2018 03:12:28 +0000 (20:12 -0700)]
t/re/script_run.t: Tests for 'sr' form of (*script_run:...)

6 years agoregcomp.c: Silence uninit compiler warning
Karl Williamson [Mon, 19 Feb 2018 19:14:06 +0000 (12:14 -0700)]
regcomp.c: Silence uninit compiler warning

This warning (only known on one compiler at the moment) is probably
wrong, but by setting this to NULL, we avoid the warning, and should
segfault if the warning were correct, instead of using uninitialized
data.

6 years agoregcomp.c: Make sure no future ambiguity on new alpha assertions
Karl Williamson [Mon, 19 Feb 2018 19:01:51 +0000 (12:01 -0700)]
regcomp.c: Make sure no future ambiguity on new alpha assertions

This change adds a colon when checking if a string is an alpha
assertion.  This is defensive coding against an unlikely future change
wherein some new (*... construct is added that has the same initial
sequence as one of these assertions.  The colon acts as a terminator and
would automatically prevent any ambiguity.  One of these had the colon,
and hence was inconsistent with the rest.

Spotted by ilmari.

6 years agoregcomp.c: White space only
Karl Williamson [Mon, 19 Feb 2018 18:57:37 +0000 (11:57 -0700)]
regcomp.c: White space only

Fit in 80 columns, outdent because of removed enclosing block in a
previous commit, consistent spacing around '+'.

ilmari spotted the '+' spacing issues

6 years agohints/hpux.sh: Note locale univ.utf8 may be defective
Karl Williamson [Mon, 19 Feb 2018 19:08:15 +0000 (12:08 -0700)]
hints/hpux.sh: Note locale univ.utf8 may be defective

A new check in 8b7358b96caf71db3213a7d72fc401e42ee0b2d0 is finding that
this locale is defective.  It is fixed by 11.31

6 years agoStorable: recurse.t: use note() rather than diag()
David Mitchell [Mon, 19 Feb 2018 22:50:59 +0000 (22:50 +0000)]
Storable: recurse.t: use note() rather than diag()

diag() goes to STDERR and should only be used when a test fails and extra
diagnostic info should be output.

6 years ago[MERGE] fixups for OP_MULTICONCAT
David Mitchell [Mon, 19 Feb 2018 22:20:40 +0000 (22:20 +0000)]
[MERGE] fixups for OP_MULTICONCAT

This branch fixes three main issues caused by the OP_MULTICONCAT
optimisation:

* When dealing with magic/tie/overloading, there were many edge cases;
the way these are handled has been completely rewritten, fixing
bugs related to exactly when and how args are sringified and/or tested
for undefinedness;

* relatedly,  on a stringified concat such as $x .= "$y", or
$a = "$b$c$d", the stringification is honoured under exactly the same
(buggy) set of conditions that pertained before multiconcat was
introduced; this is noticable in overloading whether the result calls the
stringify method and thus returns a plain string, or whether it skips that
and returns an overloaded object, e.g. for $a = "$b$c$d", does $a end up
as a ref or a string. Before the branch it was always a ref, now its
sometimes a string.

* concats within a runtime pattern code block could crash, e.g.

    /$a(?{  $b . "c" })/

6 years agomulticoncat: /$a(?{ $b . "c" })/ could crash
David Mitchell [Mon, 19 Feb 2018 21:32:36 +0000 (21:32 +0000)]
multiconcat: /$a(?{  $b . "c" })/ could crash

RT #132772

Due to the weird order in which codeblocks within patterns are optimised,
it was possible for the OP_CONCAT -> OP_MULTICONCAT optimisation to leave
freed ops in the op execution chain, leading to assertion failures or
crashes.

In particular, optimize_optree() needs to always be called before
CALL_PEEP(), otherwise the individual subtrees which make up the two
children of a concat op may not have the head of subtree as the last op in
the subtree's op_next chain: in the subtree

    RV2SV
      |
     GV

this subtree gets peephole-optimised to

    ex-RV2SV
      |
     GVSV

and GVSV->op_next no longer points to the ex-RV2SV but rather directly
to RV2SV->op_next. But S_maybe_multiconcat() assumes that the head of each
subtree is the last op to be executed: It updates RV2SV->op_next when
reorganising the optree, but leaves GVSV->op_next possibly pointing at a
freed op.

This commit provides a minimal fix by unconditionally calling
optimize_optree() on each code block in Perl_pmruntime(). This may
mean that optimize_optree() may be run against the same code block again
later, but apart from the slight inefficiency, this should be harmless.

A more general fix will be applied post 5.28.0 release.

6 years agoS_maybe_multiconcat(): fix some code comments
David Mitchell [Mon, 19 Feb 2018 17:04:52 +0000 (17:04 +0000)]
S_maybe_multiconcat(): fix some code comments

various typos and thinkos

6 years agopp_multiconcat: correctly honour stringify
David Mitchell [Mon, 19 Feb 2018 11:59:03 +0000 (11:59 +0000)]
pp_multiconcat: correctly honour stringify

RT #132793, RT #132801

In something like $x .= "$overloaded", the $overloaded stringify method
wasn't being called.

However, it turns that the existing (pre-multiconcat) behaviour is also
buggy and inconsistent. That behaviour has been restored as-is.
At some future time, these bugs might be addressed.

Here are some comments from the new tests added to overload.t:

Since 5.000, any OP_STRINGIFY immediately following an OP_CONCAT
is optimised away, on the assumption that since concat will always
return a valid string anyway, it doesn't need stringifying.
So in "$x", the stringify is needed, but on "$x$y" it isn't.
This assumption is flawed once overloading has been introduced, since
concat might return an overloaded object which still needs stringifying.
However, this flawed behaviour is apparently needed by at least one
module, and is tested for in opbasic/concat.t: see RT #124160.

There is also a wart with the OPpTARGET_MY optimisation: specifically,
in $lex = "...", if $lex is a lexical var, then a chain of 2 or more
concats *doesn't* optimise away OP_STRINGIFY:

$lex = "$x";        # stringifies
$lex = "$x$y";      # doesn't stringify
$lex = "$x$y$z..."; # stringifies

6 years agopp_multiconcat: eliminate/rename dsv/dsv_pv vars
David Mitchell [Sat, 17 Feb 2018 12:22:09 +0000 (12:22 +0000)]
pp_multiconcat: eliminate/rename dsv/dsv_pv vars

After the previous commit, dsv is always the same as targ,
so relace all uses of 'dsv' with 'targ', and rename the 'dsv_pv' var
to 'targ_pv'.

Also rename a limited scope var from 'targ_pv' to targ_buf' as that
name is now being used for dsv_pv.

Should be no functional changes.

6 years agoredo magic/overload handing in pp_multiconcat
David Mitchell [Sat, 10 Feb 2018 15:27:59 +0000 (15:27 +0000)]
redo magic/overload handing in pp_multiconcat

The way pp_multiconcat handles things like tieing and overloading
doesn't work very well at the moment. There's a lot of code to handle
edge cases, and there are still open bugs.

The basic algorithm in pp_multiconcat is to first stringify (i.e. call
SvPV() on) *all* args, then use the obtained values to calculate the total
length and utf8ness required, then do a single SvGROW and copy all the
bytes from all the args.

This ordering is wrong when variables with visible side effects, such as
tie/overload, are encountered. The current approach is to stringify args
up until such an arg is encountered, concat all args up until that one
together via the normal fast route, then jump to a special block of code
which concats any remaining args one by one the "hard" way, handling
overload etc.

This is problematic because we sometimes need to go back in time. For
example in ($undef . $overloaded), we're supposed to call
    $overloaded->concat($undef, reverse=1)
so to speak, but by the time of the method call, we've already tried to
stringify $undef and emitted a spurious 'uninit var' warning.

The new approach taken in this commit is to:

1) Bail out of the stringify loop under a greater range of problematical
variable classes - namely we stop when encountering *anything* which
might cause external effects, so in addition to tied and overloaded vars,
we now stop for any sort of get magic, or any undefined value where
warnings are in scope.

2) If we bail out, we throw away any stringification results so far,
and concatenate *all* args the slow way, even ones we're already
stringified. This solves the "going back in time" problem mentioned above.
It's safe because the only vars that get processed twice are ones for which
the first stringification could have no side effects.

The slow concat loop now uses S_do_concat(), which is a new static inline
function which implements the main body of pp_concat() - so they share
identical code.

An intentional side-effect of this commit is to fix three tickets:

    RT #132783
    RT #132827
    RT #132595

so tests for them are included in this commit.

One effect of this commit is that string concatenation of magic or
undefined vars will now be slower than before, e.g.

    "pid=$$"
    "value=$undef"

but they will probably still be faster than before pp_multiconcat was
introduced.

6 years agomove body of pp_concat() to S_do_concat()
David Mitchell [Fri, 16 Feb 2018 14:10:40 +0000 (14:10 +0000)]
move body of pp_concat() to S_do_concat()

Create an inline static function which implements the body of pp_concat(),
then replace pp_concat()'s body with a call to it.

Shortly, we'll use this function in pp_multiconcat() too.

6 years agoUpdate META files and MANIFEST for if.pm
Sawyer X [Mon, 19 Feb 2018 18:22:33 +0000 (20:22 +0200)]
Update META files and MANIFEST for if.pm

6 years agoregcomp.c: Use macro to avoid code duplication
Yves Orton [Mon, 12 Feb 2018 05:22:54 +0000 (22:22 -0700)]
regcomp.c: Use macro to avoid code duplication

Wrap RESTART_PASS1 logic in a macro layer for clarity and reduction of
duplicate code

The committer in consultation with Tony Cook changed things to avoid a
compiler warning, and added comments, white space.

6 years agoFix manifest
Sawyer X [Mon, 19 Feb 2018 09:18:20 +0000 (11:18 +0200)]
Fix manifest

6 years agoCorrect PathTools dist files and bump to 3.74:
Sawyer X [Mon, 19 Feb 2018 08:38:22 +0000 (10:38 +0200)]
Correct PathTools dist files and bump to 3.74:

There were permission errors when uploading 3.73 so we are bumping
it to 3.74.

I've included the META.json and META.yml files in the dist and
corrected their entry in MANIFEST.

6 years agoAdd alphabetic synonyms for regex assertions
Karl Williamson [Mon, 19 Feb 2018 04:30:17 +0000 (21:30 -0700)]
Add alphabetic synonyms for regex assertions

This commit came out of the committee formed with PCRE members as a
result of http://nntp.perl.org/group/perl.perl5.porters/246762

6 years agoChange syntax of script runs
Karl Williamson [Mon, 19 Feb 2018 03:28:34 +0000 (20:28 -0700)]
Change syntax of script runs

The new syntax is (*script_run:...)
and a shortcut (*sr:...)

See http://nntp.perl.org/group/perl.perl5.porters/246762

6 years agoAdd 'alpha_assertions' warnings category
Karl Williamson [Sun, 18 Feb 2018 04:20:59 +0000 (21:20 -0700)]
Add 'alpha_assertions' warnings category

This will be used in future commits.

6 years agoSort an entry in perldiag
Karl Williamson [Mon, 19 Feb 2018 03:37:34 +0000 (20:37 -0700)]
Sort an entry in perldiag

6 years ago[Merge] ‘Nonelem’ scalars
Father Chrysostomos [Mon, 19 Feb 2018 00:41:09 +0000 (16:41 -0800)]
[Merge] ‘Nonelem’ scalars

6 years agoperldelta for non-elems
Father Chrysostomos [Mon, 19 Feb 2018 00:41:02 +0000 (16:41 -0800)]
perldelta for non-elems

I don’t think the bug involving defelems, which this branch partially
fixes is significant enough to be mentioned in the bugs section.

Likewise, the memory leaks fixed (some of them introduced in the
same dev cycle) are so rare that it would add unnecessary verbiage
to perldelta.

6 years agoFix ary shifting when sparse ary is passed to sub
Father Chrysostomos [Mon, 19 Feb 2018 00:12:11 +0000 (16:12 -0800)]
Fix ary shifting when sparse ary is passed to sub

This commit fixes #132729 in the specific case where a nonexistent
element within a sparse array is passed to a subroutine.

Prior to this commit,

    some_sub($sparse_array[$n])

where $n <= $#sparse_array and the element does not exist, would exhi-
bit erroneous behaviour if some_sub shifted or unshifted the original
@sparse_array.  Any ‘holes’ (nonexistent elements) in the array would
show up in @_ as deferred element (defelem) scalars, magic scalars
that remember their index in the array.  This index is not updated and
gets out of synch when the array is shifted.

This commit fixes the bug for elements within the array by using the
new ‘nonelem’ magic introduced a few commits ago.  It stores within
the array a magic scalar that is marked as being nonexistent.

It also reduced the number of scalars that need to be created if such
a sub call happens repeatedly.

6 years agoFix two bugs when calling &xsub when @_ has holes
Father Chrysostomos [Tue, 13 Feb 2018 21:36:22 +0000 (13:36 -0800)]
Fix two bugs when calling &xsub when @_ has holes

This fixes #132729 in the particular instance where an XSUB is
called via ampersand syntax when @_ has ‘holes’, or nonexistent ele-
ments, as in:

    @_ = ();
    $_[1] = 1;
    &xsub;

This means that if the XSUB or something it calls unshifts @_, the
first argument passed to the XSUB will now refer to $_[1], not $_[0];
i.e., as of this commit it is correctly shifted over.  Previously, a
‘defelem’ was used, which is a magical scalar that remembers its index
in the array, independent of whether the array was shifted.

In addition, the old code failed to mortalize the defelem, so this
commit fixes a memory leak with the new ‘non-elem’ mechanism (a spe-
cially-marked element stored in the array itself).

6 years agoTest #132729 with array flattening
Father Chrysostomos [Mon, 12 Feb 2018 01:14:20 +0000 (17:14 -0800)]
Test #132729 with array flattening

Other instances of this bug have not yet been fixed.  This commit’s
grandparent fixed the case where an array with holes in it is flat-
tened in lvalue context, and then gets shifted/unshifted before
an element is vivified.

6 years agosvleak.t: Test for leak fixed by prev. commit
Father Chrysostomos [Mon, 12 Feb 2018 01:01:26 +0000 (17:01 -0800)]
svleak.t: Test for leak fixed by prev. commit

6 years ago‘Nonelems’ for pushing sparse array on the stack
Father Chrysostomos [Mon, 22 Jan 2018 05:55:00 +0000 (21:55 -0800)]
‘Nonelems’ for pushing sparse array on the stack

To avoid having to create deferred elements every time a sparse array
is pushed on to the stack, store a magic scalar in the array itself,
which av_exists and refto recognise as not existing.

This means there is only a one-time cost for putting such arrays on
the stack.

It also means that deferred elements that live long enough don’t
start pointing to the wrong array entry if the array gets shifted (or
unshifted/spliced) in the mean time.  Instead, the scalar is already
in the array, so it cannot lose its place.  This fix only applies
when the array as a whole is pushed on to the stack, but it could be
extended in future commits to apply to other places where we currently
use deferred elements.

6 years agoMerge branch 'add thread-safe locales' into blead
Karl Williamson [Sun, 18 Feb 2018 22:45:08 +0000 (15:45 -0700)]
Merge branch 'add thread-safe locales' into blead

6 years agoperldelta changes for this branch
Karl Williamson [Sun, 18 Feb 2018 22:36:42 +0000 (15:36 -0700)]
perldelta changes for this branch

6 years agoFixes for Perl_langinfo()
Karl Williamson [Fri, 16 Feb 2018 22:20:58 +0000 (15:20 -0700)]
Fixes for Perl_langinfo()

This commit takes advantage of thread-safe locales to improve the code
in that circumstance.  It also now doesn't needlessly copy its result to
a buffer in situations where that isn't necessary for safe operation

6 years agoAdd switch_to_globale_locale()
Karl Williamson [Fri, 16 Feb 2018 05:44:24 +0000 (22:44 -0700)]
Add switch_to_globale_locale()

This new API function is for use in applications that call alien library
routines that are expecting the old pre-POSIX 2008 locale functionality,
namely a single global locale accessible via setlocale().

This function converts the calling thread to use that global locale, if
not already there.

6 years agoRevise sync_locale() for safe multi-threaded operation
Karl Williamson [Fri, 16 Feb 2018 04:25:33 +0000 (21:25 -0700)]
Revise sync_locale() for safe multi-threaded operation

This function now returns a boolean, and does not want an aTHX
parameter.  There should be no impact on code that uses the macro form
to call it.

6 years agoperl.h: Add, revise some locale debugging info
Karl Williamson [Thu, 15 Feb 2018 04:28:51 +0000 (21:28 -0700)]
perl.h: Add, revise some locale debugging info

6 years agolib/locale_threads.t: Add safe thread test
Karl Williamson [Mon, 5 Feb 2018 19:32:41 +0000 (12:32 -0700)]
lib/locale_threads.t: Add safe thread test

6 years agoAdd thread-safe locale handling
Karl Williamson [Tue, 6 Feb 2018 05:11:51 +0000 (22:11 -0700)]
Add thread-safe locale handling

This (large) commit allows locales to be used in threaded perls on
platforms that support it.  This includes recent Windows and Posix 2008
ones.

6 years agoperl.h: Add debugging statements for mutex ops
Karl Williamson [Tue, 13 Feb 2018 23:53:43 +0000 (16:53 -0700)]
perl.h: Add debugging statements for mutex ops

6 years agoLatch LC_NUMERIC during critical sections
Karl Williamson [Tue, 13 Feb 2018 20:12:50 +0000 (13:12 -0700)]
Latch LC_NUMERIC during critical sections

It is possible for operations on threaded perls which don't 'use locale'
to still change the locale.  This happens when calling
POSIX::localeconv() and I18N::Langinfo(), and in earlier perls, it can
happen for other operations when perl has been initialized with the
environment causing the various locale categories to not have a uniform
locale.

This commit causes the areas where the locale for this category should
predictably be in one or the other state to be a critical section where
another thread can't interrupt and change it.  This is a separate
mutex, so that only these particular operations will be held up.

6 years agoMake new_numeric() static
Karl Williamson [Tue, 6 Feb 2018 04:52:54 +0000 (21:52 -0700)]
Make new_numeric() static

This core-only function is now used only in one file.

6 years agovutil.c: Revise locale version handling
Karl Williamson [Tue, 13 Feb 2018 19:44:02 +0000 (12:44 -0700)]
vutil.c: Revise locale version handling

This can be called from applications that have changed the locale behind
perl's back.  Prior to this commit, the code kind of assumed that some
things weren't broken, and that it should update perl's records to
correspond with the status of things.  But this may be an intermediate
state, and assuming perl should know about it is assuming too much.  We
might update perl, and the application restores the state, and control
gets transferred back in the wrong state.  So simply change the locale
to what it needs to be, if necessary, and change back.

This change needs to reported upstream to 'version'

6 years agoAdd Perl_setlocale()
Karl Williamson [Fri, 16 Feb 2018 21:13:19 +0000 (14:13 -0700)]
Add Perl_setlocale()

khw could not find any modules on CPAN that correctly use the C library
function setlocale().  (The very few that do try, do not use it
correctly, looking at the return value incorrectly, so they are broken.)
This analysis does not include modules that call non-Perl libaries that
may call setlocale().

And, a future commit will render the setlocale() function useless in
some configurations on some platforms.

So this commit adds Perl_setlocale(), for XS code to call, and which is
always effective, but it should not be used to alter the locale except
on platforms where the predefined variable ${^SAFE_LOCALES} evaluates to
1.

This function is also what POSIX::setlocale() calls to do the real work.

6 years agoperldelta for dTHX_DEBUGGING
Karl Williamson [Sun, 18 Feb 2018 18:40:41 +0000 (11:40 -0700)]
perldelta for dTHX_DEBUGGING

This documents the results of commit
2d17fb746d82c8098ef8cf0dee7d11f3844294a5

6 years agolocale.c: Add critical section
Karl Williamson [Thu, 15 Feb 2018 12:41:51 +0000 (05:41 -0700)]
locale.c: Add critical section

This code should be protected from another thread doing the same thing
nearly simultaneously, so that the static buffer doesn't get zapped in
this system call.

6 years agolocale.c: Generalize errno handling
Karl Williamson [Thu, 15 Feb 2018 11:55:49 +0000 (04:55 -0700)]
locale.c: Generalize errno handling

This file had been using just errno, instead of the more general macros
that can handle vax errnos as well.

6 years agolocale.c: Change some DEBUG_L to DEBUG_Lv
Karl Williamson [Thu, 15 Feb 2018 11:49:15 +0000 (04:49 -0700)]
locale.c: Change some DEBUG_L to DEBUG_Lv

These are better to display only when verbose is specified.

6 years agolocale.c: Suppress some compiler warnings
Karl Williamson [Thu, 15 Feb 2018 11:45:24 +0000 (04:45 -0700)]
locale.c: Suppress some compiler warnings

Cast these %.s precision specifiers to int.

6 years agoperlapi: Add a caution about Perl_langinfo()
Karl Williamson [Thu, 15 Feb 2018 11:42:06 +0000 (04:42 -0700)]
perlapi: Add a caution about Perl_langinfo()

6 years agolocale.c: Add debugging info
Karl Williamson [Tue, 6 Feb 2018 17:32:07 +0000 (10:32 -0700)]
locale.c: Add debugging info

This adds some information to a debugging statement, but mostly it adds
an audit of the utf8ness cache structure, invoked under -DLv.

6 years agoAdd ${^SAFE_LOCALES}
Karl Williamson [Thu, 15 Feb 2018 04:15:40 +0000 (21:15 -0700)]
Add ${^SAFE_LOCALES}

This read-only variable returns a boolean as to whether it is safe to
use locales in this perl.  Without threads it returns 1; when a future
commit adds thread-safe locale handling, it will also return 1 if that
is enabled.

6 years agoAdd information to warning msgs
Karl Williamson [Thu, 15 Feb 2018 05:43:51 +0000 (22:43 -0700)]
Add information to warning msgs

If we have nl_langinfo, this adds the codeset it returns to the messages
generated when there are anomalies in locales that are coming into
effect

6 years agolocale.c: Add comments, clarify others
Karl Williamson [Thu, 15 Feb 2018 12:24:02 +0000 (05:24 -0700)]
locale.c: Add comments, clarify others

6 years agolocale.c: White-space only
Karl Williamson [Thu, 15 Feb 2018 05:39:47 +0000 (22:39 -0700)]
locale.c: White-space only

This indents properly because of changes in the previous commit

6 years agolocale.c: Check for anomalies in UTF-8 locales
Karl Williamson [Thu, 15 Feb 2018 05:09:13 +0000 (22:09 -0700)]
locale.c: Check for anomalies in UTF-8 locales

Perl has, for some releases now, checked for anomalies in non-UTF-8
locales and raised warnings if any are found when such a locale actually
gets used.  This came about because it turns out that vendors have
defective locale definitions (that Perl has no control over, besides
reporting them as bugs to the proper places).

I was surprised to stumble across UTF-8 locales that don't adhere
strictly to Unicode, and so this commit now checks for such things and
raises an appropriate message.

Some of this is understandable because Turkish and related languages
have a locale-dependent exemption for them in the Unicode standard, but
others are simply defective locale definitions.

Perl will use the standard Unicode rules, but the user is now warned
that these aren't what the locale specified.

An example is that there are some UTF-8 locales where the common
punctuation characters like ",", "$" aren't marked as punctuation.

6 years agolocale.c: Rmv unnecessary locale toggle
Karl Williamson [Thu, 15 Feb 2018 04:40:24 +0000 (21:40 -0700)]
locale.c: Rmv unnecessary locale toggle

I don't know why this code thought it needed to change to the C locale
for LC_CTYPE, in order to output a fully formed warning message, and
then to switch back.  So remove the toggles.

6 years agoperl.h: Add dTHX_DEBUGGING
Karl Williamson [Tue, 6 Feb 2018 05:01:35 +0000 (22:01 -0700)]
perl.h: Add dTHX_DEBUGGING

which is a NOOP except on DEBUGGING builds

6 years agoExtUtils::ParseXS/lib/perlxs.pod: Nits
Karl Williamson [Tue, 29 Aug 2017 00:01:43 +0000 (18:01 -0600)]
ExtUtils::ParseXS/lib/perlxs.pod: Nits

This removes extra blanks following colons that don't mean the normal
thing for colons that traditionally have two spaces after them, and
capitalizes Perl.

6 years agomakedef.pl: Use all #ifdefs to decide
Karl Williamson [Fri, 16 Feb 2018 22:15:06 +0000 (15:15 -0700)]
makedef.pl: Use all #ifdefs to decide

This uses all the conditions that go in to deciding to define this
variable, instead of taking a shortcut.  (It's unfortunate that the
shortcut defined in perl.h now used elsewhere via commit
7e5377f714ebe84e0fe2599b3bfec50036f0d18f is not available to makedef.pl.
It would make sense to have this file look at perl.h and avoid
duplication).

This fixes some freebsd builds, which failed because their hints file
undef'd a different variable than this shortuct looked at.

6 years agoUse proper #define to see if need PLnumeric underlying_obj
Karl Williamson [Tue, 13 Feb 2018 23:34:27 +0000 (16:34 -0700)]
Use proper #define to see if need PLnumeric underlying_obj

perl.h has a single #define which is the combination of several that
determines if this object should be created or not.

6 years agoperl.h Move some #defines
Karl Williamson [Tue, 13 Feb 2018 23:25:14 +0000 (16:25 -0700)]
perl.h Move some #defines

These are used so that they appear ahead of #include intrpvar.h, so
they can be used by that file.  This enables this commit to simplify
some #ifdefs

6 years agoRevise when POSIX 2008 ops on FreeBSD
Karl Williamson [Thu, 15 Feb 2018 04:18:52 +0000 (21:18 -0700)]
Revise when POSIX 2008 ops on FreeBSD

It appears that bugs in FreeBSD are not fully fixed until later than we
thought, and so this commit updates the hints file to exclude POSIX 2008
operations on releases previously permitted.

See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=211743

6 years agoPOSIX.xs: Fix localeconv_l()
Karl Williamson [Thu, 15 Feb 2018 11:22:19 +0000 (04:22 -0700)]
POSIX.xs: Fix localeconv_l()

Commit 7d5966ae3c3b8f0e43fa09554a46cb8de9c98f5f added use of
localeconv_l().  But this commit is buggy in some locales.  It needs to
find the current locale AFTER any changes have been made due to the
LC_NUMERIC locale toggling.

6 years agoregcomp.c: Add cast to avoid compiler warning
Karl Williamson [Sun, 18 Feb 2018 15:46:56 +0000 (08:46 -0700)]
regcomp.c: Add cast to avoid compiler warning

6 years agoUpdate dist/if/Changes to current version in blead.
James E Keenan [Sun, 18 Feb 2018 00:19:58 +0000 (19:19 -0500)]
Update dist/if/Changes to current version in blead.

6 years agoAdd MANIFEST to PathTools
Sawyer X [Sat, 17 Feb 2018 20:22:04 +0000 (22:22 +0200)]
Add MANIFEST to PathTools

6 years agoReflect what I think are the correct changesets for PathTools:
Sawyer X [Sat, 17 Feb 2018 20:18:38 +0000 (22:18 +0200)]
Reflect what I think are the correct changesets for PathTools:

Building towards an upcoming release of PathTools, I'm documenting
based on the commits what I think is the correct Changeset.

Considering that at the time of this commit, CPAN only has
PathTools 3.62, I think we should be fine.

Correct if you see a mistake. :)

6 years agodefine NEED_croak_xs_usage in PathTools
Zefram [Sat, 17 Feb 2018 18:10:48 +0000 (18:10 +0000)]
define NEED_croak_xs_usage in PathTools

ppport.h nowadays defines croak_xs_usage(), which is of course used
in the XS code, but its definition is broken unless the flag macro
NEED_croak_xs_usage was defined first.  Define the flag macro to avoid
breakage.

6 years agoAdd ABSTRACT, LICENSE, AUTHOR, etc. elements.
James E Keenan [Sun, 11 Feb 2018 16:49:19 +0000 (11:49 -0500)]
Add ABSTRACT, LICENSE, AUTHOR, etc. elements.

Add them conditionally so that CPAN PathTools can accommodate different
versions of ExtUtils::MakeMaker and CPAN metadata protocols.

Styled after Module-CoreList's Makefile.PL for better readability.

See: RT 132853

6 years agoEnsure that all tests in t/cwd.t have descriptions.
James E Keenan [Sun, 11 Feb 2018 16:44:21 +0000 (11:44 -0500)]
Ensure that all tests in t/cwd.t have descriptions.

6 years agoProvide .gitignore for PathTools distribution.
James E Keenan [Sun, 11 Feb 2018 16:36:45 +0000 (11:36 -0500)]
Provide .gitignore for PathTools distribution.

6 years agoUpdate ExtUtils-MakeMaker to CPAN version 7.32
Chris 'BinGOs' Williams [Sat, 17 Feb 2018 10:42:32 +0000 (10:42 +0000)]
Update ExtUtils-MakeMaker to CPAN version 7.32

  [DELTA]

7.32  Fri Feb 16 20:10:58 GMT 2018

    No changes since v7.31_08

7.31_08 Mon Feb 12 12:19:11 GMT 2018

    VMS fixes:
    - Fix 8-space line prefixes in MM_VMS.pm

7.31_07 Tue Jan 16 16:09:04 GMT 2018

    Bug fixes:
    - Change warning text for libscan() README.pod

7.31_06 Tue Jan 16 10:28:11 GMT 2018

    Bug fixes:
    - Teach libscan() to exclude README.pod

    Doc fixes:
    - Documented when XSMULTI and XSBUILD are available
    - Documented more version requirements for attributes

7.31_05 Sat Nov 25 09:22:51 GMT 2017 (LPW Edition)

    Doc fixes:
    - Spelling fixes
    - clarify behaviour if VENDORLIB and no VENDORARCH

7.31_04 Thu Oct  5 12:22:24 BST 2017

    Darwin/NeXT fixes:
    - Escape ld -framework flags

7.31_03 Mon Jul 10 09:34:26 BST 2017

    Bug fixes:
    - Filter out non-XS .a files for static builds

7.31_02 Mon Jun 26 13:53:15 BST 2017

    VMS fixes:
    - Fixes for .PL tests
    - VMS override for static_lib_pure_cmd
    - Make the new subdirsstatic test portable

7.31_01 Wed Jun 14 15:57:52 BST 2017

    Test fixes:
    - Skip static test unless in perl core or in a .git directory

6 years agoChange name of regnode for clarity
Karl Williamson [Sat, 17 Feb 2018 04:33:24 +0000 (21:33 -0700)]
Change name of regnode for clarity

The EXACTFA nodes are in fact not generated by /a, but by /aa.  Change
the name to EXACTFAA to correspond.

I found myself getting confused by this.

6 years agoAPItest: Add U8* typemap, and use it
Karl Williamson [Mon, 12 Feb 2018 16:03:09 +0000 (09:03 -0700)]
APItest: Add U8* typemap, and use it

This missiing typemap has slowed me down on numerous occasions, as I
keep forgetting it's missing