From 5c8726d1b258dd69e1f906f463c2bcc65c1b64a5 Mon Sep 17 00:00:00 2001 From: pfg Date: Sun, 3 Aug 2014 18:28:10 +0000 Subject: MFC r268926, r268930, r268983: Use a correct errno in freopen. Use EBADF instead of EINVAL when working around incorrect O_ACCMODE. Adjust errno on failed prepwrite. rewind: always clear error indicator as required by POSIX. Obtained from: Apple Inc. (Libc 997.90.3) Phabric: D442 --- lib/libc/stdio/vfwprintf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/libc/stdio/vfwprintf.c') diff --git a/lib/libc/stdio/vfwprintf.c b/lib/libc/stdio/vfwprintf.c index 4350c48..b75c504 100644 --- a/lib/libc/stdio/vfwprintf.c +++ b/lib/libc/stdio/vfwprintf.c @@ -531,8 +531,10 @@ __vfwprintf(FILE *fp, locale_t locale, const wchar_t *fmt0, va_list ap) /* sorry, fwprintf(read_only_file, L"") returns WEOF, not 0 */ - if (prepwrite(fp) != 0) + if (prepwrite(fp) != 0) { + errno = EBADF; return (EOF); + } convbuf = NULL; fmt = (wchar_t *)fmt0; -- cgit v1.1