|
|
1.1 ! root 1: /* ! 2: * libc/stdio/_fgetc.c ! 3: * ANSI-compliant C standard i/o library internals. ! 4: * _fgetc(), _fgetca() ! 5: * Read character, unbuffered. ! 6: */ ! 7: ! 8: #include <stdio.h> ! 9: #if COHERENT || GEMDOS ! 10: #include <errno.h> ! 11: #endif ! 12: ! 13: int ! 14: _fgetc(fp) register FILE *fp; ! 15: { ! 16: unsigned char c; ! 17: register int n; ! 18: ! 19: /* Special kludge: fflush stdout if line buffered. */ ! 20: if ((stdout->_ff1 & _IOLBF) != 0) ! 21: fflush(stdout); ! 22: ! 23: if ((n = read(fileno(fp), &c, 1)) == 1) ! 24: return c; ! 25: else if (n == 0) ! 26: fp->_ff1 |= _FEOF; ! 27: else { ! 28: #if COHERENT || GEMDOS ! 29: if (errno == EINTR) ! 30: errno = 0; ! 31: else ! 32: #endif ! 33: fp->_ff1 |= _FERR; ! 34: } ! 35: return EOF; ! 36: } ! 37: ! 38: #if _ASCII ! 39: ! 40: /* ASCII: ignore '\r', map _EOFCHAR to EOF. */ ! 41: int ! 42: _fgetca(fp) register FILE *fp; ! 43: { ! 44: register int c; ! 45: ! 46: while ((c = _fgetc(fp)) == '\r') ! 47: ; ! 48: if (c == _EOFCHAR) { ! 49: fp->_ff |= _FEOF; ! 50: return EOF; ! 51: } ! 52: return c; ! 53: } ! 54: ! 55: #endif ! 56: ! 57: /* end of libc/stdio/_fgetc.c */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.