From abc0a0153433fe6596e1ca3a6b5572dc424d0f11 Mon Sep 17 00:00:00 2001 From: Nick Ing-Simmons Date: Tue, 23 Jul 2002 07:56:25 +0000 Subject: Fix #15283 - binmode() was not passing mode to PUSHED method called from PerlIO::via. p4raw-id: //depot/perlio@17653 --- ext/PerlIO/via/via.xs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'ext/PerlIO') diff --git a/ext/PerlIO/via/via.xs b/ext/PerlIO/via/via.xs index 0c247780b6..2bcd35562d 100644 --- a/ext/PerlIO/via/via.xs +++ b/ext/PerlIO/via/via.xs @@ -143,11 +143,15 @@ PerlIOVia_pushed(pTHX_ PerlIO * f, const char *mode, SV * arg, s->stash = gv_stashpvn(SvPVX(s->obj), pkglen + 13, FALSE); } if (s->stash) { - SV *modesv = - (mode) ? sv_2mortal(newSVpvn(mode, strlen(mode))) : - Nullsv; - SV *result = - PerlIOVia_method(aTHX_ f, MYMethod(PUSHED), G_SCALAR, + char lmode[8]; + SV *modesv; + SV *result; + if (!mode) { + /* binmode() passes NULL - so find out what mode is */ + mode = PerlIO_modestr(f,lmode); + } + modesv = sv_2mortal(newSVpvn(mode, strlen(mode))); + result = PerlIOVia_method(aTHX_ f, MYMethod(PUSHED), G_SCALAR, modesv, Nullsv); if (result) { if (sv_isobject(result)) { -- cgit v1.2.1