diff options
author | Roland McGrath <roland@gnu.org> | 1994-12-11 19:10:07 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1994-12-11 19:10:07 +0000 |
commit | 3bddac6781da7b20e6aedecfc6605640df8bd250 (patch) | |
tree | 29c6f0addafa54519c60a587bb4382a8776c4463 | |
parent | 0dbc9f577b6d9fc0aa3fba564866e6e2a5c2cf74 (diff) |
In fill_buffer case, check for zero buffer space after fflush and write one
char normally.
-rw-r--r-- | stdio/fwrite.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/stdio/fwrite.c b/stdio/fwrite.c index 9e04557dff..4d012f1779 100644 --- a/stdio/fwrite.c +++ b/stdio/fwrite.c @@ -157,10 +157,23 @@ DEFUN(fwrite, (ptr, size, nmemb, stream), /* We've filled the buffer, so flush it. */ if (fflush (stream) == EOF) break; + /* Reset our record of the space available in the buffer, since we have just flushed it. */ + check_space: buffer_space = (stream->__bufsize - (stream->__bufp - stream->__buffer)); + if (buffer_space == 0) + { + /* With a custom output-room function, flushing might + not create any buffer space. Try writing a single + character to create the space. */ + if (__flshfp (stream, *p++) == EOF) + goto done; + ++written; + --to_write; + goto check_space; + } } } else |