]> git.saurik.com Git - apple/libc.git/blame - locale/FreeBSD/gb2312.c.patch
Libc-391.tar.gz
[apple/libc.git] / locale / FreeBSD / gb2312.c.patch
CommitLineData
3d9156a7
A
1--- gb2312.c.orig Thu Nov 25 11:38:17 2004
2+++ gb2312.c Fri Feb 18 15:45:33 2005
3@@ -28,6 +28,8 @@
4 #include <sys/param.h>
5 __FBSDID("$FreeBSD: src/lib/libc/locale/gb2312.c,v 1.8 2004/05/12 14:09:04 tjr Exp $");
6
7+#include "xlocale_private.h"
8+
9 #include <errno.h>
10 #include <runetype.h>
11 #include <stdlib.h>
12@@ -35,31 +37,32 @@
13 #include <wchar.h>
14 #include "mblocal.h"
15
16-int _GB2312_init(_RuneLocale *);
17-size_t _GB2312_mbrtowc(wchar_t * __restrict, const char * __restrict, size_t,
18- mbstate_t * __restrict);
19-int _GB2312_mbsinit(const mbstate_t *);
20-size_t _GB2312_wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict);
21+#define GB2312_MB_CUR_MAX 2
22+
23+__private_extern__ int _GB2312_init(struct __xlocale_st_runelocale *);
24+static size_t _GB2312_mbrtowc(wchar_t * __restrict, const char * __restrict, size_t,
25+ mbstate_t * __restrict, locale_t);
26+static int _GB2312_mbsinit(const mbstate_t *, locale_t);
27+static size_t _GB2312_wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict, locale_t);
28
29 typedef struct {
30 int count;
31 u_char bytes[2];
32 } _GB2312State;
33
34-int
35-_GB2312_init(_RuneLocale *rl)
36+__private_extern__ int
37+_GB2312_init(struct __xlocale_st_runelocale *xrl)
38 {
39
40- _CurrentRuneLocale = rl;
41- __mbrtowc = _GB2312_mbrtowc;
42- __wcrtomb = _GB2312_wcrtomb;
43- __mbsinit = _GB2312_mbsinit;
44- __mb_cur_max = 2;
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 return (0);
50 }
51
52-int
53-_GB2312_mbsinit(const mbstate_t *ps)
54+static int
55+_GB2312_mbsinit(const mbstate_t *ps, locale_t loc)
56 {
57
58 return (ps == NULL || ((const _GB2312State *)ps)->count == 0);
59@@ -88,9 +91,9 @@
60 return (1);
61 }
62
63-size_t
64+static size_t
65 _GB2312_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n,
66- mbstate_t * __restrict ps)
67+ mbstate_t * __restrict ps, locale_t loc)
68 {
69 _GB2312State *gs;
70 wchar_t wc;
71@@ -110,7 +113,7 @@
72 pwc = NULL;
73 }
74
75- ncopy = MIN(MIN(n, MB_CUR_MAX), sizeof(gs->bytes) - gs->count);
76+ ncopy = MIN(MIN(n, GB2312_MB_CUR_MAX), sizeof(gs->bytes) - gs->count);
77 memcpy(gs->bytes + gs->count, s, ncopy);
78 ocount = gs->count;
79 gs->count += ncopy;
80@@ -129,8 +132,8 @@
81 return (wc == L'\0' ? 0 : len - ocount);
82 }
83
84-size_t
85-_GB2312_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps)
86+static size_t
87+_GB2312_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps, locale_t loc)
88 {
89 _GB2312State *gs;
90