diff options
author | Tom Smeding <t.j.smeding@uu.nl> | 2024-07-20 12:36:14 +0200 |
---|---|---|
committer | Tom Smeding <t.j.smeding@uu.nl> | 2024-07-20 12:36:14 +0200 |
commit | ad174804745a209a093fa78b8101d40dc2067b22 (patch) | |
tree | 105b0a8bc39461a2892fd1291a2f3d6ca1c994b1 /src | |
parent | 63d8884f8b748457c43af383f8be09ada3063565 (diff) |
Repareer omd bij geen nieuwe regel
Diffstat (limited to 'src')
-rw-r--r-- | src/io/lines.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/io/lines.c b/src/io/lines.c index 6367c1d..fd9c3a5 100644 --- a/src/io/lines.c +++ b/src/io/lines.c @@ -45,6 +45,7 @@ bool file_lines_read(struct file_lines *fl, struct string_view *dst) { // read a line size_t linelen = 0; + bool havenewline = true; while (true) { // grow buffer when small if (fl->cap - fl->cursor < 1024) { @@ -64,6 +65,7 @@ bool file_lines_read(struct file_lines *fl, struct string_view *dst) { if (feof(fl->f)) { if (fl->cursor == 0) return false; linelen = fl->cursor; + havenewline = false; break; } if (fl->fname) fprintf(stderr, "%s: Fout bij lezen van bestand '%s'\n", fl->progname, fl->fname); @@ -83,7 +85,7 @@ bool file_lines_read(struct file_lines *fl, struct string_view *dst) { // we have a newline at buffer + linelen; return lines in buffer dst->s = fl->buffer; dst->len = linelen; - fl->readfrom = linelen + 1; + fl->readfrom = linelen + havenewline; return true; } |