diff options
| author | David Schultz <das@FreeBSD.org> | 2004-06-08 05:45:32 +0000 |
|---|---|---|
| committer | David Schultz <das@FreeBSD.org> | 2004-06-08 05:45:32 +0000 |
| commit | 52183d4654e61d240982c5bfa60a05254378c41e (patch) | |
| tree | 32c47a37c84438fc9b0379f295a4d6bd77642d2b /lib/libc | |
| parent | 325d97d0d1b2826d9c0ddc5f4319dc5acf5178ff (diff) | |
Notes
Diffstat (limited to 'lib/libc')
| -rw-r--r-- | lib/libc/stdio/local.h | 5 | ||||
| -rw-r--r-- | lib/libc/stdio/vfprintf.c | 2 | ||||
| -rw-r--r-- | lib/libc/stdio/vfwprintf.c | 2 | ||||
| -rw-r--r-- | lib/libc/stdio/wbuf.c | 2 |
4 files changed, 6 insertions, 5 deletions
diff --git a/lib/libc/stdio/local.h b/lib/libc/stdio/local.h index b8bf81af7099..b1d92d999b96 100644 --- a/lib/libc/stdio/local.h +++ b/lib/libc/stdio/local.h @@ -93,9 +93,10 @@ struct __sFILEX { }; /* - * Return true iff the given FILE cannot be written now. + * Prepare the given FILE for writing, and return 0 iff it + * can be written now. Otherwise, return EOF and set errno. */ -#define cantwrite(fp) \ +#define prepwrite(fp) \ ((((fp)->_flags & __SWR) == 0 || \ ((fp)->_bf._base == NULL && ((fp)->_flags & __SSTR) == 0)) && \ __swsetup(fp)) diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c index 0d78df9b8268..2d720ae3b9de 100644 --- a/lib/libc/stdio/vfprintf.c +++ b/lib/libc/stdio/vfprintf.c @@ -642,7 +642,7 @@ __vfprintf(FILE *fp, const char *fmt0, va_list ap) decimal_point = localeconv()->decimal_point; #endif /* sorry, fprintf(read_only_file, "") returns EOF, not 0 */ - if (cantwrite(fp)) + if (prepwrite(fp) != 0) return (EOF); /* optimise fprintf(stderr) (and other unbuffered Unix files) */ diff --git a/lib/libc/stdio/vfwprintf.c b/lib/libc/stdio/vfwprintf.c index 1efa9aa11fa2..c9833aa51e47 100644 --- a/lib/libc/stdio/vfwprintf.c +++ b/lib/libc/stdio/vfwprintf.c @@ -648,7 +648,7 @@ __vfwprintf(FILE *fp, const wchar_t *fmt0, va_list ap) #endif convbuf = NULL; /* sorry, fwprintf(read_only_file, L"") returns WEOF, not 0 */ - if (cantwrite(fp)) + if (prepwrite(fp) != 0) return (EOF); /* optimise fprintf(stderr) (and other unbuffered Unix files) */ diff --git a/lib/libc/stdio/wbuf.c b/lib/libc/stdio/wbuf.c index 80945d822571..4a123052c789 100644 --- a/lib/libc/stdio/wbuf.c +++ b/lib/libc/stdio/wbuf.c @@ -65,7 +65,7 @@ __swbuf(c, fp) * calls might wrap _w from negative to positive. */ fp->_w = fp->_lbfsize; - if (cantwrite(fp)) + if (prepwrite(fp) != 0) return (EOF); c = (unsigned char)c; |
