From: Chip Salzenberg Date: Thu, 15 May 1997 22:15:00 +0000 (+1200) Subject: Make read with <> from a TTY notice EOF X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=63e4d8773d8e4bda5ca8583ec13c22520fce4101;p=p5sagit%2Fp5-mst-13.2.git Make read with <> from a TTY notice EOF (this is the same change as commit 451e086022facb7867a6764d6ffca2b71e86ff73, but as applied) --- diff --git a/sv.c b/sv.c index 23b5c58..ece94b9 100644 --- a/sv.c +++ b/sv.c @@ -3253,7 +3253,19 @@ screamer2: memNE(SvPVX(sv) + SvCUR(sv) - rslen, rsptr, rslen))) { append = -1; - goto screamer2; + /* + * If we're reading from a TTY and we get a short read, + * indicating that the user hit his EOF character, we need + * to notice it now, because if we try to read from the TTY + * again, the EOF condition will disappear. + * + * The comparison of cnt to sizeof(buf) is an optimization + * that prevents unnecessary calls to feof(). + * + * - jik 9/25/96 + */ + if (!(cnt < sizeof(buf) && PerlIO_eof(fp))) + goto screamer2; } }