1 --- gb18030.c.orig Thu Nov 25 11:38:16 2004
2 +++ gb18030.c Fri Feb 18 15:43:22 2005
5 __FBSDID("$FreeBSD: src/lib/libc/locale/gb18030.c,v 1.6 2004/05/12 14:09:04 tjr Exp $");
7 +#include "xlocale_private.h"
16 -int _GB18030_init(_RuneLocale *);
17 -size_t _GB18030_mbrtowc(wchar_t * __restrict, const char * __restrict, size_t,
18 - mbstate_t * __restrict);
19 -int _GB18030_mbsinit(const mbstate_t *);
20 -size_t _GB18030_wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict);
21 +#define GB18030_MB_CUR_MAX 4
23 +__private_extern__ int _GB18030_init(struct __xlocale_st_runelocale *);
24 +static size_t _GB18030_mbrtowc(wchar_t * __restrict, const char * __restrict, size_t,
25 + mbstate_t * __restrict, locale_t);
26 +static int _GB18030_mbsinit(const mbstate_t *, locale_t);
27 +static size_t _GB18030_wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict, locale_t);
35 -_GB18030_init(_RuneLocale *rl)
36 +__private_extern__ int
37 +_GB18030_init(struct __xlocale_st_runelocale *xrl)
40 - __mbrtowc = _GB18030_mbrtowc;
41 - __wcrtomb = _GB18030_wcrtomb;
42 - __mbsinit = _GB18030_mbsinit;
43 - _CurrentRuneLocale = rl;
45 + xrl->__mbrtowc = _GB18030_mbrtowc;
46 + xrl->__wcrtomb = _GB18030_wcrtomb;
47 + xrl->__mbsinit = _GB18030_mbsinit;
48 + xrl->__mb_cur_max = GB18030_MB_CUR_MAX;
54 -_GB18030_mbsinit(const mbstate_t *ps)
56 +_GB18030_mbsinit(const mbstate_t *ps, locale_t loc)
59 return (ps == NULL || ((const _GB18030State *)ps)->count == 0);
64 _GB18030_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s,
65 - size_t n, mbstate_t * __restrict ps)
66 + size_t n, mbstate_t * __restrict ps, locale_t loc)
74 - ncopy = MIN(MIN(n, MB_CUR_MAX), sizeof(gs->bytes) - gs->count);
75 + ncopy = MIN(MIN(n, GB18030_MB_CUR_MAX), sizeof(gs->bytes) - gs->count);
76 memcpy(gs->bytes + gs->count, s, ncopy);
84 -_GB18030_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps)
86 +_GB18030_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps, locale_t loc)