1 --- vswscanf.c.orig 2009-11-30 16:15:30.000000000 -0800
2 +++ vswscanf.c 2009-12-03 15:21:47.000000000 -0800
3 @@ -39,6 +39,8 @@ __FBSDID("FreeBSD: src/lib/libc/stdio/vs
5 __FBSDID("$FreeBSD: src/lib/libc/stdio/vswscanf.c,v 1.6 2009/01/15 18:53:52 rdivacky Exp $");
7 +#include "xlocale_private.h"
12 @@ -57,7 +59,7 @@ eofread(void *cookie, char *buf, int len
16 -vswscanf(const wchar_t * __restrict str, const wchar_t * __restrict fmt,
17 +vswscanf_l(const wchar_t * __restrict str, locale_t loc, const wchar_t * __restrict fmt,
20 static const mbstate_t initial;
21 @@ -67,16 +69,20 @@ vswscanf(const wchar_t * __restrict str,
25 + struct __sFILEX ext;
29 + NORMALIZE_LOCALE(loc);
31 * XXX Convert the wide character string to multibyte, which
32 * __vfwscanf() will convert back to wide characters.
34 - if ((mbstr = malloc(wcslen(str) * MB_CUR_MAX + 1)) == NULL)
35 + if ((mbstr = malloc(wcslen(str) * MB_CUR_MAX_L(loc) + 1)) == NULL)
39 - if ((mlen = wcsrtombs(mbstr, &strp, SIZE_T_MAX, &mbs)) == (size_t)-1) {
40 + if ((mlen = wcsrtombs_l(mbstr, &strp, SIZE_T_MAX, &mbs, loc)) == (size_t)-1) {
44 @@ -89,8 +95,16 @@ vswscanf(const wchar_t * __restrict str,
47 memset(&f._mbstate, 0, sizeof(mbstate_t));
48 - r = __vfwscanf(&f, fmt, ap);
49 + r = __vfwscanf(&f, loc, fmt, ap);
56 +vswscanf(const wchar_t * __restrict str, const wchar_t * __restrict fmt,
59 + return vswscanf_l(str, __current_locale(), fmt, ap);