Annotation of coherent/b/lib/libc/stdio/_fgetb.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * libc/stdio/_fgetb.c
        !             3:  * ANSI-compliant C standard i/o library internals.
        !             4:  * _fgetb(), _fgetba()
        !             5:  * Read character, buffered.
        !             6:  */
        !             7: 
        !             8: #include <stdio.h>
        !             9: #if    COHERENT || GEMDOS
        !            10: #include <errno.h>
        !            11: #endif
        !            12: 
        !            13: int
        !            14: _fgetb(fp) register FILE *fp;
        !            15: {
        !            16:        register _FILE2 *f2p;
        !            17: 
        !            18:        if (--fp->_cc < 0) {
        !            19:                if (fflush(fp))
        !            20:                        return EOF;
        !            21: 
        !            22:                /* Special kludge: fflush stdout if line buffered. */
        !            23:                if ((stdout->_ff1 & _IOLBF) != 0)
        !            24:                        fflush(stdout);
        !            25: 
        !            26:                f2p = fp->_f2p;
        !            27:                if ((fp->_cc = read(fileno(fp), f2p->_dp, (int)(f2p->_ep - f2p->_dp))) == -1) {
        !            28: #if    COHERENT || GEMDOS
        !            29:                        if (errno == EINTR)
        !            30:                                errno = 0;
        !            31:                        else
        !            32: #endif
        !            33:                        fp->_ff1 |= _FERR;
        !            34:                        fp->_cc = 0;
        !            35:                        return EOF;
        !            36:                } else if (fp->_cc == 0) {
        !            37:                        fp->_ff1 |= _FEOF;
        !            38:                        return EOF;
        !            39:                }
        !            40:                f2p->_dp += fp->_cc--;
        !            41:        }
        !            42:        return (*fp->_cp++);
        !            43: }
        !            44: 
        !            45: #if    _ASCII
        !            46: 
        !            47: /* ASCII: ignore '\r', map _EOFCHAR to EOF. */
        !            48: int
        !            49: _fgetba(fp) register FILE *fp;
        !            50: {
        !            51:        register int c;
        !            52: 
        !            53:        while ((c = _bingetb(fp)) == '\r')
        !            54:                ;
        !            55:        if (c == _EOFCHAR) {
        !            56:                fp->_ff |= _FEOF;
        !            57:                return EOF;
        !            58:        }
        !            59:        return c;
        !            60: }
        !            61: 
        !            62: #endif
        !            63: 
        !            64: /* end of libc/stdio/_fgetb.c */

unix.superglobalmegacorp.com

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