summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>2001-03-26 17:32:06 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>2001-03-26 17:32:06 +0000
commita9c883f63197ffe78a9fa90fb454b99d9d4027c2 (patch)
treee981b5bc2bbda851f6a58188b6b22ea388b67c09 /perlio.c
parent9133bbab1b418762e5735878fdd7f85407fdd45a (diff)
downloadperl-a9c883f63197ffe78a9fa90fb454b99d9d4027c2.tar.gz
Implement flush of linebuffered streams on read of a tty.
p4raw-id: //depot/perlio@9361
Diffstat (limited to 'perlio.c')
-rw-r--r--perlio.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/perlio.c b/perlio.c
index d33c0cb708..50e3be1062 100644
--- a/perlio.c
+++ b/perlio.c
@@ -1140,6 +1140,25 @@ PerlIO_flush(PerlIO *f)
}
}
+void
+PerlIOBase_flush_linebuf()
+{
+ PerlIO **table = &_perlio;
+ PerlIO *f;
+ while ((f = *table))
+ {
+ int i;
+ table = (PerlIO **)(f++);
+ for (i=1; i < PERLIO_TABLE_SIZE; i++)
+ {
+ if (*f && (PerlIOBase(f)->flags & (PERLIO_F_LINEBUF|PERLIO_F_CANWRITE))
+ == (PERLIO_F_LINEBUF|PERLIO_F_CANWRITE))
+ PerlIO_flush(f);
+ f++;
+ }
+ }
+}
+
#undef PerlIO_fill
int
PerlIO_fill(PerlIO *f)
@@ -2331,7 +2350,7 @@ PerlIOBuf_pushed(PerlIO *f, const char *mode, SV *arg)
dTHX;
if (fd >= 0 && PerlLIO_isatty(fd))
{
- PerlIOBase(f)->flags |= PERLIO_F_LINEBUF;
+ PerlIOBase(f)->flags |= PERLIO_F_LINEBUF|PERLIO_F_TTY;
}
posn = PerlIO_tell(PerlIONext(f));
if (posn != (Off_t) -1)
@@ -2450,6 +2469,8 @@ PerlIOBuf_fill(PerlIO *f)
*/
if (PerlIO_flush(f) != 0)
return -1;
+ if (PerlIOBase(f)->flags & PERLIO_F_TTY)
+ PerlIOBase_flush_linebuf();
if (!b->buf)
PerlIO_get_base(f); /* allocate via vtable */