summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/fgets.3
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2014-03-23 23:15:58 +0000
committertedu <tedu@openbsd.org>2014-03-23 23:15:58 +0000
commit643a55bc0a80dff073fa29d08d77374db6b16f73 (patch)
treea06c1da020d9dbfa56c5c0401fa55f04e29a7858 /lib/libc/stdio/fgets.3
parentmajor++ in preparation for coming changes (diff)
downloadwireguard-openbsd-643a55bc0a80dff073fa29d08d77374db6b16f73.tar.xz
wireguard-openbsd-643a55bc0a80dff073fa29d08d77374db6b16f73.zip
c11 compliance: remove gets()
Diffstat (limited to 'lib/libc/stdio/fgets.3')
-rw-r--r--lib/libc/stdio/fgets.365
1 files changed, 10 insertions, 55 deletions
diff --git a/lib/libc/stdio/fgets.3 b/lib/libc/stdio/fgets.3
index 56d6a703148..1e956610ea2 100644
--- a/lib/libc/stdio/fgets.3
+++ b/lib/libc/stdio/fgets.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: fgets.3,v 1.31 2013/07/17 05:42:11 schwarze Exp $
+.\" $OpenBSD: fgets.3,v 1.32 2014/03/23 23:15:58 tedu Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -31,19 +31,16 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd $Mdocdate: July 17 2013 $
+.Dd $Mdocdate: March 23 2014 $
.Dt FGETS 3
.Os
.Sh NAME
-.Nm fgets ,
-.Nm gets
+.Nm fgets
.Nd get a line from a stream
.Sh SYNOPSIS
.In stdio.h
.Ft char *
.Fn fgets "char *str" "int size" "FILE *stream"
-.Ft char *
-.Fn gets "char *str"
.Sh DESCRIPTION
The
.Fn fgets
@@ -61,36 +58,17 @@ The string will be NUL-terminated if
succeeds; otherwise the contents of
.Fa str
are undefined.
-.Pp
-The
-.Fn gets
-function is equivalent to
-.Fn fgets
-with an infinite
-.Ar size
-and a
-.Fa stream
-of
-.Em stdin ,
-except that the newline character (if any) is not stored in the string.
-It is the caller's responsibility to ensure that the input line,
-if any, is sufficiently short to fit in the string.
.Sh RETURN VALUES
Upon successful completion,
.Fn fgets
-and
-.Fn gets
-return
-a pointer to the string.
+returns a pointer to the string.
If end-of-file or an error occurs before any characters are read,
-they return
+it returns
.Dv NULL .
The
.Fn fgets
-and
-.Fn gets
-functions
-do not distinguish between end-of-file and error, and callers must use
+function does not distinguish between end-of-file and error,
+and callers must use
.Xr feof 3
and
.Xr ferror 3
@@ -130,29 +108,18 @@ for any of the errors specified for the routines
.Xr read 2 ,
or
.Xr malloc 3 .
-.Pp
-The function
-.Fn gets
-may also fail and set
-.Va errno
-for any of the errors specified for the routine
-.Xr getchar 3 .
.Sh SEE ALSO
.Xr feof 3 ,
.Xr ferror 3 ,
.Xr fgetln 3
.Sh STANDARDS
-The functions
+The function
.Fn fgets
-and
-.Fn gets
-conform to
+conforms to
.St -ansiC .
.Sh HISTORY
-The functions
+The function
.Fn fgets
-and
-.Fn gets
first appeared in
.At v7 .
.Sh CAVEATS
@@ -229,15 +196,3 @@ char buf[1024];
if (fgets(buf, sizeof(buf), fp) != NULL)
buf[strcspn(buf, "\en")] = '\e0';
.Ed
-.Sh BUGS
-Since it is usually impossible to ensure that the next input line
-is less than some arbitrary length, and because overflowing the
-input buffer is almost invariably a security violation, programs
-should
-.Em NEVER
-use
-.Fn gets .
-The
-.Fn gets
-function exists purely to conform to
-.St -ansiC .