From 47109e39d5995c7addaa932625fb0ea1e0e8200a Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Wed, 9 Jul 2008 08:22:30 +0300 Subject: [PATCH] fgetln: Fix function to make it actually work Reported by Thorsten Glaser. --- src/fgetln.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/fgetln.c b/src/fgetln.c index c92aa82..9f2a584 100644 --- a/src/fgetln.c +++ b/src/fgetln.c @@ -35,13 +35,11 @@ char * fgetln (FILE *stream, size_t *len) { char *line=NULL; - size_t nread = 0; + ssize_t nread; - while (nread == 1) { - nread = getline (&line, len, stream); - if (nread == -1) - return NULL; - } + nread = getline (&line, len, stream); + if (nread == -1) + return NULL; (*len)--; /* get rid of the trailing \0, fgetln does not have it */