platform/upstream/perl.git
11 years agoregcomp.h, sv.c, utf8.c: Comment nits
Karl Williamson [Fri, 2 Aug 2013 20:13:16 +0000 (14:13 -0600)]
regcomp.h, sv.c, utf8.c: Comment nits

Remove obsolete comment, typos in others, plus reflow one block to fit
into 79 columns

11 years agoadd adjust_size_and_find_bucket to embed.fnc
Lukas Mai [Sat, 10 Aug 2013 22:44:09 +0000 (00:44 +0200)]
add adjust_size_and_find_bucket to embed.fnc

11 years agoRemove some effect-less code.
Shlomi Fish [Sat, 10 Aug 2013 07:24:00 +0000 (10:24 +0300)]
Remove some effect-less code.

Discussed in RT #41461

11 years agoFix RT #41461 (with a test).
Shlomi Fish [Sat, 10 Aug 2013 07:21:16 +0000 (10:21 +0300)]
Fix RT #41461 (with a test).

A problem with the perl debugger of writing to an undef $LINEINFO.
Bump $VERSION to 1.42.

For: RT #41461

11 years agoAdd two "ld" variables missing from configure.com.
Craig A. Berry [Sat, 10 Aug 2013 13:07:18 +0000 (08:07 -0500)]
Add two "ld" variables missing from configure.com.

This should close [perl #119197].

11 years agoFunction name typo in malloc.c
Sergey Alekseev [Fri, 9 Aug 2013 13:55:59 +0000 (19:55 +0600)]
Function name typo in malloc.c

Error was also spotted by mauke.

For: RT #119213

11 years agoMake constant folding use the right hints
Father Chrysostomos [Fri, 9 Aug 2013 21:24:23 +0000 (14:24 -0700)]
Make constant folding use the right hints

This was brought up in ticket #117855.

PL_compiling is a cop-sized static buffer (inside the interpreter
struct under threads) that stores information during compile time
(such as file name and line number) that gets copied to each cop (con-
trol op; aka state op or nextstate op) as it is created.

Some values are not actually stored in PL_compiling, such as the
current stash (PL_curstash is used instead) and the current hints
(PL_hints is used).

The ops in each statement are created before that statement’s cop
is created.

At run time, each cop is executed at the start of the statement and
sets PL_curcop to point to itself, so that operators within that
statement can get information from PL_curcop.

Constant folding was copying the contents of PL_compiling into a tem-
porary cop used to execute the ops being folded.  That constant fold-
ing happened of course before the cop was created for that statement.

Now it just happened that commit a0ed51b321 back in 1998 modified
newSTATEOP to copy hints to PL_compiling in addition to the new cop
being created.  Presumably that was to fix the type of bug that this
commit is addressing.  (Presumably this commit renders those changes
unnecessary.)  That meant that most of the time constant folding would
see the right hints.

That fails, though, when it comes to the first statement in a string
eval.  When you do eval("uc(ä)"), the constant folding happens when
PL_compiling.cop_hints still points to whatever value it had before
the eval was executed; i.e., an unpredictable value.  Slight changes
to unrelated scopes (and, apparently, using a different compiler*) can
cause the result of that string eval to change.

The solution is to set the hints from PL_hints explicitly when doing
constant folding.

* <https://rt.perl.org/rt3/Ticket/Display.html?id=117855#txn-1241613>ff.
  I never got to the bottom of why the compiler would make a diffe-
  rence here.  Finding out would involve setting a watchpoint on
  PL_compiling.cop_hints in a C debugger and then stepping through
  the thousands of times PL_compiling changes, which is too much
  work.  Nevertheless, I know this fix is correct, as it changes
  PL_compiling.cop_hints from having a non-deterministic value during
  constant folding to having a predictable one.

11 years agotoke.c:S_incline: avoid vivifying GV under threads
Father Chrysostomos [Sat, 10 Aug 2013 01:00:22 +0000 (18:00 -0700)]
toke.c:S_incline: avoid vivifying GV under threads

Since c82ecf346 has been reverted by the previous commit, under
threads we are back to storing the name of the current file in the
cop, rather than a pointer to the GV.  This means the GV may not even
have been created, so CopFILEGV will autovivify it.  We can avoid
autovivifying it in those cases where we are not going to be copying
the lines anyway, which S_incline only does for string eval (when it
sees a #line directive).  Even if the GV already exists, this makes
the check faster, as we no longer have to look it up by name when
parsing a file.

11 years agoRevert "[perl #117855] Store CopFILEGV in a pad under ithreads"
Father Chrysostomos [Sat, 6 Jul 2013 05:51:50 +0000 (22:51 -0700)]
Revert "[perl #117855] Store CopFILEGV in a pad under ithreads"

This reverts commit c82ecf346.

It turn out to be faulty, because a location shared betweens threads
(the cop) was holding a reference count on a pad entry in a particu-
lar thread.  So when you free the cop, how do you know where to do
SvREFCNT_dec?

In reverting c82ecf346, this commit still preserves the bug fix from
1311cfc0a7b, but shifts it around.

11 years agoRevert "toke.c:incline: Avoid duplicate symbol lookup"
Father Chrysostomos [Fri, 9 Aug 2013 21:44:35 +0000 (14:44 -0700)]
Revert "toke.c:incline: Avoid duplicate symbol lookup"

This reverts commit 05c9917c892c03577828027ff71c6282a2eabe29.

This is in preparation for reverting c82ecf346, which will remove the
CopFILEGV_set macro under threads.

11 years agodump.c: Dump contents of regexps’ mother_re field
Father Chrysostomos [Fri, 9 Aug 2013 19:56:03 +0000 (12:56 -0700)]
dump.c: Dump contents of regexps’ mother_re field

This can make debugging easier if one needs to see the reference count
of the parent regular expression.

11 years agoop.c:ck_eval: remove redundant null check
Father Chrysostomos [Thu, 8 Aug 2013 21:17:08 +0000 (14:17 -0700)]
op.c:ck_eval: remove redundant null check

op_first is never null when OPf_KIDS is set.

11 years agoAvoid assert fail with s// $target = \3 /e
Father Chrysostomos [Thu, 8 Aug 2013 01:21:00 +0000 (18:21 -0700)]
Avoid assert fail with s// $target = \3 /e

When the substitution target is assigned to in pp_substcont, it is
assumed that SvPV_free and SvPOK_only_UTF8 can be used on that target.
Only COW scalars are sent through sv_force_normal.

Changing the target in the replacement code can render those assump-
tions untrue:

$  ./perl -Ilib -e '$h = 3; $h =~ s/3/$h=\3;4/e'
Assertion failed: (!((targ)->sv_flags & 0x00000800) || !(*({ SV *const _svrv = ((SV *)({ void *_p = (targ); _p; })); (__builtin_expect(!(PL_valid_types_RV[((svtype)((_svrv)->sv_flags & 0xff)) & 0xf]), 0) ? __assert_rtn(__func__, "pp_ctl.c", 269, "PL_valid_types_RV[SvTYPE(_svrv) & SVt_MASK]") : (void)0); (__builtin_expect(!(!((((_svrv)->sv_flags & (0x00004000|0x00008000)) == 0x00008000) && (((svtype)((_svrv)->sv_flags & 0xff)) == SVt_PVGV || ((svtype)((_svrv)->sv_flags & 0xff)) == SVt_PVLV))), 0) ? __assert_rtn(__func__, "pp_ctl.c", 269, "!isGV_with_GP(_svrv)") : (void)0); (__builtin_expect(!(!(((svtype)((_svrv)->sv_flags & 0xff)) == SVt_PVIO && !(((XPVIO*) (_svrv)->sv_any)->xio_flags & 64))), 0) ? __assert_rtn(__func__, "pp_ctl.c", 269, "!(SvTYPE(_svrv) == SVt_PVIO && !(IoFLAGS(_svrv) & IOf_FAKE_DIRP))") : (void)0); &((_svrv)->sv_u.svu_rv); }))), function Perl_pp_substcont, file pp_ctl.c, line 269.
Abort trap: 6

Also, matching against a hash key and locking that key with Hash::Util
within the replacement code can cause the substitution to modify that
hash key without triggering ‘Modification of a read-only value’.  But
this only happens if it is not a copy-on-write scalar:

$ ./perl -Ilib -MHash::Util=lock_hash -le '$h{foo} = 3; $h{foo} =~ s/3/$h{foo} = 3; lock_hash %h; 4/e; print $h{foo}'
4

We need to do a regular SV_THINKFIRST_COW_DROP check here, just as we
do in sv_setsv with regular scalar assignment.

Also, we need to take into account real globs:

$ ./perl -Ilib -MHash::Util=lock_hash -le '$::{foo} =~ s//*{"foo"}; 4/e'
Assertion failed: (!isGV_with_GP(targ)), function Perl_pp_substcont, file pp_ctl.c, line 259.
Abort trap: 6

11 years agoRespect SvLEN==0 and SvOOK in sv.c:sv_sethek
Father Chrysostomos [Wed, 7 Aug 2013 16:04:20 +0000 (09:04 -0700)]
Respect SvLEN==0 and SvOOK in sv.c:sv_sethek

SvLEN==0 means this scalar does not own the buffer, so it should
not free it.

SvOOK means that SvPVX does not point to the start of the buffer
because we have cheated with s/...// or substr and not copied the
string back.

I don’t believe any such scalars currently make their way into
sv_sethek and get past the THINKFIRST check in that state, but we
should still play it safe.

SvPV_free handles both cases.

11 years agoDon’t stringify undef hash keys at compile time
Father Chrysostomos [Wed, 7 Aug 2013 15:46:52 +0000 (08:46 -0700)]
Don’t stringify undef hash keys at compile time

$ ./perl -wIlib -Mconstant' u=>undef' -e '()=$a{+u} if $a'
Use of uninitialized value at -e line 1.

Well, I didn’t even execute that hash lookup, so why is it warning me
about an uninitialized value?

This is a compile-time optimisation to turn hash keys into shared hash
key scalars (containing precomputed hashes) to speed up key lookup.
It stringifies the hash key at compile time as part of the process.

The value should not be stringified if that would cause observable
difference with tied hashes.  Commit 04698ff67 fixed this for refs,
globs and regexps, but missed undef scalars.

This could be considered part of bug #79178.

11 years agoExtUtils::ParseXS: Version consistency
Steffen Mueller [Fri, 9 Aug 2013 17:07:27 +0000 (19:07 +0200)]
ExtUtils::ParseXS: Version consistency

11 years agoUpdate versions and dates in release announcement template
Steve Hay [Fri, 9 Aug 2013 12:00:37 +0000 (13:00 +0100)]
Update versions and dates in release announcement template

11 years agoperldelta for b4bf645b3d
Tony Cook [Fri, 9 Aug 2013 06:46:00 +0000 (16:46 +1000)]
perldelta for b4bf645b3d

11 years agoCarp now handles objects with string overloads.
Darin McBride [Fri, 9 Aug 2013 06:17:08 +0000 (16:17 +1000)]
Carp now handles objects with string overloads.

It also allows objects to specify how they appear in the stack dump with
a CARP_TRACE method, and also allows the user to specify their own
formatter for objects without CARP_TRACE as well as other references.
[perl #92446]

Minor fix, commit message reformatting and manifest update by Tony Cook.

11 years agoperldelta for da1929e75
Tony Cook [Fri, 9 Aug 2013 02:10:06 +0000 (12:10 +1000)]
perldelta for da1929e75

11 years ago[perl #117793] remove dangerous functions and improve SvREFCNT()
Tony Cook [Fri, 9 Aug 2013 01:41:26 +0000 (11:41 +1000)]
[perl #117793] remove dangerous functions and improve SvREFCNT()

This allows Devel::Peek::SvREFCNT() to work on any variable, not just
scalars, but has a chance of breaking backward compatibility.

Also changes the type of SvREFCNT() to U32 to match the type returned by
the underlying macro

11 years agoUpgrade libnet from 1.22 to 1.22_02
Steve Hay [Thu, 8 Aug 2013 20:21:42 +0000 (21:21 +0100)]
Upgrade libnet from 1.22 to 1.22_02

This is the latest (development) release on CPAN. It will shortly be
superseded by 1.23.

Note that Makefile.PL is only customized -- not excluded as well! Two
customized test files (actually, one changed and one added) which blead
had (but were not noted in the Maintainers.pl file!) are incorporated in
this release.

Also, change the UPSTREAM status from undef to 'blead' to reflect the fact
that GBARR is no longer actively maintaining libnet and for the immediate
future new CPAN releases are only likely to be rolled to keep in sync with
changes in blead, plus occasional simple patches from the CPAN RT queue.

11 years agoDocument non-destructive substitution: the '/r' modifier.
James E Keenan [Tue, 6 Aug 2013 01:12:55 +0000 (21:12 -0400)]
Document non-destructive substitution: the '/r' modifier.

Per bug report filed by Jacinta Richardson++.

For: RT #119151

11 years agoAdd missing versioned Config to Module::CoreList
Chris 'BinGOs' Williams [Wed, 7 Aug 2013 22:48:21 +0000 (23:48 +0100)]
Add missing versioned Config to Module::CoreList

11 years agoConfig has a VERSION, corelist.pl should set it
Chris 'BinGOs' Williams [Wed, 7 Aug 2013 22:34:14 +0000 (23:34 +0100)]
Config has a VERSION, corelist.pl should set it

11 years agoUpdate the Porting/bisect.pl documentation.
Nicholas Clark [Wed, 7 Aug 2013 16:58:00 +0000 (18:58 +0200)]
Update the Porting/bisect.pl documentation.

As of commit c8fde7fafa0a9cec (merged to blead with commit 4724da031eae31b4)
bisect.pl can be run in-place if the checkout is clean.

The most recent stable release that it will try is now v5.18.0.

11 years agoReport the perl executable path in the error if Config.pm is out of sync.
Nicholas Clark [Wed, 7 Aug 2013 12:46:05 +0000 (14:46 +0200)]
Report the perl executable path in the error if Config.pm is out of sync.

If the version that Config.pm was built for differs from the version of the
perl executable running it, Config.pm aborts with an error message. The
error message was updated to include $0 (the script filename) in Aug 2010 by
commit b982c5de5a0d9f6f. Somewhat misleadingly the commit message says
"include the path of the perl executable in the error message." which $0 is
not.

This commit adds $^X to the error message - the path of the perl executable.
The error message also shows the script name, as this might also be useful
in diagnosing the cause of the problem.

11 years agoA comment in Storable.xs was words missing two words.
Nicholas Clark [Wed, 7 Aug 2013 12:29:50 +0000 (14:29 +0200)]
A comment in Storable.xs was words missing two words.

11 years agoUpgrade IPC::Cmd from 0.82 to 0.84
Steve Hay [Wed, 7 Aug 2013 11:39:59 +0000 (12:39 +0100)]
Upgrade IPC::Cmd from 0.82 to 0.84

11 years agoClarify documentation re switch expecting an argument but none is provided.
James E Keenan [Sun, 4 Aug 2013 02:30:42 +0000 (22:30 -0400)]
Clarify documentation re switch expecting an argument but none is provided.

When a switch is expecting an argument but fails to be provided with one, the
value of the corresponding element in the options hash is set to the undefined
value.  The documentation did not make this clear.

The documentation for getopts() and getopt() has been revised and additional
tests have been provided to demonstrate the point.  Tweaked in response to
feedback from Karl Williamson++.

Also, unit tests found in lib/Getopt/Std.t actually for Getopt::Long have been
removed.  A patch holding those tests has been submitted to Getopt-Long's bug
queue on rt.cpan.org.

For: RT #41359

11 years agoMerge the refactoring of B which silences Solaris compiler warnings.
Nicholas Clark [Wed, 7 Aug 2013 09:30:05 +0000 (11:30 +0200)]
Merge the refactoring of B which silences Solaris compiler warnings.

11 years agoIn B::OP::next, flag special cases with a type, instead of an offset of -1.
Nicholas Clark [Tue, 6 Aug 2013 12:07:42 +0000 (14:07 +0200)]
In B::OP::next, flag special cases with a type, instead of an offset of -1.

This permits the offset structure member to be unsigned instead of signed,
which feels more natural. The refactoring also reduces code size by about
100 bytes on x86_64.

11 years agoRe-indent a switch statement in B::OP::next
Nicholas Clark [Tue, 6 Aug 2013 11:55:27 +0000 (13:55 +0200)]
Re-indent a switch statement in B::OP::next

This is the whitespace-only part of the next commit separated out.

11 years agoChange all B's unsigned constants from IVs to UVs.
Nicholas Clark [Tue, 6 Aug 2013 11:15:13 +0000 (13:15 +0200)]
Change all B's unsigned constants from IVs to UVs.

Apart from HEf_SVKEY, all constants are actually unsigned, so this change
avoids 2 warnings "initializer does not fit or is out of range" from the
Solaris C compiler for the two constants with the value 0x80000000

11 years agoIn B.xs use I16 to avoid an "initializer will be sign-extended" warning.
Nicholas Clark [Tue, 6 Aug 2013 10:56:04 +0000 (12:56 +0200)]
In B.xs use I16 to avoid an "initializer will be sign-extended" warning.

The Solaris C compiler warns 30 times that -1 will be sign-extended, when
it is assigned to a struct member of type size_t. Instead, use I16 (No offset
will actually be larger than 1024), and reduce the size of the types used for
other structure members.

Change SVp (etc) to be constants in the range 0x0 to 0x7, instead of 0x00000
to 0x70000, now that most use cases no longer involve to or-ing with other
values. This makes two switch statements simpler.

As well as quietening warnings, the combined changes reduce the object size
by about 800 bytes on x86_64.

11 years agoTeach makedef.pl that Perl_allocfilegv does not exist without ithreads.
Nicholas Clark [Tue, 6 Aug 2013 16:22:42 +0000 (18:22 +0200)]
Teach makedef.pl that Perl_allocfilegv does not exist without ithreads.

This linker skip was missed by commit c82ecf346a8512f2, which did add the 3
PL_ variables it added for ithreads builds.

11 years agoDon't multiply define Perl__invlist_dump.
Craig A. Berry [Wed, 7 Aug 2013 02:09:40 +0000 (21:09 -0500)]
Don't multiply define Perl__invlist_dump.

It doesn't need to be in the extension if it's already in the core
top-level code.  Defining it more than once leads to linker errors
for linkers that care about such things, namely VMS.

Broken in ad3f05adb1975.

11 years agoFix t/porting/customized.t --regen not to add DOS EOLs on Windows
Steve Hay [Tue, 6 Aug 2013 21:47:50 +0000 (22:47 +0100)]
Fix t/porting/customized.t --regen not to add DOS EOLs on Windows

11 years agoreparse compile-time /(?{})/ in right scope
David Mitchell [Tue, 6 Aug 2013 15:34:50 +0000 (16:34 +0100)]
reparse compile-time /(?{})/ in right scope

When a compile-time regex like /...(?{ code-block }) .../
is compiled in the presence of constant and concat overloading,
this can cause (still at compile-time) for the pattern to be evaled and
re-compiled, in order to re-compile any code-blocks that got messed up
during the overloading and thus whose text no longer matches that which
the perl parser previously compiled.

When this happens, eval_sv() happens to be called when the perl parser is
still in compiling state; normally its called from running state.
This tickles an undiscovered bug in Perl_find_runcv_where(), which
finds the current cop sequence by looking at PL_curcop->cop_seq.
At compile time, we need to get it from PL_cop_seqmax instead.

11 years ago[perl #119169] index with __PACKAGE__ for 2nd argument
Father Chrysostomos [Tue, 6 Aug 2013 13:08:21 +0000 (06:08 -0700)]
[perl #119169] index with __PACKAGE__ for 2nd argument

The refactoring of fbm_compile in 66379c06cd to prepare for
c72a4eedff1 put in an SvIsCOW check before doing SvPV_force.  I sim-
ply changed the logic there so that SvPV_force would continue to have
its effect but without tripping up on read-only variables for which
SvPV_force would not need to make any changes anyway.

Now, if a COW scalar is read-only, we can’t call SvPV_force on it,
because it will die.

It turns out that we don’t actually need to call SvPV_force on COWs.
We can just go ahead and attach the BM magic and continue sharing
the buffer.

11 years agosv.h: Add comment about gv_check and SvIsCOW
Father Chrysostomos [Tue, 6 Aug 2013 12:57:26 +0000 (05:57 -0700)]
sv.h: Add comment about gv_check and SvIsCOW

So that future refactorings don’t make use of 0x00010000 on
hashes without modifying gv_check to account.

11 years ago[perl #2726] Prototype is not applied until BLOCK is defined
Peter Martini [Tue, 6 Aug 2013 07:16:35 +0000 (03:16 -0400)]
[perl #2726] Prototype is not applied until BLOCK is defined

In the case of a sub definition with a prototype, the prototype
is not attached to the sub until after the body is completely
defined.  This means that any sub which calls itself will
not honor its prototype unless the prototype was declared prior to
the sub's definition.  Whether or not this behavior is desirable is
debatable, but its far too late to do anything about it other than
document it and test to make sure it doesn't change.

11 years agoStop ‘used once’ warnings from crashing on circularities
Father Chrysostomos [Mon, 5 Aug 2013 16:17:32 +0000 (09:17 -0700)]
Stop ‘used once’ warnings from crashing on circularities

gv_check was only checking for stashes nested directly inside them-
selves (*foo:: = *foo::foo) and the main stash.

Other stash circularities would cause infinite recursion, blowing the
C stack and crashing.

11 years agoUpgrade Scalar-List-Utils from 1.29 to 1.30
Steve Hay [Mon, 5 Aug 2013 17:06:23 +0000 (18:06 +0100)]
Upgrade Scalar-List-Utils from 1.29 to 1.30

11 years agoStorable should not assume that sizeof(mg_len) is 4.
Nicholas Clark [Wed, 31 Jul 2013 10:43:51 +0000 (12:43 +0200)]
Storable should not assume that sizeof(mg_len) is 4.

Commit 6174b39a88cd4874 changed mg_len from I32 to SSize_t. sizeof(I32) is 4
everywhere (except certain Crays, for which Storable has work-around code).
In the version object serialisation code, Storable was passing mg->len
directly to the macro WLEN(), and and it turns out that some paths through
this macro is relying on the assumption that the value passed in is 32 bits.
This is now invalid on on 64 bit systems, but only triggered an error with
the existing tests on big endian systems.

The easiest fix is to assign the value to a temporary variable of the
correct size, and process that. However, a lot of the code makes a lot of
unwarranted assumptions about sizeof(int), and ideally should be audited and
rewritten to use more appropriate types.

11 years agoRestore Storable's DEBUGME build after commit 591596833b093b3c
Nicholas Clark [Wed, 31 Jul 2013 10:32:27 +0000 (12:32 +0200)]
Restore Storable's DEBUGME build after commit 591596833b093b3c

Storable.xs can conditionally compile debugging code if the C pre-processor
macro DEBUGME is defined. By default, it is not.

Commit 591596833b093b3c changed the name and purpose of the second argument
to the macro BLESS(), but missed updating the name in one location, within
code conditionally enabled by DEBUGME, hence breaking compilation with
DEBUGME.

Fix compilation by correcting that code to use the new macro parameter name.

11 years agoop.c:newCONSTSUB: Stop using CopFILESV for CvFILE
Father Chrysostomos [Mon, 5 Aug 2013 09:14:39 +0000 (02:14 -0700)]
op.c:newCONSTSUB: Stop using CopFILESV for CvFILE

CopFILESV points to *{"_<filename"}, which can be modified
from perl space.  CopFILE points to the third character of
*{"_<filename"}{NAME}.

Ithreads were already using CopFILE.  Make non-threaded builds do the
same.  This makes things a little more robust.

CvFILE is not actually used anywhere as far as I can tell, so I cannot
easily test this.

11 years agoDon’t use CopFILESV for ‘once’ warnings
Father Chrysostomos [Mon, 5 Aug 2013 08:55:31 +0000 (01:55 -0700)]
Don’t use CopFILESV for ‘once’ warnings

CopFILESV points to ${"_<filename"}, which can be modified by Perl
code.  Under non-threaded builds, newGP (which records the file name
used by ‘used once’ warnings) was using CopFILESV for the file name.
It is safer just to use the name of the GV itself.

11 years agoop.c:aassign_common_vars: merge duplicate code
Father Chrysostomos [Mon, 5 Aug 2013 08:35:36 +0000 (01:35 -0700)]
op.c:aassign_common_vars: merge duplicate code

We are just asking for bugs to creep in by repeating it like this.

11 years agoop.c: correct comment
Father Chrysostomos [Mon, 5 Aug 2013 08:32:33 +0000 (01:32 -0700)]
op.c: correct comment

11 years agoRemove SAVEt_STACK_CXPOS
Father Chrysostomos [Mon, 5 Aug 2013 08:22:46 +0000 (01:22 -0700)]
Remove SAVEt_STACK_CXPOS

81ed78b25c4b removed the only use of this.

11 years agoHandle SAVEt_READONLY_OFF in ss_dup
Father Chrysostomos [Mon, 5 Aug 2013 08:13:21 +0000 (01:13 -0700)]
Handle SAVEt_READONLY_OFF in ss_dup

20d5dc239d1 added SAVEt_READONLY_OFF without adding it to ss_dup.

11 years agoHandle SAVEt_ADELETE in ss_dup
Father Chrysostomos [Mon, 5 Aug 2013 08:10:21 +0000 (01:10 -0700)]
Handle SAVEt_ADELETE in ss_dup

c68ec7a9f95 added SAVEt_ADELETE without adding it to ss_dup.

11 years agoTest that ss_dup handles all savestack items
Father Chrysostomos [Mon, 5 Aug 2013 08:02:23 +0000 (01:02 -0700)]
Test that ss_dup handles all savestack items

It is far too easy to overlook it when adding new savestack types.

11 years agotoke.c: s/below/above/
Father Chrysostomos [Mon, 5 Aug 2013 07:39:32 +0000 (00:39 -0700)]
toke.c: s/below/above/

The condition this refers to was moved in commit 4efe39d21.

11 years agotoke.c:incline: Avoid duplicate symbol lookup
Father Chrysostomos [Mon, 5 Aug 2013 07:36:50 +0000 (00:36 -0700)]
toke.c:incline: Avoid duplicate symbol lookup

If we have already looked up the GV for *{"_<newfilename"}, we
can set CopFILEGV to that instead of having CopFILE_setn look it
up itself.

11 years agotoke.c:incline: Don’t stringify a GV to look it up
Father Chrysostomos [Mon, 5 Aug 2013 07:28:48 +0000 (00:28 -0700)]
toke.c:incline: Don’t stringify a GV to look it up

If we already have the GV, there is no need to stringify it and then
look it up again.

11 years agoMake eval "#line" account for ${"_<foo"} changes
Father Chrysostomos [Mon, 5 Aug 2013 07:13:40 +0000 (00:13 -0700)]
Make eval "#line" account for ${"_<foo"} changes

If a BEGIN block in the eval modifies the ${"_<foo"} scalar where
‘foo’ is the file name in the eval, then subsequent #line directives
that change the file name won’t cause the lines to be copied to
@{"_<newname"}.  (This copying usually happens under the debugger.)

Just use the name of the GV itself, rather than CopFILESV, since the
GV name cannot be changed from Perl space.

11 years agotoke.c:incline: Move code into the block that uses it
Father Chrysostomos [Mon, 5 Aug 2013 06:54:59 +0000 (23:54 -0700)]
toke.c:incline: Move code into the block that uses it

Setting up the values of these variables is pointless if we are not
going to be using them.  They are only used inside the ‘if’ block that
this patch moves them into.

11 years agoPrevent __FILE__ corruption when ${"_<..."} is modified
Father Chrysostomos [Mon, 5 Aug 2013 06:52:20 +0000 (23:52 -0700)]
Prevent __FILE__ corruption when ${"_<..."} is modified

This fixes a longstanding bug under non-threaded builds that was
extended to threaded builds by the previous commit.

Modifying the SV slot of the file gv can cause CopFILE to violate
memory discipline, giving random strings.

Since the GV is named after the file, too, and since its name can-
not be changed from Perl space, use that for CopFILE instead.

11 years ago[perl #117855] Store CopFILEGV in a pad under ithreads
Father Chrysostomos [Sat, 6 Jul 2013 05:51:50 +0000 (22:51 -0700)]
[perl #117855] Store CopFILEGV in a pad under ithreads

This saves having to allocate a separate string buffer for every cop
(control op; every statement has one).

Under non-threaded builds, every cop has a pointer to the GV for that
source file, namely *{"_<filename"}.

Under threaded builds, the name of the GV used to be stored instead.

Now we store an offset into the per-interpreter PL_filegvpad, which
points to the GV.

This makes no significant speed difference, but it reduces mem-
ory usage.

11 years agoDon’t let list const modification affect future retvals
Father Chrysostomos [Sun, 4 Aug 2013 18:22:03 +0000 (11:22 -0700)]
Don’t let list const modification affect future retvals

In commit f99a5f08f203, I inadvertently made modifications to val-
ues return by list ‘constants’ affect what values are returned sub-
sequently.

It’s for this type of situation that PADTMP exists (values are never
referenced, but copied).  So use it.

This is similar to 5608dcc62, which fixed #3105.

11 years ago[perl #119043] Allow utf8 up/downgrade on ro COWs
Father Chrysostomos [Sun, 4 Aug 2013 06:58:56 +0000 (23:58 -0700)]
[perl #119043] Allow utf8 up/downgrade on ro COWs

Commit 1913067 allowed COW constants to be read-only.  This broke
Glib, so I reverted it with ba36554e02.  That caused this bug to reë-
merge (I hadn’t realised that I had fixed it in 1913067):

perl -e 'for(1..10){for(__PACKAGE__){warn $_; $_++}}'
main at -e line 1.
maio at -e line 1.
maip at -e line 1.
maiq at -e line 1.
mair at -e line 1.

so I reverted the revert two commits ago.

Glib was triggering a read-only error because it called
sv_utf8_upgrade on a read-only COW scalar, and sv_utf8_upgrade does
sv_force_normal on COWs to de-COW them.  sv_force_normal croaks on
read-only scalars.

The real problem here is that sv_force_normal means ‘I am going to
modify this scalar’, yet sv_utf8_upgrade conceptually does not modify
the scalar, but only changes the internal representation.

Having to call sv_force_normal to get the *side effect* of de-COWing
without triggering the various other things it does is no good.

What we need is a separate sv_uncow function that sv_force_normal
uses.  This commit introduces such a function.

11 years agoTest that __PACKAGE__ is read-only
Father Chrysostomos [Sun, 4 Aug 2013 06:08:42 +0000 (23:08 -0700)]
Test that __PACKAGE__ is read-only

I.e., test that this bug is fixed:

$ perl -e 'for(1..10){for(__PACKAGE__){warn $_; $_++}}'
main at -e line 1.
maio at -e line 1.
maip at -e line 1.
maiq at -e line 1.
mair at -e line 1.
mais at -e line 1.
mait at -e line 1.
maiu at -e line 1.
maiv at -e line 1.
maiw at -e line 1.

for my$p(__PACKAGE__){$p++for+1..55664
,;!print"Just another \u$p hacker,\n"}

11 years agoRevert "[perl #119043] Exempt shared hash key consts from ro"
Father Chrysostomos [Sun, 4 Aug 2013 06:08:08 +0000 (23:08 -0700)]
Revert "[perl #119043] Exempt shared hash key consts from ro"

This reverts commit ba36554e02872e48d146177a57a9cfb154727fae.

It turns out it reinstates bugs like this:

$ perl -e 'for(1..10){for(__PACKAGE__){warn $_; $_++}}'
main at -e line 1.
maio at -e line 1.
maip at -e line 1.
maiq at -e line 1.
mair at -e line 1.
mais at -e line 1.
mait at -e line 1.
maiu at -e line 1.
maiv at -e line 1.
maiw at -e line 1.

11 years ago_perl_abs_path() symlink tests fail on QNX Neutrino
Chris 'BinGOs' Williams [Fri, 2 Aug 2013 22:53:15 +0000 (23:53 +0100)]
_perl_abs_path() symlink tests fail on QNX Neutrino

11 years agoResolve File::Spec test failures on QNX Neutrino
Chris 'BinGOs' Williams [Fri, 2 Aug 2013 21:47:56 +0000 (22:47 +0100)]
Resolve File::Spec test failures on QNX Neutrino

11 years agoAdd note about regenerating META files when updating CPAN-Meta
Chris 'BinGOs' Williams [Fri, 2 Aug 2013 16:39:57 +0000 (17:39 +0100)]
Add note about regenerating META files when updating CPAN-Meta

11 years agoUpdate CPAN-Meta to CPAN version 2.132140
Chris 'BinGOs' Williams [Fri, 2 Aug 2013 16:34:19 +0000 (17:34 +0100)]
Update CPAN-Meta to CPAN version 2.132140

  [DELTA]

2.132140  2013-08-02 11:54:17 America/New_York

  [DOCUMENTATION]

  - Fixed some typos in CPAN::Meta::Spec

  [OTHER]

  - migrated repository to Perl-Toolchain-Gang organization on Github and
    updated metadata accordingly

11 years agoRegression tests for 4 cases reported by Philip Hazel++.
James E Keenan [Tue, 30 Jul 2013 01:31:28 +0000 (21:31 -0400)]
Regression tests for 4 cases reported by Philip Hazel++.

With revisions per suggestion by demerphq++.
For: RT #119069, 119071, 119073, 119075

11 years agoprevent a precedence warning on clang
Tony Cook [Fri, 2 Aug 2013 01:27:10 +0000 (11:27 +1000)]
prevent a precedence warning on clang

Dumper.xs:245:29: warning: '&&' within '||' [-Wlogical-op-parentheses]
                   ((k >= 7 && k <= 10 || k == 12 || k == 13 || k == 27)
                     ~~~~~~~^~~~~~~~~~ ~~
Dumper.xs:245:29: note: place parentheses around the '&&' expression to silence
      this warning
                   ((k >= 7 && k <= 10 || k == 12 || k == 13 || k == 27)

11 years agoregcomp.c: Silence clang compiler warning
Karl Williamson [Thu, 1 Aug 2013 20:19:34 +0000 (14:19 -0600)]
regcomp.c: Silence clang compiler warning

There is no pre-canned format for printing STRLEN variables.  This
commit casts to UV and uses %"UVuf".

11 years agoUpdate Scalar-List-Utils to CPAN version 1.29
Chris 'BinGOs' Williams [Thu, 1 Aug 2013 20:07:00 +0000 (21:07 +0100)]
Update Scalar-List-Utils to CPAN version 1.29

  [DELTA]

1.29 -- Thu Aug 01 13:40 UTC 2013

  * Bugfix to pairmap/pairgrep when stack moves beneath them during operation

1.28 -- Thu Aug 01 12:19 UTC 2013
  -- BROKEN; do not use. See 1.29

  * Added pairgrep, pairmap, pairs (inspired by List::Pairwise)
  * Added pairkeys and pairvalues

11 years agodump.c: White-space only
Karl Williamson [Thu, 1 Aug 2013 19:05:36 +0000 (13:05 -0600)]
dump.c: White-space only

Indent and wrap lines to correspond with newly formed block

11 years agoExtend sv_dump() to dump SVt_INVLIST
Karl Williamson [Tue, 23 Jul 2013 16:48:20 +0000 (10:48 -0600)]
Extend sv_dump() to dump SVt_INVLIST

This changes the previously unused _invlist_dump() function to be called
from sv_dump() to dump inversion list scalars.  The format for regular
SVt_PVs doesn't give human-friendly output for these.

Since these lists are currently not visible outside the Perl core, the
format is documented only in comments in the function itself.

11 years agoversion's test files are not excluded from blead
Steve Hay [Thu, 1 Aug 2013 12:43:21 +0000 (13:43 +0100)]
version's test files are not excluded from blead

They were added long ago by 543eec9e19.

11 years agoSet a large thread stack when running the regex tests in a thread.
Nicholas Clark [Tue, 30 Jul 2013 17:59:48 +0000 (19:59 +0200)]
Set a large thread stack when running the regex tests in a thread.

For testing ithreads cloning, all the regex tests are run twice. Once
"normally", and once in a child ithread, to verify that all regex
constructions can be cloned.

The recently added tests for backreferences starting with 8 or 9 causes a
lot of C recursion in the child thread, enough to bust the default thread
stack size on (at least) HP-UX. So set a large explicit thread stack size.
It doesn't matter that it's large, as we are only running one child thread.

11 years agoUse undef rather than 'undef' for Devel::PPPort's UPSTREAM status
Steve Hay [Thu, 1 Aug 2013 08:10:46 +0000 (09:10 +0100)]
Use undef rather than 'undef' for Devel::PPPort's UPSTREAM status

All other undefined UPSTREAM statuses are undef rather than 'undef'
already, which causes core-cpan-diff to emit 'upstream is: UNKNOWN!'
rather than 'upstream is: undef', which is probably the intended effect
since it indicates the status is not known rather than specifically
undefined.

11 years agoNote that three more test files are excluded from XSLoader
Steve Hay [Thu, 1 Aug 2013 07:58:30 +0000 (08:58 +0100)]
Note that three more test files are excluded from XSLoader

11 years agoPATCH: [perl #119101] Extraneous warnings in Parse::ErrorString::Perl
Karl Williamson [Wed, 31 Jul 2013 21:05:43 +0000 (15:05 -0600)]
PATCH: [perl #119101] Extraneous warnings in Parse::ErrorString::Perl

(Since 5.18.0)

This is from https://rt.cpan.org/Ticket/Display.html?id=87458.

Working on this ticket caused me to be more certain of the advisability
of the deprecation message that was added in v5.18.0, and which was
inappropriately being raised in the test suite for this module.

The message notes that escaping the metacharacter '{', '[', or '(')
doesn't actually do anything in a pattern whose delimiters are {} [] or
() respectively.

The code in question looked something like

    my $pat = "m{\Q$foo}";
    ...
    eval "$bar =~ $pat";

where $foo comes from somewhere else and contained something like
\x{61}.  The message should not be raised because the \Q changes that to
\\x\{61\}, and so the \x loses its special meaning as well, and the left
brace is not a metacharacter in this context.  The solution is to look
at all the backslashes before the 'x' and only raise the message if
there are an odd number of them.

But, if $foo had been something like "bar{3}", the \Q would have
transformed that into "bar\{3\}.  In the code above, this matches
"b" followed by "a" followed by 3 "r"s.

Similarly for [] and ().

    my $foo = "(abc)";
    my $pat = "m(\Q$foo)";
    ...
    eval "$bar =~ $pat";

will not match the parens in $foo literally, but treat them as marking a
group.

The bottom line is that currently you cannot rely on \Q to properly
quote in a regex pattern in which the delimiters are mirrored
metacharacters.  The only current safe mirrored delimiters are <>, which
are not metacharacters.  Starting in 5.18.0, there is a default-on
message that catches this.  Starting with this commit, certain false
positives have been removed, and I know of none other.

11 years agoHandle /[#]/ and /[(?#]/ with code blocks
David Mitchell [Wed, 31 Jul 2013 21:41:17 +0000 (22:41 +0100)]
Handle /[#]/ and /[(?#]/ with code blocks

This is a regression in 5.18.0.

In something like /[#](?{})/x, the perl toker incorrectly sees the '#' as a
comment and skips the code block without parsing it.

11 years agopp_match(): remove some superfluous braces
David Mitchell [Wed, 31 Jul 2013 09:29:49 +0000 (10:29 +0100)]
pp_match(): remove some superfluous braces

11 years agopp_match(): only look up pos() magic once
David Mitchell [Wed, 31 Jul 2013 09:13:31 +0000 (10:13 +0100)]
pp_match(): only look up pos() magic once

Currently before matching, we see whether the SV has any pos() magic
attached; then after the match we look it up again to update pos().
Instead just remember the previous value of mg and reuse it where
possible.

11 years agopp_match(): remove redundant condition
David Mitchell [Wed, 31 Jul 2013 09:08:18 +0000 (10:08 +0100)]
pp_match(): remove redundant condition

a successful match always sets $-[0] now, so there's no need to check
whether its set

11 years agoFix ordering of modules and pragmata in perldelta.pod
Steve Hay [Wed, 31 Jul 2013 07:52:51 +0000 (08:52 +0100)]
Fix ordering of modules and pragmata in perldelta.pod

11 years agoUpgrade parent from 0.225 to 0.226
Steve Hay [Wed, 31 Jul 2013 07:51:36 +0000 (08:51 +0100)]
Upgrade parent from 0.225 to 0.226

11 years agoperlsub: constant -> inlinable
Father Chrysostomos [Wed, 31 Jul 2013 03:09:36 +0000 (20:09 -0700)]
perlsub: constant -> inlinable

This was brought up in ticket #109744.  I cannot change the header of
the section, as it will break links.  But at least we can avoid
stressing the constancy as much.

11 years agoRemove semicolon from inline TYPEMAP in perlxstut example.
Nathan Trapuzzano [Tue, 30 Jul 2013 23:10:20 +0000 (19:10 -0400)]
Remove semicolon from inline TYPEMAP in perlxstut example.

11 years agoregcomp.c: Fix yet another C89 problem
Karl Williamson [Wed, 31 Jul 2013 00:29:37 +0000 (18:29 -0600)]
regcomp.c: Fix yet another C89 problem

In my haste to get a42823ac3c233f0a9b8aefaac74a3b1e1600e6f6 out, I
neglected to see this second instance of a improperly placed
declaration.

11 years agoregcomp.c: Properly declare variable with C89
Karl Williamson [Tue, 30 Jul 2013 23:00:27 +0000 (17:00 -0600)]
regcomp.c: Properly declare variable with C89

Commit 89d3fa0ee43d5c7489581a62b3d662c316bfcb43 introduced a syntax
error under C89 compilers, as it removed braces so a declaration wasn't
the first thing in a block.  This adds a declaration in the proper
place.

11 years agoRT #118213: handle $r=qr/.../; /$r/p properly
David Mitchell [Tue, 30 Jul 2013 15:16:35 +0000 (16:16 +0100)]
RT #118213: handle $r=qr/.../; /$r/p properly

In the case where a qr// regex is directly used by PMOP (rather than being
interpolated with some other stuff and a new regex created, such as
/a$r/p), then the PMf_KEEPCOPY flag will be set on the PMOP, but the
corresponding RXf_PMf_KEEPCOPY flag *won't* be set on the regex.

Since most of the regex handling for copying the string and extracting out
${^PREMATCH} etc is done based on the RXf_PMf_KEEPCOPY flag in the regex,
this is a bit of a problem.

Prior to 5.18.0 this wasn't so noticeable, since various other bugs around
//p handling meant that ${$PREMATCH} etc often accidentally got set
anyway. 5.18.0 fixed these bugs, and so as a side-effect, exposed the
PMOP verses regex flag issue. In particular, this stopped working in
5.18.0:

    my $pat = qr/a/;
    'aaaa' =~ /$pat/gp or die;
    print "MATCH=[${^MATCH}]\n";

(prints 'a' in 5.16.0, undef in 5.18.0).
The presence /g caused the engine to copy the string anyway by luck.

We can't just set the RXf_PMf_KEEPCOPY flag on the regex if we see the
PMf_KEEPCOPY flag on the PMOP, otherwise stuff like this will be wrong:

    $r = qr/..../;
    /$r/p;  # set RXf_PMf_KEEPCOPY on $r
    /$r/; # does a /p match by mistake

Since for 5.19.x onwards COW is enabled by default (and cheap copies are
always made regardless of /p), then this fix is mainly for PERL_NO_COW
builds and for backporting to 5.18.x. (Although it still applies to
strings that can't be COWed for whatever reason).

Since we can't set a flag in the rx, we fix this by:

1) when calling the regex engine (which may attempt to copy part or all of
the capture string), make sure we pass REXEC_COPY_STR, but neither of
REXEC_COPY_SKIP_PRE, REXEC_COPY_SKIP_POST when we call regexec() from
pp_match or pp_subst when the corresponding PMOP has PMf_KEEPCOPY set.

2) in Perl_reg_numbered_buff_fetch() etc, check for PMf_KEEPCOPY in
PL_curpm as well as for RXf_PMf_KEEPCOPY in the current rx before deciding
whether to process ${^PREMATCH} etc.

As well as adding new tests to t/re/reg_pmod.t, I also changed the
string to be matched against from being '12...' to '012...', to ensure that
the lengths of ${^PREMATCH}, ${^MATCH}, ${^POSTMATCH} would all be
different.

11 years agoregcomp.c: Remove extraneous debug info
Karl Williamson [Tue, 30 Jul 2013 17:27:20 +0000 (11:27 -0600)]
regcomp.c: Remove extraneous debug info

Prior to this commit the prhase {unicode} was emitted to mark what a
bracketed character class matched that wasn't in that classes bitmap.
This was oftern accompanied by another phrase that gave further
details.  Since everything is {unicode}, the first phrase isn't very
helpful.  Now it is changed to {utf8} for those things that won't match
unless the target string is in utf8 (this includes some upper latin1
code points under /d matches), or {outside bitmap} for where utf8 isn't
necessasily required (this happens for user-defined Unicode properties
that aren't known at compile time).

11 years agoregcomp.c: White-space only
Karl Williamson [Tue, 30 Jul 2013 17:21:11 +0000 (11:21 -0600)]
regcomp.c: White-space only

Outdent code which the previous commit removed from a block.

11 years agoregcomp.c: Remove redundant code
Karl Williamson [Tue, 30 Jul 2013 17:16:56 +0000 (11:16 -0600)]
regcomp.c: Remove redundant code

This code is redundant, attempting to output what isn't returned in 'lv'
by reglcass_swash(), but that function makes sure that 'lv' contains
everything it should, so we ended up processing (and outputting) the
same data twice.

11 years agoregexec.c: Add, clarify comments
Karl Williamson [Tue, 30 Jul 2013 16:51:35 +0000 (10:51 -0600)]
regexec.c: Add, clarify comments

11 years agoregcomp.c: Change Debug output of char classes
Karl Williamson [Sun, 28 Jul 2013 01:10:27 +0000 (19:10 -0600)]
regcomp.c: Change Debug output of char classes

This commit causes the debug output that was formerly "\x4ff", for
example to be \x{4f}f.  It always puts braces around the hex to separate
it from other characters.

11 years agoregcomp.c: Debug output clearer ranges
Karl Williamson [Sun, 28 Jul 2013 00:45:18 +0000 (18:45 -0600)]
regcomp.c: Debug output clearer ranges

It's not immediately obvious what the character class [!-~] matches.
Better is its equivalent: [\x21-\x7e].  This commit changes the debug
output to be the latter for character class matches, while retaining the
current behavior where it is clear what the range matches, in, e.g.,
[J-R].  Ranges like [A-z] include more than just alphabetics, so they
are now output as [\x41-\x7a].  (Debug output is done, for example, when
the command line option -Dr is specified.)

11 years agoregcomp.c: White-space only
Karl Williamson [Sun, 28 Jul 2013 00:21:40 +0000 (18:21 -0600)]
regcomp.c: White-space only

This indents properly to correspond to a newly formed block

11 years agoregcomp.c: Change debug output to use \t, etc instead of hex
Karl Williamson [Sun, 28 Jul 2013 00:19:29 +0000 (18:19 -0600)]
regcomp.c: Change debug output to use \t, etc instead of hex

It is easier to read the standard abbreviations \t, \n, etc than the hex
equivalents, \x09, ...

11 years agoregcomp.c: Extract duplicated code into single fcn
Karl Williamson [Sun, 28 Jul 2013 00:14:12 +0000 (18:14 -0600)]
regcomp.c: Extract duplicated code into single fcn

This code that appears twice is nearly duplicate.