This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
As freeing up PL_linestr is now done via the scope stack, there's no
authorNicholas Clark <nick@ccl4.org>
Sun, 31 Dec 2006 12:31:09 +0000 (12:31 +0000)
committerNicholas Clark <nick@ccl4.org>
Sun, 31 Dec 2006 12:31:09 +0000 (12:31 +0000)
need to make any temporary varariable a mortal, and waste effort on
the temp stack (not) clearing it up.

p4raw-id: //depot/perl@29644

toke.c

diff --git a/toke.c b/toke.c
index de98e41..eaa7e6b 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -660,17 +660,18 @@ Perl_lex_start(pTHX_ SV *line)
 #endif
     PL_lex_inwhat = 0;
     PL_sublex_info.sub_inwhat = 0;
-    PL_linestr = line;
-    s = SvPV_const(PL_linestr, len);
-    if (SvREADONLY(PL_linestr) || !len || s[len-1] != ';') {
-       PL_linestr = sv_2mortal(len ? newSVsv(PL_linestr) : newSVpvn(s, 0));
+    s = SvPV_const(line, len);
+    if (SvREADONLY(line) || !len || s[len-1] != ';') {
+       PL_linestr = len ? newSVsv(line) : newSVpvn(s, 0);
        if (!len || s[len-1] != ';')
            sv_catpvs(PL_linestr, "\n;");
+    } else {
+       SvTEMP_off(line);
+       SvREFCNT_inc_simple_void_NN(line);
+       PL_linestr = line;
     }
-    SvTEMP_off(PL_linestr);
     /* PL_linestr needs to survive until end of scope, not just the next
        FREETMPS. See changes 17505 and 17546 which fixed the symptoms only.  */
-    SvREFCNT_inc_simple_void_NN(PL_linestr);
     SAVEFREESV(PL_linestr);
     PL_oldoldbufptr = PL_oldbufptr = PL_bufptr = PL_linestart = SvPVX(PL_linestr);
     PL_bufend = PL_bufptr + SvCUR(PL_linestr);