From 04646db1bf7dee24d6063d61fc320e896ba36941 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Sun, 21 Oct 2018 20:45:23 +0300 Subject: Make for_each_line_in_file work with non \n stuff --- src/util.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/util.h b/src/util.h index 8dc2fb9..79a7e7e 100644 --- a/src/util.h +++ b/src/util.h @@ -49,5 +49,9 @@ for_each_line_in_file(FILE *f, void (*cb)(const char *line, void *data), void *d memmove(buffer, buffer + ate, (written = written - ate)); } while ((read = fread(buffer + written, 1, allocated - written, f))); + + if (written > 0) + cb(buffer, data); + free(buffer); } -- cgit v1.2.3