From: Nick Ing-Simmons Date: Thu, 22 Mar 2001 09:02:45 +0000 (+0000) Subject: perlio tweaks (reported by Nicholas Clark) X-Git-Tag: accepted/trunk/20130322.191538~23899^2~755 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1f47406448f2d51ae8241e146df3675f96b72815;p=platform%2Fupstream%2Fperl.git 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 --- diff --git a/perlio.c b/perlio.c index f0e8074..132fe47 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; }