1 --- fputws.c.orig 2010-03-18 18:11:42.000000000 -0700
2 +++ fputws.c 2010-03-18 18:17:53.000000000 -0700
5 __FBSDID("$FreeBSD: src/lib/libc/stdio/fputws.c,v 1.8 2009/01/15 18:53:52 rdivacky Exp $");
7 +#include "xlocale_private.h"
12 @@ -39,14 +41,18 @@ __FBSDID("$FreeBSD: src/lib/libc/stdio/f
16 -fputws(const wchar_t * __restrict ws, FILE * __restrict fp)
17 +fputws_l(const wchar_t * __restrict ws, FILE * __restrict fp, locale_t loc)
24 + const wchar_t *wsp = ws;
25 + size_t (*__wcsnrtombs)(char * __restrict, const wchar_t ** __restrict,
26 + size_t, size_t, mbstate_t * __restrict, locale_t);
28 + NORMALIZE_LOCALE(loc);
29 + __wcsnrtombs = loc->__lc_ctype->__wcsnrtombs;
32 if (prepwrite(fp) != 0)
33 @@ -55,15 +61,14 @@ fputws(const wchar_t * __restrict ws, FI
38 nbytes = __wcsnrtombs(buf, &wsp, SIZE_T_MAX, sizeof(buf),
40 + &fp->_mbstate, loc);
41 if (nbytes == (size_t)-1)
43 iov.iov_len = uio.uio_resid = nbytes;
44 if (__sfvwrite(fp, &uio) != 0)
46 - } while (ws != NULL);
47 + } while (wsp != NULL);
51 @@ -71,3 +76,9 @@ error:
57 +fputws(const wchar_t * __restrict ws, FILE * __restrict fp)
59 + return fputws_l(ws, fp, __current_locale());