#define Nullcop Null(COP*)
+#define CopFILEGV(c) (c)->cop_filegv
+#define CopFILEGV_set(c,gv) ((c)->cop_filegv = gv)
+#define CopFILESV(c) (CopFILEGV(c) ? GvSV(CopFILEGV(c)) : Nullsv)
+#define CopFILEAV(c) (CopFILEGV(c) ? GvAV(CopFILEGV(c)) : Nullav)
+#define CopFILE(c) (CopFILESV(c) ? SvPVX(CopFILESV(c)) : Nullch)
+#define CopLINE(c) ((c)->cop_line)
+#define CopLINE_set(c,l) ((c)->cop_line = (l))
+
/*
* Here we have some enormously heavy (or at least ponderous) wizardry.
*/
#ifdef DEBUGGING
dTHR;
register I32 i;
- GV* gv = PL_curcop->cop_filegv;
+ char* file = CopFILE(PL_curcop);
#ifdef USE_THREADS
PerlIO_printf(Perl_debug_log, "0x%"UVxf" (%s:%ld)\t",
PTR2UV(thr),
- SvTYPE(gv) == SVt_PVGV ? SvPVX(GvSV(gv)) : "<free>",
- (long)PL_curcop->cop_line);
+ (file ? file : "<free>"),
+ (long)CopLINE(PL_curcop));
#else
- PerlIO_printf(Perl_debug_log, "(%s:%ld)\t",
- SvTYPE(gv) == SVt_PVGV ? SvPVX(GvSV(gv)) : "<free>",
- (long)PL_curcop->cop_line);
+ PerlIO_printf(Perl_debug_log, "(%s:%ld)\t", (file ? file : "<free>"),
+ (long)CopLINE(PL_curcop));
#endif /* USE_THREADS */
(void) PerlIO_vprintf(Perl_debug_log, pat, *args);
#endif /* DEBUGGING */
Newz(602, gp, 1, GP);
GvGP(gv) = gp_ref(gp);
GvSV(gv) = NEWSV(72,0);
- GvLINE(gv) = PL_curcop->cop_line;
- GvFILE(gv) = PL_curcop->cop_filegv ? SvPVX(GvSV(PL_curcop->cop_filegv)) : "";
+ GvLINE(gv) = CopLINE(PL_curcop);
+ GvFILE(gv) = CopFILE(PL_curcop) ? CopFILE(PL_curcop) : "";
GvCVGEN(gv) = 0;
GvEGV(gv) = gv;
sv_magic((SV*)gv, (SV*)gv, '*', name, len);
gv = (GV*)HeVAL(entry);
if (SvTYPE(gv) != SVt_PVGV || GvMULTI(gv))
continue;
- PL_curcop->cop_line = GvLINE(gv);
+ CopLINE_set(PL_curcop, GvLINE(gv));
filegv = GvFILEGV(gv); /* XXX could be made faster */
- PL_curcop->cop_filegv = filegv;
+ CopFILEGV_set(PL_curcop, filegv);
if (filegv && GvMULTI(filegv)) /* Filename began with slash */
continue;
Perl_warner(aTHX_ WARN_ONCE,
S_cop_free(pTHX_ COP* cop)
{
Safefree(cop->cop_label);
- SvREFCNT_dec(cop->cop_filegv);
+ SvREFCNT_dec(CopFILEGV(cop));
if (! specialWARN(cop->cop_warnings))
SvREFCNT_dec(cop->cop_warnings);
}
if (cv) {
dSP;
PUSHMARK(SP);
- XPUSHs((SV*)PL_compiling.cop_filegv);
+ XPUSHs((SV*)CopFILEGV(&PL_compiling));
PUTBACK;
call_sv((SV*)cv, G_DISCARD);
}
if (PL_copline == NOLINE)
cop->cop_line = PL_curcop->cop_line;
else {
- cop->cop_line = PL_copline;
+ cop->cop_line = PL_copline;
PL_copline = NOLINE;
}
- cop->cop_filegv = (GV*)SvREFCNT_inc(PL_curcop->cop_filegv);
+ CopFILEGV_set(cop, (GV*)SvREFCNT_inc(CopFILEGV(PL_curcop)));
cop->cop_stash = PL_curstash;
if (PERLDB_LINE && PL_curstash != PL_debstash) {
- SV **svp = av_fetch(GvAV(PL_curcop->cop_filegv),(I32)cop->cop_line, FALSE);
+ SV **svp = av_fetch(CopFILEAV(PL_curcop), (I32)CopLINE(cop), FALSE);
if (svp && *svp != &PL_sv_undef && !SvIOK(*svp)) {
(void)SvIOK_on(*svp);
SvIVX(*svp) = 1;
HV *hv;
Perl_sv_setpvf(aTHX_ sv, "%_:%ld-%ld",
- GvSV(PL_curcop->cop_filegv),
- (long)PL_subline, (long)PL_curcop->cop_line);
+ CopFILESV(PL_curcop),
+ (long)PL_subline, (long)CopLINE(PL_curcop));
gv_efullname3(tmpstr, gv, Nullch);
hv_store(GvHV(PL_DBsub), SvPVX(tmpstr), SvCUR(tmpstr), sv, 0);
hv = GvHVn(db_postponed);
if (strEQ(s, "BEGIN")) {
I32 oldscope = PL_scopestack_ix;
ENTER;
- SAVESPTR(PL_compiling.cop_filegv);
+ SAVESPTR(CopFILEGV(&PL_compiling));
SAVEI16(PL_compiling.cop_line);
save_svref(&PL_rs);
sv_setsv(PL_rs, PL_nrs);
}
}
- PL_curcop->cop_filegv = gv_fetchfile(PL_origfilename);
+ CopFILEGV_set(PL_curcop, gv_fetchfile(PL_origfilename));
if (strEQ(PL_origfilename,"-"))
scriptname = "";
if (*fdscript >= 0) {
#ifdef DOSUID
#ifndef IAMSUID /* in case script is not readable before setuid */
if (PL_euid &&
- PerlLIO_stat(SvPVX(GvSV(PL_curcop->cop_filegv)),&PL_statbuf) >= 0 &&
+ PerlLIO_stat(CopFILE(PL_curcop),&PL_statbuf) >= 0 &&
PL_statbuf.st_mode & (S_ISUID|S_ISGID))
{
/* try again */
#endif
#endif
Perl_croak(aTHX_ "Can't open perl script \"%s\": %s\n",
- SvPVX(GvSV(PL_curcop->cop_filegv)), Strerror(errno));
+ CopFILE(PL_curcop), Strerror(errno));
}
}
* But I don't think it's too important. The manual lies when
* it says access() is useful in setuid programs.
*/
- if (PerlLIO_access(SvPVX(GvSV(PL_curcop->cop_filegv)),1)) /*double check*/
+ if (PerlLIO_access(CopFILE(PL_curcop),1)) /*double check*/
Perl_croak(aTHX_ "Permission denied");
#else
/* If we can swap euid and uid, then we can determine access rights
#endif
|| PerlProc_getuid() != PL_euid || PerlProc_geteuid() != PL_uid)
Perl_croak(aTHX_ "Can't swap uid and euid"); /* really paranoid */
- if (PerlLIO_stat(SvPVX(GvSV(PL_curcop->cop_filegv)),&tmpstatbuf) < 0)
+ if (PerlLIO_stat(CopFILE(PL_curcop),&tmpstatbuf) < 0)
Perl_croak(aTHX_ "Permission denied"); /* testing full pathname here */
#if defined(IAMSUID) && !defined(NO_NOSUID_CHECK)
if (fd_on_nosuid_fs(PerlIO_fileno(PL_rsfp)))
(Filename of set-id script was %s, uid %"Uid_t_f" gid %"Gid_t_f".)\n\nSincerely,\nperl\n",
PL_uid,(long)tmpstatbuf.st_dev, (long)tmpstatbuf.st_ino,
(long)PL_statbuf.st_dev, (long)PL_statbuf.st_ino,
- SvPVX(GvSV(PL_curcop->cop_filegv)),
+ CopFILE(PL_curcop),
PL_statbuf.st_uid, PL_statbuf.st_gid);
(void)PerlProc_pclose(PL_rsfp);
}
PUSHs(&PL_sv_undef);
else
PUSHs(sv_2mortal(newSVpv(HvNAME(hv), 0)));
- PUSHs(sv_2mortal(newSVpvn(SvPVX(GvSV(cx->blk_oldcop->cop_filegv)),
- SvCUR(GvSV(cx->blk_oldcop->cop_filegv)))));
+ PUSHs(sv_2mortal(newSVsv(CopFILESV(cx->blk_oldcop))));
PUSHs(sv_2mortal(newSViv((I32)cx->blk_oldcop->cop_line)));
if (!MAXARG)
RETURN;
SAVESPTR(PL_compiling.cop_stash);
PL_compiling.cop_stash = PL_curstash;
}
- SAVESPTR(PL_compiling.cop_filegv);
+ SAVESPTR(CopFILEGV(&PL_compiling));
SAVEI16(PL_compiling.cop_line);
sprintf(tmpbuf, "_<(%.10s_eval %lu)", code, (unsigned long)++PL_evalseq);
- PL_compiling.cop_filegv = gv_fetchfile(tmpbuf+2);
+ CopFILEGV_set(&PL_compiling, gv_fetchfile(tmpbuf+2));
PL_compiling.cop_line = 1;
/* XXX For C<eval "...">s within BEGIN {} blocks, this ends up
deleting the eval's FILEGV from the stash before gv_check() runs
PL_op->op_type = OP_ENTEREVAL;
PL_op->op_flags = 0; /* Avoid uninit warning. */
PUSHBLOCK(cx, CXt_EVAL, SP);
- PUSHEVAL(cx, 0, PL_compiling.cop_filegv);
+ PUSHEVAL(cx, 0, Nullgv);
rop = doeval(G_SCALAR, startop);
POPBLOCK(cx,PL_curpm);
POPEVAL(cx);
if (cv) {
dSP;
PUSHMARK(SP);
- XPUSHs((SV*)PL_compiling.cop_filegv);
+ XPUSHs((SV*)CopFILEGV(&PL_compiling));
PUTBACK;
call_sv((SV*)cv, G_DISCARD);
}
}
}
}
- SAVESPTR(PL_compiling.cop_filegv);
- PL_compiling.cop_filegv = gv_fetchfile(tryrsfp ? tryname : name);
+ SAVESPTR(CopFILEGV(&PL_compiling));
+ CopFILEGV_set(&PL_compiling, gv_fetchfile(tryrsfp ? tryname : name));
SvREFCNT_dec(namesv);
if (!tryrsfp) {
if (PL_op->op_type == OP_REQUIRE) {
/* Assume success here to prevent recursive requirement. */
(void)hv_store(GvHVn(PL_incgv), name, strlen(name),
- newSVsv(GvSV(PL_compiling.cop_filegv)), 0 );
+ newSVsv(CopFILESV(&PL_compiling)), 0 );
ENTER;
SAVETMPS;
/* switch to eval mode */
push_return(PL_op->op_next);
PUSHBLOCK(cx, CXt_EVAL, SP);
- PUSHEVAL(cx, name, PL_compiling.cop_filegv);
+ PUSHEVAL(cx, name, Nullgv);
SAVEI16(PL_compiling.cop_line);
PL_compiling.cop_line = 0;
/* switch to eval mode */
- SAVESPTR(PL_compiling.cop_filegv);
+ SAVESPTR(CopFILEGV(&PL_compiling));
sprintf(tmpbuf, "_<(eval %lu)", (unsigned long)++PL_evalseq);
- PL_compiling.cop_filegv = gv_fetchfile(tmpbuf+2);
+ CopFILEGV_set(&PL_compiling, gv_fetchfile(tmpbuf+2));
PL_compiling.cop_line = 1;
/* XXX For C<eval "...">s within BEGIN {} blocks, this ends up
deleting the eval's FILEGV from the stash before gv_check() runs
push_return(PL_op->op_next);
PUSHBLOCK(cx, (CXt_EVAL|CXp_REAL), SP);
- PUSHEVAL(cx, 0, PL_compiling.cop_filegv);
+ PUSHEVAL(cx, 0, Nullgv);
/* prepare to compile string */
if (PERLDB_LINE && PL_curstash != PL_debstash)
- save_lines(GvAV(PL_compiling.cop_filegv), PL_linestr);
+ save_lines(CopFILEAV(&PL_compiling), PL_linestr);
PUTBACK;
#ifdef USE_THREADS
MUTEX_LOCK(&PL_eval_mutex);
HV *stash = SvSTASH(SvRV(error));
GV *gv = gv_fetchmethod(stash, "PROPAGATE");
if (gv) {
- SV *file = sv_2mortal(newSVsv(GvSV(PL_curcop->cop_filegv)));
+ SV *file = sv_2mortal(newSVsv(CopFILESV(PL_curcop)));
SV *line = sv_2mortal(newSViv(PL_curcop->cop_line));
EXTEND(SP, 3);
PUSHMARK(SP);
if (GvCVu(gv))
PL_sub_generation++; /* taking a method out of circulation */
- else if (GvIOp(gv) && (IoFLAGS(GvIOp(gv)) & IOf_ARGV)) {
+ if (GvIOp(gv) && (IoFLAGS(GvIOp(gv)) & IOf_ARGV)) {
gp->gp_io = newIO();
IoFLAGS(gp->gp_io) |= IOf_ARGV|IOf_START;
}
ch = *t;
*t = '\0';
if (t - s > 0)
- PL_curcop->cop_filegv = gv_fetchfile(s);
+ CopFILEGV_set(PL_curcop, gv_fetchfile(s));
else
- PL_curcop->cop_filegv = gv_fetchfile(PL_origfilename);
+ CopFILEGV_set(PL_curcop, gv_fetchfile(PL_origfilename));
*t = ch;
PL_curcop->cop_line = atoi(n)-1;
}
sv_upgrade(sv, SVt_PVMG);
sv_setpvn(sv,PL_bufptr,PL_bufend-PL_bufptr);
- av_store(GvAV(PL_curcop->cop_filegv),(I32)PL_curcop->cop_line,sv);
+ av_store(CopFILEAV(PL_curcop),(I32)PL_curcop->cop_line,sv);
}
}
}
sv_upgrade(sv, SVt_PVMG);
sv_setsv(sv,PL_linestr);
- av_store(GvAV(PL_curcop->cop_filegv),(I32)PL_curcop->cop_line,sv);
+ av_store(CopFILEAV(PL_curcop),(I32)PL_curcop->cop_line,sv);
}
goto retry;
}
sv_upgrade(sv, SVt_PVMG);
sv_setsv(sv,PL_linestr);
- av_store(GvAV(PL_curcop->cop_filegv),(I32)PL_curcop->cop_line,sv);
+ av_store(CopFILEAV(PL_curcop),(I32)PL_curcop->cop_line,sv);
}
PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr);
if (PL_curcop->cop_line == 1) {
*/
SV *x = GvSV(gv_fetchpv("\030", TRUE, SVt_PV));
assert(SvPOK(x) || SvGMAGICAL(x));
- if (sv_eq(x, GvSV(PL_curcop->cop_filegv))) {
+ if (sv_eq(x, CopFILESV(PL_curcop))) {
sv_setpvn(x, ipath, ipathend - ipath);
SvSETMAGIC(x);
}
case KEY___FILE__:
yylval.opval = (OP*)newSVOP(OP_CONST, 0,
- newSVsv(GvSV(PL_curcop->cop_filegv)));
+ newSVsv(CopFILESV(PL_curcop)));
TERM(THING);
case KEY___LINE__:
sv_upgrade(sv, SVt_PVMG);
sv_setsv(sv,PL_linestr);
- av_store(GvAV(PL_curcop->cop_filegv),
- (I32)PL_curcop->cop_line,sv);
+ av_store(CopFILEAV(PL_curcop), (I32)PL_curcop->cop_line,sv);
}
if (*s == term && memEQ(s,PL_tokenbuf,len)) {
s = PL_bufend - 1;
sv_upgrade(sv, SVt_PVMG);
sv_setsv(sv,PL_linestr);
- av_store(GvAV(PL_curcop->cop_filegv),
- (I32)PL_curcop->cop_line, sv);
+ av_store(CopFILEAV(PL_curcop), (I32)PL_curcop->cop_line, sv);
}
/* having changed the buffer, we must update PL_bufend */
}
msg = sv_2mortal(newSVpv(s, 0));
Perl_sv_catpvf(aTHX_ msg, " at %_ line %"IVdf", ",
- GvSV(PL_curcop->cop_filegv), (IV)PL_curcop->cop_line);
+ CopFILESV(PL_curcop), (IV)PL_curcop->cop_line);
if (context)
Perl_sv_catpvf(aTHX_ msg, "near \"%.*s\"\n", contlen, context);
else
else
qerror(msg);
if (PL_error_count >= 10)
- Perl_croak(aTHX_ "%_ has too many errors.\n", GvSV(PL_curcop->cop_filegv));
+ Perl_croak(aTHX_ "%_ has too many errors.\n", CopFILESV(PL_curcop));
PL_in_my = 0;
PL_in_my_stash = Nullhv;
return 0;
dTHR;
if (PL_curcop->cop_line)
Perl_sv_catpvf(aTHX_ sv, " at %_ line %"IVdf,
- GvSV(PL_curcop->cop_filegv), (IV)PL_curcop->cop_line);
+ CopFILESV(PL_curcop), (IV)PL_curcop->cop_line);
if (GvIO(PL_last_in_gv) && IoLINES(GvIOp(PL_last_in_gv))) {
bool line_mode = (RsSIMPLE(PL_rs) &&
SvCUR(PL_rs) == 1 && *SvPVX(PL_rs) == '\n');