platform/upstream/perl.git
13 years agoAdd Nobuhiro Iwamatsu to AUTHORS
Father Chrysostomos [Sun, 5 Jun 2011 00:40:05 +0000 (17:40 -0700)]
Add Nobuhiro Iwamatsu to AUTHORS

13 years agoUpdate lengthen time-out time for t/re/re.t.
Nobuhiro Iwamatsu [Sun, 5 Jun 2011 00:38:58 +0000 (17:38 -0700)]
Update lengthen time-out time for t/re/re.t.

When we carry out this test on SH4, it becomes the time-out.
2 seconds are set in watchdog, but are too short for SH4.
This patch was changed for 10 seconds.

$ time ./perl  t/re/re.t
1..19
ok 1 - is_regexp(REGEXP ref)
ok 2 - is_regexp(REGEXP)
ok 3 - is_regexp("")
ok 4 - regexp_pattern[0] (ref)
ok 5 - regexp_pattern[1] (ref)
ok 6 - scalar regexp_pattern (ref)
ok 7 - regexp_pattern[0] (bare REGEXP)
ok 8 - regexp_pattern[1] (bare REGEXP)
ok 9 - scalar regexp_pattern (bare REGEXP)
ok 10 - !regexp_pattern("")
ok 11 - regnames
ok 12 - regnames
ok 13 - regnames in scalar context
ok 14 - regnames
ok 15
ok 16
ok 17
ok 18
ok 19 - Didn't loop

real    0m7.482s
user    0m3.848s
sys     0m0.036s

13 years agoAdd Pau Amma to AUTHORS
Father Chrysostomos [Sat, 4 Jun 2011 21:31:58 +0000 (14:31 -0700)]
Add Pau Amma to AUTHORS

13 years agomove "garbage collection" glossary entry where it belongs
Pau Amma [Sat, 4 Jun 2011 21:31:07 +0000 (14:31 -0700)]
move "garbage collection" glossary entry where it belongs

13 years agoStop localised ties from becoming ro when COW
Father Chrysostomos [Sat, 4 Jun 2011 20:10:41 +0000 (13:10 -0700)]
Stop localised ties from becoming ro when COW

13 years agoAllow restricted hashes containing COWs to be cleared
Father Chrysostomos [Sat, 4 Jun 2011 18:58:14 +0000 (11:58 -0700)]
Allow restricted hashes containing COWs to be cleared

13 years agoAllow COW values to be deleted from restricted hashes
Father Chrysostomos [Sat, 4 Jun 2011 18:54:10 +0000 (11:54 -0700)]
Allow COW values to be deleted from restricted hashes

I wonder how many other things a604c75 broke....

13 years agoAllow lvalue subs to return COWs in reference context
Father Chrysostomos [Sat, 4 Jun 2011 18:38:02 +0000 (11:38 -0700)]
Allow lvalue subs to return COWs in reference context

(That’s ‘reference’ as in ‘pass by reference’. It applies to
foo(lvalue_func()) and for(lvalue_func()).)

Commit f71f472 took care of scalar context.
Commit a0aa607 came and long and took care of list context, but,
unfortunately, missed reference context.

This commit takes care of that.

13 years agoAdd tests for [perl #87908]
Karl Williamson [Sat, 4 Jun 2011 20:41:25 +0000 (14:41 -0600)]
Add tests for [perl #87908]

13 years agoFix several array-returning bugs in lvalue subs
Father Chrysostomos [Sat, 4 Jun 2011 13:44:01 +0000 (06:44 -0700)]
Fix several array-returning bugs in lvalue subs

This finishes fixing bug #23790.

When called in reference context (for(...) or map $_, ...), lvalue
subs returning arrays or hashes would return the AV or HV itself, as
though it were lvalue context.

The result was that $_ would be bound to an AV or HV, which is not
supposed to happen, as it’s a scalar (that’s when you start getting
‘Bizarre copy’ errors).

Commit 91e34d82 fixed this in pp_leavesublv, but the if condition it
added was placed outside the loop, so it only applied when the array
was the first thing returned. It also did not take hashes into account.

By changing the lvalue-context check in pp_padav, pp_padhv and
pp_rv2av (which also serves as pp_rv2hv), I was able to apply a more
general fix, which also fix another bug: Those array and hash ops were
croaking when called in scalar reference context (...->$method).

Because it is no longer part of the sub-leaving code, explicitly
returning an array in reference context works now, too.

This commit also eliminates the code added by 91e34d82, as it’s no
longer necessary.

13 years agoGet f_map.t working on non-threaded perls
Father Chrysostomos [Sat, 4 Jun 2011 12:53:29 +0000 (05:53 -0700)]
Get f_map.t working on non-threaded perls

(broken by 767eda4)

13 years agoTeach B::Concise about OPpMAYBE_LVSUB
Father Chrysostomos [Sat, 4 Jun 2011 05:14:41 +0000 (22:14 -0700)]
Teach B::Concise about OPpMAYBE_LVSUB

13 years agoRemove duplicate test
Father Chrysostomos [Sat, 4 Jun 2011 04:50:35 +0000 (21:50 -0700)]
Remove duplicate test

13 years ago[perl #88138] ' is not equivalent to :: before a null
Father Chrysostomos [Sat, 4 Jun 2011 04:34:45 +0000 (21:34 -0700)]
[perl #88138] ' is not equivalent to :: before a null

' is usually equivalent to :: in a symbol name. At the *end* of a
symbol name (as in $'), it’s not equivalent. (That’s a feature.)
Perl_gv_fetchpvn_flags was checking for the end by saying
if(next character), which returns false for a null. It should be
checking the length, which it was already doing for ::, and which
this commit makes it do.

13 years ago[perl #7946] Lvalue subs do not autovivify
Father Chrysostomos [Sat, 4 Jun 2011 03:06:24 +0000 (20:06 -0700)]
[perl #7946] Lvalue subs do not autovivify

This commit makes autovivification work with lvalue subs. It follows
the same technique used by other autovivifiable ops (aelem, helem,
tc.), except that, due to flag constraints, it uses a single flag and
instead checks the op tree at run time to find out what sort of thing
to vivify.

The flag constraints are that these two flags:

#define OPpENTERSUB_HASTARG 32 /* Called from OP tree. */
#define OPpENTERSUB_NOMOD 64 /* Immune to op_lvalue() for :attrlist. */

conflict with these:

#define OPpDEREF (32|64) /* autovivify: Want ref to something: */
#define OPpDEREF_AV 32 /*   Want ref to AV. */
#define OPpDEREF_HV 64 /*   Want ref to HV. */
#define OPpDEREF_SV (32|64) /*   Want ref to SV. */

Renumbering HASTARG and NOMOD is problematic, as there are places in
op.c that change entersubs into rv2cvs, and the entersub and rv2cv
flags would conflict. Setting the flags correctly when changing the
type is hard and would result in subtle bugs if not done perfectly.

Ops like ${...} don’t actually autovivify; it’s the op inside that
does it. In those cases, the parent op is flagged with OPpDEREFed, and
it skips get-magic, as it has already been called by the inner op.

Since entersub is now marked as being an autovivifying op, ${...} in
lvalue context ends up skipping get-magic if there is a foo() inside.
And this affects even regular subs. So pp_leavesub and pp_return have
to call get-magic; hence the new tests in gmagic.t.

13 years agoFollow-up to d34a6664
Father Chrysostomos [Fri, 3 Jun 2011 21:20:10 +0000 (14:20 -0700)]
Follow-up to d34a6664

As Nicholas Clark wrote in
nntp://nntp.perl.org/20110603192458.GZ2604@plum.flirble.org:

> $ valgrind ./perl -Ilib 91880.pl
> ==5542== Memcheck, a memory error detector
...
> I think that the problem is that this code in S_run_user_filter()
>
>  ENTER_with_name("call_filter_sub");
>  SAVEGENERICSV(GvSV(PL_defgv));
>  SAVETMPS;
>  EXTEND(SP, 2);
>
>
> is putting an action on the save stack to write to an address within
> the GP of PL_defgv. However, the perl code run about 10 lines later
> frees up the GP of PL_defgv, so the scope stack now has a dangling
> pointer. 12 lines later at scope exit, the scope stack unwinding
> writes to the pointer, and nasal daemons emerge.

This commit precedes the SAVEGENERICSV with a call to save_gp, to make
sure the GP is not freed (and then a call to GvINTRO_off [set by
save_gp], so that subsequent glob assignments are not implicitly
localised).

This basically emulates what happens with ‘local *_ = \$some_scalar’,
but without the extra intermediate RV.

13 years agoCorrect entersub/rv2cv priv constants in B::Concise
Father Chrysostomos [Fri, 3 Jun 2011 16:25:21 +0000 (09:25 -0700)]
Correct entersub/rv2cv priv constants in B::Concise

See the commit message of d4ddbae for detail.

13 years agoFix a confusing comment in perly.y
Father Chrysostomos [Fri, 3 Jun 2011 13:41:48 +0000 (06:41 -0700)]
Fix a confusing comment in perly.y

There’s no arrow there.

13 years agoRearrange some private op flag constants
Father Chrysostomos [Fri, 3 Jun 2011 13:26:18 +0000 (06:26 -0700)]
Rearrange some private op flag constants

Some constants in op.h were a bit muddled up and were not grouped
according to which ops used them. And one of the comments was wrong.
The history is a bit involved:

Commit 7a52d87 added this comment, which was correct:

+  /* OP_RV2CV only */
 #define OPpENTERSUB_AMPER 8 /* Used & form to call. */

Commit 9675f7a added this constant:

   /* OP_RV2CV only */
 #define OPpENTERSUB_AMPER 8 /* Used & form to call. */
+#define OPpENTERSUB_NOPAREN 128 /* bare sub call (without parens) */

Commit cd06dff added this one, which is confusing, as it is only used
on entersub:

   /* OP_RV2CV only */
 #define OPpENTERSUB_AMPER 8 /* Used & form to call. */
 #define OPpENTERSUB_NOPAREN 128 /* bare sub call (without parens) */
+#define OPpENTERSUB_INARGS 4 /* Lval used as arg to a sub. */

Commit e26df76 added this, resulting in there being two
OP_RV2CV sections:

+  /* OP_RV2CV only */
+#define OPpMAY_RETURN_CONSTANT 1 /* If a constant sub, return the constant */
+

To top it all, commit b900987 unfortunately ‘fixed’ a mislead-
ing comment:

-  /* OP_RV2CV only */
+  /* OP_ENTERSUB and OP_RV2CV only */
 #define OPpENTERSUB_AMPER 8 /* Used & form to call. */
 #define OPpENTERSUB_NOPAREN 128 /* bare sub call (without parens) */
 #define OPpENTERSUB_INARGS 4 /* Lval used as arg to a sub. */

13 years agoMove the lvalue code from pp_return into a separate func
Father Chrysostomos [Fri, 3 Jun 2011 04:18:50 +0000 (21:18 -0700)]
Move the lvalue code from pp_return into a separate func
so that upcoming commits can add more conditions without
slowing down the most common cases, and so that it can
eventually be merged with pp_leavesublv.

13 years agoregexp.h: work around -Werror compile failure of XS in linux perf tool
Jim Cromie [Wed, 1 Jun 2011 04:15:11 +0000 (22:15 -0600)]
regexp.h: work around -Werror compile failure of XS in linux perf tool

The linux perf tool has an XS component, but when built using system
perl 5.14.0, its compilation errors out on the switch statement in
regexp.h: get_regex_charset_name(), which lacks a default case.  Add
one, copying the end-of-function return "?".

Preserve the end-of-function return "?", to avoid a hypothetical
compiler bug which misses the default case, and infers a void return
for a function thats declared otherwize.

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
13 years ago[perl #4362] Test for ‘Can't find terminator’
Father Chrysostomos [Thu, 2 Jun 2011 17:55:49 +0000 (10:55 -0700)]
[perl #4362] Test for ‘Can't find terminator’

13 years agoDeparse $obj->$meth=... [perl #62498]
Father Chrysostomos [Thu, 2 Jun 2011 13:01:57 +0000 (06:01 -0700)]
Deparse $obj->$meth=... [perl #62498]

When an lvalue method-as-variable is compiled, the method
op has a sibling that is an rv2cv:

a     <2> sassign vKS/2 ->b
3        <$> const[IV 1] s ->4
9        <1> entersub[t3] sKRMS*/NO(),TARG ->a
4           <0> pushmark s ->5
-           <1> ex-rv2sv sKM/1 ->6
5              <#> gvsv[*obj] s ->6
7           <1> method sK/1 ->8
-              <1> ex-rv2sv sK/1 ->7
6                 <#> gvsv[*meth] s ->7
8           <1> rv2cv /NO() ->9

Deparse didn’t know about it, and was iterating through the
children of entersub, thinking the last one was the method,
stopping at any item named ‘method_named’. So I modified it
to stop at ‘method’ as well.

13 years agoTweak the test from 183eb698e2ceb8ab to work with PERL_UNICODE set.
Nicholas Clark [Thu, 2 Jun 2011 08:51:14 +0000 (09:51 +0100)]
Tweak the test from 183eb698e2ceb8ab to work with PERL_UNICODE set.

One should always generate the golden B::Concise output with PERL_UNICODE set
so that ${^OPEN} is set, as the test system knows how to take it out, not put
it in.

13 years agoCollapse some repetitive code
Father Chrysostomos [Thu, 2 Jun 2011 01:00:45 +0000 (18:00 -0700)]
Collapse some repetitive code

13 years agoDeparse glob the same way regardless of PERL_EXTERNAL_GLOB
Father Chrysostomos [Thu, 2 Jun 2011 00:50:45 +0000 (17:50 -0700)]
Deparse glob the same way regardless of PERL_EXTERNAL_GLOB

This should fix the recent new failure in the VMS smokes
(since 2f77d7b).

13 years ago[perl #62498] Scalar context breaks lvalue subs
Father Chrysostomos [Wed, 1 Jun 2011 23:37:17 +0000 (16:37 -0700)]
[perl #62498] Scalar context breaks lvalue subs

That RT ticket reported that a $ prototype puts an implicit scalar()
on its argument, and that scalar(lvalue()) causes the function to
return a temporary value. In particular:

  ${\scalar($_)} = 1; # ok
  ${\scalar f()} = 1; # no effect

(where f is an lvalue sub that returns $_).

It turns out that this does not only affect scalar(), but also
|| and &&:

  ${\($_  && undef)} = 3; # ok
  ${\(f() && undef)} = 3; # no effect

Also, that comment in pp_leavesublv about f()->meth() not being lvalue
context is wrong, as

  $o->${\sub { $_[0] = "whatever" }};

assigns to $o, and

  sub UNIVERSAL::undef { undef $_[0] }

allows calls like

  $x->undef

to undefine $x, if it contains an object or package name.

Since copying values in rvalue context is wasteful anyway, since the
definition of rvalue context is that the value is going to be copied
(resulting in *two* copies), the easiest solution is not to copy val-
ues in rvalue context.

This ends up applying to what I call ‘reference’ context (semi-lvalue,
or potential lvalue) as well.

This works already with explicit return.

As a bonus, this also fixes bug #78680, for which there are already
to-do tests that were added before the bug was reported. See also:

http://www.nntp.perl.org/group/perl.perl5.porters/;msgid=20060118203058.GQ616@plum.flirble.org

13 years ago[perl #91946] add constant folding tests
Jim Cromie [Wed, 1 Jun 2011 21:13:40 +0000 (14:13 -0700)]
[perl #91946] add constant folding tests

test arithmetic folding, conditional folding (both true & false),
and string, lc() & uc() folds, and mixed string.int folds.

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
13 years agoWarn when list-assigning to TEMP
Father Chrysostomos [Wed, 1 Jun 2011 21:11:37 +0000 (14:11 -0700)]
Warn when list-assigning to TEMP

13 years agoTests for XS lvalue functions
Father Chrysostomos [Wed, 1 Jun 2011 21:07:04 +0000 (14:07 -0700)]
Tests for XS lvalue functions

including the ‘Useless assignment to a temporary’ warning
which is only triggered by these.

13 years agoCorrect mistake in perldelta temlate
Father Chrysostomos [Wed, 1 Jun 2011 20:24:46 +0000 (13:24 -0700)]
Correct mistake in perldelta temlate

13 years agoperlhack.pod: invoke git-format-patch with --attach
Jim Cromie [Tue, 31 May 2011 16:47:29 +0000 (10:47 -0600)]
perlhack.pod: invoke git-format-patch with --attach

As George Greer noted on p5p, --attach causes the message to be
written using MIME-attach syntax, so when perlbug sends it,
rt.perl.org detaches the file and adds it to the ticket.

While tradtional inline patches appear to survive without whitespace
mangling, attachments are more in keeping with RTs design and use.

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
13 years agoperlbug: replace all $::opt_* with %opt
Jim Cromie [Fri, 27 May 2011 17:33:30 +0000 (11:33 -0600)]
perlbug: replace all $::opt_* with %opt

patch does:
perl -pi -e 's/$::opt_(\w)/$opt{$1}/g' perlbug.PL
adds my %opt decl, and in getopts.
drops no warnings 'once'

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
13 years agoAdd alternate e-mail for Dennis Kaarsemaker.
Craig A. Berry [Wed, 1 Jun 2011 12:36:23 +0000 (07:36 -0500)]
Add alternate e-mail for Dennis Kaarsemaker.

13 years agoAdvise the pumpking to make new maint branches available in the APC
Dennis Kaarsemaker [Tue, 31 May 2011 21:10:52 +0000 (23:10 +0200)]
Advise the pumpking to make new maint branches available in the APC

13 years agoRemove unnecessary stuff from sub_lval.t
Father Chrysostomos [Wed, 1 Jun 2011 04:56:35 +0000 (21:56 -0700)]
Remove unnecessary stuff from sub_lval.t

I cannot find any information on these, but that comment
is erroneous and that sub is not doing anything.

13 years agoRevert "Accept lvalue subroutines as a useful feature."
Father Chrysostomos [Wed, 1 Jun 2011 04:55:13 +0000 (21:55 -0700)]
Revert "Accept lvalue subroutines as a useful feature."

This reverts commit c72c0c0bdd3dbc2b529b28a4f324a1cc149a6453
at Jesse’s request.

13 years agoRevert "Remove a line added by the prev commit"
Father Chrysostomos [Wed, 1 Jun 2011 04:54:25 +0000 (21:54 -0700)]
Revert "Remove a line added by the prev commit"

This reverts commit 6b8305409e650748b2e6fb75634200370b69238b
at Jesse’s request.

13 years agoIt’s still the 20th century?
Father Chrysostomos [Wed, 1 Jun 2011 04:46:55 +0000 (21:46 -0700)]
It’s still the 20th century?

13 years agoMake empty lvalue subs work correctly
Father Chrysostomos [Wed, 1 Jun 2011 04:32:28 +0000 (21:32 -0700)]
Make empty lvalue subs work correctly

In perl 5.8.1 and earlier, sub{} would return @_ in list context. This
was fixed in 5.8.2 for regular subs, but not lvalue subs.

Before the syntactic restriction on return values was removed in
commit 145b2bb, there was a bug affecting compilation of empty subs
before any use statement:

$ perl5.14.0 -e 'sub foo :lvalue {}'
Can't modify stub in lvalue subroutine return at -e line 1, near "{}"
Execution of -e aborted due to compilation errors.
$ perl5.14.0 -le 'use sigtrap; sub foo :lvalue {} print "ok"'
ok

But I digress. :-)

Up to 5.14, lvalue subs were still returning @_, or, rather, the ele-
ments of @_ as separate scalars:

$ perl5.14.0 -Mre -le '(sub :lvalue {}->($a,$b))=(3,4); print "$a $b"'
Useless use of "re" pragma at -e line 0
3 4

(Not exactly useless, eh? The -Mre allows the sub to compile.)

This commit fixes that bug.

13 years agoRemove a line added by the prev commit
Father Chrysostomos [Wed, 1 Jun 2011 03:07:32 +0000 (20:07 -0700)]
Remove a line added by the prev commit

Lvalue subs *can* return lists

13 years agoAccept lvalue subroutines as a useful feature.
Johan Vromans [Mon, 30 May 2011 06:03:03 +0000 (08:03 +0200)]
Accept lvalue subroutines as a useful feature.

Support for lvalue subroutines has been stable and reliable for more
than 10 years. Despite this, they are still marked as being
experimental.

This patch removes the 'experimental' warnings from the docs, and
adjusts the description accordingly.

13 years agoAllow rvalue syntax in expr returned from lvalue sub
Father Chrysostomos [Wed, 1 Jun 2011 01:13:43 +0000 (18:13 -0700)]
Allow rvalue syntax in expr returned from lvalue sub

This changes the syntax of the last statement and the arguments to
‘return’ in an lvalue subroutine to be the same as that of a non-
lvalue routine. This almost finishes the work begun by commit fa1e92c.
(return still needs to enforce the same rules as leavesublv.)

13 years agoAllow lvalue subs to return TEMPs
Father Chrysostomos [Wed, 1 Jun 2011 00:09:15 +0000 (17:09 -0700)]
Allow lvalue subs to return TEMPs

This is perhaps not ideal, but it fixes (or allows to be fixed) seve-
ral bugs.

I was hoping that the cases that this perhaps erroneously allows
through would fall back to the warning I added in commit 8fe85e3, but,
unfortunately, in all these cases the refcount is greater than 1 when
pp_sassign is reached.

To be less vague: ‘foo() = 3’ warns if foo() returns a TEMP with no
set-magic and a refcount of 1 (meaning it will be freed shortly). But
truly temporary values returned by pure-Perl lvalue subs have a refer-
ence count of at least 2, and as many entries on the mortals stack.

I cannot distinguish between truly temporary values and those that
are but nominally temporary (marked TEMP because the refcount will go
down, but not to zero) by checking for a refcount <= 2 in pp_sassign,
because this example returns with a refcount of 2:

+sub :lvalue { return delete($_[0]), $x }->($x) = 3; # returns a TEMP

There’s no logical reason why that shouldn’t work, if this does:

+sub :lvalue { return foo(), $x }->($x) = 3; # not TEMP

as they are conceptually identical.

The advantages to this change:

• The delete example above will work.
• It allows XS lvalue subs that return TEMPs to work in the debugger
  [perl #71172], restoring the bug fix that b724cc1 implemented but
  c73030b reverted.
• It makes these three cases identical, as they should be. Note that
  only two of them return TEMPs:
    +sub :lvalue { return shift }->($x) = 3;
    +sub :lvalue { \@_; return shift }->($x) = 3; # returns a TEMP
    +sub :lvalue { return delete $_[0] }->($x) = 3; # returns a TEMP

So I think the advantages outweigh the disadvantages.

13 years agoRevert "Allow returning of temps and ro’s from lv subs"
Father Chrysostomos [Tue, 31 May 2011 21:42:14 +0000 (14:42 -0700)]
Revert "Allow returning of temps and ro’s from lv subs"

This reverts commit b724cc14b25929aee44eee20bd26102cceb520b6.

Lvalue subroutines are more of a mess than I realised when I made
that commit.

I just tried removing the syntactical restriction on what the last
statement or the argument to return can be in an lvalue sub. It opened
a whole can of worms.

PADTMPs are bizarre creatures that have somewhat erratic behaviour.
Since assigning to a PADTMP is almost always a mistake (since the
value will definitely be discarded), those *should* be disallowed,
when the sub is called in lvalue context. That also avoids propagating
a whole load of bugs when referencing PADTMPs, aliasing to them, etc.

Read-only scalars end up triggering a ‘Modification of a read-only
value attempted’ message without the restrictions in pp_leavesublv,
but the message the latter was providing (which this revert restores)
is clearer (‘Can't return a readonly value from lvalue subroutine’).

Speaking of lvalue context, there are three types of context with
regard to lvalue-ness (orthogonal to the usual void/scalar/list
contexts):
• rvalue context ($x = func())
• lvalue context (func() = $x)
• semi-lvalue context (\func())

Each is handle by a separate code path in pp_leavesublv:
• rvalue context - any value can be returned; it’s copied (waste-
  ful, perhaps?)
• semi-lvalue context - any value can be returned; it’s not copied
• lvalue context - stringent rules about what can and cannot be
  returned (which this revert restores)

So it is perfectly fine to restrict what can be returned from an
lvalue sub *in true lvalue context*, without affected rvalue use.

Now, regarding TEMPs, although this commit restores the restriction on
returning TEMPs, a forthcoming commit will relax that restriction once
more, since it causes bugs.

13 years agoreflags.t: Remove no longer applicable TODO
Karl Williamson [Tue, 31 May 2011 15:22:13 +0000 (09:22 -0600)]
reflags.t: Remove no longer applicable TODO

When this test was written, t the new 5.14 regex modifiers were
not usable in suffix notation.  That changed before 5.14 shipped,
but the test did not.

13 years agoregcomp.c: Add comment
Karl Williamson [Tue, 31 May 2011 15:19:11 +0000 (09:19 -0600)]
regcomp.c: Add comment

13 years agoperlhack.pod: fix perlbug invocation
Jim Cromie (via RT) [Sun, 29 May 2011 01:39:48 +0000 (18:39 -0700)]
perlhack.pod: fix perlbug invocation

In perlhack,

  % perlbug -s "[PATCH] $(git log -1 --format=%s HEAD)" -f 0001-*.patch

is incomplete; --format=%s needs a proper value.
Use --oneline instead, as it also --abbrev(iates) sha1

$ git log --oneline -1
c8dfc96 regexp.h: repair linux perf compilation

Note that HEAD is optional, but just as clear as <branch-name>.

13 years ago[perl #91790] Perlguts documentation for sv_setref_pv
David Mitchell [Tue, 31 May 2011 12:45:55 +0000 (13:45 +0100)]
[perl #91790] Perlguts documentation for sv_setref_pv

The section of documentation in perlguts for the sv_setref_* functions
was ambiguous: it wasn't clear whether each paragraph was referring to
the function above or below it. Fix this by prepending lots of "The
following function...".

Also fix a couple of functions signatures.

13 years agoAllow lvalue subs to return COWs in list context
Father Chrysostomos [Tue, 31 May 2011 06:01:39 +0000 (23:01 -0700)]
Allow lvalue subs to return COWs in list context

Commit f71f472 missed list assignment. :-(

13 years agoAllow returning of temps and ro’s from lv subs
Father Chrysostomos [Tue, 31 May 2011 03:43:03 +0000 (20:43 -0700)]
Allow returning of temps and ro’s from lv subs

This commit removes the restriction on returning temps and read-only
scalars from lvalue subs that occurs when the sub returns implicitly
(with no ‘return’ statement; ‘return’ has never had that restriction).

It does not actually help pure-Perl lvalue subs much yet, as op.c
still enforces lvalue syntax on the last statement.

But this should fix bug #71172, allowing XS lvalue subs to work under
the debugger.

13 years ago[perl #72706] Test recursive substr lvalue
Father Chrysostomos [Tue, 31 May 2011 02:00:51 +0000 (19:00 -0700)]
[perl #72706] Test recursive substr lvalue

13 years agoMake explicit return in lvalue subs work under recursion
Father Chrysostomos [Tue, 31 May 2011 01:45:26 +0000 (18:45 -0700)]
Make explicit return in lvalue subs work under recursion

This is something that fa1e92c missed.

13 years agoBump DD’s version to 1.05
Father Chrysostomos [Mon, 30 May 2011 21:48:18 +0000 (14:48 -0700)]
Bump DD’s version to 1.05

5.14.1 is now using the number 1.04.

13 years agoAdd Craig DeForest to AUTHORS
Father Chrysostomos [Mon, 30 May 2011 16:52:36 +0000 (09:52 -0700)]
Add Craig DeForest to AUTHORS

13 years ago[perl #31946] Warn when assigning to a TEMP
Father Chrysostomos [Mon, 30 May 2011 16:49:36 +0000 (09:49 -0700)]
[perl #31946] Warn when assigning to a TEMP

This is the first step in downgrading a fatal error (Can't return a
temporary from lvalue subroutine) to a warning. Currently only XS
lvalue routines that return TEMPs and pure-Perl lvalue routines that
use explicit return (which don’t quite work properly yet anyway,
despite commit fa1e92c) are affected by this.

This is implemented in pp_sassign and pp_aassign, rather than
pp_leavesublv, so it will affect explicit returns and so it will
be skipped for overloaded ‘.=’, etc.

Thanks to Craig DeForest for suggesting how to do this.

13 years ago[perl #91880] $_ refcounting problems in @INC filters
Father Chrysostomos [Mon, 30 May 2011 15:55:40 +0000 (08:55 -0700)]
[perl #91880] $_ refcounting problems in @INC filters

In @INC filters (subs returned by subs in @INC), $_ is localised to a
variable to which the next line of source code is to be assigned. The
function in pp_ctl.c that calls it (S_run_user_filter) has a pointer
to that variable.

Up till now, it was not setting the refcount or localising
$_ properly.

‘undef *_’ inside the sub would destroy the only refcount it
had, leaving a freed sv for toke.c to parse (which would crash,
of course).

In some cases, S_run_user_filter has to created a new variable. In
those cases, it was setting $_ to a mortal variable with the TEMP
flag, but with a refcount of 1, which would result in ‘Attempt to free
unreferenced scalar’ warnings if the $_ were freed by the subroutine.

This commit changes S_run_user_filter to use SAVEGENERICSV, rather
than SAVE_DEFSV, to localise $_, since the former lowers the refcount
on scope exit, while the latter does not. So now I have also made it
increase the refcount after assigning to the now-properly-localised $_
(DEFSV). I also turned off the TEMP flag, to avoid weird side effects
(which were what led me to this bug to begin with).

13 years ago2nd try: [perl #91834] utf8::decode does not respect copy-on-write
Father Chrysostomos [Mon, 30 May 2011 03:39:33 +0000 (20:39 -0700)]
2nd try: [perl #91834] utf8::decode does not respect copy-on-write

I reverted the first version of this patch because I put the if()
statement before a declaration. I did a revert, rather than a correc-
tion, to make back-porting easier.

13 years agoRevert "[perl #91834] utf8::decode does not respect copy-on-write"
Father Chrysostomos [Mon, 30 May 2011 03:36:05 +0000 (20:36 -0700)]
Revert "[perl #91834] utf8::decode does not respect copy-on-write"

This reverts commit 40f11004fb3b5fa1cd207a20090df837d721b736.

13 years agomktables: Avoid possible user-defined property
Karl Williamson [Mon, 30 May 2011 03:14:51 +0000 (21:14 -0600)]
mktables: Avoid possible user-defined property

Properties with no elements are defined in terms of the complement
of the property which matches all of Unicode: \p{Any}.  But it
currently is defined in terms of IsAny, which is user-overridable;
Just drop the 'Is'

13 years ago[perl #91834] utf8::decode does not respect copy-on-write
Father Chrysostomos [Sun, 29 May 2011 21:21:06 +0000 (14:21 -0700)]
[perl #91834] utf8::decode does not respect copy-on-write

utf8::decode was not respecting copy-on-write, but simply modify-
ing the PV (the scalar’s string buffer) in place, causing problems
with hashes:

my $name = "\x{c3}\x{b3}";
my ($k1) = keys %{ { $name=>undef } };
my $k2 = $name;
utf8::decode($k1);
utf8::decode($k2);
print "k1 eq k2 = '", $k1 eq $k2, "'\n";
my $h = { $k1 => 1, $k2 => 2 };
print "{k1} '", $h->{$k1}, "'\n";
print "{k2} '", $h->{$k2}, "'\n";

This example (from the RT ticket) shows that there were two hash ele-
ments with the same key.

As of this commit, the hash only has one element.

13 years agoCorrect English
Father Chrysostomos [Sun, 29 May 2011 20:07:20 +0000 (13:07 -0700)]
Correct English

13 years agoformats: allow > 256 decimal places
David Mitchell [Sun, 29 May 2011 19:17:14 +0000 (20:17 +0100)]
formats: allow > 256 decimal places

Currently bits 256 and 512 of the floating point len arg are used to
flag extra things. Since we have 32-bit args now, change these bits
to higher ones so there's no such arbitrary restriction.

Also, define two symbolic constants rather than hard-coding in the bit
values.

13 years agoAllow formats with lines >64K
David Mitchell [Sun, 29 May 2011 18:54:58 +0000 (19:54 +0100)]
Allow formats with lines >64K

Back in 2003, the format bytecode was changed to allow 32-bit offsets,
but all the stored offsets were still being cast to U16. So for example
only the first char of a 65537 char literal would be output.

This commit removes all the U16 casts.

13 years agopp_formline: handle growing better
David Mitchell [Sun, 29 May 2011 18:27:56 +0000 (19:27 +0100)]
pp_formline: handle growing better

We initially grow PL_formtarget by the largest amount a formline can
append (since formats are fixed width). The only thing that can exceed
that is @*; but also, if PL_formtarget gets upgraded to utf8, then some of
the extra buffer we allocated can get eaten up by the upgrade.

Codify this so we only grow when necessary, but always enough.

Prior to this commit, we were growing FF_ITEM/FF_LITERAL too much, and
FF_LINEGLOB too little (the latter being my mistake from a few commits
ago).

Also rename 'fudge' to 'linemax', to give a better idea what it's for.

13 years agopp_formline: keep linemark consistent
David Mitchell [Sun, 29 May 2011 16:13:07 +0000 (17:13 +0100)]
pp_formline: keep linemark consistent

linemark is a pointer to the current start of the line. This allows
things like ~ to delete back to the start of the line.

Convert it into an offset, so that it isn't invalidated if PL_formtarget
is reallocated. Also recalculate it if PL_formtarget is upgraded to utf8.

13 years agopp_formline: make FF_ITEM use FF_LINEGLOB code
David Mitchell [Sun, 29 May 2011 15:07:36 +0000 (16:07 +0100)]
pp_formline: make FF_ITEM use FF_LINEGLOB code

Now that we've got the two chunks of append code similar enough to each
other, make FF_ITEM just goto into the append part of the FF_LINEGLOB
code.

13 years agopp_formline: make FF_LITERAL use FF_LINEGLOB code
David Mitchell [Sun, 29 May 2011 13:29:45 +0000 (14:29 +0100)]
pp_formline: make FF_LITERAL use FF_LINEGLOB code

Now that we've got the two chunks of append code similar enough to each
other, make FF_LITERAL just goto into the append part of the FF_LINEGLOB
code.

13 years agopp_formline: don't overgrow PL_formtarget
David Mitchell [Sun, 29 May 2011 13:01:11 +0000 (14:01 +0100)]
pp_formline: don't overgrow PL_formtarget

In various places, PL_formtarget is grown by fudge bytes.
But fudge is already equal to the whole width of the format line,
and PL_formtarget is pre-grown by fudge at the start, so normally
there's no need to extend it further. So don't.
Instead, only grow it by the amount needed (which will ormally be nothing)
as a safety measure.

Also add an assert at the end to check that we haven't overrun the buffer.

13 years agopp_formline: no need to *t = '\0' until end
David Mitchell [Sun, 29 May 2011 12:34:31 +0000 (13:34 +0100)]
pp_formline: no need to *t = '\0' until end

We don't care whether PL_formtarget has a trailling \0 until we return;
so remove the bits where we add one in between.

13 years agopp_formline: FF_LINEGLOB: always SvCUR_set
David Mitchell [Sun, 29 May 2011 12:03:54 +0000 (13:03 +0100)]
pp_formline: FF_LINEGLOB: always SvCUR_set

The code currently does SvCUR_set(PL_formtarget,...) in three out of four
of the condition branches. Since it's harmless to do it also for the
fourth, remove the three individual SvCUR_set()s and replace with a single
unconditional one.

13 years agopp_formline: don't set itemsize in FF_LINEGLOB
David Mitchell [Sun, 29 May 2011 11:41:42 +0000 (12:41 +0100)]
pp_formline: don't set itemsize in FF_LINEGLOB

This var is used to enable padding or truncating of output items.
FF_LINESNGL/FF_LINEGLOB do their own version of this, so there's
no need to set it there.

Or to put it another way, we don't expect a FF_LINESNGL or FF_LINEGLOB op
to be followed immediately by FF_SPACE, FF_HALFSPACE, FF_ITEM nor FF_MORE.

Not calculating it makes the code simpler and eases the path to merging
the appending code.

13 years agopp_formline: make FF_LITERAL use item_is_utf8 flag
David Mitchell [Sun, 29 May 2011 11:16:23 +0000 (12:16 +0100)]
pp_formline: make FF_LITERAL use item_is_utf8 flag

This is in preparation for merging with the FF_LINEGLOB code.
Should be no change in functionality.

13 years agopp_formline: don't do get mg on PL_formtarget
David Mitchell [Sat, 28 May 2011 14:59:05 +0000 (15:59 +0100)]
pp_formline: don't do get mg on PL_formtarget

Two of the three branches that upgrade PL_formtarget to utf8 (FF_LITERAL,
FF_ITEM) do get magic while doing so, while the third (FF_LINEGLOB)
doesn't. I think the first two were just co-incidental
(they started out as simple sv_utf8_upgrade() calls added by
1bd51a4ce2ce8, and probably no consideration was given as to whether to
use the _nomg variant instead).

Make the first two no longer call magic, to be consistent with
FF_LINEGLOB.

13 years agopp_formline: split FF_LINEGLOB into two blocks
David Mitchell [Sat, 28 May 2011 14:17:37 +0000 (15:17 +0100)]
pp_formline: split FF_LINEGLOB into two blocks

The second block is shortly going to be used by others too

13 years agopp_formline: FF_LINEGLOB: hoist 2 vars to fn scope
David Mitchell [Sat, 28 May 2011 14:13:27 +0000 (15:13 +0100)]
pp_formline: FF_LINEGLOB: hoist 2 vars to fn scope

more groundwork for making the code in FF_LINEGLOB re-usable

13 years agopp_formline: reduce indent in FF_LINEGLOB
David Mitchell [Sat, 28 May 2011 13:56:54 +0000 (14:56 +0100)]
pp_formline: reduce indent in FF_LINEGLOB

change

    {
        block
    }

to

    block

(the diff looks more confusing than it actually is).

No code changes.

13 years agopp_formline: restruture FF_LINEGLOB
David Mitchell [Sat, 28 May 2011 13:52:41 +0000 (14:52 +0100)]
pp_formline: restruture FF_LINEGLOB

change

    if (linebreak) {
        decl;
        ....
    }

to
    decl;
    if (!linebreak)
        break;

    {
        ....
    }

shouldn't change the meaning of the code but will allow us to remove one
level of indentation and begin to reuse that block of code

13 years agopp_formline: combine two similar code chunks
David Mitchell [Fri, 27 May 2011 12:35:25 +0000 (13:35 +0100)]
pp_formline: combine two similar code chunks

FF_BLANK and FF_END do almost identical tidying up before returning

13 years agostop ~ in format modifying format string
David Mitchell [Thu, 26 May 2011 07:57:07 +0000 (08:57 +0100)]
stop ~ in format modifying format string

Currently, the format parser converts ~ or ~~ in a format string into
blank spaces. Since the previous-but-one commit, it only does it in a copy
rather than the original string, but this still defeats the "if the string
is the same don't recompile" mechanism.

Fix this by leaving the ~ alone in the format string, but instead cause
FF_LITERAL to convert '~' to ' ' when appending to the target.

Also, in S_doparseform(), improve the processing of '~~': previously
it only skipped one '~', and processed the second '~' on the next loop;
this happened to work, but it's less unexpected to process both chars at
once.

I've also added some tests, but these don't actually test whether the
format gets re-compiled: I couldn't think of a way to do that short of
checking the output of perl -Df. Instead the tests I added were based
around making sure I didn't break anything related to ~~ formatting.

I also improved the description string for some of the existing tests.

13 years agobetter document format code
David Mitchell [Wed, 25 May 2011 12:46:01 +0000 (13:46 +0100)]
better document format code

add descriptions of:
    format op constants
    local vars
    code blocks
to generally make navigating the format code easier.
(Oh, and fix one incorrect indent).

No code changes.

13 years agoRT #91032: formline: bugs with non-string formats
David Mitchell [Tue, 24 May 2011 16:08:51 +0000 (17:08 +0100)]
RT #91032: formline: bugs with non-string formats

When the format SV used by formline isn't a simple POK (such as
ties, overloads, or stringified refs), many many things go wrong,
and SEGVs ensue.

Originally, pp_formline forced the SV to a PV, and then assumed it could
rely on the resulting SvPVX value. Recent commits fixed this to
skip the force (good), but then broke things such as:

* in the absence of POK or pPOK, $^A was grown by 0 bytes rather than the
length of the format, so the buffer overran;

* the compiled format stored indexes into the original format string
  to refer to chunks of content text and the like. If there's no real
  SvPVX around, that's bad.

* Stuff like tie and overload could return different format strings on
  each get, but the format would not be re-compiled (but would index into
  the new string anyway)

Also, the format compiler would convert strings like '~~' into blanks
in the original format SV.

The easiest way to fix all these is to save a copy of the original string
at the time it is compiled. This can conveniently be stored in the mg_obj
slot of the fm magic (the compiled format already goes in mg_ptr).

This way we're always guaranteed to have an unadulterated copy of the
string to mess with.

Also, the ~~ self-modification now happens to the copy rather than the
original.

Now each time formline is called, we also compare the current value of the
SV with the stored copy, and if it's changed (e.g. tie with a FETCH that
returns different values each time), then we recompile.

Note that the recompile test is currently defeated by the ~~ modification,
so re-compiles unnecessarily (but safely) in that case. A fix for that is
coming next.

13 years agoMake sigblocking tests more independent
Leon Timmermans [Sun, 29 May 2011 10:59:49 +0000 (12:59 +0200)]
Make sigblocking tests more independent

On VMS, there seems to be a bug when using sigprocmask after sigsuspend.
This patch prevents that failure from cascading to the next couple of
tests.

13 years agoperlre: Fix some line wrap issues
Karl Williamson [Sat, 28 May 2011 22:19:39 +0000 (16:19 -0600)]
perlre: Fix some line wrap issues

This fixes some verbatim text exceeding an 80 column window by shortening
two =over amounts.

13 years agoperlre: Fix some line wrap issues
Karl Williamson [Sat, 28 May 2011 22:16:43 +0000 (16:16 -0600)]
perlre: Fix some line wrap issues

This fixes some issues with the pod wrapping verbatim in 80 column
windows by indenting less, and not having the comments so far to the
right

13 years agoperlre: Change C<> to L<>
Karl Williamson [Sat, 28 May 2011 22:04:03 +0000 (16:04 -0600)]
perlre: Change C<> to L<>

13 years agoperlrun: Add link to clarification
Karl Williamson [Sat, 28 May 2011 21:52:35 +0000 (15:52 -0600)]
perlrun: Add link to clarification

13 years agoUpgrade Data::Dumper to 2.131
Steffen Mueller [Sat, 28 May 2011 12:17:25 +0000 (14:17 +0200)]
Upgrade Data::Dumper to 2.131

This has no functional changes, just updating the version
and change log to match the stable CPAN release.

13 years agofeature.pm: Improve pod wording
Johan Vromans [Sat, 28 May 2011 02:57:58 +0000 (20:57 -0600)]
feature.pm: Improve pod wording

13 years ago[perl #72724] explicit return doesn’t work with lvalue subs
Father Chrysostomos [Fri, 27 May 2011 13:26:10 +0000 (06:26 -0700)]
[perl #72724] explicit return doesn’t work with lvalue subs

Now it does.

13 years agopodcheck.t: Guard against transitory files
Karl Williamson [Fri, 27 May 2011 14:28:59 +0000 (08:28 -0600)]
podcheck.t: Guard against transitory files

podcheck uses File::Find to look for pods in the directory structure.
It is possible for the Find to find a transitory file that is gone by
the time the file is opened for examination.  This patch will simply
skip the transitory file if the open fails and it's because it no longer
exists.  (There is a tiny window in which the open could fail, and
the file gets recreated and hence passes the exists test, but I'm not
bothering to code for that until it actually happens.)

13 years agoAdd more to-do tests for explicit return from lvalue sub
Father Chrysostomos [Fri, 27 May 2011 05:17:29 +0000 (22:17 -0700)]
Add more to-do tests for explicit return from lvalue sub

Commit 1c4274f4e11 added the first of these, copying them from the top
of the test script and adding ‘return’ to the functions, but it appar-
ently missed about 15.

13 years agoMove a test to the right file
Father Chrysostomos [Fri, 27 May 2011 05:01:07 +0000 (22:01 -0700)]
Move a test to the right file

sub_lval.t is for lvalue subs, not built-ins.

13 years agoregcomp.c: Fix memory leak regression
Nicholas Clark [Fri, 27 May 2011 04:29:40 +0000 (22:29 -0600)]
regcomp.c: Fix memory leak regression

There was a remaining memory leak in the new inversion lists data
structure under threading.  This solves it by changing the
implementation to use a SVpPV instead of doing our own memory
management.  Then the already existing code for handling SVs
returns the memory when done.

13 years agopodcheck.t: Add comment, explicit return
Karl Williamson [Thu, 26 May 2011 18:48:05 +0000 (12:48 -0600)]
podcheck.t: Add comment, explicit return

13 years agopodcheck.t: Skip broken symbolic links
Karl Williamson [Thu, 26 May 2011 18:39:30 +0000 (12:39 -0600)]
podcheck.t: Skip broken symbolic links

This stemmed from a build issue in some smokers.  The symbolic link 'U'
was left over.  If another type of file can't be opened, instead of
dying, this now just fails it as one test.

13 years agopodcheck.t: Skip some more non-pod files
Karl Williamson [Thu, 26 May 2011 18:35:42 +0000 (12:35 -0600)]
podcheck.t: Skip some more non-pod files

This skips editor droppings.

13 years agopodcheck.t: Force non-utf8 reading of files
Karl Williamson [Wed, 25 May 2011 19:15:27 +0000 (13:15 -0600)]
podcheck.t: Force non-utf8 reading of files

podcheck.t was failing when PERL_UNICODE was set to empty with
a UTF-8 locale, as it tried to read things in utf8 that aren't.
This led to a fatal malformed utf8 error.

This forces the :bytes layer when reading these files.

13 years ago[perl #91614] Suggestion for improving documentation of $!
John P. Linderman [Wed, 25 May 2011 15:36:27 +0000 (08:36 -0700)]
[perl #91614] Suggestion for improving documentation of $!

While trying to understand a bug report at

http://www.perlmonks.org/?node_id=906466

I realized that the documentation for $! was not crystal clear.  For example

    If used numerically, yields the current value of the
    C C<errno> variable, or in other words,
    if a system or library call fails, it sets this variable.

That's not "in other words", these are totally different
concepts.  And it isn't clear whether this variable refers to
errno or $! (I assumed the latter, and was wrong, as Devel::Peek
demonstrated).  And $! cannot be undef, as asserted (later),
because errno always contains a value, however irrelevant.

13 years agopodcheck.t: Skip files left by patch
Father Chrysostomos [Wed, 25 May 2011 03:19:55 +0000 (20:19 -0700)]
podcheck.t: Skip files left by patch