From: schwarze Date: Tue, 4 Jul 2017 15:33:03 +0000 (+0000) Subject: 1. mild deprecation notice X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=3b4daaf6c0d9f8773500fd515b8cf4aa9becc281;p=openbsd 1. mild deprecation notice 2. point to getline (suggested by nicm@) 3. cross reference fgetc(3) rather than putc(3) 4. add missing error handling to the example code OK nicm@ --- diff --git a/lib/libc/stdio/fgetln.3 b/lib/libc/stdio/fgetln.3 index a6f4af0392a..6cd9c5c9a11 100644 --- a/lib/libc/stdio/fgetln.3 +++ b/lib/libc/stdio/fgetln.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: fgetln.3,v 1.17 2015/01/13 14:02:30 schwarze Exp $ +.\" $OpenBSD: fgetln.3,v 1.18 2017/07/04 15:33:03 schwarze Exp $ .\" .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd $Mdocdate: January 13 2015 $ +.Dd $Mdocdate: July 4 2017 $ .Dt FGETLN 3 .Os .Sh NAME @@ -38,6 +38,11 @@ .Ft char * .Fn fgetln "FILE *stream" "size_t *len" .Sh DESCRIPTION +Using this function is error-prone in multiple ways; +consider using the safer and more portable function +.Xr getline 3 +instead. +.Pp The .Fn fgetln function returns a pointer to the next line from the stream referenced by @@ -103,10 +108,11 @@ or .Xr realloc 3 . .Sh SEE ALSO .Xr ferror 3 , +.Xr fgetc 3 , .Xr fgets 3 , .Xr fopen 3 , .Xr fparseln 3 , -.Xr putc 3 +.Xr getline 3 .Sh HISTORY The .Fn fgetln @@ -139,4 +145,6 @@ temporary buffer: printf("%s\en", buf); } free(lbuf); + if (ferror(fp)) + err(1, "fgetln"); .Ed