ext/PerlIO/t/encoding.t See if PerlIO encoding conversion works
ext/PerlIO/t/fail.t See if bad layers fail
ext/PerlIO/t/fallback.t See if PerlIO fallbacks work
+ext/PerlIO/t/ioleaks.t See if PerlIO layers are leaking
ext/PerlIO/t/open.t See if PerlIO certain special opens work
ext/PerlIO/t/PerlIO.t See if PerlIO works
ext/PerlIO/t/scalar.t See if PerlIO::scalar works
--- /dev/null
+#!perl
+# ioleaks.t
+
+use strict;
+use warnings;
+use Test::More 'no_plan';
+
+# :unix -> not ok
+# :stdio -> not ok
+# :perlio -> ok
+# :crlf -> ok
+
+foreach my $layer(qw(:unix :stdio :perlio :crlf)){
+ my $base_fd = do{ open my $in, '<', $0 or die $!; fileno $in };
+
+ for(1 .. 3){
+ open my $fh, "<$layer", $0 or die $!;
+
+ is fileno($fh), $base_fd, $layer;
+ binmode $fh, ':pop';
+ }
+}
+
return PerlLIO_lseek(PerlIOSelf(f, PerlIOUnix)->fd, 0, SEEK_CUR);
}
-
IV
PerlIOUnix_close(pTHX_ PerlIO *f)
{
+ return PerlIOBase_noop_ok(aTHX_ f);
+}
+
+IV
+PerlIOUnix_popped(pTHX_ PerlIO *f)
+{
dVAR;
const int fd = PerlIOSelf(f, PerlIOUnix)->fd;
int code = 0;
sizeof(PerlIOUnix),
PERLIO_K_RAW,
PerlIOUnix_pushed,
- PerlIOBase_popped,
+ PerlIOUnix_popped,
PerlIOUnix_open,
PerlIOBase_binmode, /* binmode */
NULL,
IV
PerlIOStdio_close(pTHX_ PerlIO *f)
{
+ return PerlIOBase_noop_ok(aTHX_ f);
+}
+
+IV
+PerlIOStdio_popped(pTHX_ PerlIO *f)
+{
FILE * const stdio = PerlIOSelf(f, PerlIOStdio)->stdio;
if (!stdio) {
errno = EBADF;
sizeof(PerlIOStdio),
PERLIO_K_BUFFERED|PERLIO_K_RAW,
PerlIOStdio_pushed,
- PerlIOBase_popped,
+ PerlIOStdio_popped,
PerlIOStdio_open,
PerlIOBase_binmode, /* binmode */
NULL,
IV (*Pushed)(pTHX_ PerlIO *f,const char *mode,SV *arg, PerlIO_funcs *tab);
IV (*Popped)(pTHX_ PerlIO *f);
PerlIO * (*Open)(pTHX_ PerlIO_funcs *tab,
- AV *layers, IV n,
+ PerlIO_list_t *layers, IV n,
const char *mode,
int fd, int imode, int perm,
PerlIO *old,
follows:
PerlIO * (*Open)(pTHX_ PerlIO_funcs *tab,
- AV *layers, IV n,
+ PerlIO_list_t *layers, IV n,
const char *mode,
int fd, int imode, int perm,
PerlIO *old,
Open should (perhaps indirectly) call C<PerlIO_allocate()> to allocate
a slot in the table and associate it with the layers information for
-the opened file, by calling C<PerlIO_push>. The I<layers> AV is an
+the opened file, by calling C<PerlIO_push>. The I<layers> is an
array of all the layers destined for the C<PerlIO *>, and any
arguments passed to them, I<n> is the index into that array of the
layer being called. The macro C<PerlIOArg> will return a (possibly