On Fri, 1 Jul 2022 02:02:31 -0700 lon...@linuxonhyperv.com wrote: > + while (fgets(line, sizeof(line), file) == line) { > + size_t len = strlen(line); > + int ret; > + > + /* Truncate long lines. */ > + if (len == (sizeof(line) - 1)) > + while (line[(len - 1)] != '\n') { > + ret = fgetc(file); > + if (ret == EOF) > + break; > + line[(len - 1)] = ret;
An alternative, would be to use getline() which handles arbitrary length input.