X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/3d9156a7a519a5e3aa1b92e9d9d4b991f1aed7ff..2be56ee90c5c5bee77895b8787a43e894249002b:/locale/FreeBSD/mbtowc.c diff --git a/locale/FreeBSD/mbtowc.c b/locale/FreeBSD/mbtowc.c index 5e3a368..aeb75b7 100644 --- a/locale/FreeBSD/mbtowc.c +++ b/locale/FreeBSD/mbtowc.c @@ -27,24 +27,33 @@ #include __FBSDID("$FreeBSD: src/lib/libc/locale/mbtowc.c,v 1.11 2004/07/29 06:18:40 tjr Exp $"); +#include "xlocale_private.h" + #include #include #include "mblocal.h" int -mbtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n) +mbtowc_l(wchar_t * __restrict pwc, const char * __restrict 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_mbtowc = initial; return (0); } - rval = __mbrtowc(pwc, s, n, &mbs); + rval = loc->__lc_ctype->__mbrtowc(pwc, s, n, &loc->__mbs_mbtowc, loc); if (rval == (size_t)-1 || rval == (size_t)-2) return (-1); return ((int)rval); } + +int +mbtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n) +{ + return mbtowc_l(pwc, s, n, __current_locale()); +}