]> git.saurik.com Git - apple/libc.git/blob - locale/FreeBSD/gb18030.c.patch
Libc-763.13.tar.gz
[apple/libc.git] / locale / FreeBSD / gb18030.c.patch
1 --- gb18030.c.bsdnew 2009-11-09 15:05:25.000000000 -0800
2 +++ gb18030.c 2009-11-09 15:50:31.000000000 -0800
3 @@ -32,6 +32,8 @@
4 #include <sys/param.h>
5 __FBSDID("$FreeBSD: src/lib/libc/locale/gb18030.c,v 1.8 2007/10/13 16:28:21 ache Exp $");
6
7 +#include "xlocale_private.h"
8 +
9 #include <errno.h>
10 #include <runetype.h>
11 #include <stdlib.h>
12 @@ -39,35 +41,34 @@ __FBSDID("$FreeBSD: src/lib/libc/locale/
13 #include <wchar.h>
14 #include "mblocal.h"
15
16 -extern int __mb_sb_limit;
17 +#define GB18030_MB_CUR_MAX 4
18
19 static size_t _GB18030_mbrtowc(wchar_t * __restrict, const char * __restrict,
20 - size_t, mbstate_t * __restrict);
21 -static int _GB18030_mbsinit(const mbstate_t *);
22 + size_t, mbstate_t * __restrict, locale_t);
23 +static int _GB18030_mbsinit(const mbstate_t *, locale_t);
24 static size_t _GB18030_wcrtomb(char * __restrict, wchar_t,
25 - mbstate_t * __restrict);
26 + mbstate_t * __restrict, locale_t);
27
28 typedef struct {
29 int count;
30 u_char bytes[4];
31 } _GB18030State;
32
33 -int
34 -_GB18030_init(_RuneLocale *rl)
35 +__private_extern__ int
36 +_GB18030_init(struct __xlocale_st_runelocale *xrl)
37 {
38
39 - __mbrtowc = _GB18030_mbrtowc;
40 - __wcrtomb = _GB18030_wcrtomb;
41 - __mbsinit = _GB18030_mbsinit;
42 - _CurrentRuneLocale = rl;
43 - __mb_cur_max = 4;
44 - __mb_sb_limit = 128;
45 + xrl->__mbrtowc = _GB18030_mbrtowc;
46 + xrl->__wcrtomb = _GB18030_wcrtomb;
47 + xrl->__mbsinit = _GB18030_mbsinit;
48 + xrl->__mb_cur_max = GB18030_MB_CUR_MAX;
49 + xrl->__mb_sb_limit = 128;
50
51 return (0);
52 }
53
54 static int
55 -_GB18030_mbsinit(const mbstate_t *ps)
56 +_GB18030_mbsinit(const mbstate_t *ps, locale_t loc __unused)
57 {
58
59 return (ps == NULL || ((const _GB18030State *)ps)->count == 0);
60 @@ -75,7 +76,7 @@ _GB18030_mbsinit(const mbstate_t *ps)
61
62 static size_t
63 _GB18030_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s,
64 - size_t n, mbstate_t * __restrict ps)
65 + size_t n, mbstate_t * __restrict ps, locale_t loc __unused)
66 {
67 _GB18030State *gs;
68 wchar_t wch;
69 @@ -95,7 +96,7 @@ _GB18030_mbrtowc(wchar_t * __restrict pw
70 pwc = NULL;
71 }
72
73 - ncopy = MIN(MIN(n, MB_CUR_MAX), sizeof(gs->bytes) - gs->count);
74 + ncopy = MIN(MIN(n, GB18030_MB_CUR_MAX), sizeof(gs->bytes) - gs->count);
75 memcpy(gs->bytes + gs->count, s, ncopy);
76 ocount = gs->count;
77 gs->count += ncopy;
78 @@ -158,7 +159,7 @@ ilseq:
79 }
80
81 static size_t
82 -_GB18030_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps)
83 +_GB18030_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps, locale_t loc __unused)
84 {
85 _GB18030State *gs;
86 size_t len;