From 601acae8830fe4bb3e1fc9004210c61b68666aa6 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sun, 25 Jun 2023 22:35:27 +0200 Subject: user/libc: fix fgets not storing the newline also removed an old TODO --- src/user/lib/stdio/file.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/user') diff --git a/src/user/lib/stdio/file.c b/src/user/lib/stdio/file.c index ab424d3..efaf013 100644 --- a/src/user/lib/stdio/file.c +++ b/src/user/lib/stdio/file.c @@ -242,13 +242,12 @@ int fputs(const char *s, FILE *f) { return fprintf(f, "%s\n", s); } -// TODO! c file buffering char *fgets(char *buf, int size, FILE *f) { int pos, c; - for (pos = 0; pos < size-1; pos++) { + for (pos = 0; pos < size-1; ) { c = fgetc(f); if (c == EOF) break; - buf[pos] = c; + buf[pos++] = c; if (c == '\n') break; } if (pos == 0 || f->error) { -- cgit v1.2.3