#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/libc/locale/mbstowcs.c,v 1.12 2009/01/15 18:53:52 rdivacky Exp $");
+#include "xlocale_private.h"
+
#include <limits.h>
#include <stdlib.h>
#include <wchar.h>
#include "mblocal.h"
size_t
-mbstowcs(wchar_t * __restrict pwcs, const char * __restrict s, size_t n)
+mbstowcs_l(wchar_t * __restrict pwcs, const char * __restrict s, size_t n,
+ locale_t loc)
{
static const mbstate_t initial;
mbstate_t mbs;
const char *sp;
+ NORMALIZE_LOCALE(loc);
mbs = initial;
sp = s;
- return (__mbsnrtowcs(pwcs, &sp, SIZE_T_MAX, n, &mbs));
+ return (loc->__lc_ctype->__mbsnrtowcs(pwcs, &sp, SIZE_T_MAX, n, &mbs, loc));
+}
+
+size_t
+mbstowcs(wchar_t * __restrict pwcs, const char * __restrict s, size_t n)
+{
+ return mbstowcs_l(pwcs, s, n, __current_locale());
}