]>
Commit | Line | Data |
---|---|---|
1f2f436a A |
1 | --- gb2312.c.bsdnew 2009-11-09 15:05:25.000000000 -0800 |
2 | +++ gb2312.c 2009-11-09 16:10:25.000000000 -0800 | |
3d9156a7 A |
3 | @@ -28,6 +28,8 @@ |
4 | #include <sys/param.h> | |
1f2f436a | 5 | __FBSDID("$FreeBSD: src/lib/libc/locale/gb2312.c,v 1.10 2007/10/13 16:28:21 ache Exp $"); |
3d9156a7 A |
6 | |
7 | +#include "xlocale_private.h" | |
8 | + | |
9 | #include <errno.h> | |
10 | #include <runetype.h> | |
11 | #include <stdlib.h> | |
1f2f436a | 12 | @@ -35,34 +37,32 @@ __FBSDID("$FreeBSD: src/lib/libc/locale/ |
3d9156a7 A |
13 | #include <wchar.h> |
14 | #include "mblocal.h" | |
15 | ||
1f2f436a | 16 | -extern int __mb_sb_limit; |
3d9156a7 | 17 | +#define GB2312_MB_CUR_MAX 2 |
3d9156a7 | 18 | |
1f2f436a A |
19 | static size_t _GB2312_mbrtowc(wchar_t * __restrict, const char * __restrict, |
20 | - size_t, mbstate_t * __restrict); | |
21 | -static int _GB2312_mbsinit(const mbstate_t *); | |
22 | + size_t, mbstate_t * __restrict, locale_t); | |
23 | +static int _GB2312_mbsinit(const mbstate_t *, locale_t); | |
24 | static size_t _GB2312_wcrtomb(char * __restrict, wchar_t, | |
25 | - mbstate_t * __restrict); | |
26 | - | |
27 | + mbstate_t * __restrict, locale_t); | |
3d9156a7 A |
28 | typedef struct { |
29 | int count; | |
30 | u_char bytes[2]; | |
31 | } _GB2312State; | |
32 | ||
33 | -int | |
34 | -_GB2312_init(_RuneLocale *rl) | |
35 | +__private_extern__ int | |
36 | +_GB2312_init(struct __xlocale_st_runelocale *xrl) | |
37 | { | |
38 | ||
39 | - _CurrentRuneLocale = rl; | |
40 | - __mbrtowc = _GB2312_mbrtowc; | |
41 | - __wcrtomb = _GB2312_wcrtomb; | |
42 | - __mbsinit = _GB2312_mbsinit; | |
43 | - __mb_cur_max = 2; | |
1f2f436a | 44 | - __mb_sb_limit = 128; |
3d9156a7 A |
45 | + xrl->__mbrtowc = _GB2312_mbrtowc; |
46 | + xrl->__wcrtomb = _GB2312_wcrtomb; | |
47 | + xrl->__mbsinit = _GB2312_mbsinit; | |
48 | + xrl->__mb_cur_max = GB2312_MB_CUR_MAX; | |
1f2f436a | 49 | + xrl->__mb_sb_limit = 128; |
3d9156a7 A |
50 | return (0); |
51 | } | |
52 | ||
1f2f436a | 53 | static int |
3d9156a7 | 54 | -_GB2312_mbsinit(const mbstate_t *ps) |
1f2f436a | 55 | +_GB2312_mbsinit(const mbstate_t *ps, locale_t loc __unused) |
3d9156a7 A |
56 | { |
57 | ||
58 | return (ps == NULL || ((const _GB2312State *)ps)->count == 0); | |
1f2f436a | 59 | @@ -93,7 +93,7 @@ _GB2312_check(const char *str, size_t n) |
3d9156a7 | 60 | |
1f2f436a | 61 | static size_t |
3d9156a7 A |
62 | _GB2312_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n, |
63 | - mbstate_t * __restrict ps) | |
1f2f436a | 64 | + mbstate_t * __restrict ps, locale_t loc __unused) |
3d9156a7 A |
65 | { |
66 | _GB2312State *gs; | |
67 | wchar_t wc; | |
1f2f436a | 68 | @@ -113,7 +113,7 @@ _GB2312_mbrtowc(wchar_t * __restrict pwc |
3d9156a7 A |
69 | pwc = NULL; |
70 | } | |
71 | ||
72 | - ncopy = MIN(MIN(n, MB_CUR_MAX), sizeof(gs->bytes) - gs->count); | |
73 | + ncopy = MIN(MIN(n, GB2312_MB_CUR_MAX), sizeof(gs->bytes) - gs->count); | |
74 | memcpy(gs->bytes + gs->count, s, ncopy); | |
75 | ocount = gs->count; | |
76 | gs->count += ncopy; | |
1f2f436a | 77 | @@ -133,7 +133,7 @@ _GB2312_mbrtowc(wchar_t * __restrict pwc |
3d9156a7 A |
78 | } |
79 | ||
1f2f436a | 80 | static size_t |
3d9156a7 | 81 | -_GB2312_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps) |
1f2f436a | 82 | +_GB2312_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps, locale_t loc __unused) |
3d9156a7 A |
83 | { |
84 | _GB2312State *gs; | |
85 |