Last change
on this file since c79db87 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago |
Imported original source code.
|
-
Property mode
set to
100755
|
File size:
880 bytes
|
Rev | Line | |
---|
[3ae31e9] | 1 | /*
|
---|
| 2 | ============================================================================
|
---|
| 3 | getc.c -- get a character from a stream file
|
---|
| 4 | Version 3 -- 1987-09-22 -- D.N. Lynx Crowe
|
---|
| 5 | ============================================================================
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #include "stdio.h"
|
---|
| 9 | #include "stddefs.h"
|
---|
| 10 |
|
---|
| 11 | int
|
---|
| 12 | getc(ptr)
|
---|
| 13 | register FILE *ptr;
|
---|
| 14 | {
|
---|
| 15 | register int len;
|
---|
| 16 |
|
---|
| 17 | if (ptr->_bp >= ptr->_bend) { /* see if the buffer is empty */
|
---|
| 18 |
|
---|
| 19 | if (ptr->_flags & _EOF) /* check EOF status */
|
---|
| 20 | return(EOF);
|
---|
| 21 |
|
---|
| 22 | ptr->_flags &= ~_DIRTY; /* reset the dirty buffer bit */
|
---|
| 23 |
|
---|
| 24 | if (ptr->_buff EQ NULL) /* get a buffer if none exists */
|
---|
| 25 | getbuff(ptr);
|
---|
| 26 |
|
---|
| 27 | if ((len = read(ptr->_unit, ptr->_buff, ptr->_buflen)) LE 0) {
|
---|
| 28 |
|
---|
| 29 | ptr->_flags |= ((len EQ 0) ? _EOF : _IOERR);
|
---|
| 30 | return(EOF);
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | ptr->_bend = (ptr->_bp = ptr->_buff) + len;
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | return(*ptr->_bp++ & 0xFF);
|
---|
| 37 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.