From 37351bf8bcb1c9a419515030e0f967b94394e860 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Tue, 16 Aug 2016 01:24:04 -0300 Subject: [PATCH] eeshow/file.c (file_read): use getline instead of fgets OSHW-SCHEM-PCB10mm of github.com:cpavlina/kicad-schlib/library/symbol.lib has a line > 1000 characters. --- eeshow/file.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/eeshow/file.c b/eeshow/file.c index a0a83db..8d84f6c 100644 --- a/eeshow/file.c +++ b/eeshow/file.c @@ -220,12 +220,13 @@ bool file_read(struct file *file, bool (*parse)(const struct file *file, void *user, const char *line), void *user) { - char buf[1000]; + static char *buf = NULL; + static size_t n = 0; char *nl; if (file->vcs) return vcs_read(file->vcs, file, parse, user); - while (fgets(buf, sizeof(buf), file->file)) { + while (getline(&buf, &n, file->file) > 0) { nl = strchr(buf, '\n'); if (nl) *nl = 0;