1 --- euc.c.bsdnew 2009-11-09 15:05:25.000000000 -0800
2 +++ euc.c 2009-11-09 15:44:21.000000000 -0800
3 @@ -41,6 +41,8 @@ static char sccsid[] = "@(#)euc.c 8.1 (B
5 __FBSDID("$FreeBSD: src/lib/libc/locale/euc.c,v 1.22 2007/10/13 16:28:21 ache Exp $");
7 +#include "xlocale_private.h"
12 @@ -49,13 +51,11 @@ __FBSDID("$FreeBSD: src/lib/libc/locale/
16 -extern int __mb_sb_limit;
18 static size_t _EUC_mbrtowc(wchar_t * __restrict, const char * __restrict,
19 - size_t, mbstate_t * __restrict);
20 -static int _EUC_mbsinit(const mbstate_t *);
21 + size_t, mbstate_t * __restrict, locale_t);
22 +static int _EUC_mbsinit(const mbstate_t *, locale_t);
23 static size_t _EUC_wcrtomb(char * __restrict, wchar_t,
24 - mbstate_t * __restrict);
25 + mbstate_t * __restrict, locale_t);
29 @@ -69,12 +69,20 @@ typedef struct {
34 -_EUC_init(_RuneLocale *rl)
35 +/* This will be called by the XL_RELEASE() macro to free the extra storage */
37 +_EUC_free_extra(struct __xlocale_st_runelocale *xrl)
39 + free(xrl->_CurrentRuneLocale.__variable);
42 +__private_extern__ int
43 +_EUC_init(struct __xlocale_st_runelocale *xrl)
46 int x, new__mb_cur_max;
48 + _RuneLocale *rl = &xrl->_CurrentRuneLocale;
50 if (rl->__variable == NULL)
52 @@ -113,24 +121,22 @@ _EUC_init(_RuneLocale *rl)
55 rl->__variable_len = sizeof(_EucInfo);
56 - _CurrentRuneLocale = rl;
57 - __mb_cur_max = new__mb_cur_max;
58 - __mbrtowc = _EUC_mbrtowc;
59 - __wcrtomb = _EUC_wcrtomb;
60 - __mbsinit = _EUC_mbsinit;
61 - __mb_sb_limit = 256;
62 + xrl->__mb_cur_max = new__mb_cur_max;
63 + xrl->__mbrtowc = _EUC_mbrtowc;
64 + xrl->__wcrtomb = _EUC_wcrtomb;
65 + xrl->__mbsinit = _EUC_mbsinit;
66 + xrl->__mb_sb_limit = 256;
67 + xrl->__free_extra = (__free_extra_t)_EUC_free_extra;
72 -_EUC_mbsinit(const mbstate_t *ps)
73 +_EUC_mbsinit(const mbstate_t *ps, locale_t loc __unused)
76 return (ps == NULL || ((const _EucState *)ps)->want == 0);
79 -#define CEI ((_EucInfo *)(_CurrentRuneLocale->__variable))
84 @@ -146,16 +152,18 @@ _euc_set(u_int c)
87 _EUC_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n,
88 - mbstate_t * __restrict ps)
89 + mbstate_t * __restrict ps, locale_t loc)
95 + struct __xlocale_st_runelocale *rl = loc->__lc_ctype;
96 + _EucInfo *CEI = (_EucInfo *)rl->_CurrentRuneLocale.__variable;
100 - if (es->want < 0 || es->want > MB_CUR_MAX || es->set < 0 ||
101 + if (es->want < 0 || es->want > rl->__mb_cur_max || es->set < 0 ||
105 @@ -218,11 +226,12 @@ _EUC_mbrtowc(wchar_t * __restrict pwc, c
109 -_EUC_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps)
110 +_EUC_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps, locale_t loc)
115 + _EucInfo *CEI = (_EucInfo *)loc->__lc_ctype->_CurrentRuneLocale.__variable;
117 es = (_EucState *)ps;