diff options
Diffstat (limited to 'lib/libc/stdio/fgets.3')
-rw-r--r-- | lib/libc/stdio/fgets.3 | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/libc/stdio/fgets.3 b/lib/libc/stdio/fgets.3 index 231e8f2..22ce5e6 100644 --- a/lib/libc/stdio/fgets.3 +++ b/lib/libc/stdio/fgets.3 @@ -45,7 +45,7 @@ .Sh SYNOPSIS .Fd #include <stdio.h> .Ft char * -.Fn fgets "char *str" "size_t size" "FILE *stream" +.Fn fgets "char *str" "int size" "FILE *stream" .Ft char * .Fn gets "char *str" .Sh DESCRIPTION @@ -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 @@ -128,7 +133,7 @@ for any of the errors specified for the routine .Sh SEE ALSO .Xr feof 3 , .Xr ferror 3 , -.Xr fgetline 3 +.Xr fgetln 3 .Sh STANDARDS The functions .Fn fgets |