summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-16 01:24:04 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-16 01:24:04 -0300
commit4df0ae0bba7e498bba4be4282a5f3a7a60fc2739 (patch)
tree26af62046474a43d8b7d68ab7e7f866c246c7c61
parentd049298e48523ea7285837649e72d47abdfa3827 (diff)
downloadeeshow-4df0ae0bba7e498bba4be4282a5f3a7a60fc2739.tar.gz
eeshow-4df0ae0bba7e498bba4be4282a5f3a7a60fc2739.tar.bz2
eeshow-4df0ae0bba7e498bba4be4282a5f3a7a60fc2739.zip
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.
-rw-r--r--file.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/file.c b/file.c
index a0a83db..8d84f6c 100644
--- a/file.c
+++ b/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;