about summary refs log tree commit diff
path: root/manual/stdio.texi
diff options
context:
space:
mode:
Diffstat (limited to 'manual/stdio.texi')
-rw-r--r--manual/stdio.texi31
1 files changed, 30 insertions, 1 deletions
diff --git a/manual/stdio.texi b/manual/stdio.texi
index 29888a361f..83f4f92e3f 100644
--- a/manual/stdio.texi
+++ b/manual/stdio.texi
@@ -330,6 +330,14 @@ this ability, so using @code{freopen} is more portable.
 When the sources are compiled with @code{_FILE_OFFSET_BITS == 64} on a
 32 bit machine this function is in fact @code{freopen64} since the LFS
 interface replaces transparently the old interface.
+
+@Theglibc{} only supports use of @code{freopen} on streams opened with
+@code{fopen} or @code{fopen64} and on the original values of the
+standard streams @code{stdin}, @code{stdout}, and @code{stderr}; such
+a stream may be reopened multiple times with @code{freopen}.  If it is
+called on another kind of stream (opened with functions such as
+@code{popen}, @code{fmemopen}, @code{open_memstream}, and
+@code{fopencookie}), @code{freopen} fails and returns a null pointer.
 @end deftypefun
 
 @deftypefun {FILE *} freopen64 (const char *@var{filename}, const char *@var{opentype}, FILE *@var{stream})
@@ -921,6 +929,9 @@ Therefore, @var{stream} should never be an expression with side-effects.
 @safety{@prelim{}@mtsafe{@mtsrace{:stream}}@asunsafe{@asucorrupt{}}@acunsafe{@acucorrupt{}}}
 The @code{putc_unlocked} function is equivalent to the @code{putc}
 function except that it does not implicitly lock the stream.
+Like @code{putc}, it may be implemented as a macro and may evaluate
+the @var{stream} argument more than once.  Therefore, @var{stream}
+should not be an expression with side-effects.
 @end deftypefun
 
 @deftypefun wint_t putwc_unlocked (wchar_t @var{wc}, FILE *@var{stream})
@@ -1124,6 +1135,9 @@ Therefore, @var{stream} should never be an expression with side-effects.
 @safety{@prelim{}@mtsafe{@mtsrace{:stream}}@asunsafe{@asucorrupt{}}@acunsafe{@acucorrupt{}}}
 The @code{getc_unlocked} function is equivalent to the @code{getc}
 function except that it does not implicitly lock the stream.
+Like @code{getc}, it may be implemented as a macro and may evaluate
+the @var{stream} argument more than once.  Therefore, @var{stream}
+should not be an expression with side-effects.
 @end deftypefun
 
 @deftypefun wint_t getwc_unlocked (FILE *@var{stream})
@@ -1563,6 +1577,9 @@ The @code{fread_unlocked} function is equivalent to the @code{fread}
 function except that it does not implicitly lock the stream.
 
 This function is a GNU extension.
+This function may be implemented as a macro and may evaluate
+@var{stream} more than once.  Therefore, @var{stream} should not be an
+expression with side-effects.
 @end deftypefun
 
 @deftypefun size_t fwrite (const void *@var{data}, size_t @var{size}, size_t @var{count}, FILE *@var{stream})
@@ -1581,6 +1598,9 @@ The @code{fwrite_unlocked} function is equivalent to the @code{fwrite}
 function except that it does not implicitly lock the stream.
 
 This function is a GNU extension.
+This function may be implemented as a macro and may evaluate
+@var{stream} more than once.  Therefore, @var{stream} should not be an
+expression with side-effects.
 @end deftypefun
 
 @node Formatted Output
@@ -2523,7 +2543,7 @@ store the result in which case @code{-1} is returned.  This was
 changed in order to comply with the @w{ISO C99} standard.
 @end deftypefun
 
-@deftypefun dprintf (int @var{fd}, @var{template}, ...)
+@deftypefun int dprintf (int @var{fd}, @var{template}, ...)
 @standards{POSIX, stdio.h}
 @safety{@mtsafe{@mtslocale{}}@asunsafe{@ascuheap{}}@acunsafe{@acsmem{}}}
 This function formats its arguments according to @var{template} and
@@ -4160,6 +4180,15 @@ check indicators that are part of the internal state of the stream
 object, indicators set if the appropriate condition was detected by a
 previous I/O operation on that stream.
 
+The end of file and error conditions are mutually exclusive.  For a
+narrow oriented stream, end of file is not considered an error.  For
+wide oriented streams, reaching the end of the underlying file can
+result an error if the underlying file ends with an incomplete multibyte
+sequence.  This is reported as an error by @code{ferror}, and not as an
+end of file by @code{feof}.  End of file on wide oriented streams that
+does not fall into the middle of a multibyte sequence is reported via
+@code{feof}.
+
 @deftypevr Macro int EOF
 @standards{ISO, stdio.h}
 This macro is an integer value that is returned by a number of narrow