From db616c2d5cff8477336b318d889e02112fe97f9a Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Tue, 28 May 2024 12:34:30 -0400 Subject: handle stream orientation behavior --- src/stdio/putc_unlocked.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/stdio/putc_unlocked.c') 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') || -- cgit v1.2.1