summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/fputwc.c
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2016-01-26 13:57:02 +0000
committerschwarze <schwarze@openbsd.org>2016-01-26 13:57:02 +0000
commit19fa39c6176021e91f0493c0ce81d52022b1e0f7 (patch)
tree742266e271dd39d9b6a8ead5ac1e8667af0c507c /lib/libc/stdio/fputwc.c
parentImprove the previous fix: call vmxnet3_load_mbuf, bpf_mtap, and flip (diff)
downloadwireguard-openbsd-19fa39c6176021e91f0493c0ce81d52022b1e0f7.tar.xz
wireguard-openbsd-19fa39c6176021e91f0493c0ce81d52022b1e0f7.zip
When encoding fails in fputwc(3), set the error indicator as required
by POSIX and as FreeBSD, SunOS 10/11, and glibc also do it. Note that an enquiry to the Austin Group led to the conclusion that this change probably violates the C standard: C and POSIX unintentionally conflict. But the POSIX behaviour makes more sense (easier to write correct error handling code for it, and a lower risk that programs miss errors) and is much more widespread, and the Austin Group intends to approach the C committee in order to adjust the C standard. See: http://austingroupbugs.net/view.php?id=1022 While here, do not set errno a second time, wcrtomb(3) already did that, and it is required to do it by the standard. OK millert@ and tedu@, and jca@ no longer objects
Diffstat (limited to 'lib/libc/stdio/fputwc.c')
-rw-r--r--lib/libc/stdio/fputwc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/stdio/fputwc.c b/lib/libc/stdio/fputwc.c
index 829c22c48dd..e156922ad90 100644
--- a/lib/libc/stdio/fputwc.c
+++ b/lib/libc/stdio/fputwc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fputwc.c,v 1.6 2015/10/01 02:32:07 guenther Exp $ */
+/* $OpenBSD: fputwc.c,v 1.7 2016/01/26 13:57:02 schwarze Exp $ */
/* $NetBSD: fputwc.c,v 1.3 2003/03/07 07:11:37 tshiozak Exp $ */
/*-
@@ -62,7 +62,7 @@ __fputwc_unlock(wchar_t wc, FILE *fp)
size = wcrtomb(buf, wc, st);
if (size == (size_t)-1) {
- errno = EILSEQ;
+ fp->_flags |= __SERR;
return WEOF;
}