From fe20c3b61cf7a350008af82729ff73c95143707b Mon Sep 17 00:00:00 2001 From: Bruce Evans Date: Wed, 27 Mar 1996 17:43:38 +0000 Subject: [PATCH] Say what happens to the buffer when fgets() returns NULL. Fixed bogus cross references and a misordered line. --- lib/libc/stdio/fgets.3 | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/libc/stdio/fgets.3 b/lib/libc/stdio/fgets.3 index 827de6b51463..e1693828e6ee 100644 --- a/lib/libc/stdio/fgets.3 +++ b/lib/libc/stdio/fgets.3 @@ -53,7 +53,7 @@ The .Fn fgets function reads at most one less than the number of characters specified by -.Xr size +.Fa size from the given .Fa stream and stores them in the string @@ -61,7 +61,7 @@ and stores them in the string Reading stops when a newline character is found, at end-of-file or error. The newline, if any, is retained. -In any case a +If any characters are read and there is no error, a .Ql \e0 character is appended to end the string. .Pp @@ -71,7 +71,7 @@ function is equivalent to .Fn fgets with an infinite -.Xr size +.Fa size and a .Fa stream of @@ -87,14 +87,19 @@ and .Fn gets return a pointer to the string. -If end-of-file or an error occurs before any characters are read, +If end-of-file occurs before any characters are read, they return -.Dv NULL. +.Dv NULL +and the buffer contents is unchanged. +If an error occurs, +they return +.Dv NULL +and the buffer contents is indeterminate. The .Fn fgets and -functions .Fn gets +functions do not distinguish between end-of-file and error, and callers must use .Xr feof 3 and