diff options
Diffstat (limited to 'lib/libc/locale/mbtowc.c')
-rw-r--r-- | lib/libc/locale/mbtowc.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/libc/locale/mbtowc.c b/lib/libc/locale/mbtowc.c index 67771a0..67b7b38 100644 --- a/lib/libc/locale/mbtowc.c +++ b/lib/libc/locale/mbtowc.c @@ -37,6 +37,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <errno.h> #include <stdlib.h> #include <stddef.h> #include <rune.h> @@ -53,8 +54,10 @@ mbtowc(pwc, s, n) if (s == 0 || *s == 0) return (0); /* No support for state dependent encodings. */ - if ((r = sgetrune(s, n, &e)) == _INVALID_RUNE) + if ((r = sgetrune(s, n, &e)) == _INVALID_RUNE) { + errno = EILSEQ; return (s - e); + } if (pwc) *pwc = r; return (e - s); |