]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
Expand on API guarantee for fgetln
authorThorsten Glaser <tg@mirbsd.org>
Thu, 10 Dec 2009 17:07:25 +0000 (18:07 +0100)
committerGuillem Jover <guillem@hadrons.org>
Thu, 10 Dec 2009 20:07:02 +0000 (21:07 +0100)
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>
man/fgetln.3
src/fgetln.c

index d483c09a93e423395bdf06d6e796735b36d41286..c01d1efbccfadb7d799247d6e62a2ddb8ffc44d5 100644 (file)
@@ -54,7 +54,7 @@ character.
 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.)
index 6e3d000e3ceb89710cc48da0bd3998471280cdda..317880de54ba753998f7694346e0c78e69cc22dd 100644 (file)
@@ -39,6 +39,7 @@ fgetln (FILE *stream, size_t *len)
        ssize_t nread;
 
        nread = getline(&line, &line_len, stream);
+       /* Note: the getdelim/getline API ensures nread != 0. */
        if (nread == -1) {
                *len = 0;
                return NULL;