]> git.saurik.com Git - apple/libc.git/blame - locale/FreeBSD/gb18030.c.patch
Libc-763.11.tar.gz
[apple/libc.git] / locale / FreeBSD / gb18030.c.patch
CommitLineData
1f2f436a
A
1--- gb18030.c.bsdnew 2009-11-09 15:05:25.000000000 -0800
2+++ gb18030.c 2009-11-09 15:50:31.000000000 -0800
3d9156a7
A
3@@ -32,6 +32,8 @@
4 #include <sys/param.h>
1f2f436a 5 __FBSDID("$FreeBSD: src/lib/libc/locale/gb18030.c,v 1.8 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@@ -39,35 +41,34 @@ __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 GB18030_MB_CUR_MAX 4
1f2f436a
A
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);
3d9156a7 23+static int _GB18030_mbsinit(const mbstate_t *, locale_t);
1f2f436a
A
24 static size_t _GB18030_wcrtomb(char * __restrict, wchar_t,
25- mbstate_t * __restrict);
26+ mbstate_t * __restrict, locale_t);
3d9156a7
A
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;
1f2f436a 44- __mb_sb_limit = 128;
3d9156a7
A
45+ xrl->__mbrtowc = _GB18030_mbrtowc;
46+ xrl->__wcrtomb = _GB18030_wcrtomb;
47+ xrl->__mbsinit = _GB18030_mbsinit;
48+ xrl->__mb_cur_max = GB18030_MB_CUR_MAX;
1f2f436a 49+ xrl->__mb_sb_limit = 128;
3d9156a7
A
50
51 return (0);
52 }
53
1f2f436a 54 static int
3d9156a7 55-_GB18030_mbsinit(const mbstate_t *ps)
1f2f436a 56+_GB18030_mbsinit(const mbstate_t *ps, locale_t loc __unused)
3d9156a7
A
57 {
58
59 return (ps == NULL || ((const _GB18030State *)ps)->count == 0);
1f2f436a 60@@ -75,7 +76,7 @@ _GB18030_mbsinit(const mbstate_t *ps)
3d9156a7 61
1f2f436a 62 static size_t
3d9156a7
A
63 _GB18030_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s,
64- size_t n, mbstate_t * __restrict ps)
1f2f436a 65+ size_t n, mbstate_t * __restrict ps, locale_t loc __unused)
3d9156a7
A
66 {
67 _GB18030State *gs;
68 wchar_t wch;
1f2f436a 69@@ -95,7 +96,7 @@ _GB18030_mbrtowc(wchar_t * __restrict pw
3d9156a7
A
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;
1f2f436a 78@@ -158,7 +159,7 @@ ilseq:
3d9156a7
A
79 }
80
1f2f436a 81 static size_t
3d9156a7 82-_GB18030_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps)
1f2f436a 83+_GB18030_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps, locale_t loc __unused)
3d9156a7
A
84 {
85 _GB18030State *gs;
86 size_t len;