]> git.saurik.com Git - apple/libc.git/blob - locale/FreeBSD/mblen.c.patch
6dc72fcc88a7b3e90b1e9b3351e92ef73d446a2e
[apple/libc.git] / locale / FreeBSD / mblen.c.patch
1 --- mblen.c.orig Thu Nov 25 11:38:18 2004
2 +++ mblen.c Fri Feb 18 16:55:20 2005
3 @@ -27,24 +27,32 @@
4 #include <sys/cdefs.h>
5 __FBSDID("$FreeBSD: src/lib/libc/locale/mblen.c,v 1.9 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 -mblen(const char *s, size_t n)
15 +mblen_l(const char *s, size_t n, locale_t loc)
16 {
17 static const mbstate_t initial;
18 - static mbstate_t mbs;
19 size_t rval;
20
21 + NORMALIZE_LOCALE(loc);
22 if (s == NULL) {
23 /* No support for state dependent encodings. */
24 - mbs = initial;
25 + loc->__mbs_mblen = initial;
26 return (0);
27 }
28 - rval = __mbrtowc(NULL, s, n, &mbs);
29 + rval = loc->__lc_ctype->__mbrtowc(NULL, s, n, &loc->__mbs_mblen, loc);
30 if (rval == (size_t)-1 || rval == (size_t)-2)
31 return (-1);
32 return ((int)rval);
33 +}
34 +
35 +int
36 +mblen(const char *s, size_t n)
37 +{
38 + return mblen_l(s, n, __current_locale());
39 }