Skip to content

Commit

Permalink
[BZ #5998]
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Ulrich Drepper committed Apr 9, 2008
1 parent c2a684a commit a7925a2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
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.

2008-04-08 Ulrich Drepper <drepper@redhat.com>

[BZ #6024]
Expand Down
8 changes: 6 additions & 2 deletions libio/iofwrite.c
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 6 additions & 2 deletions libio/iofwrite_u.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit a7925a2

Please sign in to comment.