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