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.
This commit is contained in:
Hisham Muhammad
2016-06-19 18:55:35 -03:00
committed by GitHub
parent 52f814481c
commit 0fa03322a9
5 changed files with 58 additions and 25 deletions

View File

@ -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;