]>
Commit | Line | Data |
---|---|---|
1f2f436a A |
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 | |
3d9156a7 | 4 | #endif |
1f2f436a | 5 | __FBSDID("$FreeBSD: src/lib/libc/stdio/vswprintf.c,v 1.7 2008/04/17 22:17:54 jhb Exp $"); |
3d9156a7 A |
6 | |
7 | +#include "xlocale_private.h" | |
8 | + | |
9 | #include <errno.h> | |
10 | #include <stdio.h> | |
11 | #include <stdlib.h> | |
1f2f436a A |
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 | |
59e0d9fe A |
24 | char *mbp; |
25 | int ret, sverrno; | |
1f2f436a A |
26 | size_t nwc; |
27 | + struct __sFILEX ext; | |
3d9156a7 A |
28 | + f._extra = &ext; |
29 | + INITEXTRA(&f); | |
59e0d9fe | 30 | |
3d9156a7 | 31 | + NORMALIZE_LOCALE(loc); |
59e0d9fe A |
32 | if (n == 0) { |
33 | errno = EINVAL; | |
3d9156a7 | 34 | return (-1); |
1f2f436a | 35 | @@ -65,7 +71,7 @@ vswprintf(wchar_t * __restrict s, size_t |
3d9156a7 | 36 | f._bf._size = f._w = 127; /* Leave room for the NUL */ |
1f2f436a A |
37 | f._orientation = 0; |
38 | memset(&f._mbstate, 0, sizeof(mbstate_t)); | |
3d9156a7 A |
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); | |
1f2f436a | 44 | @@ -79,7 +85,7 @@ vswprintf(wchar_t * __restrict s, size_t |
59e0d9fe A |
45 | * fputwc() did in __vfwprintf(). |
46 | */ | |
3d9156a7 | 47 | mbs = initial; |
1f2f436a A |
48 | - nwc = mbsrtowcs(s, (const char **)&mbp, n, &mbs); |
49 | + nwc = mbsrtowcs_l(s, (const char **)&mbp, n, &mbs, loc); | |
59e0d9fe | 50 | free(f._bf._base); |
1f2f436a A |
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 | +} |