Annotation of coherent/d/lib/libc/stdio/fflush.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * libc/stdio/fflush.c
                      3:  * Standard I/O Library.
                      4:  * Write out any unwritten data in buffer.
                      5:  */
                      6: 
                      7: #include <stdio.h>
                      8: #include <errno.h>
                      9: 
                     10: int
                     11: fflush(fp)
                     12: register FILE  *fp;
                     13: {
                     14:        register int n, cc, oerrno;
                     15: 
                     16:        oerrno = errno;
                     17:        n = errno = fp->_cc = 0;
                     18:        if (fp->_ff&_FERR)
                     19:                n = EOF;
                     20:        else if ((cc = fp->_cp - fp->_dp) <= 0
                     21:         || write(fileno(fp), fp->_dp, cc) == cc
                     22:         || errno == EINTR) {
                     23:                if (cc < 0)
                     24:                        ;
                     25:                else if (fp->_cp == _ep(fp))
                     26:                        fp->_dp = fp->_cp = fp->_bp;
                     27:                else
                     28:                        fp->_dp = fp->_cp;
                     29:        } else {
                     30:                fp->_ff |= _FERR;
                     31:                n = EOF;
                     32:        }
                     33:        if (errno == 0)
                     34:                errno = oerrno;
                     35:        return n;
                     36: }
                     37: 
                     38: /* end of libc/stdio/fflush.c */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.