From 0fa03322a935a6ffc564852068f13302f3dd1e72 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Sun, 19 Jun 2016 18:55:35 -0300 Subject: Dynamically adjust the size of line reads * Dynamically adjust the size of line reads. * Remove some more uses of fgets with arbitrary sizes. * Fix reading of lines and width of n column. Fixes #514. --- Settings.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'Settings.c') diff --git a/Settings.c b/Settings.c index eaca7829..0e296c10 100644 --- a/Settings.c +++ b/Settings.c @@ -173,12 +173,15 @@ static bool Settings_read(Settings* this, const char* fileName) { if (!fd) return false; - const int maxLine = 2048; - char buffer[maxLine]; bool readMeters = false; - while (fgets(buffer, maxLine, fd)) { + for (;;) { + char* line = String_readLine(fd); + if (!line) { + break; + } int nOptions; - char** option = String_split(buffer, '=', &nOptions); + char** option = String_split(line, '=', &nOptions); + free (line); if (nOptions < 2) { String_freeArray(option); continue; -- cgit v1.2.3