struct block_eval {
I32 old_in_eval;
I32 old_op_type;
- char * old_name;
+ SV * old_namesv;
OP * old_eval_root;
SV * cur_text;
};
#define PUSHEVAL(cx,n,fgv) \
+ STMT_START { \
cx->blk_eval.old_in_eval = PL_in_eval; \
cx->blk_eval.old_op_type = PL_op->op_type; \
- cx->blk_eval.old_name = (n ? savepv(n) : Nullch); \
+ cx->blk_eval.old_namesv = (n ? newSVpv(n,0) : Nullsv); \
cx->blk_eval.old_eval_root = PL_eval_root; \
- cx->blk_eval.cur_text = PL_linestr;
+ cx->blk_eval.cur_text = PL_linestr; \
+ } STMT_END
#define POPEVAL(cx) \
+ STMT_START { \
PL_in_eval = cx->blk_eval.old_in_eval; \
optype = cx->blk_eval.old_op_type; \
PL_eval_root = cx->blk_eval.old_eval_root; \
- Safefree(cx->blk_eval.old_name);
+ if (cx->blk_eval.old_namesv) \
+ sv_2mortal(cx->blk_eval.old_namesv); \
+ } STMT_END
/* loop context */
struct block_loop {
veop = Nullop;
- if(version != Nullop) {
+ if (version != Nullop) {
SV *vesv = ((SVOP*)version)->op_sv;
if (arg == Nullop && !SvNIOK(vesv)) {
}
else {
OP *pack;
+ SV *meth;
if (version->op_type != OP_CONST || !SvNIOK(vesv))
Perl_croak(aTHX_ "Version number must be constant number");
pack = newSVOP(OP_CONST, 0, newSVsv(((SVOP*)id)->op_sv));
/* Fake up a method call to VERSION */
+ meth = newSVpvn("VERSION",7);
+ sv_upgrade(meth, SVt_PVIV);
+ SvIOK_on(meth);
+ PERL_HASH(SvUVX(meth), SvPVX(meth), SvCUR(meth));
veop = convert(OP_ENTERSUB, OPf_STACKED|OPf_SPECIAL,
append_elem(OP_LIST,
- prepend_elem(OP_LIST, pack, list(version)),
- newSVOP(OP_METHOD_NAMED, 0,
- newSVpvn("VERSION", 7))));
+ prepend_elem(OP_LIST, pack, list(version)),
+ newSVOP(OP_METHOD_NAMED, 0, meth)));
}
}
/* Fake up an import/unimport */
if (arg && arg->op_type == OP_STUB)
imop = arg; /* no import on explicit () */
- else if(SvNIOK(((SVOP*)id)->op_sv)) {
+ else if (SvNIOK(((SVOP*)id)->op_sv)) {
imop = Nullop; /* use 5.0; */
}
else {
+ SV *meth;
+
/* Make copy of id so we don't free it twice */
pack = newSVOP(OP_CONST, 0, newSVsv(((SVOP*)id)->op_sv));
+
+ /* Fake up a method call to import/unimport */
+ meth = aver ? newSVpvn("import",6) : newSVpvn("unimport", 8);;
+ sv_upgrade(meth, SVt_PVIV);
+ SvIOK_on(meth);
+ PERL_HASH(SvUVX(meth), SvPVX(meth), SvCUR(meth));
imop = convert(OP_ENTERSUB, OPf_STACKED|OPf_SPECIAL,
- append_elem(OP_LIST,
- prepend_elem(OP_LIST, pack, list(arg)),
- newSVOP(OP_METHOD_NAMED, 0,
- aver ? newSVpvn("import", 6)
- : newSVpvn("unimport", 8))));
+ append_elem(OP_LIST,
+ prepend_elem(OP_LIST, pack, list(arg)),
+ newSVOP(OP_METHOD_NAMED, 0, meth)));
}
/* Fake up a require, handle override, if any */
{
SV *sv = Nullsv;
- if(!o)
+ if (!o)
return Nullsv;
- if(o->op_type == OP_LINESEQ && cLISTOPo->op_first)
+ if (o->op_type == OP_LINESEQ && cLISTOPo->op_first)
o = cLISTOPo->op_first->op_sibling;
for (; o; o = o->op_next) {
Perl_croak(aTHX_ "Can't redefine active sort subroutine %s", name);
if (!block)
goto withattrs;
- if(const_sv = cv_const_sv(cv))
+ if (const_sv = cv_const_sv(cv))
const_changed = sv_cmp(const_sv, op_const_sv(block, Nullcv));
if ((const_sv && const_changed) || ckWARN(WARN_REDEFINE)
&& !(CvGV(cv) && GvSTASH(CvGV(cv))
return;
if (strEQ(GvNAME(gv), "a"))
reversed = 0;
- else if(strEQ(GvNAME(gv), "b"))
+ else if (strEQ(GvNAME(gv), "b"))
reversed = 1;
else
return;
{
dSP;
OP myop;
- if (!PL_op)
+ if (!PL_op) {
+ myop.op_next = Nullop;
PL_op = &myop;
+ }
XPUSHs(sv_2mortal(newSVpv(methname,0)));
PUTBACK;
pp_method();
- if(PL_op == &myop)
- PL_op = Nullop;
return call_sv(*PL_stack_sp--, flags);
}
if (cx->blk_eval.old_op_type == OP_ENTEREVAL) {
PUSHs(cx->blk_eval.cur_text);
PUSHs(&PL_sv_no);
- }
- else if (cx->blk_eval.old_name) { /* Try blocks have old_name == 0. */
- /* Require, put the name. */
- PUSHs(sv_2mortal(newSVpv(cx->blk_eval.old_name, 0)));
+ }
+ /* try blocks have old_namesv == 0 */
+ else if (cx->blk_eval.old_namesv) {
+ PUSHs(sv_2mortal(newSVsv(cx->blk_eval.old_namesv)));
PUSHs(&PL_sv_yes);
}
}
(MARK == SP || (gimme == G_SCALAR && !SvTRUE(*SP))) )
{
/* Unassume the success we assumed earlier. */
- char *name = cx->blk_eval.old_name;
- (void)hv_delete(GvHVn(PL_incgv), name, strlen(name), G_DISCARD);
- DIE(aTHX_ "%s did not return a true value", name);
+ SV *nsv = cx->blk_eval.old_namesv;
+ (void)hv_delete(GvHVn(PL_incgv), SvPVX(nsv), SvCUR(nsv), G_DISCARD);
+ DIE(aTHX_ "%s did not return a true value", SvPVX(nsv));
}
break;
case CXt_FORMAT:
!(gimme == G_SCALAR ? SvTRUE(*SP) : SP > newsp))
{
/* Unassume the success we assumed earlier. */
- char *name = cx->blk_eval.old_name;
- (void)hv_delete(GvHVn(PL_incgv), name, strlen(name), G_DISCARD);
- retop = Perl_die(aTHX_ "%s did not return a true value", name);
+ SV *nsv = cx->blk_eval.old_namesv;
+ (void)hv_delete(GvHVn(PL_incgv), SvPVX(nsv), SvCUR(nsv), G_DISCARD);
+ retop = Perl_die(aTHX_ "%s did not return a true value", SvPVX(nsv));
/* die_where() did LEAVE, or we won't be here */
}
else {
char, regexp);
if (r == NULL)
FAIL("regexp out of space");
+#ifdef DEBUGGING
+ /* avoid reading uninitialized memory in DEBUGGING code in study_chunk() */
+ Zero(r, sizeof(regexp) + (unsigned)PL_regsize * sizeof(regnode), char);
+#endif
r->refcnt = 1;
r->prelen = xend - exp;
r->precomp = PL_regprecomp;
SAVEDESTRUCTOR_X(restore_pos, 0);
}
if (!PL_reg_curpm)
- New(22,PL_reg_curpm, 1, PMOP);
+ Newz(22,PL_reg_curpm, 1, PMOP);
PL_reg_curpm->op_pmregexp = prog;
PL_reg_oldcurpm = PL_curpm;
PL_curpm = PL_reg_curpm;
PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_OP_TYPE = %s (%s)\n",
PL_op_name[cx->blk_eval.old_op_type],
PL_op_desc[cx->blk_eval.old_op_type]);
- PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_NAME = %s\n",
- cx->blk_eval.old_name);
+ if (cx->blk_eval.old_namesv)
+ PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_NAME = %s\n",
+ SvPVX(cx->blk_eval.old_namesv));
PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_EVAL_ROOT = 0x%"UVxf"\n",
PTR2UV(cx->blk_eval.old_eval_root));
break;
case CXt_EVAL:
ncx->blk_eval.old_in_eval = cx->blk_eval.old_in_eval;
ncx->blk_eval.old_op_type = cx->blk_eval.old_op_type;
- ncx->blk_eval.old_name = SAVEPV(cx->blk_eval.old_name);
+ ncx->blk_eval.old_namesv = sv_dup_inc(cx->blk_eval.old_namesv);
ncx->blk_eval.old_eval_root = cx->blk_eval.old_eval_root;
ncx->blk_eval.cur_text = sv_dup(cx->blk_eval.cur_text);
break;
}
else {
message = Nullch;
+ msglen = 0;
}
DEBUG_S(PerlIO_printf(Perl_debug_log,