diff options
author | dzwdz | 2023-06-25 22:35:27 +0200 |
---|---|---|
committer | dzwdz | 2023-06-25 22:35:27 +0200 |
commit | 601acae8830fe4bb3e1fc9004210c61b68666aa6 (patch) | |
tree | b2badcc612d719327ca3ed42279e8d46255d6cda /src/user | |
parent | 36945ddbf7106fc692533ec145eaf124d68600ad (diff) |
user/libc: fix fgets not storing the newline
also removed an old TODO
Diffstat (limited to 'src/user')
-rw-r--r-- | src/user/lib/stdio/file.c | 5 |
1 files changed, 2 insertions, 3 deletions
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) { |