From 659805960b6a448c5bc2fd8fcd47ddcdea0a63ec Mon Sep 17 00:00:00 2001 From: EnderIce2 Date: Mon, 3 Mar 2025 12:08:39 +0000 Subject: [PATCH] fix(userspace/libc): wrong puts() implementation The implementation didn't fully followed the POSIX.1-2024 standard "The puts() function shall write the string pointed to by s, followed by a , to the standard output stream stdout. The terminating null byte shall not be written." Signed-off-by: EnderIce2 --- Userspace/libc/src/std/stdio.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Userspace/libc/src/std/stdio.c b/Userspace/libc/src/std/stdio.c index 38820c70..2338e8ee 100644 --- a/Userspace/libc/src/std/stdio.c +++ b/Userspace/libc/src/std/stdio.c @@ -455,7 +455,15 @@ export int putc(int c, FILE *stream) { return fputc(c, stream); } export int putchar(int c) { return putc(c, stdout); } export int putc_unlocked(int c, FILE *stream) { return fputc(c, stream); } export int putchar_unlocked(int c) { return putc_unlocked(c, stdout); } -export int puts(const char *s) { return fputs(s, stdout); } + +export int puts(const char *s) +{ + if (fputs(s, stdout) == EOF) + return EOF; + if (fputc('\n', stdout) == EOF) + return EOF; + return 0; +} export int remove(const char *); export int rename(const char *, const char *);