#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/libc/locale/mbrtowc.c,v 1.7 2004/05/12 14:09:04 tjr Exp $");
+#include "xlocale_private.h"
+
#include <wchar.h>
#include "mblocal.h"
+size_t
+mbrtowc_l(wchar_t * __restrict pwc, const char * __restrict s,
+ size_t n, mbstate_t * __restrict ps, locale_t loc)
+{
+ NORMALIZE_LOCALE(loc);
+ if (ps == NULL)
+ ps = &loc->__mbs_mbrtowc;
+ return (loc->__lc_ctype->__mbrtowc(pwc, s, n, ps, loc));
+}
+
size_t
mbrtowc(wchar_t * __restrict pwc, const char * __restrict s,
size_t n, mbstate_t * __restrict ps)
{
- static mbstate_t mbs;
-
- if (ps == NULL)
- ps = &mbs;
- return (__mbrtowc(pwc, s, n, ps));
+ return mbrtowc_l(pwc, s, n, ps, __current_locale());
}