1 --- fgetwc.c.bsdnew 2009-11-11 13:33:05.000000000 -0800
2 +++ fgetwc.c 2009-11-11 13:43:19.000000000 -0800
5 __FBSDID("$FreeBSD: src/lib/libc/stdio/fgetwc.c,v 1.13 2008/04/17 22:17:53 jhb Exp $");
7 +#include "xlocale_private.h"
12 @@ -47,7 +49,21 @@ fgetwc(FILE *fp)
17 + r = __fgetwc(fp, __current_locale());
24 +fgetwc_l(FILE *fp, locale_t loc)
28 + NORMALIZE_LOCALE(loc);
31 + r = __fgetwc(fp, loc);
35 @@ -57,21 +73,23 @@ fgetwc(FILE *fp)
36 * Non-MT-safe version.
40 +__fgetwc(FILE *fp, locale_t loc)
44 + struct __xlocale_st_runelocale *xrl = loc->__lc_ctype;
45 + size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict, size_t, mbstate_t * __restrict, locale_t) = xrl->__mbrtowc;
47 if (fp->_r <= 0 && __srefill(fp))
49 - if (MB_CUR_MAX == 1) {
50 + if (xrl->__mb_cur_max == 1) {
51 /* Fast path for single-byte encodings. */
57 - nconv = __mbrtowc(&wc, fp->_p, fp->_r, &fp->_mbstate);
58 + nconv = __mbrtowc(&wc, fp->_p, fp->_r, &fp->_mbstate, loc);
59 if (nconv == (size_t)-1)
61 else if (nconv == (size_t)-2)