1 --- fgetws.c.orig 2004-11-25 11:38:34.000000000 -0800
2 +++ fgetws.c 2005-02-24 16:20:29.000000000 -0800
5 __FBSDID("$FreeBSD: src/lib/libc/stdio/fgetws.c,v 1.6 2004/10/03 15:48:32 stefanf Exp $");
7 +#include "xlocale_private.h"
16 -fgetws(wchar_t * __restrict ws, int n, FILE * __restrict fp)
17 +fgetws_l(wchar_t * __restrict ws, int n, FILE * __restrict fp, locale_t loc)
23 + struct __xlocale_st_runelocale *rl;
24 + size_t (*__mbsnrtowcs)(wchar_t * __restrict, const char ** __restrict, size_t, size_t, __darwin_mbstate_t * __restrict, locale_t);
26 + NORMALIZE_LOCALE(loc);
27 + rl = loc->__lc_ctype;
28 + __mbsnrtowcs = rl->__mbsnrtowcs;
37 + src = (const char *)fp->_p;
38 nl = memchr(fp->_p, '\n', fp->_r);
39 nconv = __mbsnrtowcs(wsp, &src,
40 nl != NULL ? (nl - fp->_p + 1) : fp->_r,
41 - n - 1, &fp->_extra->mbstate);
42 + n - 1, &fp->_extra->mbstate, loc);
43 if (nconv == (size_t)-1)
44 /* Conversion error */
50 - if (!__mbsinit(&fp->_extra->mbstate))
51 + if (!rl->__mbsinit(&fp->_extra->mbstate, loc))
52 /* Incomplete character */
61 +fgetws(wchar_t * __restrict ws, int n, FILE * __restrict fp)
63 + return fgetws_l(ws, n, fp, __current_locale());