Make read with <> from a TTY notice EOF
Chip Salzenberg [Thu, 15 May 1997 22:15:00 +0000 (10:15 +1200)]
(this is the same change as commit 451e086022facb7867a6764d6ffca2b71e86ff73, but as applied)

sv.c

diff --git a/sv.c b/sv.c
index 23b5c58..ece94b9 100644 (file)
--- 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;
        }
     }