OpenBSD has begun using the API guarantee that *len is not 0 if
the fgetln(3) return value is not NULL; document this explicitly
in the manpage and add a comment to the function implementation
that this doesn’t need to be checked because getdelim/getline have
similar guarantees.
Signed-off-by: Thorsten Glaser <tg@mirbsd.org>
The length of the line, including the final newline,
is stored in the memory location to which
.Fa len
-points.
+points and is guaranteed to be greater than 0 upon successful completion.
(Note, however, that if the line is the last
in a file that does not end in a newline,
the returned text will not contain a newline.)
ssize_t nread;
nread = getline(&line, &line_len, stream);
+ /* Note: the getdelim/getline API ensures nread != 0. */
if (nread == -1) {
*len = 0;
return NULL;