platform/upstream/perl.git
11 years agoIncrease $Env::VERSION to 1.04
Father Chrysostomos [Fri, 9 Nov 2012 20:47:39 +0000 (12:47 -0800)]
Increase $Env::VERSION to 1.04

11 years agoEven more regexp charclass leaks
Father Chrysostomos [Fri, 9 Nov 2012 14:14:49 +0000 (06:14 -0800)]
Even more regexp charclass leaks

11 years agotoke.c: White-space only; no code changes
Karl Williamson [Sun, 11 Nov 2012 22:07:14 +0000 (15:07 -0700)]
toke.c: White-space only; no code changes

This indents a newly formed block, and changes one other line to line up
better.

11 years agotoke.c: Don't force \N{} into utf8 unnecessarily
Karl Williamson [Sun, 11 Nov 2012 21:47:53 +0000 (14:47 -0700)]
toke.c: Don't force \N{} into utf8 unnecessarily

regcomp.c no longer requires everything containing \N{} to be in UTF-8.
I'm not sure of the exact commit; it might even have been in 5.16.  But
it was done by the time 86e88272fdabc40e3b168a3cc43af5e86284d01b was
done.

Therefore we can remove the temporary code that forced utf8, and replace
it with code that handles the non-utf8 case.

Note that outside patterns, \N{} still forces utf8.  This is so that
Unicode semantics will be imposed on the string it resides in, no matter
how it is used.  Patterns have a flag that indicates Unicode semantics,
so don't need to be in utf8.

11 years agotoke.c: Remove redundant checks
Karl Williamson [Sun, 11 Nov 2012 21:45:19 +0000 (14:45 -0700)]
toke.c: Remove redundant checks

This code is redundant, as the whole string has been checked earlier for
valid utf8ness, or we assume that the internal Perl handler, charnames,
is correctly returning valid utf8.

11 years agotoke.c: Reorder declaration
Karl Williamson [Sun, 11 Nov 2012 21:28:17 +0000 (14:28 -0700)]
toke.c: Reorder declaration

This is in preparation for the next commit.

11 years agotoke.c: Use UTF-8 macros for portability
Karl Williamson [Thu, 8 Nov 2012 19:02:29 +0000 (12:02 -0700)]
toke.c: Use UTF-8 macros for portability

I noticed this code in toke.c that hand-rolled its own UTF-8 handling,
and is assuming an ASCII platform.  There are macros that do the same
thing that this code does, and are portable.

11 years agoutf8.h: Add macro that handled malformed 2-byte UTF-8
Karl Williamson [Thu, 8 Nov 2012 19:04:34 +0000 (12:04 -0700)]
utf8.h: Add macro that handled malformed 2-byte UTF-8

The macro used traditionally to see if there is a two-byte UTF-8
sequence doesn't make sure that there actually is a second byte
available; it only checks if the first byte indicates that there is.
This adds a macro that is safe in the face of malformed UTF-8.

I inspected the existing calls in the core to the unsafe macro, and I
believe that none of them need to be converted to the safe version.

11 years agoutil.c: Add some asserts()
Karl Williamson [Thu, 8 Nov 2012 18:11:41 +0000 (11:11 -0700)]
util.c: Add some asserts()

These functions improperly have a signed parameter, when the value
should always be at least 0.  We have a field report that one of them is
getting called with a negative value.  Add asserts to catch this
condition (if compiling assertions is on) earlier.

11 years agoutf8.c: Remove redundant unlikely branches
Karl Williamson [Tue, 30 Oct 2012 16:15:38 +0000 (10:15 -0600)]
utf8.c: Remove redundant unlikely branches

The 2 lines removed in each function provide an early exit if the input
is malformed UTF-8.  Other code executed later makes the same test.
But most inputs are going to be well-formed, so the test will almost
always fail, so will slow things up.

11 years agoValidate above-Latin1 characters in \N{} aliases
Karl Williamson [Fri, 9 Nov 2012 17:18:17 +0000 (10:18 -0700)]
Validate above-Latin1 characters in \N{} aliases

This completes the process of allowing users to define their own aliases
for \N{} in any language they choose.  Names have some validation
applied so that they can't, for example, begin with something that is a
digit in some Unicode script.  Tests and documentation are included in
this patch.  The loop in toke.c that does the validation for
user-supplied translators is revamped, and the messages that are output
when there is an error are fixed to work with UTF-8.

11 years agoembed.fnc: Allow toke.c to call core_swash_init()
Karl Williamson [Fri, 9 Nov 2012 16:46:37 +0000 (09:46 -0700)]
embed.fnc: Allow toke.c to call core_swash_init()

This internal function is allowed to just a few core functions
by #ifdef's in embed.fnc.  Expand the list to include toke.c, as it will
be needed in a future commit.

11 years agotoke.c: Fail on malformed UTF-8 in \N{} input
Karl Williamson [Thu, 1 Nov 2012 18:06:32 +0000 (12:06 -0600)]
toke.c: Fail on malformed UTF-8 in \N{} input

The handler for \N{} can be user-supplied and charnames itself
shouldn't have to worry about malformed input.  This changes toke.c to
check for malformed input before calling the \N{} handler.

11 years agotoke.c: Remove no-longer needed {...} and outdent correspondingly
Karl Williamson [Sun, 28 Oct 2012 16:29:10 +0000 (10:29 -0600)]
toke.c: Remove no-longer needed {...} and outdent correspondingly

No code changes

11 years agotoke.c: [RT#73022] Make \N{...} UTF-8 clean.
Brian Fraser [Sun, 28 Oct 2012 16:23:35 +0000 (10:23 -0600)]
toke.c: [RT#73022] Make \N{...} UTF-8 clean.

11 years agotoke.c Refactor S_get_and_check_backslash_N_name()
Karl Williamson [Sun, 28 Oct 2012 15:53:05 +0000 (09:53 -0600)]
toke.c Refactor S_get_and_check_backslash_N_name()

This code was recently factored out into a separate subroutine, and was
originally designed for a non-fatal deprecated warning.  This
refactoring just goes immediately to failure when an illegal character
is found.

(It also changes the code to use Perl standard coding practices)

11 years agoperldiag: Add entry for unknown charname
Karl Williamson [Fri, 26 Oct 2012 17:23:51 +0000 (11:23 -0600)]
perldiag: Add entry for unknown charname

11 years agotoke.c: Don't validate core charnames output
Karl Williamson [Fri, 26 Oct 2012 17:06:18 +0000 (11:06 -0600)]
toke.c: Don't validate core charnames output

charnames now refuses to allow invalid aliases to be installed, so we
only need to validate those that come from a custom translator.

11 years agocharnames: Don't accept illegal :aliases
Karl Williamson [Fri, 26 Oct 2012 16:48:48 +0000 (10:48 -0600)]
charnames: Don't accept illegal :aliases

Now that improper names for characters are an error, we can forbid them
at definition time.  For the time being allow a colon in the check that
continues to be run in toke.c.  This will be removed in a future commit.

11 years agoregen/mk_PL_charclass.pl: Use mktables table for charname
Karl Williamson [Thu, 8 Nov 2012 18:01:38 +0000 (11:01 -0700)]
regen/mk_PL_charclass.pl: Use mktables table for charname

This commit uses the mktables defined table for whether or not a
character is a legitimate charname continuation.  This will allow it to
be kept in sync with other code that needs the definition.

The only change this makes is to delete "colon" from being a legitimate
continuation character.  A colon was only accepted because it was used
in the paradigm for like "Greek: Alpha", and is not part of any
actual character name.

11 years agomktables: Create tables for charname beginning and follow-on
Karl Williamson [Thu, 8 Nov 2012 17:59:11 +0000 (10:59 -0700)]
mktables: Create tables for charname beginning and follow-on

mktables is changed to add two new tables, one that matches the first
character in a character names, and one that matches continuation
characters.

11 years agoMake \N{alias} deprecations fatal.
Karl Williamson [Fri, 26 Oct 2012 02:12:04 +0000 (20:12 -0600)]
Make \N{alias} deprecations fatal.

Since v5.12, using some non-name like characters, like commas, have
generated a deprecation warning.  The required 2 releases have been
made, and they are now being made fatal.

11 years agocharnames: Correct pod misstatement
Karl Williamson [Fri, 26 Oct 2012 02:06:17 +0000 (20:06 -0600)]
charnames: Correct pod misstatement

Character names can contain Latin1 currently, not just ASCII.

11 years agotoke.c: Extract part of \N{} processing to new function
Karl Williamson [Fri, 26 Oct 2012 01:10:03 +0000 (19:10 -0600)]
toke.c: Extract part of \N{} processing to new function

This is in preparation for making fatal the deprecations that this code
covers.

This code combines the first and final portions of the code that handles
\N{names}, leaving the middle intact.  There are no intentional logic
changes.  The code is moved and outdented as appropriate for not being
within nested "if's", and the comments are reflowed to fill 79 columns.
One declaration had a const added.

This causes the logic that checks for input name validity to be moved
from after everything is computed to doing it beforehand.  Since invalid
names are not currently fatal, there was no problem with checking them
after computing things, but a future commit will make them fatal, so
this saves the work of computing something that is erroneous.

11 years agoutf8n_to_uvuni() pod: Add clarifications
Karl Williamson [Thu, 25 Oct 2012 04:06:48 +0000 (22:06 -0600)]
utf8n_to_uvuni() pod: Add clarifications

11 years agocharnames pod: Nits
Karl Williamson [Thu, 25 Oct 2012 04:05:47 +0000 (22:05 -0600)]
charnames pod: Nits

11 years agocharnames.t: Make EXPECTs more robust
Karl Williamson [Thu, 25 Oct 2012 03:56:27 +0000 (21:56 -0600)]
charnames.t: Make EXPECTs more robust

We can use OPTIONS regex in test.pl to avoid tieing to a spcific line.
The random option is no longer needed, as the messages that were coming
out in random order have been removed by another commit.  The Execution
aborted messages also can be omitted, and the tests pass.

11 years agoPreserve filename case on VMS.
Craig A. Berry [Sun, 11 Nov 2012 14:55:41 +0000 (08:55 -0600)]
Preserve filename case on VMS.

VMS systems of the last decade or so have the ability, when
operating on an ODS-5 volume, to preserve filename case.  In order
for CRTL calls to make use of this capability, the feature setting
DECC$EFS_CASE_PRESERVE must be explicitly enabled.  We now do that
for Perl at start-up time, which depends on latent support that
has been in the core since 5.10 but not quite working until
recently.

Note that case preservation of command-line arguments is not
included in this feature.  That's a different setting and is not
entirely under Perl's control as the command line is parsed by
DCL before the CRTL sees it.

11 years agoMove VMS feature-setting function to an appropriate place.
Craig A. Berry [Sun, 11 Nov 2012 14:50:47 +0000 (08:50 -0600)]
Move VMS feature-setting function to an appropriate place.

It was in the middle of the includes at the top of the file. Move
it close to its only use and, more importantly, after the includes,
some of which it now depends on.

11 years agoSet feature logical names in VMS init code.
Craig A. Berry [Sun, 11 Nov 2012 14:45:28 +0000 (08:45 -0600)]
Set feature logical names in VMS init code.

When setting a CRTL feature, also record the setting in a user-mode
logical name since historically checking the environment is the only
way a Perl program can check a particular setting (otherwise we'd
need the currently vaporware VMS::Feature extension).

11 years agoNormalize VMS case handling in ExtUtils::Manifest.
Craig A. Berry [Sun, 11 Nov 2012 14:18:56 +0000 (08:18 -0600)]
Normalize VMS case handling in ExtUtils::Manifest.

Both manifind and maniread were not completely matching filesystem
behavior when downcasing filenames.

11 years agoFix VMS-specific case nit in File::Glob's basic.t.
Craig A. Berry [Sun, 11 Nov 2012 14:09:28 +0000 (08:09 -0600)]
Fix VMS-specific case nit in File::Glob's basic.t.

t/TEST may appear in upper or lower case and with or without a
trailing dot depending on various Unix compatibility settings.

11 years agoRemove an inadvertent case sensitivity from find.t.
Craig A. Berry [Sun, 11 Nov 2012 14:02:31 +0000 (08:02 -0600)]
Remove an inadvertent case sensitivity from find.t.

The extension of a VMS directory may be presented as .DIR or .dir
depending on various settings and its actual name on disk.

11 years agoAmplify diagnostic about in-place editing.
James E Keenan [Sat, 10 Nov 2012 14:05:06 +0000 (09:05 -0500)]
Amplify diagnostic about in-place editing.

An uneditable directory is a "special file" from the point of view of 'perl
-wne'.

For RT #72284.  Thanks to frank.wiegand for report.

11 years agoUpdate IO-Compress to CPAN version 2.057
Chris 'BinGOs' Williams [Sat, 10 Nov 2012 23:57:07 +0000 (23:57 +0000)]
Update IO-Compress to CPAN version 2.057

  [DELTA]

  2.057 10 November 2012

      * IO::Compress::Zip
        Allow member name & Zip Comment to be "0"

      * IO::Compress::Base::Common
        Remove "-r" test - the file open will catch this.
        RT# 80855: IO::Compress::Base::Common returns that it cannot read readable files in NFS

      * RT# 79820: Install to 'site' instead of 'perl' when perl version is 5.11+

      * General Performance improvements.

11 years agoUpdate Compress-Raw-Bzip2 to CPAN version 2.057
Chris 'BinGOs' Williams [Sat, 10 Nov 2012 23:53:54 +0000 (23:53 +0000)]
Update Compress-Raw-Bzip2 to CPAN version 2.057

  [DELTA]

  2.057 10 November 2012

      * Compress::Raw::Bzip2 needs to use PERL_NO_GET_CONTEXT
        [#80318]

      * Install to 'site' instead of 'perl' when perl version is 5.11+
        [#79811]

      * update to ppport.h that includes SvPV_nomg_nolen
        [#78080]

11 years agoUpdate Compress-Raw-Zlib to CPAN version 2.057
Chris 'BinGOs' Williams [Sat, 10 Nov 2012 23:48:16 +0000 (23:48 +0000)]
Update Compress-Raw-Zlib to CPAN version 2.057

  [DELTA]

  2.057 10 November 2012

      * Compress::Raw::Zlib needs to use PERL_NO_GET_CONTEXT
        [#80319]

      * Install to 'site' instead of 'perl' when perl version is 5.11+
        [#79812]

      * update to ppport.h that includes SvPV_nomg_nolen
        [#78079]

11 years agomake MULTICALL safe across cxstack reallocs
David Mitchell [Sun, 11 Nov 2012 00:01:21 +0000 (00:01 +0000)]
make MULTICALL safe across cxstack reallocs

[perl #115602]
MUTLICALL sets a local var, cx, to point to the current context stack
frame. When a function is called, the context stack might be realloc()ed,
in which case cx would point to freed memory.

11 years agoREADME: add pointer to super-quick patch quide
David Mitchell [Sat, 10 Nov 2012 22:39:03 +0000 (22:39 +0000)]
README: add pointer to super-quick patch quide

11 years agofix NAME of perl5125delta.pod
David Mitchell [Sat, 10 Nov 2012 17:43:53 +0000 (17:43 +0000)]
fix NAME of perl5125delta.pod

11 years agoModule-CoreList updated to 2.77
Chris 'BinGOs' Williams [Sat, 10 Nov 2012 15:37:00 +0000 (15:37 +0000)]
Module-CoreList updated to 2.77

  - Documented decprecated_in() function
  - Updated with v5.16.2 data
  - Updated with v5.12.5 data
  - Updated POD to reflect included perl data

11 years agoThe v5.16.2 updates had disappeared (if they were there in the first place) reinstate
Chris 'BinGOs' Williams [Sat, 10 Nov 2012 15:16:24 +0000 (15:16 +0000)]
The v5.16.2 updates had disappeared (if they were there in the first place) reinstate

11 years agoadd 5.12.5 to perlhist
Dominic Hargreaves [Sat, 10 Nov 2012 15:16:41 +0000 (15:16 +0000)]
add 5.12.5 to perlhist

11 years agoAdd the 5.12.5 perldelta
Dominic Hargreaves [Sat, 10 Nov 2012 15:13:35 +0000 (15:13 +0000)]
Add the 5.12.5 perldelta

11 years agoadd 5.12.5 epigraph
Dominic Hargreaves [Sat, 10 Nov 2012 14:26:22 +0000 (14:26 +0000)]
add 5.12.5 epigraph

11 years ago[MERGE] add PADRANGE op and $B::overlay
David Mitchell [Sat, 10 Nov 2012 11:35:46 +0000 (11:35 +0000)]
[MERGE] add PADRANGE op and $B::overlay

This commit implements three optimisations and one new feature.

The new feature is $B::overlay, which can be set to a hash ref, indexed by
op address, that allows you to override the values returned by the various
B::*OP methods for a particular op. This specifically allows Deparse to be
tricked into seeing a pre-optimisation view of the optree, and so makes
adding new optimisations (like the one in this commit) a lot easier.

As regards optimisations: first, a new save type is added:
SAVEt_CLEARPADRANGE, which is like SAVEt_CLEARSV but specifies a range of
targs to be cleared. The save type, target base and range all fit within a
single integer pushed on the save stack.

Second, a pushmark followed by one or more pad[ahs]v ops (and possibly
some mixed-in null, list and nextstate ops) will sometimes be replaced by
a single padrange op. Like other pad ops, this specifies a targ, but in
addition the bottom 7 bits of op_private indicate a target range.
pp_padrange has two main actions: with OPpLVAL_INTRO, it pushes a
SAVEt_CLEARPADRANGE onto the save stack and turns off SvPADSTALE on all
the lexicals; and in non-void context, it pushes all the lexicals onto the
stack.

Third, for the specific case of the construct my(...) = @_, the
ops to push @_ onto the stack (pushmark/gv[*_]/rv2sv) are skipped,
and the OPf_SPECIAL flag on the padrange op is set: this tells
pp_padrange to push @_ directly.

Note that not sequences of pad ops are consolidated into a single
padrange op; the chief constraints are that:

* they must form a list (i.e. start with pushmark);
* the targs must form a contiguous range;
* the flags of the ops must all be similar; e.g. all INTRO or all not,
   all void or all not, etc;
* only a subset of flags are allowed; e.g. we don't optimise with
  OPpPAD_STATE or OPpMAYBE_LVSUB present.

For the specific case of void/INTRO, we consolidate across nextstate
boundaries (keeping only the last nextstate); i.e.

    my ($a,$b); my @c; my (%d,$e,$f)

becomes a single padrange op. Note that the padrange optimisation is
particularly efficient for the void/INTRO combination: formerly,
my($a,$b,@c,%d); would be compiled as

    pushmark; padsv[$a]; padsv[$b]; padav[@c]; padhv[%d]; list; nextstate

which would have the effect of pushing $a, $b onto the stack, then
pushing the (non-existent) elements of @c, then pushing the %d HV; then
pp_list would pop all the elements except the last, %h; finally, nextstate
would pop %h.  Instead, padrange skips all the pushing and popping in void
context.  Note that this means that there is one user-visible change caused
by this optimisation:

    f();
    my @a;
    sub f { tie @a, ...; push @a, .... }

Here, @a is tied and already has elements by the time the 'my @a' is
executed; formerly, FETCH would be called repeatedly to push the elements
of @a onto the stack, then they would all be popped again at the end of the
'my @a' statement; now FETCH is never called.

The optimisation itself is implemented by converting the initial pushmark
op into a padrange, and updating its op_next. The skipped ops are *not*
cleared; this makes it easier for S_find_uninit_var() and Deparse.pm to do
their stuff. Deparse is implemented by using the new $B::overlay facility
to make the padrange op look like a pushmark op again; the rest of the
Deparse code just sees the original unoptimised optree and so doesn't
require any knowledge of the padrange op.

11 years agoext/B/t/OptreeCheck.pm: fix hint stripping
David Mitchell [Mon, 5 Nov 2012 13:54:51 +0000 (13:54 +0000)]
ext/B/t/OptreeCheck.pm: fix hint stripping

The code that strips hints from a nextstate couldn't handle
the 'next' pointer being '-', e.g. v:>,<,% ->-

11 years agofix optree_misc.t test after smoke
David Mitchell [Mon, 5 Nov 2012 13:06:38 +0000 (13:06 +0000)]
fix optree_misc.t test after smoke

Some of the unicode setting in a smoke environment sets the open hints
output on nextstate lines.

11 years agoConsolidate any single pad ops after a padrange
David Mitchell [Fri, 2 Nov 2012 16:18:20 +0000 (16:18 +0000)]
Consolidate any single pad ops after a padrange

Given something like
    my ($a,$b); my $c; my $d;
then after having detected that we can create a padrange op for $a,$b,
extend it to include $c,$d too.

Together with the previous commit that consolidates adjacent padrange
ops, this means that any contiguous sequence of void 'my' declarations
that starts with a list (i.e. my ($x,..) rather than my $x) will
all be compressed into a single padrange op. For example

    my ($a,$b);
    my @c;
    my %d;
    my ($e,@f);

becomes the two ops

    padrange[$a;$b;@c;%d;$e;@f]
    nextstate

The restriction on the first 'my' being a list is that we only ever
convert pushmarks into padranges, to keep things manageable (both for
compiling and for Deparse). This simply means that

    my $x; my ($a,$b); my @c; my %d; my ($e,@f)

becomes

    padsv[$x]
    nextstate
    padrange[$a;$b;@c;%d;$e;@f]
    nextstate

11 years agoConsolidate adjacent padrange ops
David Mitchell [Fri, 2 Nov 2012 14:37:29 +0000 (14:37 +0000)]
Consolidate adjacent padrange ops

In something like

    my ($a,$b);
    my ($c,$d);

when converting $c,$d into a padrange op, check first whether we're
immediately preceded by a similar padrange (and nextstate) op,
and if so re-use the existing padrange op (by increasing the count).
Also, skip the first nextstate and only use the second nextstate.

So

    pushmark;
    padsv[$a]; padsv[$b]; list;
    nextstate 1;
    pushmark;
    padsv[$c]; padsv[$c]; list;
    nextstate 2;

becomes

    padrange[$a,$b]
    nextstate 1;
    pushmark;
    padsv[$c]; padsv[$c]; list;
    nextstate 2;

which then becomes

    padrange[$a,$b,$c,$d];
    nextstate 2;

11 years agopadrange: handle @_ directly
David Mitchell [Tue, 30 Oct 2012 15:10:06 +0000 (15:10 +0000)]
padrange: handle @_ directly

In a construct like
    my ($x,$y) = @_
the pushmark/padsv/padsv is already optimised into a single padrange
op. This commit makes the OPf_SPECIAL flag on the padrange op indicate
that in addition, @_ should be pushed onto the stack, skipping an
additional pushmark/gv[*_]/rv2sv combination.

So in total (including the earlier padrange work), the above construct
goes from being

    3  <0> pushmark s
    4  <$> gv(*_) s
    5  <1> rv2av[t3] lK/1
    6  <0> pushmark sRM*/128
    7  <0> padsv[$x:1,2] lRM*/LVINTRO
    8  <0> padsv[$y:1,2] lRM*/LVINTRO
    9  <2> aassign[t4] vKS

to

    3  <0> padrange[$x:1,2; $y:1,2] l*/LVINTRO,2 ->4
    4  <2> aassign[t4] vKS

11 years agoreindent block in leave_scope
David Mitchell [Sun, 28 Oct 2012 12:58:22 +0000 (12:58 +0000)]
reindent block in leave_scope

The previous commit added a loop round a block of code; now increase
the indent of the body of the loop.

11 years agoadd SAVEt_CLEARPADRANGE
David Mitchell [Wed, 17 Oct 2012 18:45:38 +0000 (19:45 +0100)]
add SAVEt_CLEARPADRANGE

Add a new save type that does the equivalent of multiple SAVEt_CLEARSV's
for a given target range. This makes the new padange op more efficient.

11 years agoadd padrange op
David Mitchell [Mon, 24 Sep 2012 12:50:22 +0000 (13:50 +0100)]
add padrange op

This single op can, in some circumstances, replace the sequence of a
pushmark followed by one or more padsv/padav/padhv ops, and possibly
a trailing 'list' op, but only where the targs of the pad ops form
a continuous range.

This is generally more efficient, but is particularly so in the case
of void-context my declarations, such as:

    my ($a,@b);

Formerly this would be executed as the following set of ops:

    pushmark  pushes a new mark
    padsv[$a] pushes $a, does a SAVEt_CLEARSV
    padav[@b] pushes all the flattened elements (i.e. none) of @a,
              does a SAVEt_CLEARSV
    list      pops the mark, and pops all stack elements except the last
    nextstate pops the remaining stack element

It's now:

    padrange[$a..@b] does two SAVEt_CLEARSV's
    nextstate        nothing needing doing to the stack

Note that in the case above, this commit changes user-visible behaviour in
pathological cases; in particular, it has always been possible to modify a
lexical var *before* the my is executed, using goto or closure tricks.
So in principle someone could tie an array, then could notice that FETCH
is no longer being called, e.g.

    f();
    my ($s, @a); # this no longer triggers two FETCHES
    sub f {
tie @a, ...;
push @a, 1,2;
    }

But I think we can live with that.

Note also that having a padrange operator will allow us shortly to have
a corresponding SAVEt_CLEARPADRANGE save type, that will replace multiple
individual SAVEt_CLEARSV's.

11 years agopad_free(): don't clear SVs_PADSTALE
David Mitchell [Tue, 25 Sep 2012 11:47:51 +0000 (12:47 +0100)]
pad_free(): don't clear SVs_PADSTALE

pad_free() clears the SVs_PADTMP bit. Since that bit is now shared
with SVs_PADSTALE, that gets cleared on state vars. It didn't matter up
till now, but the next commit will start optimising away pad ops, and
op_null() will call pad_free() which would clear the SVs_PADSTALE bit.

So only clear SVs_PADTMP/SVs_PADSTALE for non-lexical var ops.

11 years agoadd $B::overlay feature
David Mitchell [Tue, 23 Oct 2012 20:39:10 +0000 (21:39 +0100)]
add $B::overlay feature

This allows you to alter the read-only "view" of an optree, by making
particular B::*OP methods on particular op nodes return customised values.
Intended to be used by B::Deparse to "undo" optimisations, thus making it
easier to add new optree optimisations without breaking Deparse.

11 years agoUpdate CGI to CPAN version 3.62
Chris 'BinGOs' Williams [Sat, 10 Nov 2012 12:31:46 +0000 (12:31 +0000)]
Update CGI to CPAN version 3.62

  [DELTA]

  Version 3.62, Nov 9th, 2012

    [INTERNALS]
    - Changed how the  deprecated endform function was defined for compatibilty
      with the development version of Perl.
    - Fix failures in t/tmpdir.t when run as root
      https://github.com/markstos/CGI.pm/issues/22, RT#80659)

    - Made it possible to force a sorted order for things like hash
      attributes so that tests are not dependent on a particular hash
      ordering. This will be required in modern perls which will
      change the ordering per process. (Yves, RT#80659)

11 years agoUpdate Term-UI to CPAN version 0.32
Chris 'BinGOs' Williams [Sat, 10 Nov 2012 12:29:21 +0000 (12:29 +0000)]
Update Term-UI to CPAN version 0.32

  [DELTA]

  Changes for 0.32        Sat Nov 10 11:00:31 GMT 2012
  =====================================================
  * Add a delimiter to a prompt that doesn't have a default
    (Tommy Stanton)

11 years agoRestore non-DEBUGGING build on Win32, broken in 28e70dfacc
Steve Hay [Fri, 9 Nov 2012 15:04:35 +0000 (15:04 +0000)]
Restore non-DEBUGGING build on Win32, broken in 28e70dfacc

11 years agoRestore DEBUGGING build with USE_ITHREADS on Win32, broken in 9399a70c62
Steve Hay [Fri, 9 Nov 2012 08:39:36 +0000 (08:39 +0000)]
Restore DEBUGGING build with USE_ITHREADS on Win32, broken in 9399a70c62

11 years agoFix the phrasing of the previous patch.
Shlomi Fish [Fri, 9 Nov 2012 04:15:14 +0000 (06:15 +0200)]
Fix the phrasing of the previous patch.

Thanks to Father C, and David Golden for their input. Removed what was
said about the -w being deprecated.

11 years agoReplace mentions of the "-w" flag in perl.pod.
Shlomi Fish [Thu, 8 Nov 2012 09:38:59 +0000 (11:38 +0200)]
Replace mentions of the "-w" flag in perl.pod.

Replace these mentions of the deprecated -w flag (which is applied
globally) with mentions of use warnings (and possibly also use strict).

Thanks to tm604 on Freenode's #perl for noticing that.

11 years agorefactor gv.c:Perl_newGP
Daniel Dragan [Wed, 7 Nov 2012 23:03:10 +0000 (18:03 -0500)]
refactor gv.c:Perl_newGP

This commit fixes a scenario was strlen("") was called unnecessarily.
Replaced with 0. Also various func calls were rearranged for more calls
to happen near the beginning to maximize use of volatile registers
towards the end for PERL_HASH. PERL_HASH was moved to be closer to the
first usage of var hash. Setting gp_line to 0 was removed since the block
was just calloced and is already 0. Filling of gp.gp_egv was moved early
so var gv on C stack might get reused by compiler optimizer to store
something else to decrease the stack frame size of Perl_newGP.
PERL_ARGS_ASSERT_NEWGP was moved to be outside of an ifdef.

Also see commits 128165928a7 , 19bad6733a8 , 1df5f7c1950 , f4890806d3 .

11 years agoTo-do test for eval "END OF TERMS" leaking
Father Chrysostomos [Fri, 9 Nov 2012 02:14:06 +0000 (18:14 -0800)]
To-do test for eval "END OF TERMS" leaking

I found this memory leak by evaluating lines of the Copying file as
Perl code. :-)

The parser requires yylex to return exactly one token with each call.
Sometimes yylex needs to record a few tokens ahead of time, so its
puts them in its forced token stack.  The next call to yylex then pops
the pending token off that stack.

Ops belong to their subroutines.  If the subroutine is freed before
its root is attached, all the ops created when PL_compcv pointed
to that sub are freed as well.  To avoid crashes, the ops on the
savestack and the forced token stack are specially marked so they are
not freed when the sub is freed.

When it comes to evaluating "END OF TERMS AND CONDITIONS", the END
token causes a subroutine to be created and placed in PL_compcv.  The
OF token is treated by the lexer as a method call on the TERMS pack-
age.  The TERMS token is placed in the forced token stack as an sv in
an op for a WORD token, and a METHOD token for OF is returned.  As
soon as the parser sees the OF, it generates an error, which results
in LEAVE_SCOPE being called, which frees the subroutine for END while
TERMS is still on the forced token stack.  So the subroutine’s op
cleanup skips that op.  Then the parser calls back into the lexer,
which returns the TERMS token from the forced token stack.  Since
there has been an error, the parser discards that token, so the op
is never freed.  The forced token stack cleanup that happens in
parser_free does not catch this, as the token is no longer on
that stack.

I have not yet determined how to fix this problem.

11 years agoAnother regexp charclass leak
Father Chrysostomos [Wed, 7 Nov 2012 07:59:51 +0000 (23:59 -0800)]
Another regexp charclass leak

Compiling a negated character class can cause internal temporary sca-
lars to leak, as of v5.17.1-252-gea364ff.

(I don’t understand how v5.17.1-252-gea364ff caused it, but bisect
points to it.)

11 years agoleakfinder.pl: Yet mair exceptions
Father Chrysostomos [Wed, 7 Nov 2012 07:56:56 +0000 (23:56 -0800)]
leakfinder.pl: Yet mair exceptions

11 years agoregcomp.c: Typo
Father Chrysostomos [Wed, 7 Nov 2012 00:42:34 +0000 (16:42 -0800)]
regcomp.c: Typo

11 years agoremove various redundant dTHXes
Daniel Dragan [Mon, 5 Nov 2012 07:19:29 +0000 (02:19 -0500)]
remove various redundant dTHXes

Remove either unused dTHXes, or remove dTHXes where a nocontext func can
be used instead. Smaller/faster machine code is the result.

11 years agoremove unused dTHXes in /win32/*
Daniel Dragan [Sat, 3 Nov 2012 18:53:55 +0000 (14:53 -0400)]
remove unused dTHXes in /win32/*

Remove dTHXes in win32 perl funcs where they were not used, or could be
replaced with nocontext croaks/warns. Since Perl_get_context is a function
it is not optimized away by the compiler.

11 years agocreate aTHXa, some unused dTHXs removed in /win32/*
Daniel Dragan [Wed, 31 Oct 2012 06:13:42 +0000 (02:13 -0400)]
create aTHXa, some unused dTHXs removed in /win32/*

dTHXes that were unused, or because Newx/Safefree were the only things
called were removed. In some places the dTHX turned into dTHXa and aTHXa
so the context is  not fetched until it is actually used
(locality/frees a C stack slot or frees a non-volatile register). Also see
http://www.nntp.perl.org/group/perl.perl5.porters/2012/10/msg194414.html
and http://www.nntp.perl.org/group/perl.perl5.porters/2012/10/msg194861.html

11 years ago"func not implemented" croaks optimizations in /win32/*
Daniel Dragan [Sun, 28 Oct 2012 02:25:47 +0000 (22:25 -0400)]
"func not implemented" croaks optimizations in /win32/*

This commit removes a number of "* not implemented" strings from the image.
A win32_croak_not_implemented wrapper is created to reduce machine code
by not putting the format string on the C stack many times. embed.fnc was
used to declare win32_croak_not_implemented for proper cross compiler
support of noreturn (noreturn on GCC and VC ok). Tailcalling and noreturn
optimizations of the C compiler are heavily used in this commit.

11 years agoperlpolicy: remove 5.12 references from maint cherry pick policy
David Golden [Thu, 8 Nov 2012 19:24:20 +0000 (14:24 -0500)]
perlpolicy: remove 5.12 references from maint cherry pick policy

11 years agoSync version of autodie in Maintainers.pl with CPAN
Yves Orton [Thu, 8 Nov 2012 07:12:53 +0000 (08:12 +0100)]
Sync version of autodie in Maintainers.pl with CPAN

11 years agofix a hash key order dependency in cpan/autodie/t/hints_pod_examples.t
Yves Orton [Mon, 27 Aug 2012 06:54:50 +0000 (08:54 +0200)]
fix a hash key order dependency in cpan/autodie/t/hints_pod_examples.t

At the same time make part of the internals deterministic Just In Case.

Version bump on autodie to 2.13 as well.

11 years agolimit number of args before formatting
Jesse Luehrs [Wed, 7 Nov 2012 17:45:16 +0000 (11:45 -0600)]
limit number of args before formatting

this makes a difference when the number of args is quite large

11 years agofix Carp stacktraces after deleting a stash
Jesse Luehrs [Thu, 29 Mar 2012 02:44:41 +0000 (21:44 -0500)]
fix Carp stacktraces after deleting a stash

When a stash is deleted, caller() will return undef in the package slot
for any stack level for which the deleted stash was the current package.
This made Carp confused in some cases, so fix that.

11 years agoRemove x bit from MANIFEST
Father Chrysostomos [Tue, 6 Nov 2012 20:32:47 +0000 (12:32 -0800)]
Remove x bit from MANIFEST

11 years agoUpgrade to Thread::Queue 3.01
Jerry D. Hedden [Wed, 24 Oct 2012 02:48:50 +0000 (22:48 -0400)]
Upgrade to Thread::Queue 3.01

11 years agosvleak.t: Fix a mad failure
Father Chrysostomos [Tue, 6 Nov 2012 18:02:21 +0000 (10:02 -0800)]
svleak.t: Fix a mad failure

11 years agoStop eval "qq'\$\0foo'" from leaking
Father Chrysostomos [Tue, 6 Nov 2012 18:00:12 +0000 (10:00 -0800)]
Stop eval "qq'\$\0foo'" from leaking

If the dollar sign in a double-quoted string is followed by a null,
then scan_ident gets confused, as it uses the nullness to keep track
of whether it has found an identifier.  In this case it treats $\0 as
a punctuation variable but then loses track of that fact and thinks it
has found the end of the string.

It’s complicated, but the end result is that the sequence of tokens
emitted for eval "qq'$\0foo'" would be the following:

    stringify ( $ . "foo" )

instead of this:

    stringify ( $ <ident> . "foo" )

But the missing identifier after the dollar sign results in a syn-
tax error that prevents yylex from having a chance to emit the
"foo", which by that time it has put on the forced token stack.

There are cases in which the CV that owns the ops on the forced token
stack can be freed while the ops are still on that stack and will
still be fed to the parser, so we treat the forced token stack like
the savestack, and do not allow ops thereon to be freed when their CV
is freed, to avoid feeding freed ops to the parser.

In this case, it means that the ops on the stack are never freed,
resulting in a memory leak.

Whether scan_ident needs to be fixed (or ‘fixed’) I don’t know.  I do
know that when the parser is freed any remaining forced tokens should
also be freed.  Even if this leak could be fixed some other way, it
would still be a good idea for parser_free to check for forced tokens
that need to be cleaned up.

11 years agoleakfinder.pl: Clean up exceptions
Father Chrysostomos [Mon, 5 Nov 2012 21:10:11 +0000 (13:10 -0800)]
leakfinder.pl: Clean up exceptions

Remove two (exit and END) that were from preliminary versions of
the script.

Skip all lines beginning with push and unshift.

Remove leading whitespace when looking up exceptions.

11 years agoleakfinder.pl: Another exception
Father Chrysostomos [Mon, 5 Nov 2012 21:07:47 +0000 (13:07 -0800)]
leakfinder.pl: Another exception

11 years agoSkip non-functional glob test on VMS.
Craig A. Berry [Tue, 6 Nov 2012 13:02:51 +0000 (07:02 -0600)]
Skip non-functional glob test on VMS.

11 years agoSync the version of Module::Pluggable in Maintainers.pl with CPAN
Chris 'BinGOs' Williams [Tue, 6 Nov 2012 13:06:27 +0000 (13:06 +0000)]
Sync the version of Module::Pluggable in Maintainers.pl with CPAN

11 years agoupgrade Module::Pluggable to 4.5 (test changes only)
Yves Orton [Tue, 6 Nov 2012 08:26:35 +0000 (09:26 +0100)]
upgrade Module::Pluggable to 4.5 (test changes only)

note there is an untrue comment next to VERSION line in Pluggable.pm, 4.5 is also on CPAN.

Also note this patch keeps the old Makefile.PL based make process intact.

11 years agofix NO_TAINT_SUPPORT on g++
David Mitchell [Mon, 5 Nov 2012 14:57:28 +0000 (14:57 +0000)]
fix NO_TAINT_SUPPORT on g++

A '&' got lost in the conversion

11 years agoperl.h: s/non-existant/nonexistent/
Father Chrysostomos [Mon, 5 Nov 2012 14:21:35 +0000 (06:21 -0800)]
perl.h: s/non-existant/nonexistent/

11 years agoLose the loose. Fix documentation typo.
Paul Johnson [Mon, 5 Nov 2012 13:39:45 +0000 (14:39 +0100)]
Lose the loose. Fix documentation typo.

11 years agoMore violent warning about using NO_TAINT_SUPPORT
Steffen Mueller [Mon, 5 Nov 2012 07:06:43 +0000 (08:06 +0100)]
More violent warning about using NO_TAINT_SUPPORT

I failed to update the commit message of the previous commit (sorry!).
The code is in a much better shape than the message claims and Configure
support, for example, won't be added at all to require more
determination from users. PL_taint_warn has since received the same
treatment. To wit:

 #   define TAINT_WARN_get       (PL_taint_warn)
 #   define TAINT_WARN_set(s)    (PL_taint_warn = (s))

11 years agoAdd C define to remove taint support from perl
Steffen Mueller [Tue, 9 Oct 2012 09:19:37 +0000 (11:19 +0200)]
Add C define to remove taint support from perl

By defining NO_TAINT_SUPPORT, all the various checks that perl does for
tainting become no-ops. It's not an entirely complete change: it doesn't
attempt to remove the taint-related interpreter variables, but instead
virtually eliminates access to it.

Why, you ask? Because it appears to speed up perl's run-time
significantly by avoiding various "are we running under taint" checks
and the like.

This change is not in a state to go into blead yet. The actual way I
implemented it might raise some (valid) objections. Basically, I
replaced all uses of the global taint variables (but not PL_taint_warn!)
with an extra layer of get/set macros (TAINT_get/TAINTING_get).
Furthermore, the change is not complete:

- PL_taint_warn would likely deserve the same treatment.
- Obviously, tests fail. We have tests for -t/-T
- Right now, I added a Perl warn() on startup when -t/-T are detected
  but the perl was not compiled support it. It might be argued that it
  should be silently ignored! Needs some thinking.
- Code quality concerns - needs review.
- Configure support required.
- Needs thinking: How does this tie in with CPAN XS modules that use
  PL_taint and friends? It's easy to backport the new macros via PPPort,
  but that doesn't magically change all code out there. Might be
  harmless, though, because whenever you're running under
  NO_TAINT_SUPPORT, any check of PL_taint/etc is going to come up false.
  Thus, the only CPAN code that SHOULD be adversely affected is code
  that changes taint state.

11 years agoStop the glob operator from leaking GVs
Father Chrysostomos [Mon, 5 Nov 2012 04:18:51 +0000 (20:18 -0800)]
Stop the glob operator from leaking GVs

It was adding GVs to the symbol table (via newGVgen), so they
would never be freed, even after the op was freed, unless done so
explicitly.

There is no reason for these GVs to be exposed.

11 years agoleakfinder.pl: Mair exceptions
Father Chrysostomos [Mon, 5 Nov 2012 02:33:52 +0000 (18:33 -0800)]
leakfinder.pl: Mair exceptions

11 years agoleakfinder.pl: Show file names
Father Chrysostomos [Mon, 5 Nov 2012 02:26:12 +0000 (18:26 -0800)]
leakfinder.pl: Show file names

It can take a *very* long time to run, so give some indication
that it is actually doing something.

11 years agoop.c:opslab_force_free: Make paranoid code reflect reality
Father Chrysostomos [Mon, 5 Nov 2012 02:21:34 +0000 (18:21 -0800)]
op.c:opslab_force_free: Make paranoid code reflect reality

When opslab_force_free is called, the CV still has a reference count
on the slab.  In fact, we don’t even bother lowering it if all goes
well, but simply free the slab with the reference count set to 1.
So the paranoid code that increments the reference count before free-
ing an op is not necessary.  Also, the shortcut out of the loop
was never triggered, as it was checking for a reference count of 0,
rather than 1.

11 years agoop.c: Stop SAVEFREEOP from leaking slabs
Father Chrysostomos [Mon, 5 Nov 2012 01:44:06 +0000 (17:44 -0800)]
op.c: Stop SAVEFREEOP from leaking slabs

When a CV is freed prematurely, it cleans up its op slab.  But
SAVEFREEOP may cause the savestack to point to an op in that slab
after the CV has been freed, so SAVEFREEOP is allowed to coun-
termand the freeing of the slab.  Every op that is not on the
savestack is freed.

The reference count of the slab was being left off by one.  The result
was that when the stack unwinding freed the op, it would leave the
slab behind and leak it.

11 years agoStop %! after syntax error from leaking the module name
Father Chrysostomos [Sun, 4 Nov 2012 22:57:49 +0000 (14:57 -0800)]
Stop %! after syntax error from leaking the module name

11 years agogv.c:S_require_tie_mod: remove SPAGAIN
Father Chrysostomos [Sun, 4 Nov 2012 22:39:07 +0000 (14:39 -0800)]
gv.c:S_require_tie_mod: remove SPAGAIN

We are not using SP after this point.

11 years agoDon’t leak BEGIN blocks after syntax errors
Father Chrysostomos [Sun, 4 Nov 2012 19:03:17 +0000 (11:03 -0800)]
Don’t leak BEGIN blocks after syntax errors

11 years agoleakfinder.pl: Use DD for output
Father Chrysostomos [Sun, 4 Nov 2012 07:38:45 +0000 (00:38 -0700)]
leakfinder.pl: Use DD for output

This solves the problem of binary code being dumped into the
terminal.

11 years agoDon’t leak pattern buffer when invalid flags croak
Father Chrysostomos [Sun, 4 Nov 2012 07:03:43 +0000 (00:03 -0700)]
Don’t leak pattern buffer when invalid flags croak

Normally if there is a syntax error yyerror just records it and pars-
ing continues anyway.  If there are too many syntax errors, it croaks.

It just happened that if it croaked when encountering invalid flags
for quote-like operators it would leak the buffer containing the pat-
tern (and the substitution for s///).

Since those are stored in the parser struct and are set to null when-
ever something else takes ownership of the SV, these struct members
will only ever be non-null in parser_free when they have leaked.  So
we can free them there.  (I.e., these slots have always been refer-
ence-counted, so treat them that way.)