fix flsbuf('\377'); make _cnt backward comp. with old putc macro.
authorRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Thu, 22 Nov 1984 04:10:10 +0000 (20:10 -0800)
committerRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Thu, 22 Nov 1984 04:10:10 +0000 (20:10 -0800)
SCCS-vsn: lib/libc/stdio/wbuf.c 4.8

usr/src/lib/libc/stdio/wbuf.c

index e14c597..26aa915 100644 (file)
@@ -1,4 +1,4 @@
-/* @(#)wbuf.c  4.7 (Berkeley) %G% */
+/* @(#)wbuf.c  4.8 (Berkeley) %G% */
 #include       <stdio.h>
 #include       <sys/types.h>
 #include       <sys/stat.h>
 #include       <stdio.h>
 #include       <sys/types.h>
 #include       <sys/stat.h>
@@ -6,6 +6,7 @@
 char   *malloc();
 
 _flsbuf(c, iop)
 char   *malloc();
 
 _flsbuf(c, iop)
+unsigned char c;
 register FILE *iop;
 {
        register char *base;
 register FILE *iop;
 {
        register char *base;
@@ -28,9 +29,9 @@ tryagain:
                if (iop->_ptr >= base+iop->_bufsiz || c == '\n') {
                        n = write(fileno(iop), base, rn = iop->_ptr - base);
                        iop->_ptr = base;
                if (iop->_ptr >= base+iop->_bufsiz || c == '\n') {
                        n = write(fileno(iop), base, rn = iop->_ptr - base);
                        iop->_ptr = base;
+                       iop->_cnt = 0;
                } else
                        rn = n = 0;
                } else
                        rn = n = 0;
-               iop->_cnt = 0;
        } else if (iop->_flag&_IONBF) {
                c1 = c;
                rn = 1;
        } else if (iop->_flag&_IONBF) {
                c1 = c;
                rn = 1;