mirror of
git://git.musl-libc.org/musl
synced 2025-02-24 06:46:49 +00:00
make vfprintf set stream orientation even for zero-length output
if no output is produced, no underlying fwrite will ever be called, but byte-oriented printf functions are still required to set the orientation of the stream to byte-oriented. call __towrite explicitly if the FILE is not already in write mode.
This commit is contained in:
parent
f1791f42ef
commit
a43a7b215c
@ -678,7 +678,8 @@ int vfprintf(FILE *restrict f, const char *restrict fmt, va_list ap)
|
||||
f->buf_size = sizeof internal_buf;
|
||||
f->wpos = f->wbase = f->wend = 0;
|
||||
}
|
||||
ret = printf_core(f, fmt, &ap2, nl_arg, nl_type);
|
||||
if (!f->wend && __towrite(f)) ret = -1;
|
||||
else ret = printf_core(f, fmt, &ap2, nl_arg, nl_type);
|
||||
if (saved_buf) {
|
||||
f->write(f, 0, 0);
|
||||
if (!f->wpos) ret = -1;
|
||||
|
Loading…
Reference in New Issue
Block a user