summaryrefslogtreecommitdiff
path: root/userland/libc/stdio/getdelim.c
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-06-23 12:42:37 +0200
committerAnton Kling <anton@kling.gg>2024-06-23 12:42:56 +0200
commiteb606d798b18be08e4a403132350b6dc350b522b (patch)
treedb4aa1e6ec799f9d5bf4bd8c9b71ed0dc45bedad /userland/libc/stdio/getdelim.c
parent5fbd9b519e082fc235a8a57c6cf761e6cefbfb62 (diff)
LibC: Include delim in getdelim if it was seen
Diffstat (limited to 'userland/libc/stdio/getdelim.c')
-rw-r--r--userland/libc/stdio/getdelim.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/userland/libc/stdio/getdelim.c b/userland/libc/stdio/getdelim.c
index 3a6f23e..606a545 100644
--- a/userland/libc/stdio/getdelim.c
+++ b/userland/libc/stdio/getdelim.c
@@ -10,10 +10,6 @@ size_t getdelim(char **lineptr, size_t *n, int delimiter, FILE *stream) {
for (;;) {
char c;
if (0 == fread(&c, 1, 1, stream)) {
- s++;
- break;
- }
- if (c == delimiter) {
break;
}
if (s + 1 >= *n) {
@@ -22,6 +18,9 @@ size_t getdelim(char **lineptr, size_t *n, int delimiter, FILE *stream) {
}
(*lineptr)[s] = c;
s++;
+ if (c == delimiter) {
+ break;
+ }
}
(*lineptr)[s] = '\0';
return s;