--- wctomb.c.orig 2004-11-25 11:38:20.000000000 -0800 +++ wctomb.c 2005-02-18 18:40:43.000000000 -0800 @@ -27,23 +27,31 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD: src/lib/libc/locale/wctomb.c,v 1.8 2004/07/29 06:18:40 tjr Exp $"); +#include "xlocale_private.h" + #include <stdlib.h> #include <wchar.h> #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()); +}