]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
fgetln: Fix function to make it actually work
authorGuillem Jover <guillem@hadrons.org>
Wed, 9 Jul 2008 05:22:30 +0000 (08:22 +0300)
committerGuillem Jover <guillem@hadrons.org>
Wed, 9 Jul 2008 05:22:30 +0000 (08:22 +0300)
Reported by Thorsten Glaser.

src/fgetln.c

index c92aa823f6e6975dde2e82268814b7e02e0e4ece..9f2a584708a813213e6c68fd5b2805aee6e014d8 100644 (file)
@@ -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 */