X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/3d9156a7a519a5e3aa1b92e9d9d4b991f1aed7ff..a9aaacca3a68bb8d74fec09d8d8681a0efda2581:/locale/FreeBSD/mblen.c diff --git a/locale/FreeBSD/mblen.c b/locale/FreeBSD/mblen.c index 2891e90..f6bfa52 100644 --- a/locale/FreeBSD/mblen.c +++ b/locale/FreeBSD/mblen.c @@ -27,24 +27,32 @@ #include __FBSDID("$FreeBSD: src/lib/libc/locale/mblen.c,v 1.9 2004/07/29 06:18:40 tjr Exp $"); +#include "xlocale_private.h" + #include #include #include "mblocal.h" int -mblen(const char *s, size_t n) +mblen_l(const char *s, size_t n, locale_t loc) { static const mbstate_t initial; - static mbstate_t mbs; size_t rval; + NORMALIZE_LOCALE(loc); if (s == NULL) { /* No support for state dependent encodings. */ - mbs = initial; + loc->__mbs_mblen = initial; return (0); } - rval = __mbrtowc(NULL, s, n, &mbs); + rval = loc->__lc_ctype->__mbrtowc(NULL, s, n, &loc->__mbs_mblen, loc); if (rval == (size_t)-1 || rval == (size_t)-2) return (-1); return ((int)rval); } + +int +mblen(const char *s, size_t n) +{ + return mblen_l(s, n, __current_locale()); +}