This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
7 years agoMove a recently-added test
Father Chrysostomos [Tue, 16 Aug 2016 18:14:51 +0000 (11:14 -0700)]
Move a recently-added test

It’s not really a method test (no method call is involved, but a check
to see whether the code might compile to a method call), but a lexer
test.

7 years agoav_fetch(): use less branches.
David Mitchell [Wed, 17 Aug 2016 11:06:27 +0000 (12:06 +0100)]
av_fetch(): use less branches.

The code that handles negative array indexes and out-of-bounds
negative indices used to require:

    2 conditions for a +ve index
    3 conditions for a -ve index

After this commit, for the common case where the index is in bounds,
it requires a single condition regardless of sign. For the less common
case of out-of-bounds, it requires 2 conditions.

Also, the one condition is more branch-predict friendly - it's whether
the index is in bounds or not. Previously the first test was whether
key < 0, and in code that does mixed signs, such as $a[0] + $a[-1],
branch prediction could be tricky.

It achieves this at the expense of a more complex expression for the key.

7 years agoav_fetch(): sprinkle UNLIKELY()
David Mitchell [Wed, 17 Aug 2016 10:18:46 +0000 (11:18 +0100)]
av_fetch(): sprinkle UNLIKELY()

7 years agoav_fetch(): optimise the negative index branch.
David Mitchell [Wed, 17 Aug 2016 08:59:06 +0000 (09:59 +0100)]
av_fetch(): optimise the negative index branch.

For a negative index one conditional is redundant, since after determining
that key < 0 and recomputing key as (AvFILLp(av) - key), key can't
be > AvFILLp(av).

7 years agoav_fetch(): use AvFILLp rather than AvFILL
David Mitchell [Wed, 17 Aug 2016 08:52:48 +0000 (09:52 +0100)]
av_fetch(): use AvFILLp rather than AvFILL

The point in the code which uses AvFILL will never be reached if the array
is tied, so use AvFILLp insead, which directly accesses the xav_fill
field.

This only affects the $a[-N] branch: the $a[+N] branch already uses
AvFILLp().

7 years agoCoverity CID #152143: annotate switch fallthru.
Jarkko Hietaniemi [Wed, 17 Aug 2016 11:18:03 +0000 (07:18 -0400)]
Coverity CID #152143: annotate switch fallthru.

7 years agoav_fetch(): remove redundant condition
David Mitchell [Wed, 17 Aug 2016 08:01:44 +0000 (09:01 +0100)]
av_fetch(): remove redundant condition

At the point of testing for !AvARRAY(av)[key] if AvREIFY(av), it's already
been confirmed that the array element isn't null.

7 years agoadd any_op field to the ANY savestack union
David Mitchell [Wed, 17 Aug 2016 06:52:57 +0000 (07:52 +0100)]
add any_op field to the ANY savestack union

This is an attempt to silence a (probably spurious) Coverity warning.

7 years agoThe 48c0e89d broke minitest by unconditional use Hash::Util.
Jarkko Hietaniemi [Wed, 17 Aug 2016 01:56:43 +0000 (21:56 -0400)]
The 48c0e89d broke minitest by unconditional use Hash::Util.

7 years agoperldelta for dd1dbff0
Jarkko Hietaniemi [Wed, 17 Aug 2016 00:34:49 +0000 (20:34 -0400)]
perldelta for dd1dbff0

7 years agoCoverity CID #15149: Missing varargs init or cleanup
Jarkko Hietaniemi [Tue, 16 Aug 2016 23:15:50 +0000 (19:15 -0400)]
Coverity CID #15149: Missing varargs init or cleanup

The return was returning after va_start but before va_end.

7 years agoRevert "Check against negative uid/gid for fchown()."
Jarkko Hietaniemi [Tue, 16 Aug 2016 23:06:31 +0000 (19:06 -0400)]
Revert "Check against negative uid/gid for fchown()."

This reverts commit f95ba548a286b17c260cc168715a9d0d441b14a6.

[rt.perl.org #128967]

The negative arguments to fchown depend on the platform,
so Coverity should not claim it knows what is acceptable.

7 years ago[perl #126482] Fix assert fail ‘a_const a_const’
Father Chrysostomos [Tue, 16 Aug 2016 01:09:17 +0000 (18:09 -0700)]
[perl #126482] Fix assert fail ‘a_const a_const’

Mentioning a constant twice in a row results in an assertion failure:

$ ./miniperl -e 'sub ub(){0} ub ub'
Assertion failed: (SvTYPE(cv) == SVt_PVCV || SvTYPE(cv) == SVt_PVFM), function Perl_cv_const_sv_or_av, file op.c, line 7926.
Abort trap: 6

A bisect points to 2eaf799e7, but I don’t understand why that commit
introduced it.  I suspect it was failing an assertion for a slightly
different reason back then, but am too lazy to check.

In any case, it fails now because, while ‘ub ub’ is being compiled,
when the sub is looked up initially (in toke.c:yylex), we call
rv2cv_op_cv with the RV2GVOPCV_RETURN_STUB flag, which allows a
bare constant ref to be returned.  So the ‘cv’ variable contains
an RV (\0):

    cv = lex
? isGV(gv)
    ? GvCV(gv)
    : SvROK(gv) && SvTYPE(SvRV(gv)) == SVt_PVCV
? (CV *)SvRV(gv)
: ((CV *)gv)
: rv2cv_op_cv(rv2cv_op, RV2CVOPCV_RETURN_STUB);

(‘ub’ here is a constant 0, which is stored in the symbol table as
\0; i.e., ‘sub ub(){0}’ is equivalent to ‘BEGIN { $::{ub} = \0 }’.)

Then if we see a word immediately following it (the second ‘ub’) we
check a little further down to see whether it might be a method call.
That entails calling intuit_method, which does this:

indirgv = gv_fetchpvn_flags(tmpbuf, len, ( UTF ? SVf_UTF8 : 0 ), SVt_PVCV);
if (indirgv && GvCVu(indirgv))
    return 0;

So we are looking to see whether the second word refers to a sub and
deciding this is not an indirect method call if there is a sub.

But calling gv_fetchpvn_flags like that has the effect of upgrading
the symbol table entry to a full GV.  Since the ‘cv’ variable in yylex
points to that symbol table entry, it ends up pointing to a GV, which
certain code later on does not expect to happen.

So we should pass the GV_NOADD_NOINIT flag to gv_fetchpvn_flags to
prevent lookup of the second bareword from upgrading the entry (we
already do that earlier in intuit_method for the first bareword).  We
only check the GV to see whether it has a sub or io thingy in it any-
way, so we don’t actually need a full GV.  (As a bonus, GvIO will
already work on a non-GV and return NULL, so that part of the code
remains unchanged.)

7 years agobuffer overflow in "string terminator" err msg
David Mitchell [Tue, 16 Aug 2016 12:50:46 +0000 (13:50 +0100)]
buffer overflow in "string terminator" err msg

RT #128952

In
    eval "q" . chr(100000000064);

generating the error message C<Can't find string terminator "XXX"'>
was overrunning a buffer designed to hold a single utf8 char, since
it wasn't allowing for the \0 at the end.

7 years agoperldelta for e94ea821c9
Father Chrysostomos [Tue, 16 Aug 2016 01:09:17 +0000 (18:09 -0700)]
perldelta for e94ea821c9

7 years agoperldelta for #128740 / d35c1b5e4
Father Chrysostomos [Tue, 16 Aug 2016 01:07:43 +0000 (18:07 -0700)]
perldelta for #128740 / d35c1b5e4

7 years agoperldelta for 10030f4b9
Father Chrysostomos [Tue, 16 Aug 2016 01:03:43 +0000 (18:03 -0700)]
perldelta for 10030f4b9

7 years agoperldelta for 7bb33634741
Father Chrysostomos [Tue, 16 Aug 2016 01:00:08 +0000 (18:00 -0700)]
perldelta for 7bb33634741

7 years agoperldelta for b199a3980
Father Chrysostomos [Tue, 16 Aug 2016 00:58:12 +0000 (17:58 -0700)]
perldelta for b199a3980

7 years agoperldelta for #128701 / cb65013574
Father Chrysostomos [Tue, 16 Aug 2016 00:54:29 +0000 (17:54 -0700)]
perldelta for #128701 / cb65013574

7 years agoXS::APItest: Note why we do not want efficiency
Father Chrysostomos [Mon, 15 Aug 2016 04:36:39 +0000 (21:36 -0700)]
XS::APItest: Note why we do not want efficiency

7 years ago"" . open(my $fh,...) gave wrong warning
David Mitchell [Mon, 15 Aug 2016 10:39:11 +0000 (11:39 +0100)]
"" . open(my $fh,...) gave wrong warning

RT #128940

    $ perl -we 'print "" . open my $fh, "<", "no / such / file"'
    Use of uninitialized value $fh in concatenation (.) or string at -e line 1.
                           ^^^

7 years agoperldelta: @a = sort @a fix
David Mitchell [Mon, 15 Aug 2016 08:36:22 +0000 (09:36 +0100)]
perldelta: @a = sort @a fix

7 years agoHash-Util/Util.xs: silence compiler warnings
David Mitchell [Mon, 15 Aug 2016 08:17:52 +0000 (09:17 +0100)]
Hash-Util/Util.xs: silence compiler warnings

    Util.c: In function ‘XS_Hash__Util_bucket_ratio’:
    Util.c:638:7: warning: unused variable ‘RETVAL’ [-Wunused-variable]
      SV * RETVAL;

Don't declare a return type if we're not going to use it.

7 years agosilence warning in Opcode.xs
David Mitchell [Mon, 15 Aug 2016 07:55:06 +0000 (08:55 +0100)]
silence warning in Opcode.xs

Opcode.xs:71:21: warning: overflow in implicit constant conversion [-Woverflow]
     bitmap[len-1] = (PL_maxo & 0x07) ? ~(0xFF << (PL_maxo & 0x07)) : 0xFF;

This was due to to PL_maxo being converted from a var into a const value
in a previous commit.

7 years agoRevert "#define PERL_NO_GET_CONTEXT in XS::APItest"
Father Chrysostomos [Mon, 15 Aug 2016 02:00:16 +0000 (19:00 -0700)]
Revert "#define PERL_NO_GET_CONTEXT in XS::APItest"

This reverts commit 6b6b24f11907f607277fd8cf6f08264c234cc693.

In <20160814191141.32442.qmail@lists-nntp.develooper.com> Daniel
Dragan writes:
> If there is 1 module that shouldn't use PERL_NO_GET_CONTEXT XS::APItest
> is the one. *Ideally* in perl core, there is nothing else to test that
> Get-context-everywhere mode works since no production core module would
> be that bitrotten to not use PERL_NO_GET_CONTEXT. I thought about adding
> PERL_NO_GET_CONTEXT XS::APItest 2 years ago and decided against it to
> make sure there is a test in core that get-context-everywhere
> back-compat mode works.

7 years agoRe-order intrp struct
Father Chrysostomos [Sun, 14 Aug 2016 08:12:19 +0000 (01:12 -0700)]
Re-order intrp struct

7 years agoRemove PL_maxo
Father Chrysostomos [Sun, 14 Aug 2016 08:11:07 +0000 (01:11 -0700)]
Remove PL_maxo

We have an interpreter variable using memory, PL_maxo, which is
defined to be the same as MAXO, a #defined constant.  As far as I can
tell, it is never used in lvalue context, in core or on CPAN, except
for the initialisation in intrpvar.h.

It can simply be removed and replaced with a macro defined as equiva-
lent to MAXO.

It was added in this commit:

commit 84ea024ac9cdf20f21223e686dddea82d5eceb4f
Author: Perl 5 Porters <perl5-porters.nicoh.com>
Date:   Tue Jan 2 23:21:55 1996 +0000

    perl 5.002beta1h patch: perl.h

    5.002beta1 attempted some memory optimizations, but unfortunately
    they can result in a memory leak problem.  This can be
    avoided by #define STRANGE_MALLOC.  I do that here until
    consensus is reached on a better strategy for handling the
    memory optimizations.

    Include maxo for the maximum number of operations (needed
    for the Safe extension).

But apparently it is not needed for the Safe extension (tests pass
without it).

7 years ago#define PERL_NO_GET_CONTEXT in XS::APItest
Father Chrysostomos [Sun, 14 Aug 2016 07:52:36 +0000 (00:52 -0700)]
#define PERL_NO_GET_CONTEXT in XS::APItest

We want efficiency.  But more importantly, we want to be able to see
errors in the output, without them getting drowned by:

APItest.xs:197: warning: unused parameter ‘my_perl’
APItest.xs:242: warning: unused parameter ‘my_perl’
APItest.xs:327: warning: unused parameter ‘my_perl’
APItest.xs:341: warning: unused parameter ‘my_perl’
APItest.xs:362: warning: unused parameter ‘my_perl’
APItest.xs:376: warning: unused parameter ‘my_perl’
APItest.xs:390: warning: unused parameter ‘my_perl’
APItest.xs:400: warning: unused parameter ‘my_perl’
APItest.xs:410: warning: unused parameter ‘my_perl’
APItest.xs:426: warning: unused parameter ‘my_perl’
APItest.xs:446: warning: unused parameter ‘my_perl’
APItest.xs:466: warning: unused parameter ‘my_perl’
APItest.xs:474: warning: unused parameter ‘my_perl’
APItest.xs:488: warning: unused parameter ‘my_perl’
APItest.xs:553: warning: unused parameter ‘my_perl’
APItest.xs:564: warning: unused parameter ‘my_perl’
APItest.xs:576: warning: unused parameter ‘my_perl’
APItest.xs:606: warning: unused parameter ‘my_perl’
APItest.xs:620: warning: unused parameter ‘my_perl’
APItest.xs:632: warning: unused parameter ‘my_perl’
APItest.xs:654: warning: unused parameter ‘my_perl’
APItest.xs:672: warning: unused parameter ‘my_perl’
APItest.xs:754: warning: unused parameter ‘my_perl’
APItest.xs:782: warning: unused parameter ‘my_perl’
APItest.xs:851: warning: unused parameter ‘my_perl’
APItest.xs:866: warning: unused parameter ‘my_perl’
APItest.xs:883: warning: unused parameter ‘my_perl’
APItest.xs:904: warning: unused parameter ‘my_perl’
APItest.xs:915: warning: unused parameter ‘my_perl’
APItest.xs:922: warning: unused parameter ‘my_perl’
APItest.xs:937: warning: unused parameter ‘my_perl’
APItest.xs:946: warning: unused parameter ‘my_perl’
APItest.xs:962: warning: unused parameter ‘my_perl’
APItest.xs:969: warning: unused parameter ‘my_perl’
APItest.xs:978: warning: unused parameter ‘my_perl’
APItest.xs:989: warning: unused parameter ‘my_perl’
APItest.xs:995: warning: unused parameter ‘my_perl’
APItest.xs:1001: warning: unused parameter ‘my_perl’
APItest.xs:1007: warning: unused parameter ‘my_perl’
APItest.xs:1013: warning: unused parameter ‘my_perl’
APItest.xs:1019: warning: unused parameter ‘my_perl’
APItest.xs:1034: warning: unused parameter ‘my_perl’
APItest.xs:1040: warning: unused parameter ‘my_perl’
APItest.xs:1050: warning: unused parameter ‘my_perl’
APItest.xs:1124: warning: unused parameter ‘my_perl’
APItest.xs:1136: warning: unused parameter ‘my_perl’
APItest.xs:1146: warning: unused parameter ‘my_perl’
APItest.xs:1237: warning: unused parameter ‘my_perl’
APItest.xs:1243: warning: unused parameter ‘my_perl’
APItest.xs:1251: warning: unused parameter ‘my_perl’
etc.

g++ likes to warn about unused parameters.

7 years agoTest call_argv
Father Chrysostomos [Sun, 14 Aug 2016 07:41:19 +0000 (00:41 -0700)]
Test call_argv

7 years agoautomatically detect GCC vs VC and set VC ver number on Win32
Daniel Dragan [Sun, 14 Aug 2016 08:34:37 +0000 (04:34 -0400)]
automatically detect GCC vs VC and set VC ver number on Win32

This fixes a bug, if you use gmake, without a GCC in PATH (but you do have
a VC in PATH) GNUMakefile is unusable because target info fatally errors.
I usually keep a strawberry perl's /c/bin dir in PATH for dmake and gmake
on my VC builds, but in 1 build config, I installed gmake to my C:/Windows
dir and did not have SP's /c/bin dir in my PATH, so GNUMakefile was broken
in that case. This patch fixes the bug.

-move the gcc -dumpversion shell outs to the GCC only section in both mkfs
 dont run gcc -dumpversion on a VC build
-dont have a default CCTYPE anymore, autodetect it, if user supplies CCTYPE
 explicitly on cmd line to make tool, then dont do autodetection (its
 faster by 50-100ms to manually specify CCTYPE not call gcc.exe and cl.exe
 with the auto detect code), "FREE" detection is unimplemented but seems
 to make no difference with VC except for an old rare "free" VC 2003
 I personally use a paid VC 2003.
-silence console messages and warnings from a missing gcc.exe causing
 "gcc -dumpmachine" to warn or fatally error, gmake doesn't care about
 exit code, dmake does
-on dmake, use := instead of *= or =, otherwise the long for loop shell
 line runs dozens of times (multiple eval problem)
-on dmake, since GCCBIN macro doesn't exist and dmake mfk is "simpler"
 than gmake just call gcc.exe always and not a prefixed version of GCC for
 the GCCTARGET macro, it isn't used outside the autodetection code anyways
 and if a user neglected to specify CCTYPE it is assumed they neglected to
 specify GCCCROSS too

7 years agolocale.c: Add missing '{'
Karl Williamson [Sun, 14 Aug 2016 15:59:11 +0000 (09:59 -0600)]
locale.c: Add missing '{'

Spotted by bulk88, http://nntp.perl.org/group/perl.perl5.porters/238968

7 years agosilence MSVC warnings for NATIVE_UTF8_TO_I8/I8_TO_NATIVE_UTF8
Daniel Dragan [Sun, 14 Aug 2016 15:01:00 +0000 (11:01 -0400)]
silence MSVC warnings for NATIVE_UTF8_TO_I8/I8_TO_NATIVE_UTF8

The result of I8_TO_NATIVE_UTF8 has to be U8 casted for the MSVC specific
PERL_SMALL_MACRO_BUFFER option just like it is for newer CCs that dont
have a small CPP buffer. Commit 1a3756de64/#127426 did add U8 casts to
NATIVE_TO_LATIN1/LATIN1_TO_NATIVE but missed
NATIVE_UTF8_TO_I8/I8_TO_NATIVE_UTF8. This commit fixes that.

One example of the C4244 warning is VC6 thinks 0xFF & (0xFE << 6) in
UTF_START_MARK could be bigger than 0xff (a char), fixes
..\inline.h(247) : warning C4244: '=' : conversion from 'long ' to
'unsigned char ', possible loss of data

Also fixes
..\utf8.c(146) : warning C4244: '=' : conversion from 'UV' to 'U8',
possible loss of data
and alot more warnings in utf8.c

7 years agoFollow-up on a149d118.
Jarkko Hietaniemi [Sun, 14 Aug 2016 14:16:55 +0000 (10:16 -0400)]
Follow-up on a149d118.

The added tests were meant only for x86-80-bit long doubles,
but were accidentally run also on 128-bit doubles (quadmath,
or probably also on true IEEE 754 quadruples).

7 years agofirst step to documenting the Internals namespace
Yves Orton [Sun, 14 Aug 2016 11:56:56 +0000 (13:56 +0200)]
first step to documenting the Internals namespace

After discussion, we have decided to document Internals. This is a
first step doing so, with lib/Internals.pod. At the same time I
updated sv.h that there were equivalents for SvREFCNT and SvREADONLY
in the Internals namespace, this required adding docs for SvREADONLY.

I also tweaked the test name in Porting/Maintainers.pm
so that it pointed at Porting/Maintainers.pl to make it more obvious
how to specify a maintainer for a new file.

7 years agoMove hash introspection routines into Hash::Util/Util.xs and out of universal.c
Yves Orton [Mon, 8 Aug 2016 18:06:01 +0000 (20:06 +0200)]
Move hash introspection routines into Hash::Util/Util.xs and out of universal.c

7 years agos/XS_hash_util_/XS_Hash_Util_/g
Yves Orton [Mon, 8 Aug 2016 17:48:01 +0000 (19:48 +0200)]
s/XS_hash_util_/XS_Hash_Util_/g

7 years agomove a declaration so that the Internals:: functions are grouped together
Yves Orton [Mon, 8 Aug 2016 17:35:49 +0000 (19:35 +0200)]
move a declaration so that the Internals:: functions are grouped together

7 years agomove Internals::hv_clear_placeholders() to Hash::Util::_clear_placeholders()
Yves Orton [Mon, 8 Aug 2016 16:53:20 +0000 (18:53 +0200)]
move Internals::hv_clear_placeholders() to Hash::Util::_clear_placeholders()

There is no reason for this code to be in Internals:: or in universal.c at
all, it should only be used from Hash::Util during things like lock_keys().

Moves the function to the XS code in Hash::Util, and renames it as well,
along with commented out documentation for what it does.

7 years ago[perl #128919] limited exponent range in hex fp literal with long double
Jarkko Hietaniemi [Sat, 13 Aug 2016 23:13:58 +0000 (19:13 -0400)]
[perl #128919] limited exponent range in hex fp literal with long double

7 years agoperldiag: Rewrap an entry for better splain output
Father Chrysostomos [Sat, 13 Aug 2016 21:30:56 +0000 (14:30 -0700)]
perldiag: Rewrap an entry for better splain output

In an eighty-column terminal, this is what it looked like before
this commit:

$ ./perl -Ilib -Mdiagnostics -E 'state ($x)=1'
Initialization of state variables in list context currently forbidden at -e line 1, at EOF
Execution of -e aborted due to compilation errors (#1)
    (F) state only permits initializing a single scalar variable, in scalar
    context. So state $a = 42 is allowed, but not state ($a) = 42. To apply
    state semantics to a hash or array, store a hash or array reference in a sca
lar
    variable.

7 years agoRemove claim that state @a will be supported
Smylers [Fri, 12 Aug 2016 15:34:17 +0000 (16:34 +0100)]
Remove claim that state @a will be supported

perldiag doesn't seem to be the right place to announce future changes to
Perl, especially since this claim was made 9 years ago, in 6dbe9451, and
doesn't show any sign of becoming true.

7 years agoMore AUTHORS sorting
Father Chrysostomos [Fri, 12 Aug 2016 22:28:35 +0000 (15:28 -0700)]
More AUTHORS sorting

7 years agoAvoid test noise on non-longdouble.
Jarkko Hietaniemi [Fri, 12 Aug 2016 23:08:56 +0000 (19:08 -0400)]
Avoid test noise on non-longdouble.

7 years ago[rt.perl.org #128909] printf %a mishandles exponent-crossing rounding with long double
Jarkko Hietaniemi [Fri, 12 Aug 2016 21:36:58 +0000 (17:36 -0400)]
[rt.perl.org #128909] printf %a mishandles exponent-crossing rounding with long double

7 years agoBogus skip count.
Jarkko Hietaniemi [Fri, 12 Aug 2016 21:30:25 +0000 (17:30 -0400)]
Bogus skip count.

Didn't break anything but still bogus.

7 years agouniversal.c:XS_re_regnames_count: redundant code
Father Chrysostomos [Fri, 12 Aug 2016 21:35:33 +0000 (14:35 -0700)]
universal.c:XS_re_regnames_count: redundant code

If we croak when items != 0, then SP -= items is a no-op, as is PUTBACK.

7 years agoscope.c: Appease C++
Father Chrysostomos [Fri, 12 Aug 2016 15:43:39 +0000 (08:43 -0700)]
scope.c: Appease C++

C++ is dumb.

7 years agogv.c:require_tie_mod: Make var name a char param
Father Chrysostomos [Fri, 12 Aug 2016 15:37:37 +0000 (08:37 -0700)]
gv.c:require_tie_mod: Make var name a char param

This reduces machine code size a little and simplifies
require_tie_mod.

On a non-debugging Linux GCC build with -O2:

Before:
$ ls -l gv.o
-rw-r--r-- 1 sprout p5p 88704 Aug 12 07:29 gv.o

After:
$ ls -l gv.o
-rw-r--r-- 1 sprout p5p 88656 Aug 12 17:29 gv.o

7 years agoperlcall: Remove redundant dSP
Father Chrysostomos [Fri, 12 Aug 2016 15:31:43 +0000 (08:31 -0700)]
perlcall: Remove redundant dSP

call_argv does not use a stack pointer.  This example has had the
redundant dSP since perl 5.000, presumably due to copying and
pasting from another example.

7 years agoTest new hexfp fixes also on (x86 80-bit) long doubles.
Jarkko Hietaniemi [Fri, 12 Aug 2016 12:12:41 +0000 (08:12 -0400)]
Test new hexfp fixes also on (x86 80-bit) long doubles.

7 years agoleave_scope(): combine the SAVEt_*PTR branches
David Mitchell [Fri, 12 Aug 2016 11:59:14 +0000 (12:59 +0100)]
leave_scope(): combine the SAVEt_*PTR branches

They're all the same, except for casts between different pointer types.

7 years agoleave_scope(): eliminate a couple of local vars
David Mitchell [Fri, 12 Aug 2016 11:33:08 +0000 (12:33 +0100)]
leave_scope(): eliminate a couple of local vars

Remove svp and i from the main loop and only declare them in the
inner scopes that require them. Where values get passing around in
goto restore_sv/restore_svp, pass the value in an unused a0/a2 var
instead.

Also eliminate the one use of the 'type' var within the loop - that way
the compiler doesn't have to hang on the value when executing the switch.

Makes the object code a bit smaller.

7 years agoclean up leave_scope()
David Mitchell [Fri, 12 Aug 2016 08:59:42 +0000 (09:59 +0100)]
clean up leave_scope()

Rather than having a whole bunch of casting macros like

    #define ARG0_SV  MUTABLE_SV(arg0.any_ptr)

just add extra pointer types to the ANY union and directly do

    arg0.any_sv

etc.

Also, rename arg0, arg1, arg2 to a0, a1, a2 and reverse their order;
previously if 3 args A,B,C were pushed onto the savestack, they were
popped as a0=C, a1=B, a2=A; now do it as a0=A, a1=B, a2=C. The previous
(rather odd) order was an artifact of the old way leave_scope() used to
pop its args.

There should be no functional changes.

7 years agoFix on top of 75326c48.
Jarkko Hietaniemi [Thu, 11 Aug 2016 23:53:30 +0000 (19:53 -0400)]
Fix on top of 75326c48.

Worked partly accidentally, and as a bonus caused asan
off-stack-variable read violations.

7 years agoThe new tests are valid only for IEEE 754 64-bit doubles.
Jarkko Hietaniemi [Thu, 11 Aug 2016 22:19:00 +0000 (18:19 -0400)]
The new tests are valid only for IEEE 754 64-bit doubles.

The tests do not fail (I wish), they would just need to be different
for example for the 80-bt x86 long doubles, for example, which scale
differently:

    perl -wle 'printf "%a\n", -1.5'  # IEEE 754 64-bit
    -0x1.8+0
    perl -wle 'printf "%a\n", -1.5'  # x86 80-bit
    -0xcp-3

In any system:

    perl -wle 'print -0x1.8p+0'
    -1.5
    perl -wle 'print -0xcp-3'
    -1.5

See earlier in this file a long if-elsif chain when testing
the @hexfloat because of this very same reason.

7 years agoembed.fnc: sv_copypv is still API
Father Chrysostomos [Fri, 12 Aug 2016 01:20:56 +0000 (18:20 -0700)]
embed.fnc: sv_copypv is still API

This commit removed the A flag, causing the documentation to move from
perlapi to perlintern:

commit 4bac9ae47b5ad7845a24e26b0e95609805de688a
Author: Chip Salzenberg <chip@pobox.com>
Date:   Fri Jun 22 15:18:18 2012 -0700

    Magic flags harmonization.

But it is still API, even though it is implemented as a macro (and a mathomly function).

(This is one reason why checking in generated files can be helpful.
It avoids mistakes like this by making them more visible.)

7 years agomathoms.c: Restore previous behaviour of sv_copypv
Father Chrysostomos [Fri, 12 Aug 2016 01:12:40 +0000 (18:12 -0700)]
mathoms.c: Restore previous behaviour of sv_copypv

This commit made it a simple wrapper around the new sv_copypv_flags:

commit 4bac9ae47b5ad7845a24e26b0e95609805de688a
Author: Chip Salzenberg <chip@pobox.com>
Date:   Fri Jun 22 15:18:18 2012 -0700

    Magic flags harmonization.

But in so doing it changed the behaviour of the functional version
(Perl_sv_copypv), while preserving the existing behaviour in the new
macro (sv_copypv).  The latter invokes get-magic, while the former
used to but stopped doing so.

7 years agoperlinterp.pod: typoes
Father Chrysostomos [Thu, 11 Aug 2016 06:10:02 +0000 (23:10 -0700)]
perlinterp.pod: typoes

7 years agoAdd epigraphs for 5.22.3-RC3 and 5.24.1-RC3
Steve Hay [Fri, 12 Aug 2016 00:09:28 +0000 (01:09 +0100)]
Add epigraphs for 5.22.3-RC3 and 5.24.1-RC3

7 years ago5.22.3-RC3 and 5.24.1-RC3 today
Steve Hay [Thu, 11 Aug 2016 21:19:34 +0000 (22:19 +0100)]
5.22.3-RC3 and 5.24.1-RC3 today

7 years agoAdd probe for gai_strerror
H.Merijn Brand [Thu, 11 Aug 2016 16:35:47 +0000 (18:35 +0200)]
Add probe for gai_strerror

7 years ago[rt.perl.org #128893]: printf %a botches 0 flag for negative values
Jarkko Hietaniemi [Thu, 11 Aug 2016 13:18:27 +0000 (09:18 -0400)]
[rt.perl.org #128893]: printf %a botches 0 flag for negative values

7 years ago[rt.perl.org #128890]: printf %a rounds incorrectly
Jarkko Hietaniemi [Thu, 11 Aug 2016 13:15:21 +0000 (09:15 -0400)]
[rt.perl.org #128890]: printf %a rounds incorrectly

7 years ago[rt.perl.org #128889]: printf %a mishandles negative pseudo-precision
Jarkko Hietaniemi [Thu, 11 Aug 2016 13:12:04 +0000 (09:12 -0400)]
[rt.perl.org #128889]: printf %a mishandles negative pseudo-precision

(the fix for [rt.perl.org #128888] fixed also this one)

7 years ago[rt.perl.org #128888]: printf %a mishandles zero precision
Jarkko Hietaniemi [Wed, 10 Aug 2016 23:06:03 +0000 (19:06 -0400)]
[rt.perl.org #128888]: printf %a mishandles zero precision

7 years agoComment fix for b6d9b423
Jarkko Hietaniemi [Wed, 10 Aug 2016 23:47:19 +0000 (19:47 -0400)]
Comment fix for b6d9b423

7 years agoAdd rt.perl.org reference for b6d9b423
Jarkko Hietaniemi [Wed, 10 Aug 2016 23:13:36 +0000 (19:13 -0400)]
Add rt.perl.org reference for b6d9b423

7 years agoleave_scope(): pop args in each branch
David Mitchell [Thu, 11 Aug 2016 11:07:07 +0000 (12:07 +0100)]
leave_scope(): pop args in each branch

About 4 years ago I heavily refactored Perl_leave_scope(). One of the
things I did was to pop the args for each action once at the top of the
loop. This involved a number of nested condtionals.

This commit makes each action (i.e. each switch branch) responsible
for copying its own args off the save stack, while the top of loop is
still responsible for decrementing PL_savestack_ix.

The gain is marginal, but it makes the code cleaner and the object code
smaller.

7 years agoCarp: say what cluck() does
David Mitchell [Thu, 11 Aug 2016 08:37:39 +0000 (09:37 +0100)]
Carp: say what cluck() does

Nowhere did it actually describe what cluck does.

7 years agoUpdate Config::Perl::V to 0.27
H.Merijn Brand [Thu, 11 Aug 2016 10:57:57 +0000 (12:57 +0200)]
Update Config::Perl::V to 0.27

7 years agoUpgrade Encode from version 2.85 to 2.86
Steve Hay [Thu, 11 Aug 2016 07:21:52 +0000 (08:21 +0100)]
Upgrade Encode from version 2.85 to 2.86

This incorporates all current blead customizations.

7 years agoPATCH: [perl #128867] Locale failures on FREE BSD
Karl Williamson [Wed, 10 Aug 2016 21:20:39 +0000 (15:20 -0600)]
PATCH: [perl #128867] Locale failures on FREE BSD

The main failure appears to be a bug in freebsd.  Jim Keenan and I have
created a stand-alone C program, not involving Perl, that reproduces it,
which I will attach to the ticket.  I have searched their bug db and not
found this reported, so will create a ticket against them.

Several of the failures are bugs in some of the locale definitions for
freebsd, like not all lowercase letters also being alphas.  I will
report these as well, and adjust the allowable failure percentage for
this platform, if necessary, to get these to not fail the test at large.

The bug is that newlocale() and/or uselocale() are not working properly.
These are from POSIX 2008, and perl has not used them previously.
I sort of expected some platforms to have not implemented them properly;
this is the first one we've encountered that does so.

This changes the hints file so that it appears that uselocale() is not
on the system.

7 years agopp_sort.c: Missing cast
Father Chrysostomos [Wed, 10 Aug 2016 20:00:51 +0000 (13:00 -0700)]
pp_sort.c: Missing cast

This is a compilation error under C++.

7 years agot/uni/parser.t: Fix failing test on VMS
Karl Williamson [Tue, 9 Aug 2016 19:35:41 +0000 (13:35 -0600)]
t/uni/parser.t: Fix failing test on VMS

Commit 2aa61ac397079a33eb3c36c2e7c1f41be224c657 caused this failure.
Simply turn off warnings, though this won't work once the deprecation is
made fatal.

Spotted by Craig Berry.

7 years agoAdd Sergey Aleynikov to AUTHORS
Karl Williamson [Mon, 8 Aug 2016 23:28:30 +0000 (17:28 -0600)]
Add Sergey Aleynikov to AUTHORS

7 years agolib/locale_threads.t: Add new test file
Karl Williamson [Mon, 8 Aug 2016 23:22:54 +0000 (17:22 -0600)]
lib/locale_threads.t: Add new test file

This file tests locale and thread interactions.  At the moment, it has
just one test, adapted from [perl #127708].  The adaptations include
placing it under t/test.pl, and using my knowledge of the underlying bug
cause to stress it more than the original by Sergey Aleynikov.
He says it fails nearly 50% of the time on an unpatched perl.

7 years agoMove some global destruction to where it belongs
Karl Williamson [Wed, 10 Aug 2016 18:02:38 +0000 (12:02 -0600)]
Move some global destruction to where it belongs

Out of ignorance, I put this locale global destruction in the per-thread
destruction code, leading to segfaults on at least Darwin.

7 years agoAdd some error checking/debugging for locale
Karl Williamson [Wed, 10 Aug 2016 18:08:51 +0000 (12:08 -0600)]
Add some error checking/debugging for locale

We are starting to use libc functions for locale that have never been
used before.  I previously hadn't bothered to check error returns on
things that "shouldn't" fail.  But given that there may be bugs in
various vendors' implementations or documentation of these, and/or my
misreading of how to use them, it is warranted to actually do the
checking.

This also adds a couple of debug statements to lib/locale.t that I
wished were already there.

7 years agoNote the provenance of the Encode customizations
Steve Hay [Wed, 10 Aug 2016 16:56:40 +0000 (17:56 +0100)]
Note the provenance of the Encode customizations

(and request syncing in https://github.com/dankogai/p5-encode/issues/61)

7 years agoUpgrade File-Fetch from version 0.48_01 to 0.50
Steve Hay [Wed, 10 Aug 2016 16:30:48 +0000 (17:30 +0100)]
Upgrade File-Fetch from version 0.48_01 to 0.50

7 years agoin-place sort preserved element lvalue identity
David Mitchell [Wed, 10 Aug 2016 15:19:55 +0000 (16:19 +0100)]
in-place sort preserved element lvalue identity

RT #128340

The in-place sorting optimisation @a = sort @a, was preserving the
elements of @a rather than (logically) making copies. So make a copy
of any element whose refcount is greater than 1. This may not be the
perfect condition, but keeps performance for the common cases.

Note that several of the tests in t/op/sort.t actually relied on this
behaviour to test whether the sort was being in-placed, so I've added
tests for in-placing to t/perf/opcount.t instead.

See the previous commit for a general discussion of performance;
to the A, B, C in that commit message, here's a fourth column added:
D is like C but with this commit added:

                     A       B       C       D
                ------  ------  ------  ------
            Ir  5238.0  2324.0  2772.0  2801.0
            Dr  1464.0   649.0   765.0   765.0
            Dw   919.0   298.0   370.0   380.0
          COND   782.0   320.0   405.0   405.0
           IND    25.0    25.0    26.0    26.0

        COND_m    14.9    13.0    17.0    17.1
         IND_m     8.0     5.0     5.0     5.0

so it has little effect on performance.

7 years agoPartially pessimise in-place sorting
David Mitchell [Wed, 10 Aug 2016 14:12:56 +0000 (15:12 +0100)]
Partially pessimise in-place sorting

There's currently an optimisation that converts at compile-time

    @a = sort { .... } @a

into (approximately)

    sort { ... } \@a

Then at run time, rather than passing an svp pointer to the appropriate
sort routine which points to a list of SV*'s on the stack, pp_sort()
passes a pointer to @a's AvARRAY. This allows the array to be sorted
in-place, which is more efficient.

However, it has some issues. First, the @a visible to the sort routine
will be varying, whereas logically it should still hold the original list
of values until after the '@a = ...' assignment.

Secondly, the mergesort algorithm cureently used internally, when in
mid-sort, temporarily stores pointers in the array which aren't pointers
to SVs - this means that if @a elements are accessed mid-sort, it can
crash.

The solution to both these problems is for pp_sort() to push the elements
of @a onto the stack at the beginning, sort the stack (like normal sorts
do), then copy back to @a at the end. This is less efficient than before,
but is still a lot more efficient than executing separate padav and
aassign ops.

Here are benchmark results in raw instruction counts etc (lower is better)
for the sort line in this code block:

    my (@a, @b);
    @a = reverse 1..10;
    @b = sort { $a <=> $b } @a;

A is for a non-in-place sort, i.e. @b = sort ... @a;
B and C are for an inline sort, i.e. as above, but  @a = sort ... @a;
where B is blead before this commit and C is this commit.

                 A       B       C
            ------  ------  ------
        Ir  5238.0  2324.0  2772.0
        Dr  1464.0   649.0   765.0
        Dw   919.0   298.0   370.0
      COND   782.0   320.0   405.0
       IND    25.0    25.0    26.0

    COND_m    14.9    13.0    17.0
     IND_m     8.0     5.0     5.0

As can be seen, this partial pessimisation slows down in-place sorting by
round 20%, but overall in-place is still nearly twice the speed as without
the optimisation.

These are the figures for a plain numeric sort (which is optimised to use
a C comparison function); for other types of sort, the cost of the
comparator dominates, and so the slowdown is much less marked.

7 years agoAdd missing CUSTOMIZED entry for base.pm
Steve Hay [Wed, 10 Aug 2016 13:13:26 +0000 (14:13 +0100)]
Add missing CUSTOMIZED entry for base.pm

and update customized.dat

7 years agohexfp: IEEE 754 subnormals printf %a
Jarkko Hietaniemi [Sun, 7 Aug 2016 23:20:37 +0000 (19:20 -0400)]
hexfp: IEEE 754 subnormals printf %a

7 years agoExclude a new Pod-Perldoc test script for now, since it's failing in core
Steve Hay [Wed, 10 Aug 2016 12:54:26 +0000 (13:54 +0100)]
Exclude a new Pod-Perldoc test script for now, since it's failing in core

Failures on Win32/MSVC++ when dropped into core are:

not ok 3 - got expected output in STDOUT
#   Failed test 'got expected output in STDOUT'
#   at t/02_module_pod_output.t line 40.
#                   undef
#     doesn't match '(?^:Look up Perl documentation)'

not ok 7 - got expected output in STDERR
#   Failed test 'got expected output in STDERR'
#   at t/02_module_pod_output.t line 73.
#                   ''perl' is not recognized as an internal or external command
,
# operable program or batch file.
# '
#     doesn't match '(?^:No documentation)'

7 years agoUpgrade Pod-Perldoc from vesion 3.25_03 to 3.27
Steve Hay [Wed, 10 Aug 2016 12:24:22 +0000 (13:24 +0100)]
Upgrade Pod-Perldoc from vesion 3.25_03 to 3.27

7 years agoSync CPAN Locale::Maketext 1.28 with blead
Steve Hay [Wed, 10 Aug 2016 12:10:26 +0000 (13:10 +0100)]
Sync CPAN Locale::Maketext 1.28 with blead

7 years agodump.c: dump physical, not logical, AVs
David Mitchell [Wed, 10 Aug 2016 08:30:55 +0000 (09:30 +0100)]
dump.c: dump physical, not logical, AVs

Perl_do_sv_dump() (as used by Devel::Peek) dumped a logical AV - i.e.
if it was tied, it called tie methods to get its size and to get its
elements.

Instead, dump the physical fields in the AV - e.g. a tied AV will likely
have a FILL of -1 and no elements.

7 years agoUpgrade Encode from version 2.84 to 2.85
Steve Hay [Tue, 9 Aug 2016 16:55:29 +0000 (17:55 +0100)]
Upgrade Encode from version 2.84 to 2.85

This retains the customizations to Byte/Makefile.PL, encoding.pm and
various test scripts that have not yet been assimilated.

7 years agoUpgrade Digest-SHA from version 5.95 to 5.96
Steve Hay [Tue, 9 Aug 2016 16:36:33 +0000 (17:36 +0100)]
Upgrade Digest-SHA from version 5.95 to 5.96

7 years agoAdd Richard Levitte to AUTHORS.
Craig A. Berry [Tue, 9 Aug 2016 15:48:31 +0000 (10:48 -0500)]
Add Richard Levitte to AUTHORS.

7 years agoFile::Spec::VMS->canonpath() incorrect with ODS-5 style directory specs.
Richard Levitte [Tue, 9 Aug 2016 15:22:56 +0000 (10:22 -0500)]
File::Spec::VMS->canonpath() incorrect with ODS-5 style directory specs.

I've found a bug in File::Spec::VMS->canonpath(), when a dash
component in a directory spec is preceded by a name containing an
escaped period.

My examples show quite clearly where things go wrong:

    $ perl -e "use File::Spec::Functions; print canonpath('foo:[bar.coo.kie.--]')"
    foo:[bar]

    check!

    $ perl -e "use File::Spec::Functions; print canonpath('foo:[bar^.coo.kie.--]')"
    foo:[bar^.coo.-]

    WRONG!

    $ perl -e "use File::Spec::Functions; print canonpath('foo:[bar.coo^.kie.--]')"
    foo:[bar.coo^.kie.--]

    WRONG!

    $ perl -e "use File::Spec::Functions; print canonpath('foo:[bar.coo.kie.-]')"
    foo:[bar.coo]

    check!

    $ perl -e "use File::Spec::Functions; print canonpath('foo:[bar^.coo.kie.-]')"
    foo:[bar^.coo]

    check!

    $ perl -e "use File::Spec::Functions; print canonpath('foo:[bar.coo^.kie.-]')"
    foo:[bar.coo^.kie.-]

    WRONG!

I've created a patch (attached) that solves the issue, with these
correct results (same paths)

[Committer's note: this fixes perl RT #128865]

7 years agoUpgrade Test-Simple from version 1.302045 to 1.302049
Steve Hay [Tue, 9 Aug 2016 07:34:16 +0000 (08:34 +0100)]
Upgrade Test-Simple from version 1.302045 to 1.302049

7 years agoUpgrade IO-Socket-IP from version 0.37 to 0.38
Steve Hay [Tue, 9 Aug 2016 07:29:33 +0000 (08:29 +0100)]
Upgrade IO-Socket-IP from version 0.37 to 0.38

7 years agoperlhacktips: Add link for %formatting size_t args
Karl Williamson [Thu, 4 Aug 2016 00:59:36 +0000 (18:59 -0600)]
perlhacktips: Add link for %formatting size_t args

7 years agoperlguts: Note how to print Size_t, SSize_t
Karl Williamson [Mon, 8 Aug 2016 21:48:24 +0000 (15:48 -0600)]
perlguts: Note how to print Size_t, SSize_t

7 years agoperldiag: YA case of too large code point breakage
Karl Williamson [Mon, 8 Aug 2016 21:28:10 +0000 (15:28 -0600)]
perldiag: YA case of too large code point breakage

This adds another case where having a code point above IV_MAX doesn't
work properly, and stresses there may be more.

7 years agoAdd test for [perl #126606]
Karl Williamson [Mon, 8 Aug 2016 21:11:03 +0000 (15:11 -0600)]
Add test for [perl #126606]

7 years agoperlop: Clarify tr/// casing statement
Karl Williamson [Mon, 8 Aug 2016 17:00:03 +0000 (11:00 -0600)]
perlop: Clarify tr/// casing statement