Commit 47109e39d5995c7addaa932625fb0ea1e0e8200a

Guillem Jover 2008-07-09T08:22:30

fgetln: Fix function to make it actually work Reported by Thorsten Glaser.

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 */