Deleted Added
full compact
utf8.c (128081) utf8.c (128155)
1/*-
2 * Copyright (c) 2002-2004 Tim J. Robbins
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/param.h>
1/*-
2 * Copyright (c) 2002-2004 Tim J. Robbins
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/param.h>
28__FBSDID("$FreeBSD: head/lib/libc/locale/utf8.c 128081 2004-04-10 00:27:52Z tjr $");
28__FBSDID("$FreeBSD: head/lib/libc/locale/utf8.c 128155 2004-04-12 13:09:18Z tjr $");
29
30#include <errno.h>
31#include <runetype.h>
32#include <stdlib.h>
33#include <string.h>
34#include <wchar.h>
35
36extern size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,

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

74{
75 _UTF8State *us;
76 int ch, i, len, mask, ocount;
77 wchar_t lbound, wch;
78 size_t ncopy;
79
80 us = (_UTF8State *)ps;
81
29
30#include <errno.h>
31#include <runetype.h>
32#include <stdlib.h>
33#include <string.h>
34#include <wchar.h>
35
36extern size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,

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

74{
75 _UTF8State *us;
76 int ch, i, len, mask, ocount;
77 wchar_t lbound, wch;
78 size_t ncopy;
79
80 us = (_UTF8State *)ps;
81
82 if (us->count < 0 || us->count > sizeof(us->bytes)) {
83 errno = EINVAL;
84 return ((size_t)-1);
85 }
86
82 if (s == NULL) {
83 s = "";
84 n = 1;
85 pwc = NULL;
86 }
87
88 ncopy = MIN(MIN(n, MB_CUR_MAX), sizeof(us->bytes) - us->count);
89 memcpy(us->bytes + us->count, s, ncopy);

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

171 }
172 if (pwc != NULL)
173 *pwc = wch;
174 us->count = 0;
175 return (wch == L'\0' ? 0 : len - ocount);
176}
177
178size_t
87 if (s == NULL) {
88 s = "";
89 n = 1;
90 pwc = NULL;
91 }
92
93 ncopy = MIN(MIN(n, MB_CUR_MAX), sizeof(us->bytes) - us->count);
94 memcpy(us->bytes + us->count, s, ncopy);

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

176 }
177 if (pwc != NULL)
178 *pwc = wch;
179 us->count = 0;
180 return (wch == L'\0' ? 0 : len - ocount);
181}
182
183size_t
179_UTF8_wcrtomb(char * __restrict s, wchar_t wc,
180 mbstate_t * __restrict ps __unused)
184_UTF8_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps)
181{
185{
186 _UTF8State *us;
182 unsigned char lead;
183 int i, len;
184
187 unsigned char lead;
188 int i, len;
189
190 us = (_UTF8State *)ps;
191
192 if (us->count < 0 || us->count > sizeof(us->bytes)) {
193 errno = EINVAL;
194 return ((size_t)-1);
195 }
196
185 if (s == NULL)
186 /* Reset to initial shift state (no-op) */
187 return (1);
188
189 /*
190 * Determine the number of octets needed to represent this character.
191 * We always output the shortest sequence possible. Also specify the
192 * first few bits of the first octet, which contains the information

--- 39 unchanged lines hidden ---
197 if (s == NULL)
198 /* Reset to initial shift state (no-op) */
199 return (1);
200
201 /*
202 * Determine the number of octets needed to represent this character.
203 * We always output the shortest sequence possible. Also specify the
204 * first few bits of the first octet, which contains the information

--- 39 unchanged lines hidden ---