]> git.saurik.com Git - apple/libc.git/blob - stdio/FreeBSD/vswprintf.c.patch
Libc-763.13.tar.gz
[apple/libc.git] / stdio / FreeBSD / vswprintf.c.patch
1 --- vswprintf.c.orig 2009-11-30 16:15:30.000000000 -0800
2 +++ vswprintf.c 2009-12-03 15:21:59.000000000 -0800
3 @@ -33,6 +33,8 @@ __FBSDID("FreeBSD: src/lib/libc/stdio/va
4 #endif
5 __FBSDID("$FreeBSD: src/lib/libc/stdio/vswprintf.c,v 1.7 2008/04/17 22:17:54 jhb Exp $");
6
7 +#include "xlocale_private.h"
8 +
9 #include <errno.h>
10 #include <stdio.h>
11 #include <stdlib.h>
12 @@ -40,8 +42,8 @@ __FBSDID("$FreeBSD: src/lib/libc/stdio/v
13 #include "local.h"
14
15 int
16 -vswprintf(wchar_t * __restrict s, size_t n, const wchar_t * __restrict fmt,
17 - __va_list ap)
18 +vswprintf_l(wchar_t * __restrict s, size_t n, locale_t loc,
19 + const wchar_t * __restrict fmt, __va_list ap)
20 {
21 static const mbstate_t initial;
22 mbstate_t mbs;
23 @@ -49,7 +51,11 @@ vswprintf(wchar_t * __restrict s, size_t
24 char *mbp;
25 int ret, sverrno;
26 size_t nwc;
27 + struct __sFILEX ext;
28 + f._extra = &ext;
29 + INITEXTRA(&f);
30
31 + NORMALIZE_LOCALE(loc);
32 if (n == 0) {
33 errno = EINVAL;
34 return (-1);
35 @@ -65,7 +71,7 @@ vswprintf(wchar_t * __restrict s, size_t
36 f._bf._size = f._w = 127; /* Leave room for the NUL */
37 f._orientation = 0;
38 memset(&f._mbstate, 0, sizeof(mbstate_t));
39 - ret = __vfwprintf(&f, fmt, ap);
40 + ret = __vfwprintf(&f, loc, fmt, ap);
41 if (ret < 0) {
42 sverrno = errno;
43 free(f._bf._base);
44 @@ -79,7 +85,7 @@ vswprintf(wchar_t * __restrict s, size_t
45 * fputwc() did in __vfwprintf().
46 */
47 mbs = initial;
48 - nwc = mbsrtowcs(s, (const char **)&mbp, n, &mbs);
49 + nwc = mbsrtowcs_l(s, (const char **)&mbp, n, &mbs, loc);
50 free(f._bf._base);
51 if (nwc == (size_t)-1) {
52 errno = EILSEQ;
53 @@ -93,3 +99,10 @@ vswprintf(wchar_t * __restrict s, size_t
54
55 return (ret);
56 }
57 +
58 +int
59 +vswprintf(wchar_t * __restrict s, size_t n,
60 + const wchar_t * __restrict fmt, __va_list ap)
61 +{
62 + return vswprintf_l(s, n, __current_locale(), fmt, ap);
63 +}