summary refs log tree commit diff
path: root/libio/iofwrite_u.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2008-04-09 07:42:19 +0000
committerUlrich Drepper <drepper@redhat.com>2008-04-09 07:42:19 +0000
commita7925a24fe104a2ab54fb8a6bdec1e5cf80a8db7 (patch)
treebdd5ae76466ac8d30555eeddb9fe3b096a8a00ba /libio/iofwrite_u.c
parentc2a684a419ce936d7443bcb1e71ea7725fee0507 (diff)
downloadglibc-a7925a24fe104a2ab54fb8a6bdec1e5cf80a8db7.tar.gz
glibc-a7925a24fe104a2ab54fb8a6bdec1e5cf80a8db7.tar.xz
glibc-a7925a24fe104a2ab54fb8a6bdec1e5cf80a8db7.zip
[BZ #5998]
2008-04-09  Ulrich Drepper  <drepper@redhat.com>
	[BZ #5998]
	* libio/iofwrite.c (_IO_fwrite): Return correct count if flushing
	in line-buffered stream failed.
	* libio/iofwrite_u.c (fwrite_unlocked): Likewise.
Diffstat (limited to 'libio/iofwrite_u.c')
-rw-r--r--libio/iofwrite_u.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libio/iofwrite_u.c b/libio/iofwrite_u.c
index 738cc5b28f..d27c02ac31 100644
--- a/libio/iofwrite_u.c
+++ b/libio/iofwrite_u.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1996-2000, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1996-2000, 2002, 2008 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -45,7 +45,11 @@ fwrite_unlocked (buf, size, count, fp)
   if (_IO_fwide (fp, -1) == -1)
     {
       written = _IO_sputn (fp, (const char *) buf, request);
-      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;
     }