This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
6 years agoAdd comment to explain why we want to probe for statfs() et al
Aaron Crane [Wed, 1 Nov 2017 17:52:24 +0000 (17:52 +0000)]
Add comment to explain why we want to probe for statfs() et al

6 years agopp_multiconcat: don't stringify LHS overload arg
David Mitchell [Sat, 4 Nov 2017 10:30:00 +0000 (10:30 +0000)]
pp_multiconcat: don't stringify LHS overload arg

RT #132385

In something like

    $a1 . $a2

where $a2 is overloaded, the concat overload method was being called
like

    concat($a2, "$a1", 1);

(The 1 indicated that the args are reversed).

This commit changes it so that it's called as

    concat($a2, $a1, 1);

i.e. that the original arg is passed in rather than a stringified copy
of it. This is important if for example $a1 is a ref.

6 years agoperldelta for b3937e202aaf1 (Carp & ISA constant)
Father Chrysostomos [Sat, 4 Nov 2017 04:36:20 +0000 (21:36 -0700)]
perldelta for b3937e202aaf1 (Carp & ISA constant)

6 years agoAvoid unique REGCOMP in dynaloader
J. Nick Koston [Wed, 6 Sep 2017 17:18:51 +0000 (12:18 -0500)]
Avoid unique REGCOMP in dynaloader

Dynaloader has 4 unique regex's that cannot be de-duplicated
by perlcc.  Switch them to index/substr

References: CPANEL-15683

Signed-off-by: Nicolas R <atoomic@cpan.org>
6 years agoSpeed up Carp.pm when backtrace arguments are references
Nicolas R [Tue, 22 Aug 2017 18:26:15 +0000 (13:26 -0500)]
Speed up Carp.pm when backtrace arguments are references

Avoid downgrading the string when not required.

Author: J. Nick Koston <nick@cpanel.net>
References: CPANEL-15140

6 years agoAvoid a segfault when untying an object
Nicolas R [Mon, 31 Oct 2016 17:53:17 +0000 (11:53 -0600)]
Avoid a segfault when untying an object

Check if the tied object has a stash set
before calling UNTIE method.

6 years ago(perl #131895) fail stat on names with \0 embedded
Tony Cook [Thu, 2 Nov 2017 20:18:56 +0000 (20:18 +0000)]
(perl #131895) fail stat on names with \0 embedded

Also lstat() and the file test ops.

6 years agoyada-yada is a term, not an operator
Lukas Mai [Thu, 2 Nov 2017 19:48:38 +0000 (19:48 +0000)]
yada-yada is a term, not an operator

6 years agodocument qw's whitespace rules
Zefram [Thu, 2 Nov 2017 19:29:33 +0000 (19:29 +0000)]
document qw's whitespace rules

qw only splits on ASCII whitespace, like primary tokenisation, but
nowadays unlike the split() formulation with which it's documented.
Document this additional difference from split().  Fixes [perl #132272].

6 years agotoke.c: Rmv useless code
Karl Williamson [Sat, 25 Mar 2017 23:38:40 +0000 (17:38 -0600)]
toke.c: Rmv useless code

This code is unreachable because the code above makes sure that the
variable can't be larger than PL_bufend, and the code is only executed
if it is larger.

6 years agotoke.c: White space only
Karl Williamson [Sat, 25 Mar 2017 21:18:27 +0000 (15:18 -0600)]
toke.c: White space only

Fix up some white space, including outdenting a block that was doubly
indented

6 years agomulticoncat: use append_utf8_from_native_byte()
David Mitchell [Wed, 1 Nov 2017 18:45:36 +0000 (18:45 +0000)]
multiconcat: use append_utf8_from_native_byte()

This small inline function does what my code was doing manually in a
couple of places. Should be no functional difference, just makes the code
tidier.

Suggested by Karl.

6 years agosprintf-as-multiconcat: fix \x80 issue
David Mitchell [Wed, 1 Nov 2017 17:14:58 +0000 (17:14 +0000)]
sprintf-as-multiconcat: fix \x80 issue

My recent OP_MULTICONCAT merge which (amongst other things) converts
sprintfs with a constant format that only containing %s's into a
multiconcat op, miscounted variant chars (i.e. chars like \x80, which if
upgraded to utf8, expand the number of bytes they require).
This could cause buffer overruns.

Spotted by Karl Williamson++

NPD

6 years agoIncrease $Carp::Heavy::VERSION to 1.44
Father Chrysostomos [Wed, 1 Nov 2017 20:59:05 +0000 (13:59 -0700)]
Increase $Carp::Heavy::VERSION to 1.44

6 years agoIncrease $Carp::VERSION to 1.44
Father Chrysostomos [Wed, 1 Nov 2017 20:13:00 +0000 (13:13 -0700)]
Increase $Carp::VERSION to 1.44

6 years agoCarp: Don’t choke on ISA constant
Father Chrysostomos [Wed, 1 Nov 2017 20:11:27 +0000 (13:11 -0700)]
Carp: Don’t choke on ISA constant

This broke some time between 1.29 (perl 5.18) and 1.3301 (perl 5.20):

$ perl5.20.1 -e 'package Foo { use constant ISA => 42; Bar::f() } package Bar { use Carp; sub f { carp "tun syn" } }'
Not a GLOB reference at /usr/local/lib/perl5/5.20.1/Carp.pm line 560.

and still persisted in bleadperl (Carp 1.43) until this commit.

The code that goes poking through the symbol table needs to take into
account that not all stash elements are globs.

6 years agocustomized.dat: Add generator note
Father Chrysostomos [Wed, 1 Nov 2017 05:18:10 +0000 (22:18 -0700)]
customized.dat: Add generator note

So that people like me who do not do this very often can see just
by looking at the file how it got generated.

6 years agoPorting/Maintainers.pl: vutil.c is no longer CUSTOMIZED
Father Chrysostomos [Wed, 1 Nov 2017 05:12:42 +0000 (22:12 -0700)]
Porting/Maintainers.pl: vutil.c is no longer CUSTOMIZED

6 years agoRevert "vutil.c: use new SvPVCLEAR and constant string friendly macros"
Father Chrysostomos [Wed, 1 Nov 2017 05:02:49 +0000 (22:02 -0700)]
Revert "vutil.c: use new SvPVCLEAR and constant string friendly macros"

This reverts commit 7394beb1401a6ac5e5e19cff7f08486e5141126c.

This change to vutil.c is unnecessary and makes it differ needlessly
from the CPAN release (CPAN *is* upstream for this file), making syn-
chronisation harder.

6 years agometaconfig.h: Rmv HAS_MEMRCHR
Karl Williamson [Wed, 1 Nov 2017 16:56:24 +0000 (10:56 -0600)]
metaconfig.h: Rmv HAS_MEMRCHR

This is now used in code, and hence no longer needed in this file

6 years agometaconfig.h: Rmv HAS_THREAD_SAFE_NL_LANGINFO_L
Karl Williamson [Wed, 1 Nov 2017 16:55:07 +0000 (10:55 -0600)]
metaconfig.h: Rmv HAS_THREAD_SAFE_NL_LANGINFO_L

This is now used in code, and hence no longer needed in this file

6 years agoAdd my_memrchr() implementation of memrchr()
Karl Williamson [Sat, 25 Mar 2017 18:45:34 +0000 (12:45 -0600)]
Add my_memrchr() implementation of memrchr()

On platforms that have memrchr(), my_mrchr() maps to use that instead.

This is useful functionality, lacking on many platforms.  This commit
also uses the new function in two places in the core where the comments
previously indicated it would be advantageous to use it if we had it.

It is left usable only in core, so that if this turns out to have been a
bad idea, it can be easily removed.

6 years agoAPItest.xs: Omit unused variable
Karl Williamson [Tue, 31 Oct 2017 00:52:14 +0000 (18:52 -0600)]
APItest.xs: Omit unused variable

6 years agoutf8.c: Rmv obsolete comment
Karl Williamson [Mon, 30 Oct 2017 15:32:36 +0000 (09:32 -0600)]
utf8.c: Rmv obsolete comment

This was no longer true

6 years agofix Perl_get_cvn_flags() return value
David Mitchell [Wed, 1 Nov 2017 10:51:13 +0000 (10:51 +0000)]
fix Perl_get_cvn_flags() return value

One branch returned an SV* when it should return CV*.
This upset g++.

6 years agofix ext/B/t/optree_samples.t
David Mitchell [Tue, 31 Oct 2017 23:36:40 +0000 (23:36 +0000)]
fix ext/B/t/optree_samples.t

The recent OP_MULTICONCAT merge broke it under PERL_UNICODE=""

6 years agoMake get_cv cope with subrefs
Father Chrysostomos [Tue, 31 Oct 2017 17:16:59 +0000 (10:16 -0700)]
Make get_cv cope with subrefs

When called with GV_NOADD_NOINIT, get_cv will fail an assertion if the
thingy in the stash is not a GV.

While calling with GV_NOADD_NOINIT is a strange thing to do, neverthe-
less Cpanel::JSON::XS does it with "Encode::decode", which is not an
unreasonable thing to do if it is known that the sub already exists.

This commit makes get_cv take sub refs into account, so that, when we
reënable the optimisation reverted by 9bceb75b8d9, Cpanel::JSON::XS
will continue to work with bleadperl.

(Currently, the optimisation only applies to the main package, which
is why I am able to test this now.)

6 years agoBasic tests for get_cvn_flags
Father Chrysostomos [Tue, 31 Oct 2017 04:49:04 +0000 (21:49 -0700)]
Basic tests for get_cvn_flags

6 years ago[MERGE] add OP_MULTICONCAT and optimize_optree()
David Mitchell [Tue, 31 Oct 2017 16:08:06 +0000 (16:08 +0000)]
[MERGE] add OP_MULTICONCAT and optimize_optree()

This branch contains one main commit which adds the new OP_MULTICONCAT op,
plus a few prior commits to provide support; in particular, adding an extra
top-down optree scan phase to allow extra optimisation opportunities, just
before the peephole optimiser is run.

See the OP_MULTICONCAT for more details, but in summary it:
allows multiple OP_CONCAT, OP_CONST ops, plus optionally an OP_SASSIGN
or OP_STRINGIFY, to be combined into a single OP_MULTICONCAT op, which can
make things a *lot* faster: 4x or more.

6 years agoperldelta entry for OP_MULTICONCAT
David Mitchell [Wed, 25 Oct 2017 10:58:47 +0000 (11:58 +0100)]
perldelta entry for OP_MULTICONCAT

6 years agoAdd OP_MULTICONCAT op
David Mitchell [Tue, 8 Aug 2017 17:42:14 +0000 (18:42 +0100)]
Add OP_MULTICONCAT op

Allow multiple OP_CONCAT, OP_CONST ops, plus optionally an OP_SASSIGN
or OP_STRINGIFY, to be combined into a single OP_MULTICONCAT op, which can
make things a *lot* faster: 4x or more.

In more detail: it will optimise into a single OP_MULTICONCAT, most
expressions of the form

    LHS RHS

where LHS is one of

    (empty)
    my $lexical =
    $lexical    =
    $lexical   .=
    expression  =
    expression .=

and RHS is one of

    (A . B . C . ...)            where A,B,C etc are expressions and/or
                                 string constants

    "aAbBc..."                   where a,A,b,B etc are expressions and/or
                                 string constants

    sprintf "..%s..%s..", A,B,.. where the format is a constant string
                                 containing only '%s' and '%%' elements,
                                 and A,B, etc are scalar expressions (so
                                 only a fixed, compile-time-known number of
                                 args: no arrays or list context function
                                 calls etc)

It doesn't optimise other forms, such as

    ($a . $b) . ($c. $d)

    ((($a .= $b) .= $c) .= $d);

(although sub-parts of those expressions might be converted to an
OP_MULTICONCAT). This is partly because it would be hard to maintain the
correct ordering of tie or overload calls.

The compiler uses heuristics to determine when to convert: in general,
expressions involving a single OP_CONCAT aren't converted, unless some
other saving can be made, for example if an OP_CONST can be eliminated, or
in the presence of 'my $x = .. ' which OP_MULTICONCAT can apply
OPpTARGET_MY to, but OP_CONST can't.

The multiconcat op is of type UNOP_AUX, with the op_aux structure directly
holding a pointer to a single constant char* string plus a list of segment
lengths. So for

    "a=$a b=$b\n";

the constant string is "a= b=\n", and the segment lengths are (2,3,1).
If the constant string has different non-utf8 and utf8 representations
(such as "\x80") then both variants are pre-computed and stored in the aux
struct, along with two sets of segment lengths.

For all the above LHS types, any SASSIGN op is optimised away. For a LHS
of '$lex=', '$lex.=' or 'my $lex=', the PADSV is optimised away too.

For example where $a and $b are lexical vars, this statement:

    my $c = "a=$a, b=$b\n";

formerly compiled to

    const[PV "a="] s
    padsv[$a:1,3] s
    concat[t4] sK/2
    const[PV ", b="] s
    concat[t5] sKS/2
    padsv[$b:1,3] s
    concat[t6] sKS/2
    const[PV "\n"] s
    concat[t7] sKS/2
    padsv[$c:2,3] sRM*/LVINTRO
    sassign vKS/2

and now compiles to:

    padsv[$a:1,3] s
    padsv[$b:1,3] s
    multiconcat("a=, b=\n",2,4,1)[$c:2,3] vK/LVINTRO,TARGMY,STRINGIFY

In terms of how much faster it is, this code:

    my $a = "the quick brown fox jumps over the lazy dog";
    my $b = "to be, or not to be; sorry, what was the question again?";

    for my $i (1..10_000_000) {
        my $c = "a=$a, b=$b\n";
    }

runs 2.7 times faster, and if you throw utf8 mixtures in it gets even
better. This loop runs 4 times faster:

    my $s;
    my $a = "ab\x{100}cde";
    my $b = "fghij";
    my $c = "\x{101}klmn";

    for my $i (1..10_000_000) {
        $s = "\x{100}wxyz";
        $s .= "foo=$a bar=$b baz=$c";
    }

The main ways in which OP_MULTICONCAT gains its speed are:

* any OP_CONSTs are eliminated, and the constant bits (already in the
  right encoding) are copied directly from the constant string attached to
  the op's aux structure.

* It optimises away any SASSIGN op, and possibly a PADSV op on the LHS, in
  all cases; OP_CONCAT only did this in very limited circumstances.

* Because it has a holistic view of the entire concatenation expression,
  it can do the whole thing in one efficient go, rather than creating and
  copying intermediate results. pp_multiconcat() goes to considerable
  efforts to avoid inefficiencies. For example it will only SvGROW() the
  target once, and to the exact size needed, no matter what mix of utf8
  and non-utf8 appear on the LHS and RHS.  It never allocates any
  temporary SVs except possibly in the case of tie or overloading.

* It does all its own appending and utf8 handling rather than calling
  out to functions like sv_catsv().

* It's very good at handling the LHS appearing on the RHS; for example in

    $x = "abcd";
    $x = "-$x-$x-";

  It will do roughly the equivalent of the following (where targ is $x);

    SvPV_force(targ);
    SvGROW(targ, 11);
    p = SvPVX(targ);
    Move(p,   p+1,  4, char);
    Copy("-", p,    1, char);
    Copy("-", p+5,  1, char);
    Copy(p+1, p+6,  4, char);
    Copy("-", p+10, 1, char);
    SvCUR(targ) = 11;
    p[11] = '\0';

  Formerly, pp_concat would have used multiple PADTMPs or temporary SVs to
  handle situations like that.

The code is quite big; both S_maybe_multiconcat() and pp_multiconcat()
(the main compile-time and runtime parts of the implementation) are over
700 lines each. It turns out that when you combine multiple ops, the
number of edge cases grows exponentially ;-)

6 years agooverload.t: add more concat tests
David Mitchell [Fri, 18 Aug 2017 13:51:45 +0000 (14:51 +0100)]
overload.t: add more concat tests

The '.' and '.=' string concatenation overload methods don't seem to be
heavily tested. Add some more tests, especially with an eye to things that
might break when multiple concat ops are optimised into a single op
(as I intend to do shortly).

6 years agofix a benchmarks sprintf entry
David Mitchell [Mon, 14 Aug 2017 15:46:01 +0000 (16:46 +0100)]
fix a benchmarks sprintf entry

an sprintf entry in t/perf/benchmarks was missing two %s's due to an
earlier cut+paste error. Also, it was being constant folded, so
use vars rather literals for the arguments.

6 years agoadd extra optimization phase
David Mitchell [Wed, 20 Sep 2017 15:02:55 +0000 (16:02 +0100)]
add extra optimization phase

Add the function optimize_optree(). Optree optimization/finalization is
now done in three main phases:

    1) optimize_optree(optree);
    2) CALL_PEEP(*startp);
    3) finalize_optree(optree);

(1) and (3) are done in top-down order, while (2) is done in execution
order.

Note that this function doesn't actually optimize anything yet; this
commit is just adding the necessary infrastructure.

Adding this extra top-down phase allows certain combinations of ops
to be recognised in ways that the peephole optimizer would find hard.

For example in

    $a = expression1 . expression2 . expression3 . expression4

the top-down tree looks like

    sassign
        concat
            concat
                concat
                    expression1
                        ...
                    expression2
                        ...
                expression3
                    ...
            expression4
                ...
        padsv[$a]

so its easy to see the nested concats, while execution order looks like

    ... lots of ops for expression1 ...
    ... lots of ops for expression2 ...
    concat
    ... lots of ops for expression3 ...
    concat
    ... lots of ops for expression4 ...
    concat
    padsv[$a]
    sassign

where its not at all obvious that there is a chain of nested concats.

Similarly, trying to do this in finalize_optree() is hard because the
peephole optimizer will have messed things up. Also it will be too
late to remove nulled-out ops from the execution path.

6 years agopanic if a freed op is called
David Mitchell [Wed, 4 Oct 2017 10:29:40 +0000 (11:29 +0100)]
panic if a freed op is called

On debugging builds, when freeing an op, set its op_ppaddr to point to
a function which dies. That way if a freed op accidentally remains in the
execution path, you'll know immediately, rather than crashing sometime
later with a stack underflow or whatever.

6 years agoregen/opcode.pl: display duplicate bit name
David Mitchell [Sun, 20 Aug 2017 11:21:09 +0000 (12:21 +0100)]
regen/opcode.pl: display duplicate bit name

change this error message:

    addbits(): bit 4 of multiconcat already specified  at ...

to

    addbits(): bit 4 of multiconcat already specified (OPpTARGET_MY) at ...

6 years agoUse nl_langinfo_l() if available
Karl Williamson [Thu, 26 Oct 2017 14:29:50 +0000 (08:29 -0600)]
Use nl_langinfo_l() if available

This function allows us to avoid using a mutex and changing the locale.

6 years agomake_ext.pl: Use version.pm for version cmp
Father Chrysostomos [Mon, 30 Oct 2017 20:37:21 +0000 (13:37 -0700)]
make_ext.pl: Use version.pm for version cmp

We do a version comparison to determine whether Makefile.PL needs to
be run (in case a module version changed).  The simple string compar-
ison we have done up till now fails if the two version numbers differ
simply by a trailing zero (as currently happens with DB_File, which
is at version 1.840, with XS_VERSION set to 1.84.  Since version.pm’s
routines are compiled into miniperl, there is no reason not to do this
‘properly’, and it stops multiple ‘make’ invocations from rebuilding
DB_File again, and again....

6 years agoperldeprecation: Change some uses of "in Perl $version" to "as of Perl $version"
Dagfinn Ilmari Mannsåker [Mon, 30 Oct 2017 18:24:50 +0000 (18:24 +0000)]
perldeprecation: Change some uses of "in Perl $version" to "as of Perl $version"

In present and present perfect tense sentences, this makes it clearer
that it doesn't just apply to that version, but subsequent versions
too.  Sentences in simple past tense have been left as is.

6 years agoThe AIX doubledouble longdouble has been left broken for three years.
Jarkko Hietaniemi [Mon, 30 Oct 2017 05:19:18 +0000 (07:19 +0200)]
The AIX doubledouble longdouble has been left broken for three years.

I must have left the test in the wrong position while
working on getting it to work, and never tested it since.
My apologies.

With this simple trick the following failing tests start to work.

        ../cpan/Math-Complex/t/Complex.t
        ../cpan/Math-Complex/t/Trig.t
        ../cpan/Math-Complex/t/underbar.t
        ../cpan/Scalar-List-Utils/t/uniq.t
        ../ext/POSIX/t/math.t
        ../lib/warnings.t
        op/sprintf2.t
        op/time.t

Or rather, the broken part of the functionality, Infinity,
starts being avoided, as it should be.  See the comment above
about the known brokenness of long doubles and infinity in AIX.

Note that even after this fix the following are still broken in
this AIX (the perl5 aix machine), but these are unrelated to infnan:

        ../cpan/ExtUtils-MakeMaker/t/03-xsstatic.t
        ../dist/Storable/t/store.t
        ../ext/XS-APItest/t/handy00.t
        re/uniprops01.t
        re/uniprops02.t
        re/uniprops03.t
        re/uniprops04.t
        re/uniprops05.t
        re/uniprops06.t
        re/uniprops07.t
        re/uniprops08.t
        re/uniprops09.t
        re/uniprops10.t

(as of blead 4faa3060)

6 years agoperldelta for e8d55f27af46, ebcc725e3f7e
Tony Cook [Mon, 30 Oct 2017 00:14:36 +0000 (11:14 +1100)]
perldelta for e8d55f27af46ebcc725e3f7e

6 years ago(perl #132245) don't leak on \N{}
Tony Cook [Wed, 18 Oct 2017 23:47:22 +0000 (10:47 +1100)]
(perl #132245) don't leak on \N{}

get_and_check_backslash_N_name() failed to free its working SV if
the name was empty.

6 years ago(perl #132245) don't try to process a char range with no preceding char
Tony Cook [Wed, 18 Oct 2017 23:46:04 +0000 (10:46 +1100)]
(perl #132245) don't try to process a char range with no preceding char

A range like \N{}-0 eventually results in compilation failing, but
before that, get_and_check_backslash_N_name() attempts to treat
the memory before the empty output of \N{} as a character.

6 years agoShow that '/o' modifier no longer has adverse effects on 'split'.
Harald Jörg [Sun, 29 Oct 2017 13:41:59 +0000 (09:41 -0400)]
Show that '/o' modifier no longer has adverse effects on 'split'.

    The underlying problem was already fixed in
    3cb4cde3dd4d2af2f5065053905708bffa5168f9 (Jul 4 2017).  For clarity, adding
    test adapted from original poster in RT 132334.

    Add Harald Jörg to Perl AUTHORS.

6 years agoClarify comments around deprecated attributes
Dagfinn Ilmari Mannsåker [Sun, 29 Oct 2017 12:57:25 +0000 (12:57 +0000)]
Clarify comments around deprecated attributes

6 years agobytes_to_utf8(): Trim unused malloc'd space
Karl Williamson [Sun, 29 Oct 2017 05:13:47 +0000 (23:13 -0600)]
bytes_to_utf8(): Trim unused malloc'd space

I asked on p5p if anyone had an opinion about whether to trim
overallocated space in this function, and got no replies.

It seems to me to be best to tidy up upon return.

6 years agoBump Socket version to 2.020_04
Karl Williamson [Sat, 28 Oct 2017 19:08:02 +0000 (13:08 -0600)]
Bump Socket version to 2.020_04

Commit 0cdc775ef423ad6415e6f80b9244c17a52bf5149 made a small change in
cpan/Socket/Socket.pm, causing a porting test failure, which is solved
by a version bump, and changing customized.dat to account for that.

6 years agoperlre: Slight clarification
Karl Williamson [Sat, 28 Oct 2017 18:51:07 +0000 (12:51 -0600)]
perlre: Slight clarification

6 years agoperldiag: More detail on /i var length lookbehind
Karl Williamson [Sat, 28 Oct 2017 18:32:57 +0000 (12:32 -0600)]
perldiag: More detail on /i var length lookbehind

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

6 years agoregcomp.h: Add comment
Karl Williamson [Fri, 27 Oct 2017 18:52:26 +0000 (12:52 -0600)]
regcomp.h: Add comment

6 years agoNumify $Socket::VERSION
Dagfinn Ilmari Mannsåker [Sat, 28 Oct 2017 15:23:33 +0000 (16:23 +0100)]
Numify $Socket::VERSION

We have a customised version with _ in the version, which causes
warnings from modules that check it numerically instead of calling
->VERSION(...).

6 years agoChange upper limit handling of -Dr output
Karl Williamson [Fri, 27 Oct 2017 18:28:57 +0000 (12:28 -0600)]
Change upper limit handling of -Dr output

Commit 2bfbbbaf9ef1783ba914ff9e9270e877fbbb6aba changed things so -Dr
output could be changed through an environment variable to truncate
the output differently than the default.

For most purposes, the default is good enough, but for someone trying to
debug the regcomp internals, sometimes one wants to see more than is
output by default.

That commit did not catch all the places.  This one changes the handling
so that any place that use the previous default maximum now uses the
environment variable (if set) instead.

6 years agoDevel-PPPort: Fix up pod
Karl Williamson [Fri, 27 Oct 2017 16:40:42 +0000 (10:40 -0600)]
Devel-PPPort: Fix up pod

Now that this module is in dist, podcheck runs, and found problems,
which this commit fixes.

6 years agomv Devel-PPPort from cpan to dist
Karl Williamson [Tue, 17 Oct 2017 12:54:57 +0000 (06:54 -0600)]
mv Devel-PPPort from cpan to dist

It was decided at the perl core hackathon in October 2017 to go ahead
and do this.

6 years agoregcomp.c: Skip UTF-8 decoding for invariants
Karl Williamson [Fri, 27 Oct 2017 16:15:29 +0000 (10:15 -0600)]
regcomp.c: Skip UTF-8 decoding for invariants

By adding two branches, we can avoid the expensive UTF-8 decode step for
the common case of the input being an ASCII character.

6 years agotoke.c: Add commentary
Karl Williamson [Fri, 27 Oct 2017 16:08:35 +0000 (10:08 -0600)]
toke.c: Add commentary

6 years agoregcomp.c: Don't forget to restore state
Karl Williamson [Fri, 27 Oct 2017 15:51:23 +0000 (09:51 -0600)]
regcomp.c: Don't forget to restore state

In code reading (so I don't have a test case), I realized that this code
could return out of its function without restoring the state that it has
changed out from under the caller, and that can lead to havoc when the
caller continues on assuming the original state.

This commit moves the return and other checking to after the state
restoral code.  It can call FAIL2 as part of a panic after the state the
failure is in is gone.  This would be a problem if it called vFAIL2
instead, but isn't because FAIL2 doesn't need the state the failure was
in.

6 years agoregcomp.c: Remove redundant 'if'
Karl Williamson [Fri, 27 Oct 2017 15:32:26 +0000 (09:32 -0600)]
regcomp.c: Remove redundant 'if'

We have already assured earlier in the function that this 'if' is always
true.

6 years agoregcomp.c: White-space only
Karl Williamson [Fri, 27 Oct 2017 15:25:56 +0000 (09:25 -0600)]
regcomp.c: White-space only

Vertically align some text.

6 years agoregcomp.c: Add assertion
Karl Williamson [Fri, 27 Oct 2017 15:23:01 +0000 (09:23 -0600)]
regcomp.c: Add assertion

6 years agoDon't link in Perl_my_strnlen when we don't have it.
Craig A. Berry [Thu, 26 Oct 2017 12:46:46 +0000 (07:46 -0500)]
Don't link in Perl_my_strnlen when we don't have it.

6 years agoUse File::Spec->tmpdir() instead of hard-coded /tmp
Steve Hay [Thu, 26 Oct 2017 07:28:25 +0000 (08:28 +0100)]
Use File::Spec->tmpdir() instead of hard-coded /tmp

The latter doesn't necessarily work on Windows (it depends whether you have
such a folder on the current drive), leading to a failed chdir(), which in
turn results in temporary files being created in the wrong folder, which
then don't get cleaned up.

6 years agoRestore parenthesis that went missing in 083b2a61ee6281f.
Craig A. Berry [Thu, 26 Oct 2017 01:28:23 +0000 (20:28 -0500)]
Restore parenthesis that went missing in 083b2a61ee6281f.

6 years agoRedirect STDERR to /dev/null instead of just closing it
Steve Hay [Wed, 25 Oct 2017 16:46:44 +0000 (17:46 +0100)]
Redirect STDERR to /dev/null instead of just closing it

See perl #132358: Just closing it leaves that file descriptor available
for use by the next open(), which can have unforeseen consequences...

6 years agoRemove unused probes in configure.com.
Craig A. Berry [Wed, 25 Oct 2017 12:33:34 +0000 (07:33 -0500)]
Remove unused probes in configure.com.

Recent commits for the C89 work had us stop using the result of
these probes, so there is no point in continuing to build and run
them.

6 years agoRevert "vms/vmsish.h: move a function declaration from doio.c"
Craig A. Berry [Wed, 25 Oct 2017 12:29:35 +0000 (07:29 -0500)]
Revert "vms/vmsish.h: move a function declaration from doio.c"

This reverts commit d4bd48023fe0ba950fface5aa859b6852aa29fc4.

perlio.h depends on vmsish.h and comes in (via iperlsys.h) about
a thousand lines later in perl.h.  So we can't put a prototype
that uses PerlIO in vmsish.h

Maybe there is a way to get that prototype out of doio.c, but
this isn't it.

6 years agoFix missing skip counts in PathTools' cwd.t
Dagfinn Ilmari Mannsåker [Wed, 25 Oct 2017 10:24:52 +0000 (11:24 +0100)]
Fix missing skip counts in PathTools' cwd.t

6 years agoUpgrade Net::Ping from version 2.55 to 2.61
Steve Hay [Tue, 24 Oct 2017 07:34:23 +0000 (08:34 +0100)]
Upgrade Net::Ping from version 2.55 to 2.61

This retains blead customizations 0fc44d0a18 and 7bfdd8260c. Other
customizations have been incorporated into the CPAN release.

6 years agodquote.c: Rmv extraneous #ifdef; add assertions
Karl Williamson [Sat, 25 Mar 2017 17:35:11 +0000 (11:35 -0600)]
dquote.c: Rmv extraneous #ifdef; add assertions

assert() already does nothing unless -DDEBUGGING; no need to enclose
them in #ifdef DEBUGGING.  And this adds another assertion that is
required to be true on entry to the function.

6 years agohandy.h: Add parens around macro expansion
Karl Williamson [Mon, 24 Apr 2017 19:09:16 +0000 (13:09 -0600)]
handy.h: Add parens around macro expansion

This guarantees the expected precedence no matter what the context it is
called in.

6 years agonumeric.c: Add comment
Karl Williamson [Sat, 25 Mar 2017 20:01:58 +0000 (14:01 -0600)]
numeric.c: Add comment

6 years agoConvert strncmp into strnEQ, strnNE
Karl Williamson [Thu, 9 Mar 2017 04:55:08 +0000 (21:55 -0700)]
Convert strncmp into strnEQ, strnNE

The new versions are much easier to comprehend.

There are several cases in vms.c where strEQ and strNE suffice, instead
of having to have a count parameter.

6 years agoConvert strcmp into strEQ, strNE
Karl Williamson [Thu, 9 Mar 2017 20:13:07 +0000 (13:13 -0700)]
Convert strcmp into strEQ, strNE

The latter two are easier to read

6 years agoUnweaken refs in in-place reverse
Dagfinn Ilmari Mannsåker [Tue, 26 Sep 2017 22:11:04 +0000 (23:11 +0100)]
Unweaken refs in in-place reverse

For consistency with assignment and in-place sort

6 years agoDynaLoader: Use strlcpy instead of strcpy
Karl Williamson [Mon, 27 Mar 2017 20:16:27 +0000 (14:16 -0600)]
DynaLoader: Use strlcpy instead of strcpy

strlcpy is safer.

6 years agoSkip various tests if PERL_BUILD_PACKAGING is set
Dominic Hargreaves [Sat, 14 Oct 2017 14:27:53 +0000 (16:27 +0200)]
Skip various tests if PERL_BUILD_PACKAGING is set

These are tests which tend not to be useful for downstream packagers

t/porting/customized.t change originally from Todd Rinaldo

6 years agoFurther simplify XSLoader .bs file handling
Dagfinn Ilmari Mannsåker [Mon, 23 Oct 2017 17:50:31 +0000 (18:50 +0100)]
Further simplify XSLoader .bs file handling

Because we're not actually doing anything with it, combine the check
with the one for the missing file.

6 years agoAvoid loading .bs files twice when using XSLoader
Dagfinn Ilmari Mannsåker [Mon, 23 Oct 2017 17:33:11 +0000 (18:33 +0100)]
Avoid loading .bs files twice when using XSLoader

When a .bs file is found, XSLoader::load() falls back to
DynalLoader::bootstrap() which will load it, so there's no need to do
it twice.

6 years agoIncrease $B::VERSION to 1.71
Father Chrysostomos [Mon, 23 Oct 2017 16:52:23 +0000 (09:52 -0700)]
Increase $B::VERSION to 1.71

6 years agoB::walksymtable: clear cached methods
Father Chrysostomos [Mon, 23 Oct 2017 16:50:10 +0000 (09:50 -0700)]
B::walksymtable: clear cached methods

There was a dummy assignment in B::walksymtable that I removed in com-
mit 6a4fc5265ba1 because it appeared to be redundant.  Removing that
assignment broke Module::Info (rt.cpan.org #123352), because it
changed the behaviour of B::Utils (by changing the behaviour of
B::walksymtable).  That seemingly useless assignment was actually
clearing cached methods, so that any B::GV object passed to the call-
back method sees ->CV pointing to something only if there is a real
sub there.  Since this seems like a reasonable expectation, this com-
mit restores the old behaviour, with a comment explaining what the
assignment is for, and tests it.

6 years agoRT#132347: fix building Tk
Aaron Crane [Mon, 23 Oct 2017 16:22:34 +0000 (17:22 +0100)]
RT#132347: fix building Tk

The Tk distribution has its own portability layer that expects to find
certain settings in %Config, as well as some cpp symbols defined in
perl.h. The recent Perl changes to require a C89 compiler caused some of
the metaconfig units defining those %Config settings and cpp symbols to
be omitted. This commit restores compatibility with Tk, by ensuring that
the things it wants are available even though they are no longer
provided by metaconfig.

6 years agoQuieten Time-HiRes test noise
Dagfinn Ilmari Mannsåker [Mon, 23 Oct 2017 14:50:55 +0000 (15:50 +0100)]
Quieten Time-HiRes test noise

The notices about testing for subsecond file timestamps don't belong
on STDERR, since we skip_all based on the result anyway.

6 years ago[MERGE] various bench.pl enhancements and fixes
David Mitchell [Mon, 23 Oct 2017 11:57:57 +0000 (12:57 +0100)]
[MERGE] various bench.pl enhancements and fixes

Various enhancements and fixups to bench.pl. The most notable ones are:

* Add 'compile' benchmark field

    If a benchmark has this flag set, measure the compile time of the
    construct rather than its execution time, by wrapping the code in

        eval q{ sub { ... } }

* Add 'pre' and 'post' benchmark fields

    These allow actions to be performed each time round the loop, just before
    and after the benchmarked code, but without contributing to the timings.

    For example to benchmark appending to a string, you need to reset the
    string to a known state before each iteration, otherwise the string gets
    bigger and bigger with each iteration:

        code => '$s = ""; $s .= "foo"',

    but now you're measuring both the concat and an assign. To measure just
    the concat, you can now do:

        pre  => '$s = ""',
        code => '$s .= "foo"',

    Note the contrast with 'setup', which is only executed once, outside the
    loop.

* Make 'desc' default to 'code'

    Any entries in the benchmarks file which don't have a 'desc' description
    field will have the description set to the string for 'code'

* Allow negative column indices

    e.g. --norm=-2 will make the second-to-rightmost column the 100% one

* Miscellaneous:

     Make -v an alias for --verbose

     --compact: display description too

     Add checks for bad benchmark files

     Display large values as 'Inf'

     Allow variable-width data columns

     --autolabel: avoid degenerate cases

     Fix race condition in test

     List the valid perls as part of an 'unrecognised perl' error message

6 years agobenchmarks.t: update to handle field changes
David Mitchell [Mon, 23 Oct 2017 11:46:04 +0000 (12:46 +0100)]
benchmarks.t: update to handle field changes

desc and setup are now optional; pre, post and compile have been added.

6 years agobench.pl: add 'compile' benchmark field
David Mitchell [Mon, 23 Oct 2017 10:29:18 +0000 (11:29 +0100)]
bench.pl: add 'compile' benchmark field

If a benchmark has this flag set, measure the compile time of the
construct rather than its execution time, by wrapping the code in

    eval q{ sub { ... } }

6 years agobench.pl: add 'pre' and 'post' benchmark fields
David Mitchell [Sat, 21 Oct 2017 22:53:03 +0000 (23:53 +0100)]
bench.pl: add 'pre' and 'post' benchmark fields

These allow actions to be performed each time round the loop, just before
and after the benchmarked code, but without contributing to the timings.

For example to benchmark appending to a string, you need to reset the
string to a known state before each iteration, otherwise the string gets
bigger and bigger with each iteration:

    code => '$s = ""; $s .= "foo"',

but now you're measuring both the concat and an assign. To measure just
the concat, you can now do:

    pre  => '$s = ""',
    code => '$s .= "foo"',

Note the contrast with 'setup', which is only executed once, outside the
loop.

6 years agobench.pl: make 'desc' default to 'code'
David Mitchell [Sat, 21 Oct 2017 15:44:58 +0000 (16:44 +0100)]
bench.pl: make 'desc' default to 'code'

Any entries in the benchmarks file which don't have a 'desc' description
fields will have the description set to the string for 'code'

6 years agobench.pl: add checks for bad benchmark files
David Mitchell [Sat, 21 Oct 2017 14:53:05 +0000 (15:53 +0100)]
bench.pl: add checks for bad benchmark files

When reading in a --benchmark file, do some basic sanity checks on the
values read in:
    * an even number of name => {} pairs
    * a valid test name
    * valid hash keys

6 years agobench.pl: display large values as 'Inf'
David Mitchell [Sat, 21 Oct 2017 14:19:28 +0000 (15:19 +0100)]
bench.pl: display large values as 'Inf'

When calculating percentages, you might end up with something like

    1 / 0.0000001

which really means that the new perl had one cache miss (say) and the old
perl had zero misses, but due to measurement noise, the 0 wasn't measured
as quite 0.

So if the value is more than a million, display as 'Inf' instead.

6 years agobench.pl: allow variable-width data columns
David Mitchell [Sat, 21 Oct 2017 14:13:35 +0000 (15:13 +0100)]
bench.pl: allow variable-width data columns

Rather than using a fixed(ish) format width like "%6.2f" (which was only
increased based on the width of the label heading each column), calculate
separately for each column, the minimum width based on both the label and
all the data to be displayed in that column.

6 years agobench.pl: factor out some common code
David Mitchell [Sat, 21 Oct 2017 10:05:39 +0000 (11:05 +0100)]
bench.pl: factor out some common code

put the code which prints a single data cell into a separate function,
grind_format_cell()

6 years agobench.pl: make -v an alias for --verbose
David Mitchell [Fri, 20 Oct 2017 12:30:27 +0000 (13:30 +0100)]
bench.pl: make -v an alias for --verbose

I'm too lazy to type the whole word every time.

6 years agobench.pl --autolabel: avoid degenerate cases
David Mitchell [Fri, 20 Oct 2017 12:06:27 +0000 (13:06 +0100)]
bench.pl --autolabel: avoid degenerate cases

If there was only one executable, it was creating the label ''; use '0'
instead.

Also, if the auto-generated labels are integers, prefix them with 'p'
so that things like --norm=2 aren't ambiguous (column number versus label)

6 years agobench.pl: fix race condition in test
David Mitchell [Fri, 20 Oct 2017 11:52:17 +0000 (12:52 +0100)]
bench.pl: fix race condition in test

The test that forces cachegrind to give an error by providing an invalid
arg, tests that bench.pl complains about the bad output from cachegrind.

But due to the way bench.pl's main event loop works, its possible for the
process to be reaped and for bench.pl to complain about its exit status
*before* any error message is read back from the pipe.

So test for both types of possible error message.

See
    Subject: Intermittent failure in bench.t
    http://nntp.perl.org/group/perl.perl5.porters/245218

6 years agobench.pl --compact: display description too
David Mitchell [Fri, 20 Oct 2017 11:35:18 +0000 (12:35 +0100)]
bench.pl --compact: display description too

As well as displaying the test name on each line, e.g.

    call::sub::empty

display the description too, e.g.

    call::sub::empty   function call with no args or body

6 years agobench.pl: allow negative column indices
David Mitchell [Fri, 20 Oct 2017 11:21:01 +0000 (12:21 +0100)]
bench.pl: allow negative column indices

e.g. --norm=-2 will make the second-to-rightmost column the 100% one

Also fix a slight bug in the existing positive (0..N-1) column selection
code: it didn't match against more than one digit, so for example
--norm=10 didn't work.

6 years agobench.pl: list valid in 'unrecognised perl' err
David Mitchell [Fri, 20 Oct 2017 11:01:14 +0000 (12:01 +0100)]
bench.pl: list valid in 'unrecognised perl' err

For something like --norm=foo where foo isn't a valid name of a perl
executable, list the valiud names as part of the error message

6 years agometaconfig: ignore "index", "rindex"
Aaron Crane [Mon, 23 Oct 2017 10:43:23 +0000 (11:43 +0100)]
metaconfig: ignore "index", "rindex"

This permits deletion of our modified d_strchr.U metaconfig unit.

6 years agoConfigure: rebuild from latest units
Aaron Crane [Mon, 23 Oct 2017 10:34:06 +0000 (11:34 +0100)]
Configure: rebuild from latest units

This is a whitespace-only change.

6 years agoNew .metaconf-exclusions.txt file
Aaron Crane [Mon, 23 Oct 2017 10:25:06 +0000 (11:25 +0100)]
New .metaconf-exclusions.txt file

This file lists symbols that metaconfig should ignore when calculating
what units Perl needs.