diff options
Diffstat (limited to 'lib/libc/locale/mbtowc.c')
-rw-r--r-- | lib/libc/locale/mbtowc.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/libc/locale/mbtowc.c b/lib/libc/locale/mbtowc.c index a690bec..27bebcf 100644 --- a/lib/libc/locale/mbtowc.c +++ b/lib/libc/locale/mbtowc.c @@ -48,15 +48,14 @@ mbtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n) const char *e; rune_t r; - if (s == NULL || *s == '\0') + if (s == NULL) /* No support for state dependent encodings. */ return (0); - if ((r = sgetrune(s, n, &e)) == _INVALID_RUNE) { errno = EILSEQ; - return (s - e); + return (-1); } if (pwc != NULL) *pwc = r; - return (e - s); + return (r == 0 ? 0 : e - s); } |