X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/1f2f436a38f7ae2d39a943ad2898d8fed4ed2e58..065eae9f38780a3602538caa52399f41f061a88e:/stdio/FreeBSD/fputws.c diff --git a/stdio/FreeBSD/fputws.c b/stdio/FreeBSD/fputws.c index 6c4a333..1ff0484 100644 --- a/stdio/FreeBSD/fputws.c +++ b/stdio/FreeBSD/fputws.c @@ -27,6 +27,8 @@ #include __FBSDID("$FreeBSD: src/lib/libc/stdio/fputws.c,v 1.8 2009/01/15 18:53:52 rdivacky Exp $"); +#include "xlocale_private.h" + #include "namespace.h" #include #include @@ -39,14 +41,18 @@ __FBSDID("$FreeBSD: src/lib/libc/stdio/fputws.c,v 1.8 2009/01/15 18:53:52 rdivac #include "mblocal.h" int -fputws(const wchar_t * __restrict ws, FILE * __restrict fp) +fputws_l(const wchar_t * __restrict ws, FILE * __restrict fp, locale_t loc) { size_t nbytes; char buf[BUFSIZ]; struct __suio uio; struct __siov iov; - const wchar_t *wsp; + const wchar_t *wsp = ws; + size_t (*__wcsnrtombs)(char * __restrict, const wchar_t ** __restrict, + size_t, size_t, mbstate_t * __restrict, locale_t); + NORMALIZE_LOCALE(loc); + __wcsnrtombs = loc->__lc_ctype->__wcsnrtombs; FLOCKFILE(fp); ORIENT(fp, 1); if (prepwrite(fp) != 0) @@ -55,15 +61,14 @@ fputws(const wchar_t * __restrict ws, FILE * __restrict fp) uio.uio_iovcnt = 1; iov.iov_base = buf; do { - wsp = ws; nbytes = __wcsnrtombs(buf, &wsp, SIZE_T_MAX, sizeof(buf), - &fp->_mbstate); + &fp->_mbstate, loc); if (nbytes == (size_t)-1) goto error; iov.iov_len = uio.uio_resid = nbytes; if (__sfvwrite(fp, &uio) != 0) goto error; - } while (ws != NULL); + } while (wsp != NULL); FUNLOCKFILE(fp); return (0); @@ -71,3 +76,9 @@ error: FUNLOCKFILE(fp); return (-1); } + +int +fputws(const wchar_t * __restrict ws, FILE * __restrict fp) +{ + return fputws_l(ws, fp, __current_locale()); +}