]> git.saurik.com Git - apple/libc.git/blob - locale/FreeBSD/mbtowc.c.patch
Libc-594.9.5.tar.gz
[apple/libc.git] / locale / FreeBSD / mbtowc.c.patch
1 --- mbtowc.c.orig Thu Nov 25 11:38:18 2004
2 +++ mbtowc.c Fri Feb 18 17:12:35 2005
3 @@ -27,24 +27,33 @@
4 #include <sys/cdefs.h>
5 __FBSDID("$FreeBSD: src/lib/libc/locale/mbtowc.c,v 1.11 2004/07/29 06:18:40 tjr Exp $");
6
7 +#include "xlocale_private.h"
8 +
9 #include <stdlib.h>
10 #include <wchar.h>
11 #include "mblocal.h"
12
13 int
14 -mbtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n)
15 +mbtowc_l(wchar_t * __restrict pwc, const char * __restrict s, size_t n,
16 + locale_t loc)
17 {
18 static const mbstate_t initial;
19 - static mbstate_t mbs;
20 size_t rval;
21
22 + NORMALIZE_LOCALE(loc);
23 if (s == NULL) {
24 /* No support for state dependent encodings. */
25 - mbs = initial;
26 + loc->__mbs_mbtowc = initial;
27 return (0);
28 }
29 - rval = __mbrtowc(pwc, s, n, &mbs);
30 + rval = loc->__lc_ctype->__mbrtowc(pwc, s, n, &loc->__mbs_mbtowc, loc);
31 if (rval == (size_t)-1 || rval == (size_t)-2)
32 return (-1);
33 return ((int)rval);
34 +}
35 +
36 +int
37 +mbtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n)
38 +{
39 + return mbtowc_l(pwc, s, n, __current_locale());
40 }