X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=doio.c;h=c37f2dccacb0a02766a0bdbe7c55c46b8bdadc0a;hb=5782d502273e5b6d06607ebe625248c4c102d93b;hp=16d8d01c6bafc425e143589cb91a7286a69dd1e7;hpb=7918f24d20384771923d344a382e1d16d9552018;p=p5sagit%2Fp5-mst-13.2.git diff --git a/doio.c b/doio.c index 16d8d01..c37f2dc 100644 --- a/doio.c +++ b/doio.c @@ -926,7 +926,7 @@ Perl_do_close(pTHX_ GV *gv, bool not_implicit) if (!gv) gv = PL_argvgv; - if (!gv || SvTYPE(gv) != SVt_PVGV) { + if (!gv || !isGV_with_GP(gv)) { if (not_implicit) SETERRNO(EBADF,SS_IVCHAN); return FALSE; @@ -1096,12 +1096,10 @@ Perl_do_sysseek(pTHX_ GV *gv, Off_t pos, int whence) } int -Perl_mode_from_discipline(pTHX_ SV *discp) +Perl_mode_from_discipline(pTHX_ const char *s, STRLEN len) { int mode = O_BINARY; - if (discp) { - STRLEN len; - const char *s = SvPV_const(discp,len); + if (s) { while (*s) { if (*s == ':') { switch (s[1]) { @@ -1309,11 +1307,11 @@ Perl_my_stat(pTHX) const char *s; STRLEN len; PUTBACK; - if (SvTYPE(sv) == SVt_PVGV) { + if (isGV_with_GP(sv)) { gv = (GV*)sv; goto do_fstat; } - else if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVGV) { + else if (SvROK(sv) && isGV_with_GP(SvRV(sv))) { gv = (GV*)SvRV(sv); goto do_fstat; } @@ -1343,6 +1341,7 @@ Perl_my_lstat(pTHX) static const char no_prev_lstat[] = "The stat preceding -l _ wasn't an lstat"; dSP; SV *sv; + const char *file; if (PL_op->op_flags & OPf_REF) { EXTEND(SP,1); if (cGVOP_gv == PL_defgv) { @@ -1364,15 +1363,15 @@ Perl_my_lstat(pTHX) PL_statgv = NULL; sv = POPs; PUTBACK; - if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVGV && ckWARN(WARN_IO)) { + if (SvROK(sv) && isGV_with_GP(SvRV(sv)) && ckWARN(WARN_IO)) { Perl_warner(aTHX_ packWARN(WARN_IO), "Use of -l on filehandle %s", GvENAME((GV*) SvRV(sv))); return (PL_laststatval = -1); } - /* XXX Do really need to be calling SvPV() all these times? */ - sv_setpv(PL_statname,SvPV_nolen_const(sv)); - PL_laststatval = PerlLIO_lstat(SvPV_nolen_const(sv),&PL_statcache); - if (PL_laststatval < 0 && ckWARN(WARN_NEWLINE) && strchr(SvPV_nolen_const(sv), '\n')) + file = SvPV_nolen_const(sv); + sv_setpv(PL_statname,file); + PL_laststatval = PerlLIO_lstat(file,&PL_statcache); + if (PL_laststatval < 0 && ckWARN(WARN_NEWLINE) && strchr(file, '\n')) Perl_warner(aTHX_ packWARN(WARN_NEWLINE), PL_warn_nl, "lstat"); return PL_laststatval; } @@ -1625,7 +1624,7 @@ Perl_apply(pTHX_ I32 type, register SV **mark, register SV **sp) tot = sp - mark; while (++mark <= sp) { GV* gv; - if (SvTYPE(*mark) == SVt_PVGV) { + if (isGV_with_GP(*mark)) { gv = (GV*)*mark; do_fchmod: if (GvIO(gv) && IoIFP(GvIOp(gv))) { @@ -1641,7 +1640,7 @@ Perl_apply(pTHX_ I32 type, register SV **mark, register SV **sp) tot--; } } - else if (SvROK(*mark) && SvTYPE(SvRV(*mark)) == SVt_PVGV) { + else if (SvROK(*mark) && isGV_with_GP(SvRV(*mark))) { gv = (GV*)SvRV(*mark); goto do_fchmod; } @@ -1665,7 +1664,7 @@ Perl_apply(pTHX_ I32 type, register SV **mark, register SV **sp) tot = sp - mark; while (++mark <= sp) { GV* gv; - if (SvTYPE(*mark) == SVt_PVGV) { + if (isGV_with_GP(*mark)) { gv = (GV*)*mark; do_fchown: if (GvIO(gv) && IoIFP(GvIOp(gv))) { @@ -1681,7 +1680,7 @@ Perl_apply(pTHX_ I32 type, register SV **mark, register SV **sp) tot--; } } - else if (SvROK(*mark) && SvTYPE(SvRV(*mark)) == SVt_PVGV) { + else if (SvROK(*mark) && isGV_with_GP(SvRV(*mark))) { gv = (GV*)SvRV(*mark); goto do_fchown; } @@ -1837,7 +1836,7 @@ nothing in the core. tot = sp - mark; while (++mark <= sp) { GV* gv; - if (SvTYPE(*mark) == SVt_PVGV) { + if (isGV_with_GP(*mark)) { gv = (GV*)*mark; do_futimes: if (GvIO(gv) && IoIFP(GvIOp(gv))) { @@ -1854,7 +1853,7 @@ nothing in the core. tot--; } } - else if (SvROK(*mark) && SvTYPE(SvRV(*mark)) == SVt_PVGV) { + else if (SvROK(*mark) && isGV_with_GP(SvRV(*mark))) { gv = (GV*)SvRV(*mark); goto do_futimes; }