summaryrefslogtreecommitdiff
path: root/lib/libc/stdio/fputc.c
diff options
context:
space:
mode:
authorKacper <kacper@mail.openlinux.dev>2025-12-09 21:17:12 +0100
committerKacper <kacper@mail.openlinux.dev>2025-12-09 21:17:12 +0100
commitb5cd18739a64c8d923a55b61c89ae3900faafd84 (patch)
treed192f7b25257ae9a8a4760c68f5314dcbc0d9b91 /lib/libc/stdio/fputc.c
parent119aed5bc787ccbf23d2f151759ec1f3a80977e1 (diff)
Fix include paths and formatting inconsistencies
Diffstat (limited to 'lib/libc/stdio/fputc.c')
-rw-r--r--lib/libc/stdio/fputc.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/lib/libc/stdio/fputc.c b/lib/libc/stdio/fputc.c
index c544d5dd..08ab0cfc 100644
--- a/lib/libc/stdio/fputc.c
+++ b/lib/libc/stdio/fputc.c
@@ -1,27 +1,24 @@
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <io.h>
+#include "stddef.h" // for NULL
+
+#include <errno.h> // for EINVAL, errno
+#include <libc.h> // for __IMPL
+#include <stdio.h> // for EOF, fwrite, FILE, fputc
int fputc(int c, FILE *stream)
{
- if (!stream) {
+ if (stream == NULL) {
errno = EINVAL;
return EOF;
}
- // Special case for string buffer operations (snprintf)
- // When fd is -1, we're writing to a string buffer
- if (stream->fd == -1 && stream->buf != NULL) {
- // Check if there's space (leave room for null terminator)
- if (stream->buf_len >= stream->buf_size - 1) {
+ if (__IMPL(stream)->fd == -1 && __IMPL(stream)->buf != NULL) {
+ if (__IMPL(stream)->buf_len >= __IMPL(stream)->buf_size - 1) {
return EOF;
}
- stream->buf[stream->buf_len++] = (char)c;
+ __IMPL(stream)->buf[__IMPL(stream)->buf_len++] = (char)c;
return (unsigned char)c;
}
- // For regular file operations, use fwrite
return fwrite(&c, 1, 1, stream) ? c : EOF;
}