fgetln: Fix function to make it actually work

Reported by Thorsten Glaser.
This commit is contained in:
Guillem Jover 2008-07-09 08:22:30 +03:00
parent da92787d48
commit 47109e39d5

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