platform/upstream/perl.git
12 years agoRemove some set but unused variables
Florian Ragwitz [Mon, 10 Sep 2012 21:14:59 +0000 (17:14 -0400)]
Remove some set but unused variables

Thanks, gcc, for letting me know.

12 years agoPerldelta up to 9e533305
Florian Ragwitz [Mon, 10 Sep 2012 17:22:10 +0000 (13:22 -0400)]
Perldelta up to 9e533305

12 years agoStop CPAN from indexing mad/
Florian Ragwitz [Sat, 26 May 2012 21:15:43 +0000 (23:15 +0200)]
Stop CPAN from indexing mad/

12 years agoCorrect obvious typos in acknowledgements list
Dominic Hargreaves [Mon, 10 Sep 2012 18:33:00 +0000 (19:33 +0100)]
Correct obvious typos in acknowledgements list

12 years agoFix [perl #114812] Configure not finding isblank().
Andy Dougherty [Mon, 10 Sep 2012 12:35:16 +0000 (08:35 -0400)]
Fix [perl #114812] Configure not finding isblank().

Configure would not find isblank() when run with g++ because
the probe used exit() without including <stdlib.h>.  The simplest fix
is to have the probe use return instead.

12 years agoRefactor t/op/my.t to use test.pl instead of making TAP by hand
Colin Kuskie [Sun, 9 Sep 2012 20:33:05 +0000 (13:33 -0700)]
Refactor t/op/my.t to use test.pl instead of making TAP by hand

12 years agoRefactor t/op/cond.t to use test.pl instead of making TAP by hand
Colin Kuskie (via RT) [Sat, 8 Sep 2012 22:31:53 +0000 (15:31 -0700)]
Refactor t/op/cond.t to use test.pl instead of making TAP by hand

12 years agoRefactor t/porting/customized to use test.pl instead of making TAP by hand
Colin Kuskie (via RT) [Mon, 10 Sep 2012 00:32:53 +0000 (17:32 -0700)]
Refactor t/porting/customized to use test.pl instead of making TAP by hand

12 years agoFix C++, MYMALLOC, sdbm combination.
Craig A. Berry [Mon, 10 Sep 2012 02:27:44 +0000 (21:27 -0500)]
Fix C++, MYMALLOC, sdbm combination.

The prototypes for the home-grown malloc replacements were not
protected with extern "C" declarations, so linking the SDBM_File
extension failed when configuring with -Dusemymalloc=y and building
with C++.

12 years agoOut of memory message should not allocate memory.
Craig A. Berry [Mon, 3 Sep 2012 02:30:55 +0000 (21:30 -0500)]
Out of memory message should not allocate memory.

This fixes [perl #40595].  When Perl_malloc reports an out of
memory error, it should not make calls to PerlIO functions that
may turn around and allocate memory using Perl_malloc.  A simple
write() should be ok, though.  Inspired by S_write_no_mem() from
util.c.  Also replaces the local write2 function, which did the
same thing slightly differently.

Under -DDEBUGGING, there are other calls to PerlIO_printf that are
also likely unsafe, but that problem is not addressed here.

12 years agofix s/(.)/die/e
David Mitchell [Sat, 8 Sep 2012 19:17:42 +0000 (20:17 +0100)]
fix s/(.)/die/e

Commit 6502e08109cd003b2cdf39bc94ef35e52203240b introduced copying just
the part of the regex string that were needed; but piggy-backing on that
commit was a temporary change I made that I forgot to undo, which - it
turns out - causes SEGVs and similar when the replacement part of a
substitution dies.

This commits reverts that change.

Spotted as
    Bleadperl v5.17.3-255-g6502e08 breaks GAAS/URI-1.60.tar.gz
(not assigned an RT ticket number yet)

12 years ago[MERGE] only copy bits of regex match string
David Mitchell [Sat, 8 Sep 2012 14:42:56 +0000 (15:42 +0100)]
[MERGE] only copy bits of regex match string

When making a copy of the string being matched against (so that $1, $&
et al continue to show the correct value even if the original string is
subsequently modified), only copy that substring of the original string
needed for the capture variables, rather than copying the whole string.

This is a big win for code like

    $&;
    $_ = 'x' x 1_000_000;
    1 while /(.)/;

Also, when pessimizing if the code contains $`, $& or $', record
the presence of each variable separately, so that the determination of the
substring range is based on each variable separately. So performance-wise,

   $&; /x/

is now roughly equivalent to

   /(x)/

whereas previously it was like

   /^(.*)(x)(.*)$/

and

   $&; $'; /x/

is now roughly equivalent to

   /(x)(.*)$/

etc.

Finally, this code (when not in the presence of $& etc)

    $_ = 'x' x 1_000_000;
    1 while /(.)/;

used to skip the buffer copy for performance reasons, but suffered from $1
etc changing if the original string changed. That's now been fixed too.

12 years agofix a bug in handling $+[0] and unicode
David Mitchell [Fri, 7 Sep 2012 12:32:11 +0000 (13:32 +0100)]
fix a bug in handling $+[0] and unicode

The code to decide what substring of a pattern target to copy for the
sake of $1, $& etc, would, in the absence of $&, only copy the minimum
range needed to cover $1,$2,...., which might be a shorter range than
what $& covers. This is fine most of the time, but, when calculating
$+[0] on a unicode string, it needs a copy of the whole part of the string
covered by $&, since it needs to convert the byte offest into a char
offset.
So to fix this, always copy as a minimum, the $& range.
I suppose we could be more clever about this: detect the presence
of @+ in the code, only do it for UTF8 etc; but this is simple
and non-fragile.

12 years agom// and s///; don't copy TEMP/AMAGIC strings
David Mitchell [Sat, 1 Sep 2012 10:43:53 +0000 (11:43 +0100)]
m// and s///; don't copy TEMP/AMAGIC strings

Currently pp_match and pp_subst make a copy of the match string if it's
SvTEMP(), and in the case of pp_match, also if it's SvAMAGIC().

This is no longer necessary, as the code will always copy the string
anyway if its actually needed after the match, i.e. if it detects the
presence of $1, $& or //p etc. Until a few commits ago, this wasn't the
case for pp_match: it would sometimes skip copying even in the presence of
$1 et al for efficiency reasons. Now that that's fixed, we can remove the
SvTEMP() and SvAMAGIC() tests.

As to why pp_subst did the SvTEMP test, I don't know: but removing it
didn't make any tests fail!

12 years agotidy up patten match copying code
David Mitchell [Sat, 1 Sep 2012 10:23:58 +0000 (11:23 +0100)]
tidy up patten match copying code

(no functional changes).

1. Remove some dead code from pp_split; it's protected by an assert
that it could never be called.

2. Simplify the flags settings for the call to CALLREGEXEC() in
pp_substcont: on subsequent matches we always set REXEC_NOT_FIRST,
which forces the regex engine not to copy anyway, so passing the
REXEC_COPY_STR is pointless, as is the conditional code to set it.

3. (whitespace change): split a conditional expression over 2 lines
for easier reading.

12 years agostop $foo =~ /(bar)/g skipping copy
David Mitchell [Fri, 24 Aug 2012 15:17:47 +0000 (16:17 +0100)]
stop $foo =~ /(bar)/g skipping copy

Normally in the presence of captures, a successful regex execution
makes a copy of the matched string, so that $1 et al give the right
value even if the original string is changed; i.e.

    $foo =~ /(123)/g;
    $foo = "bar";
    is("$1", "123");

Until now that test would fail, because perl used to skip the copy for
the scalar /(...)/g case (but not the C<$&; //g> case). This was to
avoid a huge slowdown in code like the following:

    $x = 'x' x 1_000_000;
    1 while $x =~ /(.)/g;

which would otherwise end up copying a 1Mb string a million times.

Now that (with the last commit but one) we copy only the required
substring of the original string (a 1-byte substring in the above
example), we can remove this fast-but-incorrect hack.

12 years agorationalise t/re/pat_psycho.t
David Mitchell [Fri, 24 Aug 2012 14:49:21 +0000 (15:49 +0100)]
rationalise t/re/pat_psycho.t

Do some cleanup of this file, without changing its functionality.

Once upon a time, the psycho tests were scattered throughout a single
pat.t file, before being moved into their own file. Now that they're all
in a single file, make the $PERL_SKIP_PSYCHO_TEST test a single "skip_all"
test at the beginning of the file, rather than testing it separately in
each code block.

Also, make some of the test descriptions more useful, and add a bit of
debugging output.

12 years agoDon't copy all of the match string buffer
David Mitchell [Thu, 26 Jul 2012 15:04:09 +0000 (16:04 +0100)]
Don't copy all of the match string buffer

When a pattern matches, and that pattern contains captures (or $`, $&, $'
or /p are present), a copy is made of the whole original string, so
that $1 et al continue to hold the correct value even if the original
string is subsequently modified. This can have severe performance
penalties; for example, this code causes a 1Mb buffer to be allocated,
copied and freed a million times:

    $&;
    $x = 'x' x 1_000_000;
    1 while $x =~ /(.)/g;

This commit changes this so that, where possible, only the needed
substring of the original string is copied: in the above case, only a
1-byte buffer is copied each time. Also, it now reuses or reallocs the
buffer, rather than freeing and mallocing each time.

Now that PL_sawampersand is a 3-bit flag indicating separately whether
$`, $& and $' have been seen, they each contribute only their own
individual penalty; which ones have been seen will limit the extent to
which we can avoid copying the whole buffer.

Note that the above code *without* the $& is not currently slow, but only
because the copying is artificially disabled to avoid the performance hit.
The next but one commit will remove that hack, meaning that it will still
be fast, but will now be correct in the presence of a modified original
string.

We achieve this by by adding suboffset and subcoffset fields to the
existing subbeg and sublen fields of a regex, to indicate how many bytes
and characters have been skipped from the logical start of the string till
the physical start of the buffer. To avoid copying stuff at the end, we
just reduce sublen. For example, in this:

    "abcdefgh" =~ /(c)d/

subbeg points to a malloced buffer containing "c\0"; sublen == 1,
and suboffset == 2 (as does subcoffset).

while if $& has been seen,

subbeg points to a malloced buffer containing "cd\0"; sublen == 2,
and suboffset == 2.

If in addition $' has been seen, then

subbeg points to a malloced buffer containing "cdefgh\0"; sublen == 6,
and suboffset == 2.

The regex engine won't do this by default; there are two new flag bits,
REXEC_COPY_SKIP_PRE and REXEC_COPY_SKIP_POST, which in conjunction with
REXEC_COPY_STR, request that the engine skip the start or end of the
buffer (it will still copy in the presence of the relevant $`, $&, $',
/p).

Only pp_match has been enhanced to use these extra flags; substitution
can't easily benefit, since the usual action of s///g is to copy the
whole string first time round, then perform subsequent matching iterations
against the copy, without further copying. So you still need to copy most
of the buffer.

12 years agoSeparate handling of ${^PREMATCH} from $` etc
David Mitchell [Thu, 26 Jul 2012 14:35:39 +0000 (15:35 +0100)]
Separate handling of ${^PREMATCH} from $` etc

Currently the handling of getting the value, length etc of ${^PREMATCH}
etc is identical to that of $` etc.

Handle them separately, by adding RX_BUFF_IDX_CARET_PREMATCH etc
constants to the existing RX_BUFF_IDX_PREMATCH set.

This allows, when retrieving them, to always return undef if the current
match didn't use //p. Previously the result depended on stuff such
as whether the (non-//p) pattern included captures or not.

The documentation for ${^PREMATCH} etc states that it's only guaranteed to
return a defined value when the last pattern was //p.

As well as making things more consistent, this is a necessary
prerequisite for the following commit, which may not always copy the
whole string during a non-//p match.

12 years agoregexec_flags(): simplify length calculation
David Mitchell [Fri, 22 Jun 2012 15:26:08 +0000 (16:26 +0100)]
regexec_flags(): simplify length calculation

The code to calculate the length of the string to copy was

    PL_regeol - startpos + (stringarg - strbeg);

This is a hangover from the original (perl 3) regexp implementation
that under //i, copied and folded the original buffer: so startpos might
not equal stringarg. These days it always is (except under a match failure
with (*COMMIT), and the code we're interested is only executed on success).

So simplify to just PL_regeol - strbeg.

12 years agoPL_sawampersand: use 3 bit flags rather than bool
David Mitchell [Fri, 22 Jun 2012 11:36:03 +0000 (12:36 +0100)]
PL_sawampersand: use 3 bit flags rather than bool

Set a separate flag for each of $`, $& and $'.
It still works fine in boolean context.

This will allow us to have more refined control over what parts
of a match string to copy (we currently copy the whole string).

12 years agodocument args to regexec_flags and API
David Mitchell [Wed, 20 Jun 2012 13:17:05 +0000 (14:17 +0100)]
document args to regexec_flags and API

Document in the API, and clarify in the source code, what the arguments
to Perl_regexec_flags are.

NB: this info is based on code inspection, not any real knowledge on my
part.

12 years agoUpgrade to threads::shared 1.41
Jerry D. Hedden [Wed, 5 Sep 2012 17:23:00 +0000 (13:23 -0400)]
Upgrade to threads::shared 1.41

12 years agoFix alignment for darwin with -Dusemorebits.
Andy Dougherty [Tue, 4 Sep 2012 21:13:34 +0000 (17:13 -0400)]
Fix alignment for darwin with -Dusemorebits.

By default, the darwin build assumes a "multiarchitecture" build.
Configure has a hardwired default of '8' for alignbytes (and then
proceeds to ignore it with another hard-wired '8' in config.h).
That '8' was supposed to be a safe value, in case perl was built
on one architecture but run on another with a stricter constraint.
With darwin and -Dusemorebits, however, the alignment should be on
16-byte boundaries.  We don't want to penalize all darwin builds for
this unlikely configuration, but we do want to allow it.

This patch causes Configure to compute alignbytes even for multiarch
builds, but if the result is less than 8, it sets it to 8 (which preserves
the previous behavior).  If, however, alignbytes is 16, Configure won't
decrease it.  Then, this patch also fixes config_h.SH so that it uses
the value determined by Configure instead of the previous hardwired value.

12 years agoUpdate Archive-Tar to CPAN version 1.90
Chris 'BinGOs' Williams [Wed, 5 Sep 2012 18:22:27 +0000 (19:22 +0100)]
Update Archive-Tar to CPAN version 1.90

  [DELTA]

  * important changes in version 1.90 05/09/2012 (Tom Jones)
  - documentation fixes

12 years agoperl5db: more tests
Shlomi Fish [Wed, 5 Sep 2012 02:40:38 +0000 (22:40 -0400)]
perl5db: more tests

This patch adds more tests for lib/perl5db.pl on lib/perl5db.t. One note
is that I'm a bit uncomfortable about the test for ".", which did
not initially work exactly as I expected, due to debugger quirks.

This patch also fixes a bug where the /pattern/ command (and possibly
the ?pattern? command as well) got broken due to the addition of "use
strict;", and adds tests for them.

12 years agoperl5db: fix an accidental effect of strictures
Shlomi Fish [Wed, 5 Sep 2012 02:37:13 +0000 (22:37 -0400)]
perl5db: fix an accidental effect of strictures

see https://rt.perl.org/rt3/Ticket/Display.html?id=114284

12 years agoFix compiler warning about empty if body
Jerry D. Hedden [Tue, 4 Sep 2012 17:19:26 +0000 (13:19 -0400)]
Fix compiler warning about empty if body

This is meant to correct the following 'blead' build warning:

op.c: In function 'Perl_op_free':
op.c:713:30: warning: suggest braces around empty body in an 'if' statement

12 years agoCollapse duplicate settings in hints/solaris_2.sh
Andy Dougherty [Tue, 4 Sep 2012 15:36:53 +0000 (11:36 -0400)]
Collapse duplicate settings in hints/solaris_2.sh

12 years agoAvoid garbled sed command in hints/solaris_2.sh
Andy Dougherty [Tue, 4 Sep 2012 15:35:56 +0000 (11:35 -0400)]
Avoid garbled sed command in hints/solaris_2.sh

Solaris sed does not understand the GNU /i flag.

12 years agoDocument the reason for the early return in Perl_newPROG() for OP_STUB.
Nicholas Clark [Tue, 4 Sep 2012 10:54:35 +0000 (12:54 +0200)]
Document the reason for the early return in Perl_newPROG() for OP_STUB.

12 years agoMerge improvements to -DPERL_DEBUG_READONLY_OPS into blead.
Nicholas Clark [Tue, 4 Sep 2012 10:07:35 +0000 (12:07 +0200)]
Merge improvements to -DPERL_DEBUG_READONLY_OPS into blead.

All tests pass with -Dusethreads -DPERL_DEBUG_READONLY_OPS (on this system)

12 years agoIn Perl_cv_forget_slab(), simplify the conditionally compiled code.
Nicholas Clark [Tue, 4 Sep 2012 09:54:06 +0000 (11:54 +0200)]
In Perl_cv_forget_slab(), simplify the conditionally compiled code.

This refactoring reduces the line count and makes it clear that the basic
logic is the same with or without -DPERL_DEBUG_READONLY_OPS. It make no
change to the generated assembler on a normal build.

12 years agoPerl_magic_setdbline() should clear and set read-only OP slabs.
Nicholas Clark [Mon, 3 Sep 2012 14:47:15 +0000 (16:47 +0200)]
Perl_magic_setdbline() should clear and set read-only OP slabs.

The debugger implements breakpoints by setting/clearing OPf_SPECIAL on
OP_DBSTATE ops. This means that it is writing to the optree at runtime,
and it falls foul of the enforced read-only OP slabs when debugging with
-DPERL_DEBUG_READONLY_OPS

Avoid this by removing static from Slab_to_rw(), and using it and Slab_to_ro()
in Perl_magic_setdbline() to temporarily make the slab re-write whilst
changing the breakpoint flag.

With this all tests pass with -DPERL_DEBUG_READONLY_OPS (on this system)

12 years agoIn op.c, change S_Slab_to_rw() from an OP * parameter to an OPSLAB *.
Nicholas Clark [Tue, 14 Aug 2012 12:24:34 +0000 (14:24 +0200)]
In op.c, change S_Slab_to_rw() from an OP * parameter to an OPSLAB *.

This makes it consistent with Perl_Slab_to_ro(), which takes an OPSLAB *.

12 years agoWith -DPERL_DEBUG_READONLY_OPS, changing a slab refcnt shouldn't make it r/w.
Nicholas Clark [Tue, 14 Aug 2012 12:10:30 +0000 (14:10 +0200)]
With -DPERL_DEBUG_READONLY_OPS, changing a slab refcnt shouldn't make it r/w.

Perl_op_refcnt_inc() and Perl_op_refcnt_dec() now both take care to leave the
slab in the same state as they found it. Previously both would
unconditionally make the slab read-write.

12 years agoUnder -DPERL_DEBUG_READONLY_OPS don't work around glibc 2.2.5 _moddi3 bugs.
Nicholas Clark [Wed, 8 Aug 2012 10:37:48 +0000 (12:37 +0200)]
Under -DPERL_DEBUG_READONLY_OPS don't work around glibc 2.2.5 _moddi3 bugs.

The work around involves a runtime check and substituting OP pointers based
on the result. The substitution fails if the optree is mapped read-only.

12 years agoMake dual-lived constant.pm work on 5.8 again
Sébastien Aperghis-Tramoni [Tue, 4 Sep 2012 05:42:26 +0000 (07:42 +0200)]
Make dual-lived constant.pm work on 5.8 again

Before releasing the version of constant.pm from bleadperl to the CPAN,
I tested it with the versions of Perl I have by hand, and it appears
that the current code fails to compile on 5.8:

  Bareword "_DOWNGRADE" not allowed while "strict subs" in use at
  lib/constant.pm line 142.

Added by bd8cb5529605f33aa9cf95d6c471386b3a0e015d

Removing the short-circuit return allows the code to compile and the
tests to pass on all stable Perl from 5.8.2 to 5.16.1.

12 years agoMake XSLoader's UPSTREAM as undef
Rafael Garcia-Suarez [Mon, 3 Sep 2012 15:39:41 +0000 (17:39 +0200)]
Make XSLoader's UPSTREAM as undef

The upstream is supposed to be "blead", but the CPAN version of
XSLoader 0.16 and the one that has shipped with perl 5.17.3 are
different (doc changes only). The problem (cmp_version.t failing)
should disappear after the next perl release.

12 years agoUpgrade to XSLoader 0.16
Sebastien Aperghis-Tramoni [Mon, 3 Sep 2012 14:36:06 +0000 (16:36 +0200)]
Upgrade to XSLoader 0.16

12 years agonewXS_len_flags() shouldn't change the line number on PL_curcop when warning.
Nicholas Clark [Mon, 13 Aug 2012 20:00:07 +0000 (22:00 +0200)]
newXS_len_flags() shouldn't change the line number on PL_curcop when warning.

This can actually generate incorrect line numbers in runtime warnings, when
XSUBs are redefined from calls made from BEGIN blocks, and the line number
from the opening brace of the begin block is mashed with the filename of the
current line. For compiletime warnings, PL_curcop == &PL_compiling, so the
line numbers will be correct whether taken from PL_compiling or PL_parser.

This code dates back to perl-5.000, when it was added to newXS(). It appears
to be a copy of code present in newSUB() since alpha 2.

12 years agoTest that the warning for "can be 0, test with defined" is for the start.
Nicholas Clark [Wed, 8 Aug 2012 20:59:19 +0000 (22:59 +0200)]
Test that the warning for "can be 0, test with defined" is for the start.

The Perl interpreter is careful to use the line number of the start of
the 'Value of %s can be "0"; test with defined()" warning, but there were no
tests for this.

12 years agoTest that the warning for "Found = in conditional" is for the start line.
Nicholas Clark [Wed, 8 Aug 2012 20:23:29 +0000 (22:23 +0200)]
Test that the warning for "Found = in conditional" is for the start line.

The Perl interpreter is careful to use the line number of the start of
the "Found = in conditional", but there were no tests for this.

12 years agoTest that the line number for a "sub redefined" warning is for the start.
Nicholas Clark [Wed, 8 Aug 2012 14:24:57 +0000 (16:24 +0200)]
Test that the line number for a "sub redefined" warning is for the start.

The Perl interpreter is careful to use the line number of the start of a
subroutine's redefinition for the warning, but there were no tests for this.

12 years agoAdd Karen Etheridge to AUTHORS.
Craig A. Berry [Sat, 1 Sep 2012 22:56:41 +0000 (17:56 -0500)]
Add Karen Etheridge to AUTHORS.

12 years agoRT#114312: prevent ls from colourizing output
Karen Etheridge [Sat, 1 Sep 2012 17:26:37 +0000 (10:26 -0700)]
RT#114312: prevent ls from colourizing output

ANSI colour codes in the `ls -l /dev` output was preventing some substitutions
from matching, causing a subsequent test to fail when 'stdout' or 'stderr' was
not properly removed from $DEV.

12 years agoperldelta for 94814ff57e and 5e56f3f11f
Steve Hay [Fri, 31 Aug 2012 20:25:29 +0000 (21:25 +0100)]
perldelta for 94814ff57e and 5e56f3f11f

12 years agoUpgrade DB_File to 1.827
Steve Hay [Fri, 31 Aug 2012 20:24:02 +0000 (21:24 +0100)]
Upgrade DB_File to 1.827

12 years agoFix skip_without_dynamic_extension to just skip
Jerry D. Hedden [Fri, 31 Aug 2012 20:36:00 +0000 (16:36 -0400)]
Fix skip_without_dynamic_extension to just skip

skip_without_dynamic_extension() mistakenly ends with skip_all()
instead of skip().

12 years agoRevert "toke.c: PL_in_eval purge"
Father Chrysostomos [Fri, 31 Aug 2012 16:52:53 +0000 (09:52 -0700)]
Revert "toke.c: PL_in_eval purge"

This reverts commit 5c49e90fd624f3ab1cdb1f1d8e4f0525d7881b99.

This change broke line numbers under mad when the last statement in the main program lacks a semicolon.

I was mistaken in thinking that PL_rsfp would always be true when
PL_in_eval is false.

But the use of PL_in_eval is still wrong.  Under a mad build, we get
this inconsistency in line numbers:

$ perl -e 'print "\n-e undef\n"' > foo
$ ./miniperl foo
Use of uninitialized value in -e at foo line 2.
$ ./miniperl -we 'require "foo"'
Use of uninitialized value in -e at foo line 3.
foo did not return a true value at -e line 1.

12 years agotest.pl:run_multiple_progs: Document cmdline switches
Father Chrysostomos [Fri, 31 Aug 2012 16:40:40 +0000 (09:40 -0700)]
test.pl:run_multiple_progs: Document cmdline switches

12 years agos/${foo#}//e should be an error
Father Chrysostomos [Fri, 31 Aug 2012 16:29:21 +0000 (09:29 -0700)]
s/${foo#}//e should be an error

See also the previous commit.

This one was caused by 9c74ccc.

Again, we can’t just check whether PL_lex_repl has the SvEVALED
flag set (which means we are in s///e), but must also check whether
PL_lex_repl == PL_linestr (which means we are in the replacement part
of s///e).

12 years agoCommit 6b00f562ed broke s/${\%x}{3}//e
Father Chrysostomos [Fri, 31 Aug 2012 16:27:25 +0000 (09:27 -0700)]
Commit 6b00f562ed broke s/${\%x}{3}//e

It was meant to check whether it was inside the replacement part of
s///e, but it only checked that it was inside s///e.  PL_lex_repl is
set on both sides, but is only equal to PL_linestr on the rhs.

12 years agoBump Locale-Codes from 3.22 to 3.23
Sullivan Beck [Tue, 28 Aug 2012 19:18:59 +0000 (15:18 -0400)]
Bump Locale-Codes from 3.22 to 3.23

12 years agoMake new File::Copy test case insensitive.
Craig A. Berry [Fri, 31 Aug 2012 16:21:58 +0000 (11:21 -0500)]
Make new File::Copy test case insensitive.

On VMS with default setttings, the filename is reported as copy.t,
not Copy.t, so make the regex allow that.

12 years agoFiles ending in .eg are also non-pod.
Craig A. Berry [Fri, 31 Aug 2012 12:47:07 +0000 (07:47 -0500)]
Files ending in .eg are also non-pod.

12 years ago[perl #114498] Document (0)[1,2] better
Aristotle Pagaltzis [Fri, 31 Aug 2012 15:45:37 +0000 (08:45 -0700)]
[perl #114498] Document (0)[1,2] better

12 years agocorrect -Dmad skip count for tests introduced in 2d85e411 and 4dc843bc
Tony Cook [Fri, 31 Aug 2012 12:41:47 +0000 (22:41 +1000)]
correct -Dmad skip count for tests introduced in 2d85e411 and 4dc843bc

12 years agoRemove the VM/ESA port.
Nicholas Clark [Thu, 30 Aug 2012 16:25:53 +0000 (18:25 +0200)]
Remove the VM/ESA port.

VM/ESA was a mainframe OS. IBM ended service on it in June 2003. It was
superseded by Z/VM.

12 years agoSilence ParseXS warning about abusing the CODE section
Steffen Mueller [Mon, 13 Aug 2012 08:29:39 +0000 (10:29 +0200)]
Silence ParseXS warning about abusing the CODE section

See RT #114198. DynaLoader was warning about somewhat dubious use of
RETVAL with a CODE section but without an OUTPUT section. This fixes
that problem, but I have obviously not been able to test on all affected
operating systems.

12 years ago[perl #112776] avoid warning on an initialized non-parameter
Tony Cook [Thu, 30 Aug 2012 14:43:19 +0000 (00:43 +1000)]
[perl #112776] avoid warning on an initialized non-parameter

A initialized non-parameter in the parameter block would warn
when $^W was set, and Module::Build sets $^W.

12 years ago[perl #112776] TODO test for warning
Tony Cook [Fri, 31 Aug 2012 10:07:58 +0000 (20:07 +1000)]
[perl #112776] TODO test for warning

12 years agoStop calling get-magic twice in sprintf "%.1s", $utf8
Father Chrysostomos [Fri, 31 Aug 2012 06:27:43 +0000 (23:27 -0700)]
Stop calling get-magic twice in sprintf "%.1s", $utf8

12 years agoStop calling get-magic twice in sprintf "%1s", $utf8
Father Chrysostomos [Fri, 31 Aug 2012 06:19:56 +0000 (23:19 -0700)]
Stop calling get-magic twice in sprintf "%1s", $utf8

12 years agoStop calling get-magic twice in pack "u", $utf8
Father Chrysostomos [Fri, 31 Aug 2012 06:06:14 +0000 (23:06 -0700)]
Stop calling get-magic twice in pack "u", $utf8

12 years agoStop calling get-magic twice when reading lvalue substr($utf8)
Father Chrysostomos [Fri, 31 Aug 2012 05:34:38 +0000 (22:34 -0700)]
Stop calling get-magic twice when reading lvalue substr($utf8)

12 years agoStop calling get-magic twice when reading lvalue substr($utf8)
Father Chrysostomos [Fri, 31 Aug 2012 05:30:26 +0000 (22:30 -0700)]
Stop calling get-magic twice when reading lvalue substr($utf8)

12 years agoStop calling get-magic twice for lvalue pos($utf8)
Father Chrysostomos [Fri, 31 Aug 2012 05:26:33 +0000 (22:26 -0700)]
Stop calling get-magic twice for lvalue pos($utf8)

12 years agoStop substr($utf8) from calling get-magic twice
Father Chrysostomos [Fri, 31 Aug 2012 05:08:43 +0000 (22:08 -0700)]
Stop substr($utf8) from calling get-magic twice

By calling get-magic twice, it could cause its string buffer to be
reallocated, resulting in incorrect and random return values.

12 years ago[perl #114410] Reset utf8 pos cache on get
Father Chrysostomos [Fri, 31 Aug 2012 01:01:27 +0000 (18:01 -0700)]
[perl #114410] Reset utf8 pos cache on get

If a scalar is gmagical, then the string buffer could change without
the utf8 pos cache being updated.

So it should respond to get-magic, not just set-magic.  Actually add-
ing get-magic to the utf8 magic vtable would cause all scalars with
this magic to be flagged gmagical.  Instead, in magic_get, we can call
magic_setutf8.

12 years agoutf8cache.t: Skip only the XS-dependent test
Father Chrysostomos [Thu, 30 Aug 2012 23:42:30 +0000 (16:42 -0700)]
utf8cache.t: Skip only the XS-dependent test

12 years agotest.pl: Add skip_without_dynamic_extension
Father Chrysostomos [Thu, 30 Aug 2012 23:40:48 +0000 (16:40 -0700)]
test.pl: Add skip_without_dynamic_extension

12 years agoBreak s//3}->{3/e
Father Chrysostomos [Thu, 30 Aug 2012 23:09:58 +0000 (16:09 -0700)]
Break s//3}->{3/e

This should never have worked:

%_=(_,"Just another ");
$_="Perl hacker,\n";
s//_}->{_/e;print

12 years agoFix two minor s//.../e parsing bugs
Father Chrysostomos [Thu, 30 Aug 2012 22:57:18 +0000 (15:57 -0700)]
Fix two minor s//.../e parsing bugs

It may be an odd place to allow comments, but s//"" # hello/e has\
always worked, *unless* there happens to be a null before the first #.

scan_subst in toke.c wraps the replacement text in do { ... } when the
/e flag is present.

It was adding a line break before the final } if the replacement text
contained #, because otherwise the } would be commented out.

But to find the # it was using strchr, which stops at the first null.
So eval "s//'\0'#/e" would fail.

It makes little sense to me to check whether the replacement contains
# before adding the line break.  It would be faster just to add the
line break without checking.

But then I discovered this bug:

s//"#" . <<END/e;
foo
END
__END__
Can't find string terminator "END" anywhere before EOF at - line 1.

So now I have two bugs to fix.

The easiest solution seems to be to omit the line break and make the
comment parser skip the } at the end of a s///e replacement.

12 years agotoke.c: PL_in_eval purge
Father Chrysostomos [Thu, 30 Aug 2012 20:34:14 +0000 (13:34 -0700)]
toke.c: PL_in_eval purge

Many uses of PL_in_eval in toke.c are redundant.

PL_in_eval indicates not that we are parsing a string eval, but that
we are being called from an eval, whether stringy on not.  Even if
PL_in_eval were only for string eval, it would still not indicate that
we are parsing a string eval, because of eval 'require'.

This commit removes redundant uses of it (making things theoretically
slightly faster).

12 years agotoke.c:scan_heredoc: comments, comments
Father Chrysostomos [Thu, 30 Aug 2012 05:35:27 +0000 (22:35 -0700)]
toke.c:scan_heredoc: comments, comments

12 years agotoke.c:scan_heredoc: Merge similar code
Father Chrysostomos [Thu, 30 Aug 2012 05:07:18 +0000 (22:07 -0700)]
toke.c:scan_heredoc: Merge similar code

The code for looking in outer lexing scopes was mostly identical to
the code for looking in PL_linestr.

12 years agotoke.c:scan_heredoc: Remove incorrect part of comment
Father Chrysostomos [Thu, 30 Aug 2012 03:43:05 +0000 (20:43 -0700)]
toke.c:scan_heredoc: Remove incorrect part of comment

I missed this in 60f40a3895 when I stopped abusing IVX and NVX.

12 years agotoke.c:scan_heredoc: Merge two adjacent #ifdefs
Father Chrysostomos [Thu, 30 Aug 2012 03:41:09 +0000 (20:41 -0700)]
toke.c:scan_heredoc: Merge two adjacent #ifdefs

12 years agotoke.c:scan_heredoc: Remove unnecessary assignment
Father Chrysostomos [Thu, 30 Aug 2012 03:39:55 +0000 (20:39 -0700)]
toke.c:scan_heredoc: Remove unnecessary assignment

Updating PL_bufend after lex_next_chunk is not necessary, as
lex_next_chunk itself does it.

12 years agotoke.c:scan_heredoc: less pointer fiddling; one less SV
Father Chrysostomos [Thu, 30 Aug 2012 03:37:44 +0000 (20:37 -0700)]
toke.c:scan_heredoc: less pointer fiddling; one less SV

The loop for reading lines of input to find the end of a here-doc has
always checked to see whether the cursor (s) was at the end of the
current buffer:

    while (s >= PL_bufend) { /* multiple line string? */

(Actually, when it was added in perl 3.000, it was in scanstr and
that loop was not specific to here-docs, but also applied to multi-
line strings.)

The code inside the loop ends up fiddling with s by setting it explic-
itly to the end of the buffer or the end of the here-doc marker, minus
one to make sure it does not coincide with the end of the buffer.

This doesn’t make any sense, and it makes the rest of this function
more complicated.

Because the loop used to be outside the else block, it was also
reached for a here-doc inside a string eval, but the code for that
ensured the condition for the while loop was never true.

Since the while loop set s to one less than it needed to be set to,
in order to break out of it, it had to have s++ just after the loop.
That s++ was reached also by the eval code, which, consequently, had
to adjust its value of s.

That adjustment actually took place farther up in the function, where
the herewas SV was assigned to.  (herewas contains the text after the
here-doc marker to the end of the line.)  The beginning of herewas
would point to the last character of the here-doc marker inside an
eval, so that subtracting SvCUR(herewas) from the buffer end would
result in an adjusted pointer.

herewas is currently not actually used, except for the length.  Until
recently, the text inside it would be copied back into PL_linestr to
recreate where the lexer needed to continue (because PL_linestr was
being clobbered).  That no longer happens.

So we can get rid of herewas altogether.  Since it is in an else
block, the stream-based parser does not need to fiddle pointers to
exit the loop.  It can just break explicitly.  So the s++ can also
go, requiring changes (and simplifications) to the eval code.  The
comment about it being a multiline string is irrelevant and can go,
too.  It dates from when that line was actually in scanstr and applied
to quoted strings containing line breaks.

12 years agotoke.c:S_scan_heredoc: put the croaking code in one spot
Father Chrysostomos [Thu, 30 Aug 2012 00:58:33 +0000 (17:58 -0700)]
toke.c:S_scan_heredoc: put the croaking code in one spot

12 years agoMake eval "s//<<END/e" slightly faster
Father Chrysostomos [Wed, 29 Aug 2012 20:10:01 +0000 (13:10 -0700)]
Make eval "s//<<END/e" slightly faster

The code that peeks into an outer linestr buffer to find the heredoc
body has to modify that buffer and remove the heredoc body from it.

It copies the text after the quote-like operator up to the end of the
line into a new SV, concatenates the text after the heredoc body into
a new SV, and then copies it back to linestr right after the quote-
like operator.

So, in this example:

eval "s//<<END/e; # jiggles\nfoo\nEND\ndie;"

It ends up copying this:

               "; # jiggles\ndie;\n;"

into this at the position shown:

eval "s//<<END/e; # jiggles\nfoo\nEND\ndie;\n;"
                ^

There is no need for two copies.  And there is no need to copy the
rest of the line where the heredoc marker is.

12 years agolex.t: Mangle obscenity (albeit euphemistic)
Father Chrysostomos [Wed, 29 Aug 2012 19:49:56 +0000 (12:49 -0700)]
lex.t: Mangle obscenity (albeit euphemistic)

It is harder to hack on perl with someone looking over one’s shoulder
when there are comments like this, even when it is euphemistic in its
use of voiced dental stops instead of the voiceless kind.

12 years agoFix here-doc body extraction in eval 's//<<END/'
Father Chrysostomos [Wed, 29 Aug 2012 19:47:32 +0000 (12:47 -0700)]
Fix here-doc body extraction in eval 's//<<END/'

Outside of string eval, this:

s//<<END/e; print "a
END
b\n";

prints this:

a
b

But when we have string eval involved,

eval 's//<<END/e; print "a
END
b\n"';

we get this:

a

b

Amazing!

The buggy code in question goes back to commit 0244c3a403.

Since PL_linestr only contains the contents of the replacement
("<<END"), it peeks into the outer lexing scope’s linestr buffer, mod-
ifying it in place to remove the here-doc body, by copying everything
after the here-doc back to the spot where the body begins.

It was off by one, however, and left an extra line break.

When the code in question is reached, the variables are set as follows:

bufptr = "; print \"a"...  (just after the s///)
s      = "\nb\\n\""        (newline after the heredoc terminator)

The herewas variable already contains everything after the quote-
like operator containing the <<heredoc marker to the end of the line
including the \n ("; print \"a\n").

But then we concatenate everything from s onwards.  So we end up with
the \n before the here-doc body and the \n from after the here-doc
terminator juxtaposed.

So after using s to extract the re-eval string, we increment s so it
points afer the final newline.

12 years agoFinish fixing here-docs in re-evals
Father Chrysostomos [Wed, 29 Aug 2012 19:35:49 +0000 (12:35 -0700)]
Finish fixing here-docs in re-evals

This commit fixes here-docs in single-line re-evals in files (as
opposed to evals) and here-docs in single-line quote-like operators
inside re-evals.

In both cases, the here-doc parser has to look into an outer
lexing scope to find the here-doc body.  And in both cases it
was stomping on PL_linestr (the current line buffer) while
PL_sublex_info.re_eval_start was pointing to an offset in that buffer.
(re_eval_start is used to construct the string to include in the
regexp’s stringification once the lexer reaches the end of the
re-eval.)

Fixing this entails moving re_eval_start and re_eval_str to
PL_parser->lex_shared, making the pre-localised values visible.
This is so that the code that peeks into an outer linestr buffer to
steal the here-doc body can set up re_eval_str in the right scope.
(re_eval_str is used to store the re-eval text when the here-
oc parser has no choice but to modify linestr; see also commit
db4442662555874019.)

It also entails making the stream-based parser (i.e., that reads from
an input stream) leave PL_linestr alone, instead of clobbering it and
then reconstructing part of it afterwards.

12 years agotoke.c:S_scan_heredoc: Put stream-based parser in else block
Father Chrysostomos [Wed, 29 Aug 2012 15:41:41 +0000 (08:41 -0700)]
toke.c:S_scan_heredoc: Put stream-based parser in else block

We currently have the code laid out like this:

    if (peek) {
        ... peek inside the parent linestr buffer
    }
    else if (eval) {
        ... grab the heredoc body from linestr ...
    }
    else
        start with an empty string for the heredoc body

    ... parse the body of the heredoc from the input stream ...

The final bit is inside a while loop whose condition is never true
after either of the first two branches of the if/else has executed.
But the code is very hard to read, and it is difficult to fix bugs, as
code cannot be added before the while loop, and the while loop condi-
tion cannot change, without affecting heredocs in string eval.

So put the final parser inside the else.  Future commits will
depend on this.

12 years agoAvoid uninit warning for qq|${\<<FOO}|
Father Chrysostomos [Wed, 29 Aug 2012 15:36:40 +0000 (08:36 -0700)]
Avoid uninit warning for qq|${\<<FOO}|

If a here-doc occurs inside a single-line quote-like operator inside
a file (as opposed to an eval), it produces an uninitialized warning.
The goto I added in commit 99bd9d90 wentto the wrong place.

12 years agotoke.c: S_scan_heredoc: prune dead code
Father Chrysostomos [Wed, 29 Aug 2012 05:37:10 +0000 (22:37 -0700)]
toke.c: S_scan_heredoc: prune dead code

This incorrect code (using a pointer after finding it to be null)
is the result of the refactoring in 60f40a3895.  It was trying to
account for a string eval with no line break in it.  But that can’t
happen as of 11076590 (if it could it would crash).

So remove it and add an assertion, along with a comment explaining the
assertion.

12 years agoRefactor t/op/die.t to re-use the same $SIG{__DIE__} handler where possible.
Nicholas Clark [Thu, 30 Aug 2012 13:34:33 +0000 (15:34 +0200)]
Refactor t/op/die.t to re-use the same $SIG{__DIE__} handler where possible.

Restore testing that the $SIG{__DIE__} handler is called for the case of
C<die bless [ 7 ], "Error";> which was removed by the previous refactoring.
Re-using the same $SIG{__DIE__} handler results in 4 more tests of isa_ok()
for an 'ARRAY' - this isn't going to hurt anyone.

12 years agoRefactor t/op/die.t to use test.pl instead of making TAP by hand.
Colin Kuskie [Wed, 18 Jul 2012 04:59:30 +0000 (21:59 -0700)]
Refactor t/op/die.t to use test.pl instead of making TAP by hand.

[With a few whitespace tweaks]

12 years agoFix Cygwin build warnings
Jerry D. Hedden [Wed, 29 Aug 2012 14:55:12 +0000 (10:55 -0400)]
Fix Cygwin build warnings

Fixes the following build warnings under Cygwin:

cygwin.c: In function 'do_spawn':
cygwin.c:132:5: warning: assignment from incompatible pointer type
cygwin.c: In function 'XS_Cygwin_posix_to_win_path':
cygwin.c:346:9: warning: 'err' may be used uninitialized in this function
cygwin.c: In function 'XS_Cygwin_win_to_posix_path':
cygwin.c:257:9: warning: 'err' may be used uninitialized in this function

12 years agoRemove a no-longer needed lexical from t/op/lop.t
Nicholas Clark [Wed, 29 Aug 2012 20:23:19 +0000 (22:23 +0200)]
Remove a no-longer needed lexical from t/op/lop.t

Jim Keenan spotted the commented out code referencing the variable $test.
Turns out that it is completely redundant, so its declaration can go too.

12 years agoDocument the last five tests of t/op/lop.t
Colin Kuskie [Sat, 11 Aug 2012 03:24:09 +0000 (20:24 -0700)]
Document the last five tests of t/op/lop.t

12 years agoUpdate t/op/lop.t to use test.pl instead of making TAP by hand.
Colin Kuskie [Sat, 28 Jul 2012 21:14:45 +0000 (14:14 -0700)]
Update t/op/lop.t to use test.pl instead of making TAP by hand.

12 years agoRefactor t/uni/case.pl to use test.pl instead of making TAP by hand.
Colin Kuskie [Thu, 19 Jul 2012 01:35:19 +0000 (18:35 -0700)]
Refactor t/uni/case.pl to use test.pl instead of making TAP by hand.

12 years agoRefactor t/porting/checkcase.t to use test.pl instead of making TAP by hand.
Colin Kuskie [Wed, 18 Jul 2012 05:21:21 +0000 (22:21 -0700)]
Refactor t/porting/checkcase.t to use test.pl instead of making TAP by hand.

12 years agoRefactor t/re/no_utf8_pt.t to use test.pl instead of making TAP by hand.
Colin Kuskie [Wed, 18 Jul 2012 05:07:54 +0000 (22:07 -0700)]
Refactor t/re/no_utf8_pt.t to use test.pl instead of making TAP by hand.

12 years agoAdd /\.gif\z/ files to the non-Pod exceptions in t/porting/podcheck.t
Nicholas Clark [Tue, 28 Aug 2012 19:22:51 +0000 (21:22 +0200)]
Add /\.gif\z/ files to the non-Pod exceptions in t/porting/podcheck.t

12 years agot/porting/podcheck.t now passes no_chdir to File::Find::find().
Nicholas Clark [Tue, 28 Aug 2012 19:09:24 +0000 (21:09 +0200)]
t/porting/podcheck.t now passes no_chdir to File::Find::find().

File::Find::find() can call warn::warnif(), which in turn attempts to lazy
load Carp, which doesn't work for a test using relative paths in @INC with
the current directory changed.