aboutsummaryrefslogtreecommitdiff
path: root/libio/iofwrite.c
diff options
context:
space:
mode:
Diffstat (limited to 'libio/iofwrite.c')
-rw-r--r--libio/iofwrite.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libio/iofwrite.c b/libio/iofwrite.c
index 1f4331cc83..fb91d6f776 100644
--- a/libio/iofwrite.c
+++ b/libio/iofwrite.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1996, 1997, 1998, 1999, 2000, 2002, 2003
+/* Copyright (C) 1993, 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2008
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -44,7 +44,11 @@ _IO_fwrite (buf, size, count, fp)
if (_IO_vtable_offset (fp) != 0 || _IO_fwide (fp, -1) == -1)
written = _IO_sputn (fp, (const char *) buf, request);
_IO_release_lock (fp);
- 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
return written / size;