replaced getline() by fgets() for compatibility reasons
This commit is contained in:
parent
f22a3fcb71
commit
cf46f5d84b
|
@ -270,9 +270,7 @@ psl_ctx_t *psl_load_file(const char *fname)
|
||||||
_psl_entry_t suffix, *suffixp;
|
_psl_entry_t suffix, *suffixp;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int nsuffixes = 0;
|
int nsuffixes = 0;
|
||||||
char *buf = NULL, *linep, *p;
|
char buf[256], *linep, *p;
|
||||||
size_t bufsize = 0;
|
|
||||||
ssize_t buflen;
|
|
||||||
|
|
||||||
if (!(psl = calloc(1, sizeof(psl_ctx_t))))
|
if (!(psl = calloc(1, sizeof(psl_ctx_t))))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -283,9 +281,7 @@ psl_ctx_t *psl_load_file(const char *fname)
|
||||||
psl->suffix_exceptions = _vector_alloc(64, _suffix_compare);
|
psl->suffix_exceptions = _vector_alloc(64, _suffix_compare);
|
||||||
|
|
||||||
if ((fp = fopen(fname, "r"))) {
|
if ((fp = fopen(fname, "r"))) {
|
||||||
while ((buflen = getline(&buf, &bufsize, fp)) >= 0) {
|
while ((linep = fgets(&buf, sizeof(buf), fp))) {
|
||||||
linep = buf;
|
|
||||||
|
|
||||||
while (isspace(*linep)) linep++; // ignore leading whitespace
|
while (isspace(*linep)) linep++; // ignore leading whitespace
|
||||||
if (!*linep) continue; // skip empty lines
|
if (!*linep) continue; // skip empty lines
|
||||||
|
|
||||||
|
@ -311,7 +307,6 @@ psl_ctx_t *psl_load_file(const char *fname)
|
||||||
nsuffixes++;;
|
nsuffixes++;;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(buf);
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
_vector_sort(psl->suffix_exceptions);
|
_vector_sort(psl->suffix_exceptions);
|
||||||
|
|
Loading…
Reference in New Issue