diff options
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; } |