From cf46f5d84b32df2586f937f34c1718e2a352eb79 Mon Sep 17 00:00:00 2001 From: Tim Ruehsen Date: Fri, 21 Mar 2014 15:41:27 +0100 Subject: [PATCH] replaced getline() by fgets() for compatibility reasons --- src/psl.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/psl.c b/src/psl.c index 15fbb6d..c011137 100644 --- a/src/psl.c +++ b/src/psl.c @@ -270,9 +270,7 @@ psl_ctx_t *psl_load_file(const char *fname) _psl_entry_t suffix, *suffixp; FILE *fp; int nsuffixes = 0; - char *buf = NULL, *linep, *p; - size_t bufsize = 0; - ssize_t buflen; + char buf[256], *linep, *p; if (!(psl = calloc(1, sizeof(psl_ctx_t)))) return NULL; @@ -283,9 +281,7 @@ psl_ctx_t *psl_load_file(const char *fname) psl->suffix_exceptions = _vector_alloc(64, _suffix_compare); if ((fp = fopen(fname, "r"))) { - while ((buflen = getline(&buf, &bufsize, fp)) >= 0) { - linep = buf; - + while ((linep = fgets(&buf, sizeof(buf), fp))) { while (isspace(*linep)) linep++; // ignore leading whitespace if (!*linep) continue; // skip empty lines @@ -311,7 +307,6 @@ psl_ctx_t *psl_load_file(const char *fname) nsuffixes++;; } - free(buf); fclose(fp); _vector_sort(psl->suffix_exceptions);