summaryrefslogtreecommitdiff
path: root/libc/libio/iofwrite_u.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/libio/iofwrite_u.c')
-rw-r--r--libc/libio/iofwrite_u.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libc/libio/iofwrite_u.c b/libc/libio/iofwrite_u.c
index 4a9d6caa0..18dc6d032 100644
--- a/libc/libio/iofwrite_u.c
+++ b/libc/libio/iofwrite_u.c
@@ -44,12 +44,12 @@ fwrite_unlocked (buf, size, count, fp)
if (_IO_fwide (fp, -1) == -1)
{
written = _IO_sputn (fp, (const char *) buf, request);
- /* We are guaranteed to have written all of the input, none of it, or
- some of it. */
- if (written == request)
+ /* We have written all of the input in case the return value indicates
+ this or EOF is returned. The latter is a special case where we
+ simply did not manage to flush the buffer. But the data is in the
+ buffer and therefore written as far as fwrite is concerned. */
+ if (written == request || written == EOF)
return count;
- else if (written == EOF)
- return 0;
}
return written / size;