if (IoIFP(sv) &&
IoIFP(sv) != PerlIO_stdin() &&
IoIFP(sv) != PerlIO_stdout() &&
- IoIFP(sv) != PerlIO_stderr())
+ IoIFP(sv) != PerlIO_stderr() &&
+ !(IoFLAGS(sv) & IOf_FAKE_DIRP))
{
io_close(MUTABLE_IO(sv), FALSE);
}
}
}
#ifdef PERL_OLD_COPY_ON_WRITE
- else if (SvPVX_const(sv)) {
+ else if (SvPVX_const(sv)
+ && !(SvTYPE(sv) == SVt_PVIO && !(IoFLAGS(sv) & IOf_FAKE_DIRP))) {
if (SvIsCOW(sv)) {
if (DEBUG_C_TEST) {
PerlIO_printf(Perl_debug_log, "Copy on write: clear\n");
}
}
#else
- else if (SvPVX_const(sv) && SvLEN(sv))
+ else if (SvPVX_const(sv) && SvLEN(sv)
+ && !(SvTYPE(sv) == SVt_PVIO && !(IoFLAGS(sv) & IOf_FAKE_DIRP)))
Safefree(SvPVX_mutable(sv));
else if (SvPVX_const(sv) && SvREADONLY(sv) && SvFAKE(sv)) {
unshare_hek(SvSHARED_HEK_FROM_PV(SvPVX_const(sv)));
Perl_rvpv_dup(aTHX_ dstr, sstr, param);
break;
case SVt_PVIO:
- IoIFP(dstr) = fp_dup(IoIFP(dstr), IoTYPE(dstr), param);
- if (IoOFP(dstr) == IoIFP(sstr))
- IoOFP(dstr) = IoIFP(dstr);
- else
- IoOFP(dstr) = fp_dup(IoOFP(dstr), IoTYPE(dstr), param);
/* PL_parser->rsfp_filters entries have fake IoDIRP() */
if(IoFLAGS(dstr) & IOf_FAKE_DIRP) {
/* I have no idea why fake dirp (rsfps)
NOOP;
/* IoDIRP(dstr) is already a copy of IoDIRP(sstr) */
}
+ IoIFP(dstr) = fp_dup(IoIFP(sstr), IoTYPE(dstr), param);
}
+ if (IoOFP(dstr) == IoIFP(sstr))
+ IoOFP(dstr) = IoIFP(dstr);
+ else
+ IoOFP(dstr) = fp_dup(IoOFP(dstr), IoTYPE(dstr), param);
IoTOP_NAME(dstr) = SAVEPV(IoTOP_NAME(dstr));
IoFMT_NAME(dstr) = SAVEPV(IoFMT_NAME(dstr));
IoBOTTOM_NAME(dstr) = SAVEPV(IoBOTTOM_NAME(dstr));
SV** svu_array; \
HE** svu_hash; \
GP* svu_gp; \
+ PerlIO *svu_fp; \
} sv_u
struct xpvio {
_XPV_HEAD;
union _xivu xiv_u;
- PerlIO * xio_ifp; /* ifp and ofp are normally the same */
- PerlIO * xio_ofp; /* but sockets need separate streams */
+ /* ifp and ofp are normally the same, but sockets need separate streams */
+ PerlIO * xio_ofp;
/* Cray addresses everything by word boundaries (64 bits) and
* code and data pointers cannot be mixed (which is exactly what
* Perl_filter_add() tries to do with the dirp), hence the
assert(SvTYPE(_svcur) != SVt_PVAV); \
assert(SvTYPE(_svcur) != SVt_PVHV); \
assert(!isGV_with_GP(_svcur)); \
+ assert(!(SvTYPE(_svcur) == SVt_PVIO \
+ && !(IoFLAGS(_svcur) & IOf_FAKE_DIRP))); \
&(((XPV*) MUTABLE_PTR(SvANY(_svcur)))->xpv_cur); \
}))
# define SvIVX(sv) \
assert(SvTYPE(_svrv) != SVt_PVCV); \
assert(SvTYPE(_svrv) != SVt_PVFM); \
assert(!isGV_with_GP(_svrv)); \
+ assert(!(SvTYPE(_svrv) == SVt_PVIO \
+ && !(IoFLAGS(_svrv) & IOf_FAKE_DIRP))); \
&((_svrv)->sv_u.svu_rv); \
}))
# define SvRV_const(sv) \
assert(SvTYPE(_svrv) != SVt_PVCV); \
assert(SvTYPE(_svrv) != SVt_PVFM); \
assert(!isGV_with_GP(_svrv)); \
+ assert(!(SvTYPE(_svrv) == SVt_PVIO \
+ && !(IoFLAGS(_svrv) & IOf_FAKE_DIRP))); \
(_svrv)->sv_u.svu_rv; \
})
# define SvMAGIC(sv) \
assert(SvTYPE(sv) != SVt_PVAV); \
assert(SvTYPE(sv) != SVt_PVHV); \
assert(!isGV_with_GP(sv)); \
+ assert(!(SvTYPE(sv) == SVt_PVIO \
+ && !(IoFLAGS(sv) & IOf_FAKE_DIRP))); \
((sv)->sv_u.svu_pv = (val)); } STMT_END
#define SvUV_set(sv, val) \
STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \
assert(SvTYPE(sv) != SVt_PVCV); \
assert(SvTYPE(sv) != SVt_PVFM); \
assert(!isGV_with_GP(sv)); \
+ assert(!(SvTYPE(sv) == SVt_PVIO \
+ && !(IoFLAGS(sv) & IOf_FAKE_DIRP))); \
((sv)->sv_u.svu_rv = (val)); } STMT_END
#define SvMAGIC_set(sv, val) \
STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \
assert(SvTYPE(sv) != SVt_PVAV); \
assert(SvTYPE(sv) != SVt_PVHV); \
assert(!isGV_with_GP(sv)); \
+ assert(!(SvTYPE(sv) == SVt_PVIO \
+ && !(IoFLAGS(sv) & IOf_FAKE_DIRP))); \
(((XPV*) SvANY(sv))->xpv_cur = (val)); } STMT_END
#define SvLEN_set(sv, val) \
STMT_START { assert(SvTYPE(sv) >= SVt_PV); \
assert(SvTYPE(sv) != SVt_PVAV); \
assert(SvTYPE(sv) != SVt_PVHV); \
assert(!isGV_with_GP(sv)); \
+ assert(!(SvTYPE(sv) == SVt_PVIO \
+ && !(IoFLAGS(sv) & IOf_FAKE_DIRP))); \
(((XPV*) SvANY(sv))->xpv_len = (val)); } STMT_END
#define SvEND_set(sv, val) \
STMT_START { assert(SvTYPE(sv) >= SVt_PV); \
#define LvTARGOFF(sv) ((XPVLV*) SvANY(sv))->xlv_targoff
#define LvTARGLEN(sv) ((XPVLV*) SvANY(sv))->xlv_targlen
-#define IoIFP(sv) ((XPVIO*) SvANY(sv))->xio_ifp
+#define IoIFP(sv) (sv)->sv_u.svu_fp
#define IoOFP(sv) ((XPVIO*) SvANY(sv))->xio_ofp
#define IoDIRP(sv) ((XPVIO*) SvANY(sv))->xio_dirp
#define IoANY(sv) ((XPVIO*) SvANY(sv))->xio_any