X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/3d9156a7a519a5e3aa1b92e9d9d4b991f1aed7ff..974e388456677d82eb6d10d4fd72390641a5bdfe:/locale/FreeBSD/wctomb.c diff --git a/locale/FreeBSD/wctomb.c b/locale/FreeBSD/wctomb.c index 701b3ca..0df7799 100644 --- a/locale/FreeBSD/wctomb.c +++ b/locale/FreeBSD/wctomb.c @@ -27,23 +27,31 @@ #include __FBSDID("$FreeBSD: src/lib/libc/locale/wctomb.c,v 1.8 2004/07/29 06:18:40 tjr Exp $"); +#include "xlocale_private.h" + #include #include #include "mblocal.h" int -wctomb(char *s, wchar_t wchar) +wctomb_l(char *s, wchar_t wchar, 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_wctomb = initial; return (0); } - if ((rval = __wcrtomb(s, wchar, &mbs)) == (size_t)-1) + if ((rval = loc->__lc_ctype->__wcrtomb(s, wchar, &loc->__mbs_wctomb, loc)) == (size_t)-1) return (-1); return ((int)rval); } + +int +wctomb(char *s, wchar_t wchar) +{ + return wctomb_l(s, wchar, __current_locale()); +}