summaryrefslogtreecommitdiff
path: root/lib/libc/stdio
diff options
context:
space:
mode:
authorPaul Janzen <pjanzen@cvs.openbsd.org>2003-05-17 10:28:34 +0000
committerPaul Janzen <pjanzen@cvs.openbsd.org>2003-05-17 10:28:34 +0000
commit0706bf79f1afe0a3dd5cf0329753b0f756c339d3 (patch)
treee7e1a8102610f242d89f55ad7304dd4d6e1a0a71 /lib/libc/stdio
parentc84fcc81e0689216fba535f9373598219158d5e6 (diff)
Document behaviour when size = 1. ok millert@
Diffstat (limited to 'lib/libc/stdio')
-rw-r--r--lib/libc/stdio/fgets.315
-rw-r--r--lib/libc/stdio/fgets.c3
2 files changed, 16 insertions, 2 deletions
diff --git a/lib/libc/stdio/fgets.3 b/lib/libc/stdio/fgets.3
index 00f708d6be8..8d0df4d816d 100644
--- a/lib/libc/stdio/fgets.3
+++ b/lib/libc/stdio/fgets.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: fgets.3,v 1.15 2003/03/06 20:48:35 jmc Exp $
+.\" $OpenBSD: fgets.3,v 1.16 2003/05/17 10:28:33 pjanzen Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -96,6 +96,19 @@ do not distinguish between end-of-file and error, and callers must use
and
.Xr ferror 3
to determine which occurred.
+Whether
+.Fn fgets
+can possibly fail with a
+.Ar size
+argument of 1 is implementation-dependent.
+On
+.Ox ,
+.Fn fgets
+will never return
+.Dv NULL
+when
+.Ar size
+is 1.
.Sh ERRORS
.Bl -tag -width Er
.It Bq Er EBADF
diff --git a/lib/libc/stdio/fgets.c b/lib/libc/stdio/fgets.c
index c2bf76f79cf..4e527978998 100644
--- a/lib/libc/stdio/fgets.c
+++ b/lib/libc/stdio/fgets.c
@@ -35,7 +35,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: fgets.c,v 1.3 2001/07/09 06:57:44 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: fgets.c,v 1.4 2003/05/17 10:28:33 pjanzen Exp $";
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
@@ -46,6 +46,7 @@ static char rcsid[] = "$OpenBSD: fgets.c,v 1.3 2001/07/09 06:57:44 deraadt Exp $
* Read at most n-1 characters from the given file.
* Stop when a newline has been read, or the count runs out.
* Return first argument, or NULL if no characters were read.
+ * Do not return NULL if n == 1.
*/
char *
fgets(buf, n, fp)