1 --- euc.c.orig Thu Nov 25 11:38:16 2004
2 +++ euc.c Fri Feb 18 15:30:38 2005
5 __FBSDID("$FreeBSD: src/lib/libc/locale/euc.c,v 1.20 2004/06/23 07:01:43 tjr Exp $");
7 +#include "xlocale_private.h"
16 -int _EUC_init(_RuneLocale *);
17 -size_t _EUC_mbrtowc(wchar_t * __restrict, const char * __restrict, size_t,
18 - mbstate_t * __restrict);
19 -int _EUC_mbsinit(const mbstate_t *);
20 -size_t _EUC_wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict);
21 +__private_extern__ int _EUC_init(struct __xlocale_st_runelocale *);
22 +static size_t _EUC_mbrtowc(wchar_t * __restrict, const char * __restrict, size_t,
23 + mbstate_t * __restrict, locale_t);
24 +static int _EUC_mbsinit(const mbstate_t *, locale_t);
25 +static size_t _EUC_wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict,
35 -_EUC_init(_RuneLocale *rl)
36 +/* This will be called by the XL_RELEASE() macro to free the extra storage */
38 +_EUC_free_extra(struct __xlocale_st_runelocale *xrl)
40 + free(xrl->_CurrentRuneLocale.__variable);
43 +__private_extern__ int
44 +_EUC_init(struct __xlocale_st_runelocale *xrl)
47 int x, new__mb_cur_max;
49 + _RuneLocale *rl = &xrl->_CurrentRuneLocale;
51 if (rl->__variable == NULL)
56 rl->__variable_len = sizeof(_EucInfo);
57 - _CurrentRuneLocale = rl;
58 - __mb_cur_max = new__mb_cur_max;
59 - __mbrtowc = _EUC_mbrtowc;
60 - __wcrtomb = _EUC_wcrtomb;
61 - __mbsinit = _EUC_mbsinit;
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->__free_extra = (__free_extra_t)_EUC_free_extra;
71 -_EUC_mbsinit(const mbstate_t *ps)
73 +_EUC_mbsinit(const mbstate_t *ps, locale_t loc)
76 return (ps == NULL || ((const _EucState *)ps)->want == 0);
79 -#define CEI ((_EucInfo *)(_CurrentRuneLocale->__variable))
85 return ((c & 0x80) ? c == _SS3 ? 3 : c == _SS2 ? 2 : 1 : 0);
90 _EUC_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n,
91 - mbstate_t * __restrict ps)
92 + mbstate_t * __restrict ps, locale_t loc)
98 + struct __xlocale_st_runelocale *rl = loc->__lc_ctype;
99 + _EucInfo *CEI = (_EucInfo *)rl->_CurrentRuneLocale.__variable;
101 es = (_EucState *)ps;
103 - if (es->want < 0 || es->want > MB_CUR_MAX || es->set < 0 ||
104 + if (es->want < 0 || es->want > rl->__mb_cur_max || es->set < 0 ||
108 @@ -213,12 +224,14 @@
109 return (wc == L'\0' ? 0 : s - os);
113 -_EUC_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps)
115 +_EUC_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps,
121 + _EucInfo *CEI = (_EucInfo *)loc->__lc_ctype->_CurrentRuneLocale.__variable;
123 es = (_EucState *)ps;