diff options
Diffstat (limited to 'lib/libc/locale/mblen.c')
-rw-r--r-- | lib/libc/locale/mblen.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/libc/locale/mblen.c b/lib/libc/locale/mblen.c index a54e051..ad5edb3 100644 --- a/lib/libc/locale/mblen.c +++ b/lib/libc/locale/mblen.c @@ -47,13 +47,12 @@ mblen(const char *s, size_t n) { const char *e; - if (s == NULL || *s == '\0') + if (s == NULL) /* No support for state dependent encodings. */ return (0); - if (sgetrune(s, n, &e) == _INVALID_RUNE) { errno = EILSEQ; - return (s - e); + return (-1); } - return (e - s); + return (*s == '\0' ? 0 : e - s); } |