Rename cantwrite() to prepwrite(). The latter is less confusing,
since the macro isn't really a predicate, and it has side-effects.
This commit is contained in:
parent
325d97d0d1
commit
52183d4654
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=130231
@ -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))
|
||||
|
@ -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) */
|
||||
|
@ -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) */
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user