summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cop.h2
-rw-r--r--embedvar.h2
-rw-r--r--intrpvar.h1
-rw-r--r--parser.h1
-rw-r--r--perl.c5
-rw-r--r--perlapi.h2
-rw-r--r--pp_ctl.c2
-rw-r--r--sv.c30
-rw-r--r--toke.c21
9 files changed, 30 insertions, 36 deletions
diff --git a/cop.h b/cop.h
index 72cf84c60b..8b599172d8 100644
--- a/cop.h
+++ b/cop.h
@@ -388,7 +388,7 @@ struct block_eval {
cx->blk_eval.old_op_type = PL_op->op_type; \
cx->blk_eval.old_namesv = (n ? newSVpv(n,0) : NULL); \
cx->blk_eval.old_eval_root = PL_eval_root; \
- cx->blk_eval.cur_text = PL_linestr; \
+ cx->blk_eval.cur_text = PL_parser ? PL_parser->linestr : NULL; \
cx->blk_eval.cv = NULL; /* set by doeval(), as applicable */ \
cx->blk_eval.retop = NULL; \
cx->blk_eval.cur_top_env = PL_top_env; \
diff --git a/embedvar.h b/embedvar.h
index 6de77e784f..9c539781ce 100644
--- a/embedvar.h
+++ b/embedvar.h
@@ -242,7 +242,6 @@
#define PL_lex_state (vTHX->Ilex_state)
#define PL_lineary (vTHX->Ilineary)
#define PL_linestart (vTHX->Ilinestart)
-#define PL_linestr (vTHX->Ilinestr)
#define PL_localpatches (vTHX->Ilocalpatches)
#define PL_lockhook (vTHX->Ilockhook)
#define PL_madskills (vTHX->Imadskills)
@@ -508,7 +507,6 @@
#define PL_Ilex_state PL_lex_state
#define PL_Ilineary PL_lineary
#define PL_Ilinestart PL_linestart
-#define PL_Ilinestr PL_linestr
#define PL_Ilocalpatches PL_localpatches
#define PL_Ilockhook PL_lockhook
#define PL_Imadskills PL_madskills
diff --git a/intrpvar.h b/intrpvar.h
index 57afeb23dd..751784c4f3 100644
--- a/intrpvar.h
+++ b/intrpvar.h
@@ -300,7 +300,6 @@ PERLVARA(Inexttype,5, I32) /* type of next token */
PERLVAR(Inexttoke, I32)
#endif
-PERLVAR(Ilinestr, SV *)
PERLVAR(Ibufptr, char *)
PERLVAR(Ioldbufptr, char *)
PERLVAR(Ioldoldbufptr, char *)
diff --git a/parser.h b/parser.h
index da6d63bfa4..f0a1710ce8 100644
--- a/parser.h
+++ b/parser.h
@@ -58,6 +58,7 @@ typedef struct yy_parser {
char pending_ident; /* pending identifier lookup */
bool preambled;
SUBLEXINFO sublex_info;
+ SV *linestr; /* current chunk of src text */
#ifdef PERL_MAD
SV *endwhite;
diff --git a/perl.c b/perl.c
index 54b2894383..33aa78ef6f 100644
--- a/perl.c
+++ b/perl.c
@@ -260,9 +260,6 @@ perl_construct(pTHXx)
#endif
PL_curcop = &PL_compiling; /* needed by ckWARN, right away */
- PL_linestr = newSV_type(SVt_PVIV);
- SvGROW(PL_linestr, 80);
-
/* set read-only and try to insure than we wont see REFCNT==0
very often */
@@ -992,8 +989,6 @@ perl_destruct(pTHXx)
PL_preambleav = NULL;
SvREFCNT_dec(PL_subname);
PL_subname = NULL;
- SvREFCNT_dec(PL_linestr);
- PL_linestr = NULL;
#ifdef PERL_USES_PL_PIDSTATUS
SvREFCNT_dec(PL_pidstatus);
PL_pidstatus = NULL;
diff --git a/perlapi.h b/perlapi.h
index da5363d305..11eabbc6c3 100644
--- a/perlapi.h
+++ b/perlapi.h
@@ -362,8 +362,6 @@ END_EXTERN_C
#define PL_lineary (*Perl_Ilineary_ptr(aTHX))
#undef PL_linestart
#define PL_linestart (*Perl_Ilinestart_ptr(aTHX))
-#undef PL_linestr
-#define PL_linestr (*Perl_Ilinestr_ptr(aTHX))
#undef PL_localpatches
#define PL_localpatches (*Perl_Ilocalpatches_ptr(aTHX))
#undef PL_lockhook
diff --git a/pp_ctl.c b/pp_ctl.c
index 310ca86a67..85f82786cf 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3504,7 +3504,7 @@ PP(pp_entereval)
/* prepare to compile string */
if (PERLDB_LINE && PL_curstash != PL_debstash)
- save_lines(CopFILEAV(&PL_compiling), PL_linestr);
+ save_lines(CopFILEAV(&PL_compiling), PL_parser->linestr);
PUTBACK;
ret = doeval(gimme, NULL, runcv, seq);
if (PERLDB_INTER && was != (I32)PL_sub_generation /* Some subs defined here. */
diff --git a/sv.c b/sv.c
index 5a76a93ecc..c49f478154 100644
--- a/sv.c
+++ b/sv.c
@@ -9543,6 +9543,7 @@ Perl_parser_dup(pTHX_ const yy_parser *proto, CLONE_PARAMS* param)
parser->pending_ident = proto->pending_ident;
parser->preambled = proto->preambled;
parser->sublex_info = proto->sublex_info; /* XXX not quite right */
+ parser->linestr = sv_dup_inc(proto->linestr, param);
#ifdef PERL_MAD
parser->endwhite = proto->endwhite;
@@ -11206,16 +11207,21 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
PL_nexttoke = proto_perl->Inexttoke;
#endif
- PL_linestr = sv_dup_inc(proto_perl->Ilinestr, param);
- i = proto_perl->Ibufptr - SvPVX_const(proto_perl->Ilinestr);
- PL_bufptr = SvPVX(PL_linestr) + (i < 0 ? 0 : i);
- i = proto_perl->Ioldbufptr - SvPVX_const(proto_perl->Ilinestr);
- PL_oldbufptr = SvPVX(PL_linestr) + (i < 0 ? 0 : i);
- i = proto_perl->Ioldoldbufptr - SvPVX_const(proto_perl->Ilinestr);
- PL_oldoldbufptr = SvPVX(PL_linestr) + (i < 0 ? 0 : i);
- i = proto_perl->Ilinestart - SvPVX_const(proto_perl->Ilinestr);
- PL_linestart = SvPVX(PL_linestr) + (i < 0 ? 0 : i);
- PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr);
+ if (proto_perl->Iparser) {
+ i = proto_perl->Ibufptr - SvPVX_const(proto_perl->Iparser->linestr);
+ PL_bufptr = SvPVX(PL_parser->linestr) + (i < 0 ? 0 : i);
+ i = proto_perl->Ioldbufptr - SvPVX_const(proto_perl->Iparser->linestr);
+ PL_oldbufptr = SvPVX(PL_parser->linestr) + (i < 0 ? 0 : i);
+ i = proto_perl->Ioldoldbufptr - SvPVX_const(proto_perl->Iparser->linestr);
+ PL_oldoldbufptr = SvPVX(PL_parser->linestr) + (i < 0 ? 0 : i);
+ i = proto_perl->Ilinestart - SvPVX_const(proto_perl->Iparser->linestr);
+ PL_linestart = SvPVX(PL_parser->linestr) + (i < 0 ? 0 : i);
+ PL_bufend = SvPVX(PL_parser->linestr) + SvCUR(PL_parser->linestr);
+ i = proto_perl->Ilast_uni - SvPVX_const(proto_perl->Iparser->linestr);
+ PL_last_uni = SvPVX(PL_parser->linestr) + (i < 0 ? 0 : i);
+ i = proto_perl->Ilast_lop - SvPVX_const(proto_perl->Iparser->linestr);
+ PL_last_lop = SvPVX(PL_parser->linestr) + (i < 0 ? 0 : i);
+ }
PL_expect = proto_perl->Iexpect;
@@ -11225,10 +11231,6 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
PL_subline = proto_perl->Isubline;
PL_subname = sv_dup_inc(proto_perl->Isubname, param);
- i = proto_perl->Ilast_uni - SvPVX_const(proto_perl->Ilinestr);
- PL_last_uni = SvPVX(PL_linestr) + (i < 0 ? 0 : i);
- i = proto_perl->Ilast_lop - SvPVX_const(proto_perl->Ilinestr);
- PL_last_lop = SvPVX(PL_linestr) + (i < 0 ? 0 : i);
PL_last_lop_op = proto_perl->Ilast_lop_op;
PL_in_my = proto_perl->Iin_my;
PL_in_my_stash = hv_dup(proto_perl->Iin_my_stash, param);
diff --git a/toke.c b/toke.c
index c7534a6d63..7181fee56e 100644
--- a/toke.c
+++ b/toke.c
@@ -49,6 +49,8 @@
#define PL_pending_ident (PL_parser->pending_ident)
#define PL_preambled (PL_parser->preambled)
#define PL_sublex_info (PL_parser->sublex_info)
+#define PL_linestr (PL_parser->linestr)
+
#ifdef PERL_MAD
# define PL_endwhite (PL_parser->endwhite)
@@ -676,7 +678,6 @@ Perl_lex_start(pTHX_ SV *line)
SAVEPPTR(PL_last_lop);
SAVEPPTR(PL_last_uni);
SAVEPPTR(PL_linestart);
- SAVESPTR(PL_linestr);
SAVEDESTRUCTOR_X(restore_rsfp, PL_rsfp);
SAVEI8(PL_expect);
@@ -695,22 +696,20 @@ Perl_lex_start(pTHX_ SV *line)
} else {
len = 0;
}
+
if (!len) {
- PL_linestr = newSVpvs("\n;");
+ parser->linestr = newSVpvs("\n;");
} else if (SvREADONLY(line) || s[len-1] != ';') {
- PL_linestr = newSVsv(line);
+ parser->linestr = newSVsv(line);
if (s[len-1] != ';')
- sv_catpvs(PL_linestr, "\n;");
+ sv_catpvs(parser->linestr, "\n;");
} else {
SvTEMP_off(line);
SvREFCNT_inc_simple_void_NN(line);
- PL_linestr = line;
+ parser->linestr = line;
}
- /* PL_linestr needs to survive until end of scope, not just the next
- FREETMPS. See changes 17505 and 17546 which fixed the symptoms only. */
- SAVEFREESV(PL_linestr);
- PL_oldoldbufptr = PL_oldbufptr = PL_bufptr = PL_linestart = SvPVX(PL_linestr);
- PL_bufend = PL_bufptr + SvCUR(PL_linestr);
+ PL_oldoldbufptr = PL_oldbufptr = PL_bufptr = PL_linestart = SvPVX(parser->linestr);
+ PL_bufend = PL_bufptr + SvCUR(parser->linestr);
PL_last_lop = PL_last_uni = NULL;
PL_rsfp = 0;
}
@@ -721,6 +720,8 @@ Perl_lex_start(pTHX_ SV *line)
void
Perl_parser_free(pTHX_ const yy_parser *parser)
{
+ SvREFCNT_dec(parser->linestr);
+
Safefree(parser->stack);
Safefree(parser->lex_brackstack);
Safefree(parser->lex_casestack);