euc.c revision 6b5e5868e7ebf1aff3a5abd7d0c4ef0e5fbf3648
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * Copyright (c) 2002-2004 Tim J. Robbins. All rights reserved.
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * Copyright (c) 1993
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * The Regents of the University of California. All rights reserved.
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * This code is derived from software contributed to Berkeley by
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * Paul Borman at Krystal Technologies.
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * Redistribution and use in source and binary forms, with or without
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * modification, are permitted provided that the following conditions
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * 1. Redistributions of source code must retain the above copyright
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * notice, this list of conditions and the following disclaimer.
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * 2. Redistributions in binary form must reproduce the above copyright
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * notice, this list of conditions and the following disclaimer in the
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * documentation and/or other materials provided with the distribution.
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * 4. Neither the name of the University nor the names of its contributors
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * may be used to endorse or promote products derived from this software
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * without specific prior written permission.
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper * SUCH DAMAGE.
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper#define MIN(a, b) ((a) < (b) ? (a) : (b))
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeperstatic size_t _EUC_mbrtowc(wchar_t *_RESTRICT_KYWD,
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeperstatic size_t _EUC_wcrtomb(char *_RESTRICT_KYWD, wchar_t,
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reepertypedef struct {
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reepertypedef struct {
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper if ((ei = malloc(sizeof (_EucInfo))) == NULL)
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper for (x = 0; x < 4; ++x) {
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper if (v == e || !(v = e)) {
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper if (v == e || !(v = e)) {
7fadb5ee267a4d808110b0c3e704de440902cb83Mark de Reeper if (v == e || !(v = e)) {
return (EINVAL);
charset_is_ascii = 0;
static size_t
const char *os;
if (s == NULL) {
os = s;
--want;
wc = (unsigned char)*s++;
if (i < want) {
static size_t
int i, len;
if (s == NULL)
*(unsigned char *)s = _SS2;
*(unsigned char *)s = _SS3;
return (len);