sizeof(PerlIOUnix),
PERLIO_K_RAW,
PerlIOUnix_pushed,
- PerlIOBase_noop_ok,
+ PerlIOBase_popped,
PerlIOUnix_open,
NULL,
PerlIOUnix_fileno,
sizeof(PerlIOStdio),
PERLIO_K_BUFFERED,
PerlIOBase_pushed,
- PerlIOBase_noop_ok,
+ PerlIOBase_popped,
PerlIOStdio_open,
NULL,
PerlIOStdio_fileno,
}
IV
+PerlIOBuf_popped(pTHX_ PerlIO *f)
+{
+ IV code = PerlIOBase_popped(aTHX_ f);
+ PerlIOBuf *b = PerlIOSelf(f, PerlIOBuf);
+ if (b->buf && b->buf != (STDCHAR *) & b->oneword) {
+ Safefree(b->buf);
+ }
+ b->buf = NULL;
+ b->ptr = b->end = b->buf;
+ PerlIOBase(f)->flags &= ~(PERLIO_F_RDBUF | PERLIO_F_WRBUF);
+ return code;
+}
+
+IV
PerlIOBuf_close(pTHX_ PerlIO *f)
{
IV code = PerlIOBase_close(aTHX_ f);
sizeof(PerlIOBuf),
PERLIO_K_BUFFERED,
PerlIOBuf_pushed,
- PerlIOBase_noop_ok,
+ PerlIOBuf_popped,
PerlIOBuf_open,
NULL,
PerlIOBase_fileno,
sizeof(PerlIOBuf),
PERLIO_K_BUFFERED,
PerlIOPending_pushed,
- PerlIOBase_noop_ok,
+ PerlIOBuf_popped,
NULL,
NULL,
PerlIOBase_fileno,
sizeof(PerlIOCrlf),
PERLIO_K_BUFFERED | PERLIO_K_CANCRLF,
PerlIOCrlf_pushed,
- PerlIOBase_noop_ok, /* popped */
+ PerlIOBuf_popped, /* popped */
PerlIOBuf_open,
NULL,
PerlIOBase_fileno,
sizeof(PerlIOMmap),
PERLIO_K_BUFFERED,
PerlIOBuf_pushed,
- PerlIOBase_noop_ok,
+ PerlIOBuf_popped,
PerlIOBuf_open,
NULL,
PerlIOBase_fileno,
const char *mode, int fd, int imode,
int perm, PerlIO *old, int narg, SV **args);
extern IV PerlIOBuf_pushed(pTHX_ PerlIO *f, const char *mode, SV *arg);
+extern IV PerlIOBuf_popped(pTHX_ PerlIO *f);
extern PerlIO *PerlIOBuf_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param, int flags);
extern SSize_t PerlIOBuf_read(pTHX_ PerlIO *f, void *vbuf, Size_t count);
extern SSize_t PerlIOBuf_unread(pTHX_ PerlIO *f, const void *vbuf, Size_t count);