summaryrefslogtreecommitdiff
path: root/src/user
diff options
context:
space:
mode:
authordzwdz2023-06-25 22:35:27 +0200
committerdzwdz2023-06-25 22:35:27 +0200
commit601acae8830fe4bb3e1fc9004210c61b68666aa6 (patch)
treeb2badcc612d719327ca3ed42279e8d46255d6cda /src/user
parent36945ddbf7106fc692533ec145eaf124d68600ad (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.c5
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) {