]> git.saurik.com Git - apple/libc.git/blob - stdio/FreeBSD/fputws.c.patch
Libc-594.9.5.tar.gz
[apple/libc.git] / stdio / FreeBSD / fputws.c.patch
1 --- fputws.c.orig 2004-11-25 11:38:34.000000000 -0800
2 +++ fputws.c 2005-02-23 17:23:49.000000000 -0800
3 @@ -27,6 +27,8 @@
4 #include <sys/cdefs.h>
5 __FBSDID("$FreeBSD: src/lib/libc/stdio/fputws.c,v 1.6 2004/07/21 10:54:57 tjr Exp $");
6
7 +#include "xlocale_private.h"
8 +
9 #include "namespace.h"
10 #include <errno.h>
11 #include <limits.h>
12 @@ -39,13 +41,17 @@
13 #include "mblocal.h"
14
15 int
16 -fputws(const wchar_t * __restrict ws, FILE * __restrict fp)
17 +fputws_l(const wchar_t * __restrict ws, FILE * __restrict fp, locale_t loc)
18 {
19 size_t nbytes;
20 char buf[BUFSIZ];
21 struct __suio uio;
22 struct __siov iov;
23 + size_t (*__wcsnrtombs)(char * __restrict, const wchar_t ** __restrict,
24 + size_t, size_t, mbstate_t * __restrict, locale_t);
25
26 + NORMALIZE_LOCALE(loc);
27 + __wcsnrtombs = loc->__lc_ctype->__wcsnrtombs;
28 FLOCKFILE(fp);
29 ORIENT(fp, 1);
30 if (prepwrite(fp) != 0)
31 @@ -55,7 +61,7 @@
32 iov.iov_base = buf;
33 do {
34 nbytes = __wcsnrtombs(buf, &ws, SIZE_T_MAX, sizeof(buf),
35 - &fp->_extra->mbstate);
36 + &fp->_extra->mbstate, loc);
37 if (nbytes == (size_t)-1)
38 goto error;
39 iov.iov_len = uio.uio_resid = nbytes;
40 @@ -69,3 +75,9 @@
41 FUNLOCKFILE(fp);
42 return (-1);
43 }
44 +
45 +int
46 +fputws(const wchar_t * __restrict ws, FILE * __restrict fp)
47 +{
48 + return fputws_l(ws, fp, __current_locale());
49 +}