The expansion of __putc() in fputs() only periodically returns EOF
on a buffered stream when the buffer flush fails. For an unbuffered
stream, the return value of fflush() isn't checked either.
--- src/libc/ansi/stdio/fputs.c~ Mon Dec 26 15:34:46 1994
+++ src/libc/ansi/stdio/fputs.c Wed May 14 23:36:24 1997
@@ -19,11 +19,13 @@ fputs(const char *s, FILE *f)
}
while ((c = *s++))
- r = __putc(c, f);
+ if ((r = __putc(c, f)) == EOF)
+ break;
if (unbuffered)
{
- fflush(f);
+ if (fflush(f) == EOF)
+ r = EOF;
f->_flag |= _IONBF;
f->_base = NULL;
f->_bufsiz = NULL;
Also, in _write(), the detection of a returned shortened write count
appears to be wrong.
--- src/libc/dos/io/_write.c~ Thu Oct 24 22:26:26 1996
+++ src/libc/dos/io/_write.c Sun Apr 27 12:46:14 1997
@@ -49,7 +49,7 @@ _write(int handle, const void* buffer, s
nput += i;
} while(count && (i == j));
- if (count && nput == 0)
+ if (count /* && nput == 0 */) /* nput is rarely 0 here */
{
errno = ENOSPC;
return -1;