From: Ralph Campbell Date: Sat, 5 May 1984 04:52:37 +0000 (-0800) Subject: don't do 1 byte writes, buffer and flush unbuffered I/O (stderr). X-Git-Tag: BSD-4_3-Snapshot-Development~10044 X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/commitdiff_plain/96ae61b2dddadf16afa8ff7c1a1527e863e4ab05 don't do 1 byte writes, buffer and flush unbuffered I/O (stderr). SCCS-vsn: lib/libc/stdio/fprintf.c 4.2 --- diff --git a/usr/src/lib/libc/stdio/fprintf.c b/usr/src/lib/libc/stdio/fprintf.c index 4d2e1aff3b..54125e2894 100644 --- a/usr/src/lib/libc/stdio/fprintf.c +++ b/usr/src/lib/libc/stdio/fprintf.c @@ -1,10 +1,22 @@ -/* @(#)fprintf.c 4.1 (Berkeley) %G% */ +/* @(#)fprintf.c 4.2 (Berkeley) %G% */ #include fprintf(iop, fmt, args) FILE *iop; char *fmt; { - _doprnt(fmt, &args, iop); + char localbuf[BUFSIZ]; + + if (iop->_flag & _IONBF) { + iop->_flag &= ~_IONBF; + iop->_ptr = iop->_base = localbuf; + iop->_bufsiz = BUFSIZ; + _doprnt(fmt, &args, iop); + fflush(iop); + iop->_flag |= _IONBF; + iop->_base = NULL; + iop->_bufsiz = NULL; + } else + _doprnt(fmt, &args, iop); return(ferror(iop)? EOF: 0); }