Changeset bd5414e in mainline for uspace/lib/posix/source/stdio.c
- Timestamp:
- 2015-09-21T21:05:26Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c70703a
- Parents:
- bea710f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/posix/source/stdio.c
rbea710f rbd5414e 118 118 int posix_ungetc(int c, FILE *stream) 119 119 { 120 uint8_t b = (uint8_t) c; 121 122 bool can_unget = 123 /* Provided character is legal. */ 124 c != EOF && 125 /* Stream is consistent. */ 126 !stream->error && 127 /* Stream is buffered. */ 128 stream->btype != _IONBF && 129 /* Last operation on the stream was a read operation. */ 130 stream->buf_state == _bs_read && 131 /* Stream buffer is already allocated (i.e. there was already carried 132 * out either write or read operation on the stream). This is probably 133 * redundant check but let's be safe. */ 134 stream->buf != NULL && 135 /* There is still space in the stream to retreat. POSIX demands the 136 * possibility to unget at least 1 character. It should be always 137 * possible, assuming the last operation on the stream read at least 1 138 * character, because the buffer is refilled in the lazily manner. */ 139 stream->buf_tail > stream->buf; 140 141 if (can_unget) { 142 --stream->buf_tail; 143 stream->buf_tail[0] = b; 144 stream->eof = false; 145 return (int) b; 146 } else { 147 return EOF; 148 } 120 return ungetc(c, stream); 149 121 } 150 122
Note:
See TracChangeset
for help on using the changeset viewer.