BSD 4_2 release
[unix-history] / usr / src / lib / libc / stdio / filbuf.c
index c793908..6ed01ed 100644 (file)
@@ -1,4 +1,4 @@
-/* @(#)filbuf.c        4.4 (Berkeley) %G% */
+/* @(#)filbuf.c        4.6 (Berkeley) 6/30/83 */
 #include       <stdio.h>
 #include       <sys/types.h>
 #include       <sys/stat.h>
 #include       <stdio.h>
 #include       <sys/types.h>
 #include       <sys/stat.h>
@@ -17,7 +17,7 @@ register FILE *iop;
 
        if ((iop->_flag&_IOREAD) == 0)
                return(EOF);
 
        if ((iop->_flag&_IOREAD) == 0)
                return(EOF);
-       if (iop->_flag&_IOSTRG)
+       if (iop->_flag&(_IOSTRG|_IOEOF))
                return(EOF);
 tryagain:
        if (iop->_base==NULL) {
                return(EOF);
 tryagain:
        if (iop->_base==NULL) {
@@ -40,8 +40,12 @@ tryagain:
                }
                iop->_bufsiz = size;
        }
                }
                iop->_bufsiz = size;
        }
-       if (iop == stdin && (stdout->_flag&_IOLBF))
-               fflush(stdout);
+       if (iop == stdin) {
+               if (stdout->_flag&_IOLBF)
+                       fflush(stdout);
+               if (stderr->_flag&_IOLBF)
+                       fflush(stderr);
+       }
        iop->_cnt = read(fileno(iop), iop->_base,
                iop->_flag & _IONBF ? 1 : iop->_bufsiz);
        iop->_ptr = iop->_base;
        iop->_cnt = read(fileno(iop), iop->_base,
                iop->_flag & _IONBF ? 1 : iop->_bufsiz);
        iop->_ptr = iop->_base;