aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/locale/wctomb.c
diff options
context:
space:
mode:
authorTim J. Robbins <tjr@FreeBSD.org>2002-09-03 01:09:47 +0000
committerTim J. Robbins <tjr@FreeBSD.org>2002-09-03 01:09:47 +0000
commitf0c6c306f91a839c0ad2e84a3e1b84aa81b26c8f (patch)
treee4e83be417a5cc7f311b1bfe8b873102f613d4a5 /lib/libc/locale/wctomb.c
parentf10248e26b8b83ff0fbe1b025d8fd143b208e8e8 (diff)
downloadsrc-f0c6c306f91a839c0ad2e84a3e1b84aa81b26c8f.tar.gz
src-f0c6c306f91a839c0ad2e84a3e1b84aa81b26c8f.zip
Set errno to EILSEQ when invalid multibyte sequences are detected
(XSI extension to 1003.1-2001).
Notes
Notes: svn path=/head/; revision=102879
Diffstat (limited to 'lib/libc/locale/wctomb.c')
-rw-r--r--lib/libc/locale/wctomb.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/libc/locale/wctomb.c b/lib/libc/locale/wctomb.c
index ca5ed8db0095..2a225f48fa6f 100644
--- a/lib/libc/locale/wctomb.c
+++ b/lib/libc/locale/wctomb.c
@@ -37,6 +37,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <errno.h>
#include <stdlib.h>
#include <limits.h>
#include <stddef.h>
@@ -58,5 +59,9 @@ wctomb(s, wchar)
}
sputrune(wchar, s, MB_CUR_MAX, &e);
- return (e ? e - s : -1);
+ if (e == NULL) {
+ errno = EILSEQ;
+ return (-1);
+ }
+ return (e - s);
}