]> git.saurik.com Git - apple/libc.git/blob - locale/FreeBSD/gb2312.c.patch
Libc-763.12.tar.gz
[apple/libc.git] / locale / FreeBSD / gb2312.c.patch
1 --- gb2312.c.bsdnew 2009-11-09 15:05:25.000000000 -0800
2 +++ gb2312.c 2009-11-09 16:10:25.000000000 -0800
3 @@ -28,6 +28,8 @@
4 #include <sys/param.h>
5 __FBSDID("$FreeBSD: src/lib/libc/locale/gb2312.c,v 1.10 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 @@ -35,34 +37,32 @@ __FBSDID("$FreeBSD: src/lib/libc/locale/
13 #include <wchar.h>
14 #include "mblocal.h"
15
16 -extern int __mb_sb_limit;
17 +#define GB2312_MB_CUR_MAX 2
18
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);
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;
44 - __mb_sb_limit = 128;
45 + xrl->__mbrtowc = _GB2312_mbrtowc;
46 + xrl->__wcrtomb = _GB2312_wcrtomb;
47 + xrl->__mbsinit = _GB2312_mbsinit;
48 + xrl->__mb_cur_max = GB2312_MB_CUR_MAX;
49 + xrl->__mb_sb_limit = 128;
50 return (0);
51 }
52
53 static int
54 -_GB2312_mbsinit(const mbstate_t *ps)
55 +_GB2312_mbsinit(const mbstate_t *ps, locale_t loc __unused)
56 {
57
58 return (ps == NULL || ((const _GB2312State *)ps)->count == 0);
59 @@ -93,7 +93,7 @@ _GB2312_check(const char *str, size_t n)
60
61 static size_t
62 _GB2312_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n,
63 - mbstate_t * __restrict ps)
64 + mbstate_t * __restrict ps, locale_t loc __unused)
65 {
66 _GB2312State *gs;
67 wchar_t wc;
68 @@ -113,7 +113,7 @@ _GB2312_mbrtowc(wchar_t * __restrict pwc
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;
77 @@ -133,7 +133,7 @@ _GB2312_mbrtowc(wchar_t * __restrict pwc
78 }
79
80 static size_t
81 -_GB2312_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps)
82 +_GB2312_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps, locale_t loc __unused)
83 {
84 _GB2312State *gs;
85