diff options
author | tjr <tjr@FreeBSD.org> | 2002-09-03 01:09:47 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2002-09-03 01:09:47 +0000 |
commit | 573a3e8e5e20b467f547cc712016b11f63fc126e (patch) | |
tree | e4e83be417a5cc7f311b1bfe8b873102f613d4a5 /lib/libc/locale/mblen.c | |
parent | 6bb5aa6eaf6fa88a91a2d811fe133d4e0672a117 (diff) | |
download | FreeBSD-src-573a3e8e5e20b467f547cc712016b11f63fc126e.zip FreeBSD-src-573a3e8e5e20b467f547cc712016b11f63fc126e.tar.gz |
Set errno to EILSEQ when invalid multibyte sequences are detected
(XSI extension to 1003.1-2001).
Diffstat (limited to 'lib/libc/locale/mblen.c')
-rw-r--r-- | lib/libc/locale/mblen.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/libc/locale/mblen.c b/lib/libc/locale/mblen.c index 2544ba8..b5b92d1 100644 --- a/lib/libc/locale/mblen.c +++ b/lib/libc/locale/mblen.c @@ -37,6 +37,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <errno.h> #include <stdlib.h> #include <stddef.h> #include <rune.h> @@ -51,7 +52,9 @@ mblen(s, n) if (s == 0 || *s == 0) return (0); /* No support for state dependent encodings. */ - if (sgetrune(s, n, &e) == _INVALID_RUNE) + if (sgetrune(s, n, &e) == _INVALID_RUNE) { + errno = EILSEQ; return (s - e); + } return (e - s); } |