Re: binmode(STDOUT, ":unix") busted when STDOUT is piped.
authorchromatic <chromatic@wgz.org>
Tue, 25 Sep 2001 23:57:07 +0000 (17:57 -0600)
committerJarkko Hietaniemi <jhi@iki.fi>
Wed, 26 Sep 2001 12:57:11 +0000 (12:57 +0000)
Message-ID: <20010926060233.7554.qmail@onion.perl.org>

p4raw-id: //depot/perl@12236

perlio.c

index d05bf3c939517e4e2717c2fce1dfdbbb1fe4cc36..eb32a045e9977f6283a57986879bfb5d817ef83c 100644 (file)
--- a/perlio.c
+++ b/perlio.c
@@ -945,15 +945,16 @@ PerlIO_binmode(pTHX_ PerlIO *f, int iotype, int mode, const char *names)
     PerlIO_debug("PerlIO_binmode f=%p %s %c %x %s\n",
                 f, PerlIOBase(f)->tab->name, iotype, mode,
                 (names) ? names : "(Null)");
+    PerlIO_flush(f);
     if (!names && (O_TEXT != O_BINARY && (mode & O_BINARY))) {
        PerlIO *top = f;
        while (*top) {
            if (PerlIOBase(top)->tab == &PerlIO_crlf) {
-               PerlIO_flush(top);
                PerlIOBase(top)->flags &= ~PERLIO_F_CRLF;
                break;
            }
            top = PerlIONext(top);
+           PerlIO_flush(top);
        }
     }
     return PerlIO_apply_layers(aTHX_ f, NULL, names) == 0 ? TRUE : FALSE;