libbsd/fgetln.c
Guillem Jover b478b9dd03 fgetln: Cleanup function
Reindent, remove commented code and translate variable names to english
2008-05-06 08:42:49 +03:00

29 lines
403 B
C

#include <stdio.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <string.h>
#ifdef __GLIBC__
char *
fgetln (stream, len)
FILE *stream;
size_t *len;
{
char *line=NULL;
size_t nread = 0;
while (nread == 1) {
nread = getline (&line, len, stream);
if (nread == -1)
return NULL;
}
(*len)--; /* get rid of the trailing \0, fgetln
does not have it */
return line;
}
#endif