Deleted Added
sdiff udiff text old ( 128081 ) new ( 128155 )
full compact
1/*
2 * Copyright (c) 2002-2004 Tim J. Robbins. All rights reserved.
3 *
4 * ja_JP.SJIS locale table for BSD4.4/rune
5 * version 1.0
6 * (C) Sin'ichiro MIYATANI / Phase One, Inc
7 * May 12, 1995
8 *

--- 23 unchanged lines hidden (view full) ---

32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36#if defined(LIBC_SCCS) && !defined(lint)
37static char sccsid[] = "@(#)mskanji.c 1.0 (Phase One) 5/5/95";
38#endif /* LIBC_SCCS and not lint */
39#include <sys/param.h>
40__FBSDID("$FreeBSD: head/lib/libc/locale/mskanji.c 128155 2004-04-12 13:09:18Z tjr $");
41
42#include <errno.h>
43#include <runetype.h>
44#include <stdlib.h>
45#include <string.h>
46#include <wchar.h>
47
48extern size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,
49 size_t, mbstate_t * __restrict);
50extern int (*__mbsinit)(const mbstate_t *);

--- 35 unchanged lines hidden (view full) ---

86{
87 _MSKanjiState *ms;
88 wchar_t wc;
89 int len, ocount;
90 size_t ncopy;
91
92 ms = (_MSKanjiState *)ps;
93
94 if (ms->count < 0 || ms->count > sizeof(ms->bytes)) {
95 errno = EINVAL;
96 return ((size_t)-1);
97 }
98
99 if (s == NULL) {
100 s = "";
101 n = 1;
102 pwc = NULL;
103 }
104
105 ncopy = MIN(MIN(n, MB_CUR_MAX), sizeof(ms->bytes) - ms->count);
106 memcpy(ms->bytes + ms->count, s, ncopy);

--- 16 unchanged lines hidden (view full) ---

123 }
124 if (pwc != NULL)
125 *pwc = wc;
126 ms->count = 0;
127 return (wc == L'\0' ? 0 : len - ocount);
128}
129
130size_t
131_MSKanji_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps)
132{
133 _MSKanjiState *ms;
134 int len, i;
135
136 ms = (_MSKanjiState *)ps;
137
138 if (ms->count != 0) {
139 errno = EINVAL;
140 return ((size_t)-1);
141 }
142
143 if (s == NULL)
144 /* Reset to initial shift state (no-op) */
145 return (1);
146 len = (wc > 0x100) ? 2 : 1;
147 for (i = len; i-- > 0; )
148 *s++ = wc >> (i << 3);
149 return (len);
150}