]> git.saurik.com Git - apple/libc.git/blob - stdio/FreeBSD/vswscanf.c.patch
Libc-763.12.tar.gz
[apple/libc.git] / stdio / FreeBSD / vswscanf.c.patch
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
4 #endif
5 __FBSDID("$FreeBSD: src/lib/libc/stdio/vswscanf.c,v 1.6 2009/01/15 18:53:52 rdivacky Exp $");
6
7 +#include "xlocale_private.h"
8 +
9 #include <limits.h>
10 #include <stdarg.h>
11 #include <stdio.h>
12 @@ -57,7 +59,7 @@ eofread(void *cookie, char *buf, int len
13 }
14
15 int
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,
18 va_list ap)
19 {
20 static const mbstate_t initial;
21 @@ -67,16 +69,20 @@ vswscanf(const wchar_t * __restrict str,
22 size_t mlen;
23 int r;
24 const wchar_t *strp;
25 + struct __sFILEX ext;
26 + f._extra = &ext;
27 + INITEXTRA(&f);
28
29 + NORMALIZE_LOCALE(loc);
30 /*
31 * XXX Convert the wide character string to multibyte, which
32 * __vfwscanf() will convert back to wide characters.
33 */
34 - if ((mbstr = malloc(wcslen(str) * MB_CUR_MAX + 1)) == NULL)
35 + if ((mbstr = malloc(wcslen(str) * MB_CUR_MAX_L(loc) + 1)) == NULL)
36 return (EOF);
37 mbs = initial;
38 strp = str;
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) {
41 free(mbstr);
42 return (EOF);
43 }
44 @@ -89,8 +95,16 @@ vswscanf(const wchar_t * __restrict str,
45 f._lb._base = NULL;
46 f._orientation = 0;
47 memset(&f._mbstate, 0, sizeof(mbstate_t));
48 - r = __vfwscanf(&f, fmt, ap);
49 + r = __vfwscanf(&f, loc, fmt, ap);
50 free(mbstr);
51
52 return (r);
53 }
54 +
55 +int
56 +vswscanf(const wchar_t * __restrict str, const wchar_t * __restrict fmt,
57 + va_list ap)
58 +{
59 + return vswscanf_l(str, __current_locale(), fmt, ap);
60 +}
61 +