In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/e3a09cfbb80ddcd428e9868bcf0a818a8c8cae0c?hp=e74036d119d0e671765ea56042a585158a686d2c>

- Log -----------------------------------------------------------------
commit e3a09cfbb80ddcd428e9868bcf0a818a8c8cae0c
Author: Father Chrysostomos <[email protected]>
Date:   Thu Sep 4 12:52:39 2014 -0700

    toke.c: Avoid extra sv_setpv for foo <newline> =>
    
    When parsing something like
    
        time
           =>
    
    if there is a global override, the parser transforms ‘time’ into
    ‘CORE::GLOBAL::time’ before it looks at the next line to see if there
    is a fat arrow.
    
    If it finds a fat arrow, it has to set the name back to ‘time’.
    
    After finding a fat arrow on the line following a bareword, it was
    setting the name to what appears in the program source, even when
    there was no global override.  We can skip that most of the time.
    
    All that I said about global overrides applies to ‘our’ subs, too.
    ‘foo’ gets transformed into ‘ThatPackage::foo’ and needs to be 
changed
    back.  I added a test, to make sure that is not accidentally broken.
    
    I took the liberty of changing ((SVOP*)pl_yylval.opval)->op_sv to sv
    at the same time, to make the code more readable.
-----------------------------------------------------------------------

Summary of changes:
 t/op/lexsub.t |  5 ++++-
 toke.c        | 18 +++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/t/op/lexsub.t b/t/op/lexsub.t
index 50472d9..1efcf1c 100644
--- a/t/op/lexsub.t
+++ b/t/op/lexsub.t
@@ -7,7 +7,7 @@ BEGIN {
     *bar::is = *is;
     *bar::like = *like;
 }
-plan 132;
+plan 133;
 
 # -------------------- Errors with feature disabled -------------------- #
 
@@ -108,6 +108,9 @@ sub F::h { 4242 }
   print "\n";
   is $called, undef, 'our sub symbol translation & meth names after print'
 }
+our sub j;
+is j
+  =>, 'j', 'name_of_our_sub <newline> =>  is parsed properly';
 
 # -------------------- state -------------------- #
 
diff --git a/toke.c b/toke.c
index 2a13031..87a34dc 100644
--- a/toke.c
+++ b/toke.c
@@ -6611,13 +6611,17 @@ Perl_yylex(pTHX)
                if (*s == '=' && s[1] == '>' && !pkgname) {
                    op_free(rv2cv_op);
                    CLINE;
-                   /* This is our own scalar, created a few lines above,
-                      so this is safe. */
-                   SvREADONLY_off(cSVOPx(pl_yylval.opval)->op_sv);
-                   sv_setpv(((SVOP*)pl_yylval.opval)->op_sv, PL_tokenbuf);
-                   if (UTF && !IN_BYTES && is_utf8_string((U8*)PL_tokenbuf, 
len))
-                     SvUTF8_on(((SVOP*)pl_yylval.opval)->op_sv);
-                   SvREADONLY_on(cSVOPx(pl_yylval.opval)->op_sv);
+                   if (gvp || (lex && !off)) {
+                       assert (cSVOPx(pl_yylval.opval)->op_sv == sv);
+                       /* This is our own scalar, created a few lines
+                          above, so this is safe. */
+                       SvREADONLY_off(sv);
+                       sv_setpv(sv, PL_tokenbuf);
+                       if (UTF && !IN_BYTES
+                        && is_utf8_string((U8*)PL_tokenbuf, len))
+                             SvUTF8_on(sv);
+                       SvREADONLY_on(sv);
+                   }
                    TERM(WORD);
                }
 

--
Perl5 Master Repository

Reply via email to