diff options
| author | Jakob Kaivo <jkk@ung.org> | 2024-05-28 12:34:30 -0400 |
|---|---|---|
| committer | Jakob Kaivo <jkk@ung.org> | 2024-05-28 12:34:30 -0400 |
| commit | db616c2d5cff8477336b318d889e02112fe97f9a (patch) | |
| tree | 4827495015891d4492ac50e05c6fe2d430b194b0 /src/stdio/putc_unlocked.c | |
| parent | e6ef806ef40a421435b1209f0f79d778c03fe04a (diff) | |
handle stream orientation behavior
Diffstat (limited to 'src/stdio/putc_unlocked.c')
| -rw-r--r-- | src/stdio/putc_unlocked.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/stdio/putc_unlocked.c b/src/stdio/putc_unlocked.c index 9a7b3a60..f3714af8 100644 --- a/src/stdio/putc_unlocked.c +++ b/src/stdio/putc_unlocked.c @@ -23,6 +23,14 @@ int putc_unlocked(int c, FILE *stream) } stream->operation = OP_OUTPUT; + if (stream->buf == NULL) { + if (write(stream->fd, &ch, 1) != 1) { + stream->err = 1; + return EOF; + } + return ch; + } + stream->buf[stream->bpos++] = ch; if (stream->bpos == stream->bsize || (stream->bmode == _IOLBF && ch == '\n') || |
