mirror of
https://gitlab.freedesktop.org/libbsd/libbsd.git
synced 2025-10-24 17:30:47 +02:00
fgetln: Fix function to make it actually work
Reported by Thorsten Glaser.
This commit is contained in:
@@ -35,13 +35,11 @@ char *
|
|||||||
fgetln (FILE *stream, size_t *len)
|
fgetln (FILE *stream, size_t *len)
|
||||||
{
|
{
|
||||||
char *line=NULL;
|
char *line=NULL;
|
||||||
size_t nread = 0;
|
ssize_t nread;
|
||||||
|
|
||||||
while (nread == 1) {
|
|
||||||
nread = getline (&line, len, stream);
|
nread = getline (&line, len, stream);
|
||||||
if (nread == -1)
|
if (nread == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
(*len)--; /* get rid of the trailing \0, fgetln
|
(*len)--; /* get rid of the trailing \0, fgetln
|
||||||
does not have it */
|
does not have it */
|
||||||
|
|||||||
Reference in New Issue
Block a user