summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>2001-03-22 09:02:45 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>2001-03-22 09:02:45 +0000
commit1f47406448f2d51ae8241e146df3675f96b72815 (patch)
tree5edd591fc0c0056b8db78632103fab43c6240896 /perlio.c
parent6cde4e9429924ded8fa67b82555e7528e0d47b56 (diff)
downloadperl-1f47406448f2d51ae8241e146df3675f96b72815.tar.gz
perlio tweaks (reported by Nicholas Clark)
Line buffer ttys, PerlIOBuf_tell() on unseekable off-by one, error check in Pendinf_read(). p4raw-id: //depot/perlio@9293
Diffstat (limited to 'perlio.c')
-rw-r--r--perlio.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/perlio.c b/perlio.c
index f0e8074b50..132fe47380 100644
--- a/perlio.c
+++ b/perlio.c
@@ -2079,7 +2079,17 @@ IV
PerlIOBuf_pushed(PerlIO *f, const char *mode, const char *arg, STRLEN len)
{
PerlIOBuf *b = PerlIOSelf(f,PerlIOBuf);
- b->posn = PerlIO_tell(PerlIONext(f));
+ int fd = PerlIO_fileno(f);
+ Off_t posn;
+ if (fd >= 0 && PerlLIO_isatty(fd))
+ {
+ PerlIOBase(f)->flags |= PERLIO_F_LINEBUF;
+ }
+ posn = PerlIO_tell(PerlIONext(f));
+ if (posn != (Off_t) -1)
+ {
+ b->posn = posn;
+ }
return PerlIOBase_pushed(f,mode,arg,len);
}
@@ -2610,8 +2620,12 @@ PerlIOPending_read(PerlIO *f, void *vbuf, Size_t count)
avail = count;
if (avail > 0)
got = PerlIOBuf_read(f,vbuf,avail);
- if (got < count)
- got += PerlIO_read(f,((STDCHAR *) vbuf)+got,count-got);
+ if (got >= 0 && got < count)
+ {
+ SSize_t more = PerlIO_read(f,((STDCHAR *) vbuf)+got,count-got);
+ if (more >= 0 || got == 0)
+ got += more;
+ }
return got;
}