From de2fd463b1c0310d75084b6d774fb974075a4ad9 Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Wed, 28 Nov 2012 00:59:27 +0530 Subject: Make fwrite return 0 on EOF --- libio/iofwrite.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'libio/iofwrite.c') diff --git a/libio/iofwrite.c b/libio/iofwrite.c index d4610f78ca..2fff72b408 100644 --- a/libio/iofwrite.c +++ b/libio/iofwrite.c @@ -42,12 +42,12 @@ _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); - /* 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) + /* We are guaranteed to have written all of the input, none of it, or + some of it. */ + if (written == request) return count; + else if (written == EOF) + return 0; else return written / size; } -- cgit v1.2.1