Annotation of coherent/d/lib/libc/stdio/_fgetc.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * libc/stdio/_fgetc.c
        !             3:  * C Standard I/O Library internals.
        !             4:  * Unbuffered input.
        !             5:  */
        !             6: 
        !             7: #include <stdio.h>
        !             8: #include <errno.h>
        !             9: 
        !            10: extern int     _fputt();
        !            11: 
        !            12: int
        !            13: _fgetc(fp) register FILE *fp;
        !            14: {
        !            15:        register unsigned char s[1];
        !            16:        register int n, oerrno;
        !            17: 
        !            18:        if (stdout->_pt==&_fputt)       /* special kludge */
        !            19:                fflush(stdout);
        !            20:        fp->_cc = 0;
        !            21:        oerrno = errno;                 /* save old errno */
        !            22:        errno = 0;
        !            23:        n = EOF;                        /* return value in case error */
        !            24:        switch (read(fileno(fp), s, 1)) {
        !            25:        case -1:                        /* error */
        !            26:                if (errno != EINTR)
        !            27:                        fp->_ff |= _FERR;
        !            28:                break;
        !            29:        case 0:                         /* EOF */
        !            30:                fp->_ff |= _FEOF;
        !            31:                break;
        !            32:        default:                        /* success */
        !            33:                n = s[0];
        !            34:                break;
        !            35:        }
        !            36:        if (errno == 0)
        !            37:                errno = oerrno;         /* preserve errno if no error */
        !            38:        return n;
        !            39: }
        !            40: 
        !            41: /* end of libc/stdio/_fgetc.c */

unix.superglobalmegacorp.com

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