From: Nick Ing-Simmons Date: Tue, 23 Jul 2002 07:56:25 +0000 (+0000) Subject: Fix #15283 - binmode() was not passing mode X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=abc0a0153433fe6596e1ca3a6b5572dc424d0f11;p=p5sagit%2Fp5-mst-13.2.git Fix #15283 - binmode() was not passing mode to PUSHED method called from PerlIO::via. p4raw-id: //depot/perlio@17653 --- diff --git a/ext/PerlIO/via/via.xs b/ext/PerlIO/via/via.xs index 0c24778..2bcd355 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)) {