1 --- vswscanf.c.orig 2004-11-25 11:38:36.000000000 -0800
2 +++ vswscanf.c 2005-02-23 17:03:30.000000000 -0800
5 __FBSDID("$FreeBSD: src/lib/libc/stdio/vswscanf.c,v 1.3 2004/04/07 09:55:05 tjr Exp $");
7 +#include "xlocale_private.h"
16 + locale_t loc = __current_locale();
19 + * XXX Convert the wide character string to multibyte, which
20 + * __vfwscanf() will convert back to wide characters.
22 + if ((mbstr = malloc(wcslen(str) * MB_CUR_MAX_L(loc) + 1)) == NULL)
25 + if ((mlen = wcsrtombs_l(mbstr, &str, SIZE_T_MAX, &mbs, loc)) == (size_t)-1) {
31 + f._bf._base = f._p = (unsigned char *)mbstr;
32 + f._bf._size = f._r = mlen;
38 + r = __vfwscanf(&f, loc, fmt, ap);
45 +vswscanf_l(const wchar_t * __restrict str, locale_t loc,
46 + const wchar_t * __restrict fmt, va_list ap)
48 + static const mbstate_t initial;
51 + struct __sFILEX ext;
56 + NORMALIZE_LOCALE(loc);
58 * XXX Convert the wide character string to multibyte, which
59 * __vfwscanf() will convert back to wide characters.
61 - if ((mbstr = malloc(wcslen(str) * MB_CUR_MAX + 1)) == NULL)
62 + if ((mbstr = malloc(wcslen(str) * MB_CUR_MAX_L(loc) + 1)) == NULL)
65 - if ((mlen = wcsrtombs(mbstr, &str, SIZE_T_MAX, &mbs)) == (size_t)-1) {
66 + if ((mlen = wcsrtombs_l(mbstr, &str, SIZE_T_MAX, &mbs, loc)) == (size_t)-1) {
74 - r = __vfwscanf(&f, fmt, ap);
75 + r = __vfwscanf(&f, loc, fmt, ap);