This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
10 years agosilence spurious 'may be uninitialized' warnings
David Mitchell [Fri, 8 Nov 2013 11:56:34 +0000 (11:56 +0000)]
silence spurious 'may be uninitialized' warnings

-Wmaybe-uninitialized isn't smart enough, so explicitly NULL a couple
of vars to keep it happy.

10 years agoremove some unused vars from op.c and toke.c
David Mitchell [Fri, 8 Nov 2013 11:18:03 +0000 (11:18 +0000)]
remove some unused vars from op.c and toke.c

10 years agoMore stack for pat_thr.t on VMS as well.
Craig A. Berry [Fri, 8 Nov 2013 00:51:03 +0000 (18:51 -0600)]
More stack for pat_thr.t on VMS as well.

Follow-up to 66478a1b30 and 58b6d14529f.

10 years agoCommit 1735f6f53ca19f99c6e9e39496c486af323ba6a8 started to escape all
=?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= [Fri, 8 Nov 2013 01:17:08 +0000 (02:17 +0100)]
Commit 1735f6f53ca19f99c6e9e39496c486af323ba6a8 started to escape all
back-slashes which breaks case when lexicon translations contain substition
and literals with eval-non-safe characters. E.g.  these translations:

"[_1]foo\\n\n" => "[_1]bar\\n\n",
'[_1]foo\n' => '[_1]aÄ\9ba\n',

got doubled back-slashes on the maketext() output.

This patch de-escapes escaped backslashes if the literal is compiled as
function argument.

Fixes RT #120457.

10 years agoperlfunc: Clarify verbatim table
Karl Williamson [Thu, 7 Nov 2013 19:17:20 +0000 (12:17 -0700)]
perlfunc: Clarify verbatim table

When I read what was here before this patch, I thought there was a typo,
as there was no entry in column 1 for several rows.  Instead, what was
meant was that the item in column 1 row 1 was supposed to be dittoed
into the following rows.  I used the solution employed in Camel 4,
which is to repeat that item in each row it applies to.

10 years agoperlfunc.pod: long verbatim lines
Father Chrysostomos [Wed, 6 Nov 2013 13:59:41 +0000 (05:59 -0800)]
perlfunc.pod: long verbatim lines

10 years agoFix qx, `` and <<`` overrides
Father Chrysostomos [Wed, 6 Nov 2013 13:42:34 +0000 (05:42 -0800)]
Fix qx, `` and <<`` overrides

This resolves two RT tickets:
• #115330 is that qx and `` overrides do not support interpolation.
• #119827 is that <<`` does not support readpipe overrides at all.

The obvious fix for #115330 fixes #119827 at the same time.

When quote-like operators are parsed, after the string has been
scanned S_sublex_push is called, which decides which of two paths
to follow:
1) For things not requiring interpolation, the string is passed to
   tokeq (originally called q, it handles double backslashes and back-
   slashed delimiters) and returned to the parser immediately.
2) For anything that interpolates, the lexer enters a special inter-
   polation mode (LEX_INTERPPUSH) and goes through a more complex
   sequence over the next few calls (e.g., qq"a.$b.c" is turned into
  ‘stringify ( "a." . $ b . ".c" )’).

When commit e3f73d4ed (Oct 2006, perl 5.10) added support for overrid-
ing `` and qx with a readpipe sub, it did so by creating an entersub
op in toke.c and making S_sublex_push follow path no. 1, taking the
result if tokeq and inserting it into the already-constructed op tree
for the sub call.

That approach caused interpolation to be skipped when qx or `` is
overridden.  Furthermore it didn’t touch <<`` at all.

The easiest solution is to let toke.c follow its normal path and
create a backtick op (instead of trying to half-intercept it), and
to deal with override lookup afterwards in ck_backtick, the same way
require overrides are handled.  Since <<`` also turns into a backtick
op, it gets handled too that way.

10 years agoSplit ck_open into two functions
Father Chrysostomos [Wed, 6 Nov 2013 01:51:50 +0000 (17:51 -0800)]
Split ck_open into two functions

It is used for two op types, but only a small portion of it applies
to both, so we can put that in a static function.  This makes the
next commit easier.

10 years agogv.c:gv_try_downgrade: Use hv_fetchhek
Father Chrysostomos [Tue, 5 Nov 2013 23:52:59 +0000 (15:52 -0800)]
gv.c:gv_try_downgrade: Use hv_fetchhek

Unlike hv_fetch, this also passes the precomputed hash, saving
hv_common from having to recalculate it.

10 years agotoke.c: Remove unnecessary UTF check
Father Chrysostomos [Tue, 5 Nov 2013 23:47:30 +0000 (15:47 -0800)]
toke.c: Remove unnecessary UTF check

In this particular branch, the value of PL_tokenbuf will always
be a built-in keyword; i.e., pure ASCII.  So there is no need to
do a utf8 check.

10 years agoPut common override code into gv_override
Father Chrysostomos [Tue, 5 Nov 2013 22:35:45 +0000 (14:35 -0800)]
Put common override code into gv_override

When I moved the three occurrences of this code in op.c into a static
function, I did not realise at the time that it also occurred thre
etimes in toke.c.

So now it is in a new non-static function in gv.c.

Only two of the instances in toke.c could be changed to use this func-
tion, as the otherwise is a little different.  I couldn’t see a simple
way of factoring its requirements in.

10 years agoFix readline overriden with a constant
Father Chrysostomos [Tue, 5 Nov 2013 21:02:36 +0000 (13:02 -0800)]
Fix readline overriden with a constant

<> doesn’t take into account that some subs are stored in a more
lightweight form than usual.  These two programs should behave the
same way, but, as you can see below the __END__ markers, the output is
different:

use constant foo=>1;
BEGIN { *{"CORE::GLOBAL::readline"} = \&{"foo"}; 1}
warn <a>
__END__
Warning: something's wrong at - line 3.

use constant foo=>1;
BEGIN { *{"CORE::GLOBAL::readline"} = \&foo; 1}
warn <a>
__END__
Too many arguments for main::foo at - line 3, at end of line
Execution of -e aborted due to compilation errors.

The latter is the correct behaviour.  The only different is \&{"foo"}
vs \&foo, the first of which triggers an optimisation.

S_scan_inputsymbol in toke.c needs to take the optimisation into
account (that stash entries are not necessarily globs but can be
upgraded to such).

10 years agoAllow CORE::GLOBAL:: subs in general to be aliased to consts
Father Chrysostomos [Tue, 5 Nov 2013 20:52:58 +0000 (12:52 -0800)]
Allow CORE::GLOBAL:: subs in general to be aliased to consts

$ perl5.8.8 -e 'use constant foo=>1; BEGIN { *{"CORE::GLOBAL::time"} = \&{"foo"};1} warn time'
1 at -e line 1.
$ perl5.10.1 -e 'use constant foo=>1; BEGIN { *{"CORE::GLOBAL::time"} = \&{"foo"};1} warn time'
1383661397 at -e line 1.

When the storage of constants was optimised in perl 5.10, the code that
checks for global overrides was not updated to account.

10 years agoStop gv_try_downgrade from anonymising referenced CVs
Father Chrysostomos [Tue, 5 Nov 2013 14:14:59 +0000 (06:14 -0800)]
Stop gv_try_downgrade from anonymising referenced CVs

I keep discovering ways in which gv_try_downgrade, which is supposed
to be an optimisation, changes observable behaviour even without look-
ing at the stash.

This one had me confused at first:

$ ./perl -Ilib -e 'use constant foo=>1; BEGIN { $x = \&foo } undef &$x; $x->()'
Undefined subroutine called at -e line 1.
$ ./perl -Ilib -e 'use constant foo=>1; BEGIN { $x = \&{"foo"} } undef &$x; $x->()'
Undefined subroutine &main::foo called at -e line 1.

Notice how the first example (where gv_try_downgrade kicks in)
shows no name in the error message.  This only happens on non-
threaded builds.

What’s happening is that, when the BEGIN block is freed, the GV op
corresponding to &foo get freed, triggering gv_try_downgrade, which
checks to see whether it can downgrade the GV to a simple reference
to a constant (the way constants are stored by default).  It then pro-
ceeds to do that, so the GV qua GV ceases to exist, and the CV gets
automatically anonymised as a result (the same thing happens with
‘$x = \&{"foo"}; Dump $x; delete $::{foo}’, but legitimately in
that case).

The solution here is to check the reference count on the CV before
downgrading the GV.  If the CV’s reference count > 1, then we should
leave it alone.

10 years agoperlfunc: update require() pseudocode
David Mitchell [Tue, 5 Nov 2013 15:52:31 +0000 (15:52 +0000)]
perlfunc: update require() pseudocode

RT #120292

The entry for require() in perlfunc has a perl function that's supposed to
illustrate how require works is rather out of date. In particular, the
fact that the search stops on EACCES wasn't incorporated, and the various
ways of it failing and reporting errors was inaccurate.

I also removed the explicit code for executing the 'do' in the caller's
package, and replaced it with just the comment 'but run in caller's
namespace', since the details were a bit obscure.

Finally, I re-indented it since it had strange 3-space indents

10 years agogv.c: Removed redundant len==1 check
Father Chrysostomos [Tue, 5 Nov 2013 13:48:44 +0000 (05:48 -0800)]
gv.c: Removed redundant len==1 check

When I added this in ea238638, I put the same code in the branches
for the main stash and other stashes.  In the main stash branch, this
occurs in a switch that is solely for one-character names, so checking
the length again is superfluous.

10 years agotoke.c: Remove unnecessary SvRV null check
Father Chrysostomos [Tue, 5 Nov 2013 05:52:55 +0000 (21:52 -0800)]
toke.c: Remove unnecessary SvRV null check

If SvROK is true, then SvRV will never be null.  (If it is, then
serious problems will occur elsewhere, as other code assumes this.)

10 years agoFix readpipe overriden with a constant
Father Chrysostomos [Tue, 5 Nov 2013 05:49:27 +0000 (21:49 -0800)]
Fix readpipe overriden with a constant

qx and `` don’t take into account that some subs are stored in a more
lightweight form than usual.  These two programs should behave the
same way, but, as you can see below the __END__ markers, the output is
different:

use constant foo=>1;
BEGIN { *{"CORE::GLOBAL::readpipe"} = \&{"foo"}; 1}
warn ``
__END__
Warning: something's wrong at - line 3.

use constant foo=>1; BEGIN { *{"CORE::GLOBAL::readpipe"} = \&{"foo"}; 1} warn ``
__END__
Too many arguments for CORE::GLOBAL::readpipe at - line 3, at end of line
Execution of -e aborted due to compilation errors.

The latter is the correct behaviour.¹  The only different is \&{"foo"}
vs \&foo, which triggers an optimisation.

S_readpipe_override in toke.c needs to take the optimisation into
account (that stash entries are not necessarily globs but can be
upgraded to such).

¹ Except that the sub name reported is unexpected.  Non-threaded
  builds give me that; threaded builds give me main::foo.  But that is
  a separate bug.

10 years agoi_arpainet and i_sysun for configure.com.
Craig A. Berry [Tue, 5 Nov 2013 13:12:34 +0000 (07:12 -0600)]
i_arpainet and i_sysun for configure.com.

VMS does have arpa/inet.h and is supposed to be getting sys/un.h
in the near future.

10 years agocaretx.c, not caretx.x, typo in 7b74bef1.
Craig A. Berry [Tue, 5 Nov 2013 13:09:54 +0000 (07:09 -0600)]
caretx.c, not caretx.x, typo in 7b74bef1.

Though the list of C files does not appear to actually be used in
the build.

10 years agoRT #120446: /\Ga/ running slowly on long strings
David Mitchell [Tue, 5 Nov 2013 12:29:07 +0000 (12:29 +0000)]
RT #120446: /\Ga/ running slowly on long strings

This commit reverts my commit cf44e600505da0c8da2d64849647ce2d39c46808
(except for the tests), which incorrectly disabled fix-string intuiting
in the presence of anchored \G. I thought that the old behaviour was
logically incorrect, but it wasn't (or at least I don't see it that way
now, and none of the tests I added at the time fail under the old regime).

10 years ago[perl #120462] Exempt $a and $b from ‘used once’ warnings
Father Chrysostomos [Mon, 4 Nov 2013 14:14:00 +0000 (06:14 -0800)]
[perl #120462] Exempt $a and $b from ‘used once’ warnings

10 years agoMove tests for ‘used once’ from util to gv
Father Chrysostomos [Mon, 4 Nov 2013 13:51:50 +0000 (05:51 -0800)]
Move tests for ‘used once’ from util to gv

The warning itself is triggered in gv.c, so this makes the tests
easier to find.

10 years agoAnd the caretx object file for wince.
Craig A. Berry [Tue, 5 Nov 2013 03:33:47 +0000 (21:33 -0600)]
And the caretx object file for wince.

Thanks to Daniel Dragan for pointing out the omission.

10 years agoAlso fix wince for caretx after e2051532106.
Craig A. Berry [Tue, 5 Nov 2013 01:18:09 +0000 (19:18 -0600)]
Also fix wince for caretx after e2051532106.

10 years agoRestore VMS build after e205153210.
Craig A. Berry [Tue, 5 Nov 2013 01:14:41 +0000 (19:14 -0600)]
Restore VMS build after e205153210.

10 years agoRestore Windows build following commit e205153210
Steve Hay [Tue, 5 Nov 2013 01:06:48 +0000 (01:06 +0000)]
Restore Windows build following commit e205153210

10 years agoUpdate Module-Build to CPAN version 0.4008
Chris 'BinGOs' Williams [Mon, 4 Nov 2013 22:36:32 +0000 (22:36 +0000)]
Update Module-Build to CPAN version 0.4008

  [DELTA]

0.4008 - Mon Nov  4 23:10:54 CET 2013

  [BUG FIXES]

  - Fix test failing on ancient perls <= 5.8.1 [Peter Rabbitson]

  - Do not set default switches in Test::Harness; not even -w [Leon Timmermans]

  [DOCUMENTATION]

  - Fix a couple more broken links to CPAN::META::Spec that should
    have been CPAN::Meta::Spec. [Reported by Mike Doherty]

10 years agocaretx.c: Add LOTR quote
Father Chrysostomos [Mon, 4 Nov 2013 22:04:46 +0000 (14:04 -0800)]
caretx.c: Add LOTR quote

I don’t have the right edition, so could someone else please supply the
page number?

10 years agocaretx.c: Add bool warning comment
Father Chrysostomos [Mon, 4 Nov 2013 21:46:40 +0000 (13:46 -0800)]
caretx.c: Add bool warning comment

It is for this reason that this file exists.

10 years agoMove the function to set $^X to its own file
Peter Martini [Sat, 2 Nov 2013 00:12:53 +0000 (20:12 -0400)]
Move the function to set $^X to its own file

This also moves the indirect dependency on stdbool.h to its
own file, rather than being pulled in for all of perl.c, for
those cases where one may want to test using other definitions
of bool.

10 years agoUpdate Test-Simple to CPAN version 1.001002
Chris 'BinGOs' Williams [Mon, 4 Nov 2013 20:30:08 +0000 (20:30 +0000)]
Update Test-Simple to CPAN version 1.001002

  [DELTA]

1.001002     Mon Nov  4 15:13:58 EST 2013
    * no changes since 0.99

1.001001_001 Wed Oct 30 20:47:23 EDT 2013
    * no code changes, just a new version number with more room to grow

10 years agoUpdate ExtUtils-MakeMaker to CPAN version 6.82
Chris 'BinGOs' Williams [Mon, 4 Nov 2013 19:58:23 +0000 (19:58 +0000)]
Update ExtUtils-MakeMaker to CPAN version 6.82

  [DELTA]

6.82 Mon Nov  4 19:20:07 GMT 2013

    No changes from 6.81_05

6.81_05 Sat Nov  2 21:29:42 GMT 2013
    Misc:
    * Special-case the bundling of version, so
      that XS versions don't get overwritten

6.81_04 Fri Nov  1 19:54:09 GMT 2013
    Doc fixes:
    * Update XSPROTOARG docs for changes in xsubpp

6.81_03 Thu Oct 24 20:50:15 BST 2013
    Doc Fixes:
    * Clarify heir-apparent in FAQ

    Misc:
    * Changed GNU-Style to Unix-Style
    * VMS will now report 'make' style

6.81_02 Thu Oct 17 12:20:59 BST 2013
    Misc:
    * Updated bundled JSON::PP

6.81_01 Wed Oct 16 08:59:03 BST 2013
    Misc:
    * Updated bundled Test-Simple

10 years agoUpdate IPC-Cmd to CPAN release 0.86
Chris 'BinGOs' Williams [Mon, 4 Nov 2013 15:46:12 +0000 (15:46 +0000)]
Update IPC-Cmd to CPAN release 0.86

  [DELTA]

0.86 Mon Nov  4 14:09:42 GMT 2013
======================================

  Bug fixes:
  * run_forked: workaround absent CLOCK_MONOTONIC on OSX (Petya Kohts)
  * RT#89770 Patch to fix error reporting if command killed by signal
    (Ed Avis)
  * Make the false test more forgiving, for Solaris and other SVR*
    (bingos)

0.85_02 Thu Oct 10 13:59:34 BST 2013
======================================

  Bug Fixes:
  * run_forked: incomplete output more than buffer size

0.85_01 Thu Sep  5 20:30:51 BST 2013
======================================

  Enhancements:
  * run_forked() now uses Time::HiRes and Carp

10 years agoop.c: Avoid vivifying CORE::GLOBAL:: globs unnecessarily
Father Chrysostomos [Mon, 4 Nov 2013 05:51:29 +0000 (21:51 -0800)]
op.c: Avoid vivifying CORE::GLOBAL:: globs unnecessarily

If we know the upgraded glob is not going to have the IMPORTED_CV
flag, we can avoid upgrading it.

10 years agoop.c: Abstract common override code
Father Chrysostomos [Mon, 4 Nov 2013 05:48:09 +0000 (21:48 -0800)]
op.c: Abstract common override code

10 years agoStop CORE::GLOBAL::require lookup from crashing on stub
Father Chrysostomos [Mon, 4 Nov 2013 01:32:37 +0000 (17:32 -0800)]
Stop CORE::GLOBAL::require lookup from crashing on stub

‘sub CORE::GLOBAL::require;’ doesn’t create a full glob, but cheats
for efficiency.  Compilation of require ops was not taking this
into account.

10 years agoStop CORE::GLOBAL::glob lookup from crashing on stub
Father Chrysostomos [Mon, 4 Nov 2013 01:27:07 +0000 (17:27 -0800)]
Stop CORE::GLOBAL::glob lookup from crashing on stub

‘sub CORE::GLOBAL::glob;’ doesn’t create a full glob, but cheats for
efficiency.  Compilation of glob ops was not taking this into account.

10 years agoStop CORE::GLOBAL::do lookup from crashing on stub
Father Chrysostomos [Mon, 4 Nov 2013 01:24:50 +0000 (17:24 -0800)]
Stop CORE::GLOBAL::do lookup from crashing on stub

‘sub CORE::GLOBAL::do;’ doesn’t create a full glob, but cheats
for efficiency.  Compilation of do-file ops was not taking this
into account.

10 years agoMake mro code pass precomputed hash values
Father Chrysostomos [Sun, 3 Nov 2013 14:16:40 +0000 (06:16 -0800)]
Make mro code pass precomputed hash values

where possible

This involved adding hv_fetchhek and hv_storehek macros and changing
S_mro_clean_isarev to accept a hash parameter and expect HVhek_UTF8
instead of SVf_UTF8.

10 years agoCheck that stash entries are GVs when aliasing pkgs
Father Chrysostomos [Sun, 3 Nov 2013 13:49:48 +0000 (05:49 -0800)]
Check that stash entries are GVs when aliasing pkgs

$ perl5.18.1 -e '$Foo::{"Bar::"} = 0; $Bar::Bar::; *Bar:: = *Foo::'
Segmentation fault: 11

That $Foo::{"Bar::"} = 0; assignment is documented as having unde-
fined behaviour, but it shouldn’t crash.

10 years agogv.c: Tweak API docs
Father Chrysostomos [Sun, 3 Nov 2013 13:42:55 +0000 (05:42 -0800)]
gv.c: Tweak API docs

Consistent spaces after dots
Some grammar corrections (by no means sufficient, though)
Remove a sentence about ‘name’ being writable.  It has been a const
char * since these docs were added in 954c1994.

10 years agohv.h: missing macro parentheses
Father Chrysostomos [Sun, 3 Nov 2013 13:24:10 +0000 (05:24 -0800)]
hv.h: missing macro parentheses

Let’s defuse this time bomb before it causes problems.

10 years agosub NEGATIVE_INDICES; + $tied[-1] = crash
Father Chrysostomos [Sun, 3 Nov 2013 12:47:17 +0000 (04:47 -0800)]
sub NEGATIVE_INDICES; + $tied[-1] = crash

This code in av.c, when trying to find $NEGATIVE_INDICES, was doing a
direct stash element lookup--instead of going through the normal GV
functions--and then expecting the returned value to be a GV.

‘sub NEGATIVE_INDICES’ creates a stash element that is a PV, not a GV,
so it’s easy to make things crash.

10 years agomg.c: Fix misuse of AvARRAY in defelem_target
Father Chrysostomos [Sun, 3 Nov 2013 12:23:43 +0000 (04:23 -0800)]
mg.c: Fix misuse of AvARRAY in defelem_target

defelem magic does not usually apply to tied arrays, but an array can
be tied after a defelem has been created and points to it.  The code
for handling deferred elements was never updated for tied arrays when
those were added, so it still does AvFILL and AvARRAY.

AvFILL works on tied arrays, and calls FETCHSIZE.  But AvARRAY
accesses the AV’s internal structure.  So AvFILL might suggest that
the index is within the array, whereas it is actually past the end
of AvARRAY.

By tying the array after a deferred element with a high index has been
created and then extending the tied array (so AvFILL returns a big
number), we can make AvARRAY[big number] crash.

This script:

use Tie::Array;
sub {
  tie @a, "Tie::StdArray";
  $#a = 20000;
  warn pre;
  "$_[0]";
  warn post
}->($a[10000]);

gives this output:

pre at -e line 5.
Segmentation fault: 11

For tied arrays, we need to use av_fetch, rather than AvARRAY.

10 years agopp_sort.c: Remove useless assignments; reduce var scope
Father Chrysostomos [Sat, 2 Nov 2013 19:38:41 +0000 (12:38 -0700)]
pp_sort.c: Remove useless assignments; reduce var scope

6cda7db16df9 stopped the value of the stash variable from being used,
so there is no longer any need to assign to it.  sv_2cv, however,
requires an HV ** argument, so we cannot eliminate it completely.

10 years agoop.c:ck_open: Make hint lookup conditional on HINT_LOCALIZE_HH
Father Chrysostomos [Sat, 2 Nov 2013 13:48:13 +0000 (06:48 -0700)]
op.c:ck_open: Make hint lookup conditional on HINT_LOCALIZE_HH

This makes this just a teeny tiny bit faster.

HINT_LOCALIZE_HH will have been set in PL_hints if %^H has anything
in it.  So bypass the hash lookup altogether if that flag is not set.

10 years agoop.c: Combine common code for hash keys and slices
Father Chrysostomos [Mon, 4 Nov 2013 00:41:52 +0000 (16:41 -0800)]
op.c: Combine common code for hash keys and slices

10 years agoMake ‘No such class’ apply to ${$ref}{key}, too
Father Chrysostomos [Sun, 3 Nov 2013 22:48:58 +0000 (14:48 -0800)]
Make ‘No such class’ apply to ${$ref}{key}, too

$ perl -le 'use fields "foo"; my main $r; $r->{bar}'
No such class field "bar" in variable $r of type main at -e line 1.
$ perl -le 'use fields "foo"; my main $r; $$r{bar}'
No such class field "bar" in variable $r of type main at -e line 1.
$ perl -le 'use fields "foo"; my main $r; ${$r}{bar}'
$

Notice how the last one is silent.  There is already code to handle
the block for hash slices, so we can copy that.

10 years agoperlhacktips: Fix verbatim line
Father Chrysostomos [Sun, 3 Nov 2013 22:29:06 +0000 (14:29 -0800)]
perlhacktips: Fix verbatim line

Shorten this long verbatim line by removing the pod markup (which would
be rendered literally), changing the indent to 4 (to match the ‘make
foo.i’ further down) and removing the trailing space

10 years agoop.c: Apply shared hash key optimisation to slices
Father Chrysostomos [Sun, 3 Nov 2013 22:24:16 +0000 (14:24 -0800)]
op.c: Apply shared hash key optimisation to slices

10 years agoMake ‘No such field’ error apply to 1-elem slices
Father Chrysostomos [Sun, 3 Nov 2013 22:02:32 +0000 (14:02 -0800)]
Make ‘No such field’ error apply to 1-elem slices

e75d1f10 added ‘No such class field’.  It has never worked for single-
element slices.

10 years agoStop my Class + sub FIELDS + hash lookup from crashing
Father Chrysostomos [Sun, 3 Nov 2013 21:07:44 +0000 (13:07 -0800)]
Stop my Class + sub FIELDS + hash lookup from crashing

‘sub FIELDS’ cheats by not vivifying the *FIELDS glob.  The code that
checks whether hash keys are valid assumes that the FIELDS entry in a
stash is a GV, which it is not in this case, so it crashes.

10 years agoUpdate IO-Compress to CPAN version 2.063
Chris 'BinGOs' Williams [Sat, 2 Nov 2013 23:03:56 +0000 (23:03 +0000)]
Update IO-Compress to CPAN version 2.063

  [DELTA]

  2.063 20 October 2013

      * RT#89305: Typo in Compress::Zlib _combine function documentation

10 years agoUpdate Compress-Raw-Zlib to CPAN version 2.063
Chris 'BinGOs' Williams [Sat, 2 Nov 2013 23:01:02 +0000 (23:01 +0000)]
Update Compress-Raw-Zlib to CPAN version 2.063

  [DELTA]

  2.063 23 October 2013

      * gcc -g3: final link failed: Memory exhausted
        [#88936]

      * Compress::Raw::Zlib uses AutoLoader for no reason
        [#88260]

      * Typo in Compress::Zlib _combine function documentation
        [#89305]

10 years agoUpdate Compress-Raw-Bzip2 to CPAN version 2.063
Chris 'BinGOs' Williams [Sat, 2 Nov 2013 22:53:41 +0000 (22:53 +0000)]
Update Compress-Raw-Bzip2 to CPAN version 2.063

  [DELTA]

  2.063 20 October 2013

      * Compress::Raw::Bzip2 uses AutoLoader for no reason
        [#88259]

10 years agoUpdate Unicode-Collate to CPAN version 1.01
Chris 'BinGOs' Williams [Sat, 2 Nov 2013 22:43:50 +0000 (22:43 +0000)]
Update Unicode-Collate to CPAN version 1.01

  [DELTA]

1.01  Sat Nov  2 19:00:38 2013
    - DUCET is updated (for Unicode 6.3.0) as Collate/allkeys.txt.
    ! Please notice that allkeys.txt will be overwritten if you have had
      other allkeys.txt already.
    - The default UCA_Version is 28.
    - Locale/*.pl (except fr.pl) and CJK/Korean.pm are updated.
    - modified tests: loc_es.t, loc_estr.t, rewrite.t, version.t in t.

10 years agoUpdate DB_File to CPAN version 1.830
Chris 'BinGOs' Williams [Sat, 2 Nov 2013 22:37:55 +0000 (22:37 +0000)]
Update DB_File to CPAN version 1.830

  [DELTA]

1.830 2 November 2013

   * Memory leaks when failed to open db
     RT #89589

   * DB_File uses AutoLoader for no reason
     RT #88258

10 years agowin32/win32sck.c: dont close() a freed socket os handle
Daniel Dragan [Sat, 2 Nov 2013 03:04:35 +0000 (23:04 -0400)]
win32/win32sck.c: dont close() a freed socket os handle

This patch is in RT as [perl #120091] but also fixes [perl #118059].

Because the MS C lib, doesn't support sockets natively, Perl uses
open_osfhandle, to wrap a socket into CRT fd. Sockets handles must be
closed with closesocket, not CloseHandle (which CRT close calls).
Undefined behavior will happen otherwise according to MS. Swap the now
closed socket handle in the CRT to INVALID_HANDLE_VALUE. The CRT will
not call CloseHandle on INVALID_HANDLE_VALUE and returns success if it
sees INVALID_HANDLE_VALUE. CloseHandle will never be called on a socket
handle with this patch.

In #118059, a race condition was reported, where accept() failed with
ENOTSOCK, when a psuedofork was done, and connection from the child fake
perl process to parent fake perl process was done. The race condition's
effects occur inside the user mode code in mswsock.dll!_WSPAccept in the
parent perl, which winds up having a kernel handle of an unknown type
in it that is invalid. The invalid handle is passed to kernel calls, which
fail, because the handle is invalid, and the error is translated to
ENOTSOCK.  The exact mechanism of the bug and 100% reproducabilty of the
race were never established, since mswsock.dll is closed source.

Another benefit of this patch is making it easier to use C debuggers on
a Win32 Perl because of less debugger-only bad handle exceptions
(NtGlobalFlag FLG_ENABLE_HANDLE_EXCEPTIONS/0xC0000008 STATUS_INVALID_HANDLE).

This commit reverts parts of commit 9b1f18150a
"Get rid of PERL_MSVCRT_READFIX" and parts of commit 46e77f1118
"Don't use the PERL_MSVCRT_READFIX when using VC++ 7.x onwards." and
contains additional changes not found in those 2 commits. The method for
selecting the definition of struct ioinfo isn't perfect. It will break if
VC > 6 is changed to use the older msvcrt.dll. For some versions of the
CRT, like 2005/8.0, it is impossible to know the definition of ioinfo
struct at C compile time, since the struct increased in size a number of
times with higher build numbers of v8.0 CRT. SxS and security updates make
that same perl binary will run with different v8.0 CRTs at different times.
For the case when ioinfo can not be hard coded, introduce
WIN32_DYN_IOINFO_SIZE. With WIN32_DYN_IOINFO_SIZE, the size of the ioinfo
struct is determined on Perl process startup using _mize. Since VC 2013
is a brand new product at the time of this patch, even though its struct
is known, and 2008 through 2012 have been stable so far, don't assume at
this time 2013's ioinfo will be stable. Therefore, VC 2003 and older
(including Mingw's v6.0), 2008 to 2012, are hard coded. 2013 is a candidate
one day to be hard coded. VC 2005 can never be hard coded.

All non-WIN32_DYN_IOINFO_SIZE compilers will work with
WIN32_DYN_IOINFO_SIZE. Non-WIN32_DYN_IOINFO_SIZE mode is simply more
efficient.

For future compatibility concerns, 3 forms of protection are offered.
If __pioinfo isn't exported anymore, the Perl build will break. In
WIN32_DYN_IOINFO_SIZE mode, if __pioinfo isn't heap memory anymore or the
start of a memory block, the runtime panic will happen. In with and without
WIN32_DYN_IOINFO_SIZE, only on a DEBUGGING build, the handle returned by
CRT's _get_osfhandle, which is the authentic handle in the CRT, is compared
to the handle found by accessing the ioinfo struct directly. If they don't
match, the handle swapping code is broken and the assert fails.

10 years agoRevise fake bool build advice from f789f6a4bdb.
Craig A. Berry [Sat, 2 Nov 2013 18:51:42 +0000 (13:51 -0500)]
Revise fake bool build advice from f789f6a4bdb.

The suggestions from that Craig Berry fellow were only half-baked.

10 years agoUndefined lex sub used as inherited method crashes
Father Chrysostomos [Sat, 2 Nov 2013 13:17:23 +0000 (06:17 -0700)]
Undefined lex sub used as inherited method crashes

Thanks to misuse of CvGV.

$ perl5.19.5 -XMfeature=:all -e 'my sub foo {} undef &foo; *UNIVERSAL::bar = \&foo; main->bar()'
Segmentation fault: 11

When deciding under which name to autoload the sub, we can’t assume
CvGV(that_sub) is a GV, as it may be null.

10 years agoremove redundant Zero() from JMPENV_BOOTSTRAP
Daniel Dragan [Fri, 1 Nov 2013 21:50:39 +0000 (17:50 -0400)]
remove redundant Zero() from JMPENV_BOOTSTRAP

In commit 14dd3ad8c9 , a 3 NULL assigns were converted to a Zero() for what
I guess was an optimization. This also caused the large je_buf to be
zeroed even though je_buf was uninit before. At that time, JMPENV had
2 extra members that don't exist anymore. The 2 extra members in JMPENV
were removed in commit 766f891612 . The comment about je_throw was made
obsolete in commit 766f891612 so rework it.

One function call free NULL assign is faster than a memset() call.
je_buf is 0x40 bytes long on 32 bit VC2003 Win32 Perl. No need to zero it
since je_buf is never read unless je_prev is not NULL. Also there is no
need to zero the last 2 members je_ret and je_mustcatch since they are
immediatley assigned to. Move PL_top_env assignment to near je_prev so
compiler tries to optimize better since je_prev is the start of the struct
and hopefully will calculate the pointer once.

Also put some poisoning in case JMPENV gets new members in the future.
To conditionally poison in a macro, PERL_POISON_EXPR is being introduced
instead of 2 different definitions of JMPENV_BOOTSTRAP.

10 years agoremove unneeded dependency on Test::More 0.98 (RT#88531)
Karen Etheridge [Wed, 30 Oct 2013 23:27:33 +0000 (16:27 -0700)]
remove unneeded dependency on Test::More 0.98 (RT#88531)

10 years agoshared.pm: Consistent spaces after dots
Father Chrysostomos [Fri, 1 Nov 2013 19:59:53 +0000 (12:59 -0700)]
shared.pm: Consistent spaces after dots

10 years agothreads::shared: Remove redundant description just added
Father Chrysostomos [Fri, 1 Nov 2013 19:49:25 +0000 (12:49 -0700)]
threads::shared: Remove redundant description just added

In commit fd013656aac I moved the documentation for the two warnings
that threads::shared produces from perldiag.pod to shared.pm, without
rewording anything.

These two warnings had almost identical descriptions, and--I found
later--basically repeat some of the documentation of the cond_signal
function, so point to that description in the warnings section and
avoid repeating things.

10 years agoIncrease $threads::shared::VERSION to 1.45
Father Chrysostomos [Fri, 1 Nov 2013 13:21:41 +0000 (06:21 -0700)]
Increase $threads::shared::VERSION to 1.45

10 years agoMove threads::shared warnings from perldiag to shared.pm
Father Chrysostomos [Fri, 1 Nov 2013 13:18:16 +0000 (06:18 -0700)]
Move threads::shared warnings from perldiag to shared.pm

following the precedent set by threads.pm.

10 years agotoke.c:S_tokeq: add comment
Father Chrysostomos [Fri, 1 Nov 2013 12:48:41 +0000 (05:48 -0700)]
toke.c:S_tokeq: add comment

10 years agotoke.c:S_tokeq: remove dead code
Father Chrysostomos [Fri, 1 Nov 2013 12:47:40 +0000 (05:47 -0700)]
toke.c:S_tokeq: remove dead code

The argument passed to tokeq is always a plain string owning its own
buffer.  I checked all the callers.

This code has been like this since perl 5.000.

10 years agoRemove ancient threads diagnostics from perldiag
Father Chrysostomos [Fri, 1 Nov 2013 12:44:20 +0000 (05:44 -0700)]
Remove ancient threads diagnostics from perldiag

for several reasons:
• The wording has changed, so nobody is using these entries anyway.
• The perldiag entries are clearly not being maintained.
• The threads module has its own list of diagnostics.
• The actual wording depends on the version of the threads module
  installed, not the version of perl.

10 years agoperlhack.pod: consistent spaces after dots
Father Chrysostomos [Fri, 1 Nov 2013 13:24:28 +0000 (06:24 -0700)]
perlhack.pod: consistent spaces after dots

10 years agoperllexwarn: consistent spaces after dots
Father Chrysostomos [Thu, 31 Oct 2013 12:52:24 +0000 (05:52 -0700)]
perllexwarn: consistent spaces after dots

10 years ago‘Attempt to bless into a ref’ with stale method caches
Father Chrysostomos [Thu, 31 Oct 2013 13:03:53 +0000 (06:03 -0700)]
‘Attempt to bless into a ref’ with stale method caches

As of v5.16.0-81-g234df27, SvAMAGIC has only meant potentially over-
loaded.  When method changes occur, the flag is turned on.  When over-
loading tables are calculated (the first time overloading is used),
the flag is turned off if it turns out there is no overloading.

At the time I did that, I assumed that all uses of SvAMAGIC were to
avoid the inefficient code path for non-overloaded objects.  What I
did not notice at the time was that SvAMAGIC is used in pp_bless to
determine whether an object used as a class name should be exempt from
‘Attempt to bless into a reference’.

Hence, the bizarre result:

$ ./perl -Ilib -e 'sub foo{} bless [], bless []'
$ ./perl -Ilib -e 'bless [], bless []'
Attempt to bless into a reference at -e line 1.

This commit makes both die consistently, as they did in 5.16.

10 years ago[perl #119809] Disallow bless($ref, $tied_ref)
Father Chrysostomos [Thu, 31 Oct 2013 12:13:25 +0000 (05:13 -0700)]
[perl #119809] Disallow bless($ref, $tied_ref)

There is no reason tied (or otherwise magical variables like $/)
should be exempt from the ‘Attempt to bless into a reference’ error.

10 years agobless.t: More explicit test
Father Chrysostomos [Thu, 31 Oct 2013 01:05:41 +0000 (18:05 -0700)]
bless.t: More explicit test

Not only does this prevent us from accidentally producing the wrong
error, it also makes it easy to grep and see that this error is
tested.

10 years agoUse tabs consistently in AUTHORS
Father Chrysostomos [Thu, 31 Oct 2013 00:57:28 +0000 (17:57 -0700)]
Use tabs consistently in AUTHORS

10 years agoDocumentation Patches from Tom Hukins
Tom Hukins [Tue, 29 Oct 2013 10:25:21 +0000 (03:25 -0700)]
Documentation Patches from Tom Hukins

Reported as [perl #120406].

tr is documented in perlop's "Quote-Like Operators" section, not its
"Quote and Quote-like Operators" section.

Don't describe PerlIO as "new".

10 years agoperllexwarn: typo, pod syntax
Father Chrysostomos [Thu, 31 Oct 2013 12:46:39 +0000 (05:46 -0700)]
perllexwarn: typo, pod syntax

10 years agoAdd a note that users of FATAL warnings are at risk during upgrades
Yves Orton [Thu, 31 Oct 2013 12:38:43 +0000 (13:38 +0100)]
Add a note that users of FATAL warnings are at risk during upgrades

Apparently it isn't obvious to all of our users that use of FATAL
warnings means that peoples code may break when they upgrade due
to the introduction of new warnings. Accordingly we document that
the use of FATAL warnings is entirely at the users risk, and that
we do not and will not consider the introduction of a warning as
an incompatible change, and that in particular the use of features
which are discouraged, unspecified, or whatnot may in the future
trigger new warnings, and thus under FATAL warnings break their code.

10 years agoIntroduce PERL_BOOL_AS_CHAR define
Father Chrysostomos [Wed, 30 Oct 2013 12:37:43 +0000 (05:37 -0700)]
Introduce PERL_BOOL_AS_CHAR define

This allows compilers that do support real booleans (C++ or anything
with stdbool.h) to emulate those that don’t.

See ticket #120314.

This patch incorporates suggestions from Craig Berry.

10 years agoperlre: Expand and clarify /x and (?# comment)
Karl Williamson [Thu, 31 Oct 2013 00:30:26 +0000 (18:30 -0600)]
perlre: Expand and clarify /x and (?# comment)

This pod omitted some of the details about how comments in regexes work.
I had to do some experimentation to find some of the answers.
I believe this clarifies things as well.

10 years agoFix broken qr/ \N* /x
Karl Williamson [Thu, 31 Oct 2013 00:22:04 +0000 (18:22 -0600)]
Fix broken qr/ \N* /x

Under /x, the parsing was skipping the character following a \N (when
meaning [^\n]).  In fact the parse pointer was already pointing to the
first non-white-space character, so advancing skipped the character.
That character could be the beginning of a (?#...) comment, all of which
should be skipped.

10 years agoregcomp.c: Clarify some comments
Karl Williamson [Wed, 30 Oct 2013 04:41:26 +0000 (22:41 -0600)]
regcomp.c: Clarify some comments

10 years agopad.h: Correct PadlistMAX docs
Father Chrysostomos [Wed, 30 Oct 2013 23:54:06 +0000 (16:54 -0700)]
pad.h: Correct PadlistMAX docs

They have been wrong since I added them.

10 years agoIncrease $B::Deparse::VERSION to 1.24
Father Chrysostomos [Wed, 30 Oct 2013 21:01:45 +0000 (14:01 -0700)]
Increase $B::Deparse::VERSION to 1.24

10 years ago[perl #119807] Deparse s//\(3)/e in a way that does not warn
Father Chrysostomos [Wed, 30 Oct 2013 21:01:15 +0000 (14:01 -0700)]
[perl #119807] Deparse s//\(3)/e in a way that does not warn

Code that does not warn should not be deparsed in a way that warns.
s//\3/e produces a warning about misuse of \3 where $3 is meant.
s//\(3)/e compiles to the same thing and produces no such warning.
So B::Deparse should parenthesize references to numbers in the rhs
of a substitution.

10 years agoEliminate ‘Can't use \1 to mean $1’ false positives
Father Chrysostomos [Wed, 30 Oct 2013 13:18:20 +0000 (06:18 -0700)]
Eliminate ‘Can't use \1 to mean $1’ false positives

We need to check that the quote-like operator we are parsing is a sub-
stitution (not just any quote-like operator) and that we are parsing
the right-hand side.

10 years agoenable LTO/LTCG/WPO for most Visual Cs
Daniel Dragan [Mon, 28 Oct 2013 05:28:41 +0000 (01:28 -0400)]
enable LTO/LTCG/WPO for most Visual Cs

All Win32 Visual C compilers except for VC 6/_MSC_VER == 1200 support LTCG.
LTCG generates slightly smaller and slightly faster binaries.

10 years ago[perl #120408] fix dist/ExtUtils-ParseXS/t/002-more.t
François Perrad [Tue, 29 Oct 2013 13:04:01 +0000 (06:04 -0700)]
[perl #120408] fix dist/ExtUtils-ParseXS/t/002-more.t

the plan is fragile 29 = 2 + 2 + 25

Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
10 years ago'$! = EACCESS; require ...' could fail
David Mitchell [Mon, 28 Oct 2013 16:39:35 +0000 (16:39 +0000)]
'$! = EACCESS; require ...' could fail

When require is checking against a particular entry in @INC, it stats the
potential pathname, and does various checks like skipping if it's a
directory. In this case the stat succeeds, so $! is left unchanged.
Later however, pp_require() checks for $! being EACCES. So if $! was
already set before the require, this could influence require's behaviour.

10 years agoDon’t record cop address for unbreakable lines
Father Chrysostomos [Tue, 29 Oct 2013 04:22:14 +0000 (21:22 -0700)]
Don’t record cop address for unbreakable lines

The cop (control op) address for each statement is recorded in
${"_<$file"}[$line] so that breakpoints set on that line will flag the
op for that statement.

Then, at run time, pp_dbstate checks to see whether the op is flagged
as having a breakpoint, and calls the debugger if so.

Statements that are not breakable are nextstate, rather than dbstate
ops, and pp_nextstate ignores the flag on the op.

In some instances, the cop address was being recorded for nextstate
ops.  This would happen in preamble code (e.g., the PERL5DB envi-
ronment variable or the -M switch) and when $^P contained 0x400
but not 0x02.

Recording the cop address for a nextstate op serves no purpose and is
a waste of CPU cycles.

10 years ago[perl #119799] Set breakpoints without *DB::dbline
Father Chrysostomos [Mon, 28 Oct 2013 23:14:35 +0000 (16:14 -0700)]
[perl #119799] Set breakpoints without *DB::dbline

The elements of the %{"_<..."} hashes (where ‘...’ is the filename),
whose keys are line numbers, are used to set breakpoints on the given
lines.  The corresponding @{"_<..."} array contains the actual lines
of source code.

%{"_<..."} actually acts on the array of lines that @DB::dbline is
aliased to.  The assumption is that *DB::dbline = *{"_<..."} will have
taken place first.  Hence, all %{"_<..."} hashes are the same, when it
comes to writing to keys.

It is more useful for each %{"_<..."} hash to set breakpoints on its
corresponding file’s lines regardless of whether @DB::dbline has been
aliased, so that is what this commit does.

Each hash’s mg_obj pointer in its dbfile magic now points to the
array, and magic_setdbline uses it instead of PL_DBline.

10 years agopp.c:pp_undef: Don’t vivify the scalar slot
Father Chrysostomos [Mon, 28 Oct 2013 19:38:46 +0000 (12:38 -0700)]
pp.c:pp_undef: Don’t vivify the scalar slot

When PERL_DONT_CREATE_GVSV is defined, perl generally does not vivify
the scalar slot in every GV.  But it hides that implementation detail
by vivifying it when *foo{SCALAR} is accessed.

undef(*foo) was one exception to this.  It vivified the scalar in
the scalar slot regardless of whether PERL_DONT_CREATE_GVSV was
defined.

Until recently, it was not safe to remove this exception, because a
typeglob with no scalar could be a candidate for downgrading (see
gv.c:gv_try_downgrade), causing global pointers like PL_DBgv to point
to freed SVs.  Recent commits have fixed all those cases, so this
is now safe.

10 years agoMake PL_incgv fully refcounted
Father Chrysostomos [Mon, 28 Oct 2013 19:31:22 +0000 (12:31 -0700)]
Make PL_incgv fully refcounted

It was only reference-counted in the main thread:

$ ./perl -Ilib -e 'delete $::{INC}; eval q"my $foo : bar"'
$ ./perl -Ilib -e 'use threads; async {delete $::{INC}; eval q"my $foo : bar"}->join'
Assertion failed: (SvTYPE(_gvgp) == SVt_PVGV || SvTYPE(_gvgp) == SVt_PVLV), function S_apply_attrs_my, file op.c, line 2600.
Abort trap: 6

10 years agopat.t: suppress warning
Father Chrysostomos [Mon, 28 Oct 2013 19:26:17 +0000 (12:26 -0700)]
pat.t: suppress warning

10 years agoperl.h: Remove ERRHV
Father Chrysostomos [Mon, 28 Oct 2013 12:48:44 +0000 (05:48 -0700)]
perl.h: Remove ERRHV

It has been unused by the core since 5.6.0 (98eae8f58) and is
unused on CPAN.

10 years agoDon’t assume *^R has a scalar
Father Chrysostomos [Mon, 28 Oct 2013 00:09:17 +0000 (17:09 -0700)]
Don’t assume *^R has a scalar

$ perl -e '*^R = *foo; /(?{})/'
Segmentation fault: 11

10 years ago[perl #54044] Make PL_replgv refcounted
Father Chrysostomos [Sun, 27 Oct 2013 23:44:50 +0000 (16:44 -0700)]
[perl #54044] Make PL_replgv refcounted

Otherwise one can free it and make perl crash:

$ perl -e 'delete $::{"\cR"}; //'
Segmentation fault: 11

It crashes because PL_replgv now points to a freed SV which has no GV
slots, so GvSV on it fails.

10 years agogv:gv_try_downgrade: Leave PL_last_in_gv alone
Father Chrysostomos [Sun, 27 Oct 2013 23:02:44 +0000 (16:02 -0700)]
gv:gv_try_downgrade: Leave PL_last_in_gv alone

gv_try_downgrade exists to remove globs and subs that were (possibly
temporarily) vivified by bareword lookup.  It is called whenever a
gvop is freed and its gv looks like a candidate for downgrading.  That
means it applies, not only to potential sub calls, but also to *foo
and *bar.  gv_try_downgrade may delete a glob from the stash alto-
gether if it is empty.  So eval "*foo if 0" may delete the *foo glob.

PL_last_in_gv is the internal variable underlying ${^LAST_FH}.  If
gv_try_downgrade deletes the last-read handle, then ${^LAST_FH}
will become undefined, whereas eval "*foo if 0" is not supposed to
do anything:

$ ./miniperl -le 'readline *{"foo"}; warn ${^LAST_FH}; eval "*foo if 0"; warn ${^LAST_FH}'
GLOB(0x7f8f5a0052a0) at -e line 1.
Warning: something's wrong at -e line 1.

10 years agoMake PL_argvgv refcounted
Father Chrysostomos [Sun, 27 Oct 2013 21:37:10 +0000 (14:37 -0700)]
Make PL_argvgv refcounted

Otherwise one can free it and cause assertion failures when other
things do SvREFCNT_inc on a freed scalar:

$ ./miniperl -le 'undef *x; delete $::{ARGV}; $x++; eval "BEGIN{undef *x} readline"'
Assertion failed: (SvTYPE(sv) != (svtype)SVTYPEMASK), function Perl_sv_clear, file sv.c, line 6215.
Abort trap: 6