In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/975dff8cb7ca2790d93d15cbb8bad4c681ec8a89?hp=a9d1f3db5a529ac550078ac70fd09b9808b0c505>

- Log -----------------------------------------------------------------
commit 975dff8cb7ca2790d93d15cbb8bad4c681ec8a89
Author: Father Chrysostomos <spr...@cpan.org>
Date:   Tue Jun 7 20:44:28 2011 -0700

    perldelta entries for lvalue and COW fixes

M       pod/perldelta.pod

commit c31d159012baaf8e43a86fc060b715a9fa298b55
Author: Father Chrysostomos <spr...@cpan.org>
Date:   Tue Jun 7 20:36:39 2011 -0700

    Regenerate known_pod_issues.dat

M       t/porting/known_pod_issues.dat

commit 760696b85aa55406ecf251d07bdb61b0f14a05a2
Author: Father Chrysostomos <spr...@cpan.org>
Date:   Tue Jun 7 20:30:24 2011 -0700

    Update perldelta with entries copied from 5.14.1
    
    Since I just updated 5.14.1’s perldelta, it made sense to go ahead and
    do this.  For a list of the commits that are dealt with here, log into
    cherrymaint and look for anything recent marked ‘Cherry-picked’.
    
    I did not bother including the Ubuntu library path and Darwin test
    fixes.  I don’t think they are worth mentioning, but others may disa-
    gree... (‘may’ in both senses).

M       pod/perldelta.pod

commit 2aa629fafc4af31b65bb83bf556fee79269eec05
Author: Father Chrysostomos <spr...@cpan.org>
Date:   Tue Jun 7 17:56:06 2011 -0700

    Remove unnecessary TAINT_NOT
    
    (Ignore this for perldelta.)
    
    *++newsp = *MARK obviously does no tainting.  The TAINT_NOT following
    it was unnecessarily copied to S_return_lvalues from pp_return when
    the former came into existence.  (pp_return does need TAINT_NOT, as it
    uses sv_mortalcopy, which calls sv_setsv_flags, which does tainting.)

M       pp_ctl.c

commit e08be60b99b393465a58e174337c5e8237231b1f
Author: Father Chrysostomos <spr...@cpan.org>
Date:   Tue Jun 7 17:05:06 2011 -0700

    [perl #92290, #92406] Returning a pad var from lv sub
    
    This fixes a recent (post-5.14.0) regression.
    
    Commit bf8fb5e (the fix for #62498) introduced it for lvalue subs with
    no return statement [perl #92406].
    Commit fa1e92c (the fix for #72724) introduced it for lvalue subs that
    do have an explicit return [perl #92290].
    
    Simply returning a scalar itself from an lvalue sub does not work if
    it is a pad variable with a reference count of 1.  In that circum-
    stance, the sub-popping code sees that the SV can be re-used the next
    time the sub is called, so it undefines it and hangs on to it.  So
    the scalar returned gets emptied before the calling code can see it.
    
    The reference count has to be increased temporarily, which sv_2mortal
    and SvREFCNT_inc combined accomplish.

M       pp_ctl.c
M       pp_hot.c
M       t/op/sub_lval.t

commit d507ecb9ce86ef53117ff81c35d0686965c6b715
Author: Father Chrysostomos <spr...@cpan.org>
Date:   Tue Jun 7 16:09:17 2011 -0700

    Correct test names in sub_lval.t

M       t/op/sub_lval.t
-----------------------------------------------------------------------

Summary of changes:
 pod/perldelta.pod              |  229 ++++++++++++++++++++++++++++++++++++++-
 pp_ctl.c                       |   15 ++-
 pp_hot.c                       |   12 ++-
 t/op/sub_lval.t                |   14 +++-
 t/porting/known_pod_issues.dat |    2 +-
 5 files changed, 259 insertions(+), 13 deletions(-)

diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 70acfc8..a47980a 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -16,6 +16,9 @@ If you are upgrading from an earlier release such as 
5.YYY.YYY, first read
 L<perl5YYYdelta>, which describes differences between 5.ZZZ.ZZZ and
 5.YYY.YYY.
 
+Some of the changes have been included in Perl 5.14.1.  These are
+indicated with a "(5.14.1)" marker.
+
 =head1 Notice
 
 XXX Any important notices here
@@ -95,6 +98,35 @@ L<B> has been upgraded from version 1.29 to version 1.30.
 
 =item *
 
+L<B::Deparse> has been upgraded from version 1.03 to 1.05.
+
+It addresses two regressions in Perl 5.14.0:
+
+=over
+
+=item *
+
+Deparsing of the C<glob> operator and its diamond (C<< <> >>) form now
+works again [RT #90898] (5.14.1).
+
+=item *
+
+The presence of subroutines named C<::::> or C<::::::> no longer causes
+B::Deparse to hang (5.14.1).
+
+=back
+
+XXX Other Deparse fixes go here.
+
+=item *
+
+L<Devel::Peek> has been upgraded from version 1.07 to 1.08.
+
+Its C<fill_mstats> function no longer refuses to write to copy-on-write
+scalars.
+
+=item *
+
 L<Math::Complex> has been upgraded from version 1.56 to version 1.57.
 
 Correct copy constructor usage.
@@ -107,8 +139,28 @@ L<PerlIO::encoding> has been upgraded from version 0.14 to 
0.15
 
 =item *
 
+L<PerlIO::scalar> has been upgraded from version 0.11 to 0.12.
+
+It fixes a problem with C<< open my $fh, ">", \$scalar >> not working if
+C<$scalar> is a copy-on-write scalar.
+
+=item *
+
+XXX If any changes are made, the version will need to be bumped again.
+What blead has is currently (as of a9d1f3db, 7th of June) identical to
+5.14.1's version.
+
+L<Pod::Perldoc> has been upgraded from version 3.15_03 to 3.15_04.
+
+It corrects the search paths on VMS [RT #90640].
+
+=item *
+
 L<Storable> has been upgraded from version 2.27 to version 2.28.
 
+It no longer turns copy-on-write scalars into read-only scalars when
+freezing and thawing.
+
 =item *
 
 L<Time::HiRes> has been upgraded from version 1.9721_01 to version 1.9722.
@@ -156,13 +208,61 @@ XXX Changes which significantly change existing files in 
F<pod/> go here.
 However, any changes to F<pod/perldiag.pod> should go in the L</Diagnostics>
 section.
 
-=head3 L<XXX>
+=head3 L<perlfunc>
+
+=over
+
+=item *
+
+C<given>, C<when> and C<default> are now listed in L<perlfunc> (5.14.1).
+
+=back
+
+=head3 L<perllol>
+
+=over
+
+=item *
+
+L<perllol> has been expanded with examples using the new C<push $scalar>
+syntax introduced in Perl 5.14.0 (5.14.1).
+
+=back
+
+=head3 L<perlop>
 
 =over 4
 
 =item *
 
-XXX Description of the change here
+The explanation of bitwise operators has been expanded to explain how they
+work on Unicode strings (5.14.1).
+
+=item *
+
+The section on the triple-dot or yada-yada operator has been moved up, as
+it used to separate two closely related sections about the comma operator
+(5.14.1).
+
+=item *
+
+More examples for C<m//g> have been added (5.14.1).
+
+=item *
+
+The C<<< <<\FOO >>> here-doc syntax has been documented (5.14.1).
+
+=back
+
+=head3 L<perlrun>
+
+=over
+
+=item *
+
+L<perlrun> has undergone a significant clean-up.  Most notably, the
+B<-0x...> form of the B<-0> flag has been clarified, and the final section
+on environment variables has been corrected and expanded (5.14.1).
 
 =back
 
@@ -185,7 +285,9 @@ XXX Newly added diagnostic messages go here
 
 =item *
 
-XXX
+Assigning to a temporary scalar returned from an XS lvalue subroutine now
+produces a warning: "Useless assignment to a temporary".  This should help
+PDL users [RT #31946].
 
 =back
 
@@ -233,7 +335,8 @@ L</Platform Support> section, instead.
 
 =item *
 
-XXX
+F<regexp.h> has been modified for compatibility with GCC's B<-Werror>
+option, as used by some projects that include perl's header files (5.14.1).
 
 =back
 
@@ -346,7 +449,7 @@ succeeded inaprropriately.  This is now fixed.
 =item *
 
 5.14.0 introduced some memory leaks in regular expression character
-classes such as C<[\w\s]>, which have now been fixed.
+classes such as C<[\w\s]>, which have now been fixed (5.14.1).
 
 =item *
 
@@ -359,7 +462,7 @@ portion of the fold, plus some more.
 
  "s\N{U+DF}" =~ /[\x{DF}foo]/i
 
-is one such case.  C<\xDF> folds to C<"ss">
+is one such case.  C<\xDF> folds to C<"ss"> (5.14.1).
 
 =item *
 
@@ -387,6 +490,120 @@ with ties and overloading), and where the format and data 
differ in their
 encoding. In both these cases, it used to possible for the output to be
 corrupted.
 
+=item *
+
+A bug has been fixed that would cause a "Use of freed value in iteration"
+error if the next two hash elements that would be iterated over are
+deleted [RT #85026] (5.14.1).
+
+=item *
+
+Passing the same constant subroutine to both C<index> and C<formline> no
+longer causes one or the other to fail [RT #89218] (5.14.1).
+
+=item *
+
+XXX Someone tell me whether this first clause is correct (see commit
+765f542d):
+
+Copy-on-write scalars were introduced in 5.10.0.  These occur when
+C<__PACKAGE__> or a hash key is a assigned to a scalar.  Several parts
+of Perl were not updated to account for them, but have now been fixed:
+
+=over
+
+=item *
+
+C<utf8::decode> had a nasty bug that would modify copy-on-write scalars'
+string buffers in place (i.e., skipping the copy).  This could result in
+hashes having two elements with the same key [RT #91834].
+
+=item *
+
+Lvalue subroutines were not allowing COW scalars to be returned.  This was
+fixed for lvalue scalar context in Perl 5.12.3 and 5.14.0, but list context
+was not fixed until this release.
+
+=item *
+
+Elements of restricted hashes (see the L<fields> pragma) containing
+copy-on-write values couldn't be deleted, nor could such hashes be cleared
+(C<%hash = ()>).
+
+=item *
+
+Localising a tied variable used to make it read-only if it contained a
+copy-on-write string.
+
+=item *
+
+L<Storable>, L<Devel::Peek> and L<PerlIO::scalar> had similar problems.
+See L</Updated Modules and Pragmata>, above.
+
+=back
+
+=item *
+
+There have been various fixes to lvalue subroutines:
+
+XXX Should these first three go under New Features?
+
+=over
+
+=item *
+
+Explicit return now returns the actual argument passed to return, instead
+of copying it [RT #72724].
+
+=item *
+
+Lvalue subroutines used to enforce lvalue syntax (i.e., whatever can go on
+the left-hand side of C<=>) for the last statement and the arguments to
+return.  Since lvalue subroutines are not always called in lvalue context,
+this restriction has been lifted.
+
+=item *
+
+Lvalue subroutines are less restrictive as to what values can be returned.
+It used to croak on values returned by C<shift> and C<delete> and from
+other subroutines, but no longer does so.
+
+=item *
+
+Empty lvalue subroutines (C<sub :lvalue {}>) used to return C<@_> in list
+context.  In fact, all subroutines used to, but regular subs were fixed in
+Perl 5.8.2.  Now lvalue subroutines have been likewise fixed.
+
+=item *
+
+Lvalue subroutines used to copy their return values in rvalue context.  Not
+only was this a waste of CPU cycles, but it also caused bugs.  A C<($)>
+prototype would cause an lvalue sub to copy its return value [RT #62498],
+and C<while(lvalue_sub() =~ m/.../g) { ... }> would loop endlessly
+[RT #78680].
+
+=item *
+
+Autovivification now works on values returned from lvalue subroutines
+[RT #7946].
+
+=item *
+
+XXX This entry is probably too sarcastic in its use of "inanities".  But
+I'm too tired to think of a better wording.
+
+When called in pass-by-reference context (e.g., subroutine arguments or a
+list passed to C<for>), an lvalue subroutine returning arrays or hashes
+used to bind the arrays (or hashes) to scalar variables--something that is
+not supposed to happen.  This could result in "Bizzare copy of ARRAY"
+errors or C<print> ignoring its arguments.  It also made inanities like
+C<@{\$_}> "work".  This was fixed in 5.14.0 if an array were the first
+thing returned from the subroutine (but not for C<$scalar, @array> or
+hashes being returned).  Now a more general fix has been applied
+[RT #23790].
+
+=back
+
 =back
 
 =head1 Known Problems
diff --git a/pp_ctl.c b/pp_ctl.c
index eed88f8..c600a91 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2227,7 +2227,11 @@ S_return_lvalues(pTHX_ SV **mark, SV **sp, SV **newsp, 
I32 gimme,
                        sv_2mortal(*newsp);
                }
                else
-                   *++newsp = *SP;
+                   *++newsp =
+                       (!CxLVAL(cx) || CxLVAL(cx) & OPpENTERSUB_INARGS) &&
+                       !SvTEMP(*SP)
+                         ? sv_2mortal(SvREFCNT_inc_simple_NN(*SP))
+                         : *SP;
        }
        else
            *++newsp = &PL_sv_undef;
@@ -2249,9 +2253,14 @@ S_return_lvalues(pTHX_ SV **mark, SV **sp, SV **newsp, 
I32 gimme,
     }
     else if (gimme == G_ARRAY) {
        assert (!(CxLVAL(cx) & OPpENTERSUB_DEREF));
-       while (++MARK <= SP) {
+       if (!CxLVAL(cx) || CxLVAL(cx) & OPpENTERSUB_INARGS)
+           while (++MARK <= SP)
+               *++newsp =
+                    SvTEMP(*MARK)
+                      ? *MARK
+                      : sv_2mortal(SvREFCNT_inc_simple_NN(*MARK));
+       else while (++MARK <= SP) {
            *++newsp = *MARK;
-           TAINT_NOT;          /* Each item is independent */
        }
     }
     PL_stack_sp = newsp;
diff --git a/pp_hot.c b/pp_hot.c
index cd556f3..8d02826 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -2802,7 +2802,9 @@ PP(pp_leavesublv)
                        sv_2mortal(*MARK);
                }
                else
-                   *MARK = TOPs;
+                   *MARK = SvTEMP(TOPs)
+                             ? TOPs
+                             : sv_2mortal(SvREFCNT_inc_simple_NN(TOPs));
            }
            else {
                MEXTEND(MARK, 0);
@@ -2810,6 +2812,13 @@ PP(pp_leavesublv)
            }
            SP = MARK;
        }
+       else if (gimme == G_ARRAY) {
+         rvalue_array:
+           for (MARK = newsp + 1; MARK <= SP; MARK++) {
+               if (!SvTEMP(*MARK))
+                   *MARK = sv_2mortal(SvREFCNT_inc_simple_NN(*MARK));
+           }
+       }
     }
 
     if (CxLVAL(cx) & OPpENTERSUB_DEREF) {
@@ -2829,7 +2838,6 @@ PP(pp_leavesublv)
        }
     }
 
-  rvalue_array:
     PUTBACK;
 
     LEAVE;
diff --git a/t/op/sub_lval.t b/t/op/sub_lval.t
index a149a38..a9ff88b 100644
--- a/t/op/sub_lval.t
+++ b/t/op/sub_lval.t
@@ -3,7 +3,7 @@ BEGIN {
     @INC = '../lib';
     require './test.pl';
 }
-plan tests=>151;
+plan tests=>155;
 
 sub a : lvalue { my $a = 34; ${\(bless \$a)} }  # Return a temporary
 sub b : lvalue { ${\shift} }
@@ -767,6 +767,7 @@ for my $sub (sub :lvalue {$_}, sub :lvalue {return $_}) {
 continue { $suffix = ' (explicit return)' }
 
 # autovivification
+$suffix = '';
 for my $sub (sub :lvalue {$_}, sub :lvalue {return $_}) {
     undef $_;
     &$sub()->[3] = 4;
@@ -785,3 +786,14 @@ for my $sub (sub :lvalue {$_}, sub :lvalue {return $_}) {
     is join('-',%$_), '4-5', '%{func()} autovivification'.$suffix;
 }
 continue { $suffix = ' (explicit return)' }
+
+# [perl #92406] [perl #92290] Returning a pad var in rvalue context
+$suffix = '';
+for my $sub (
+         sub :lvalue { my $x = 72; $x },
+         sub :lvalue { my $x = 72; return $x }
+) {
+    is scalar(&$sub), 72, "sub returning pad var in scalar context$suffix";
+    is +(&$sub)[0], 72, "sub returning pad var in list context$suffix";
+}
+continue { $suffix = ' (explicit return)' }
diff --git a/t/porting/known_pod_issues.dat b/t/porting/known_pod_issues.dat
index 80c77fb..d325aa8 100644
--- a/t/porting/known_pod_issues.dat
+++ b/t/porting/known_pod_issues.dat
@@ -212,7 +212,7 @@ pod/perldebtut.pod  Verbatim line length including indents 
exceeds 80 by    22
 pod/perldebug.pod      ? Should you be using L<...> instead of 2
 pod/perldebug.pod      Verbatim line length including indents exceeds 80 by    
3
 pod/perldelta.pod      Apparent broken link    1
-pod/perldelta.pod      Apparent internal link is missing its forward slash     
4
+pod/perldelta.pod      Apparent internal link is missing its forward slash     
3
 pod/perldelta.pod      Pod NAME already used   2
 pod/perldiag.pod       =item type mismatch     1
 pod/perldiag.pod       Verbatim line length including indents exceeds 80 by    
2

--
Perl5 Master Repository

Reply via email to