1 --- fputwc.c.orig 2009-11-11 13:33:08.000000000 -0800
2 +++ fputwc.c 2009-11-13 11:45:45.000000000 -0800
5 __FBSDID("$FreeBSD: src/lib/libc/stdio/fputwc.c,v 1.11 2008/04/17 22:17:53 jhb Exp $");
7 +#include "xlocale_private.h"
12 @@ -41,13 +43,14 @@ __FBSDID("$FreeBSD: src/lib/libc/stdio/f
14 * Non-MT-safe version.
17 -__fputwc(wchar_t wc, FILE *fp)
18 +__private_extern__ wint_t
19 +__fputwc(wchar_t wc, FILE *fp, locale_t loc)
23 + struct __xlocale_st_runelocale *xrl = loc->__lc_ctype;
25 - if (MB_CUR_MAX == 1 && wc > 0 && wc <= UCHAR_MAX) {
26 + if (xrl->__mb_cur_max == 1 && wc > 0 && wc <= UCHAR_MAX) {
28 * Assume single-byte locale with no special encoding.
29 * A more careful test would be to check
30 @@ -56,7 +59,7 @@ __fputwc(wchar_t wc, FILE *fp)
31 *buf = (unsigned char)wc;
34 - if ((len = __wcrtomb(buf, wc, &fp->_mbstate)) == (size_t)-1) {
35 + if ((len = loc->__lc_ctype->__wcrtomb(buf, wc, &fp->_mbstate, loc)) == (size_t)-1) {
39 @@ -79,7 +82,21 @@ fputwc(wchar_t wc, FILE *fp)
43 - r = __fputwc(wc, fp);
44 + r = __fputwc(wc, fp, __current_locale());
51 +fputwc_l(wchar_t wc, FILE *fp, locale_t loc)
55 + NORMALIZE_LOCALE(loc);
58 + r = __fputwc(wc, fp, loc);