#ifndef lint
#endif
/*
* Copyright (c) 2000,2001,2002 Japan Network Information Center.
* All rights reserved.
*
* By using this file, you agree to the terms and conditions set forth bellow.
*
* LICENSE TERMS AND CONDITIONS
*
* The following License Terms and Conditions apply, unless a different
* license is obtained from Japan Network Information Center ("JPNIC"),
* a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
* Chiyoda-ku, Tokyo 101-0047, Japan.
*
* 1. Use, Modification and Redistribution (including distribution of any
* under this License Terms and Conditions.
*
* 2. Redistribution of source code must retain the copyright notices as they
* appear in each source code file, this License Terms and Conditions.
*
* 3. Redistribution in binary form must reproduce the Copyright Notice,
* materials provided with the distribution. For the purposes of binary
* distribution the "Copyright Notice" refers to the following language:
* "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
*
* 4. The name of JPNIC may not be used to endorse or promote products
* derived from this Software without specific prior written approval of
* JPNIC.
*
* 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#include <config.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <idn/logmacro.h>
#include <idn/unormalize.h>
#if !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY)
#endif
typedef struct {
} workbuf_t;
int do_composition, int compat,
const unsigned long *from,
TRACE(("idn__unormalize_formkc(from=\"%s\", tolen=%d)\n",
}
static idn_result_t
idn_result_t r = idn_success;
/*
* Initialize working buffer.
*/
workbuf_init(&wb);
while (*from != '\0') {
unsigned long c;
/*
* Get one character from 'from'.
*/
c = *from++;
/*
* Decompose it.
*/
goto ret;
/*
* Get canonical class.
*/
/*
* Reorder & compose.
*/
continue;
/*
* This is not a starter. Try reordering.
* Note that characters up to it are
* already in canonical order.
*/
continue;
}
/*
* This is a starter character, and there are
* some characters before it. Those characters
* have been reordered properly, and
* ready for composition.
*/
/*
* If CUR points to a starter character,
* then process of characters before CUR are
* already finished, because any further
* reordering/composition for them are blocked
* by the starter CUR points.
*/
/* Flush everything before CUR. */
if (r != idn_success)
goto ret;
}
}
}
if (r == idn_success) {
/*
* There is some characters left in WB.
* They are ordered, but not composed yet.
* Now CUR points just after the last character in WB,
* and since compose() tries to compose characters
* between top and CUR inclusive, we must make CUR
* one character back during compose().
*/
}
/*
* Call this even when WB.CUR == 0, to make TO
* NUL-terminated.
*/
if (r != idn_success)
goto ret;
}
if (tolen <= 0) {
r = idn_buffer_overflow;
goto ret;
}
*to = '\0';
ret:
workbuf_free(&wb);
return (r);
}
static idn_result_t
idn_result_t r;
int dec_len;
switch (r) {
case idn_success:
return (idn_success);
case idn_notfound:
return (workbuf_append(wb, c));
case idn_buffer_overflow:
return (r);
WARNING(("idn__unormalize_form*: "
"working buffer too large\n"));
return (idn_nomemory);
}
goto again;
default:
return (r);
}
/* NOTREACHED */
}
static void
int i;
}
static void
unsigned long c;
int i;
int class;
i--;
}
}
static void
int cur;
unsigned long *ucs4;
int *class;
int last_class;
int nvoids;
int i;
/*
* If there are no decomposition sequence that begins with
* the top character, composition is impossible.
*/
return;
last_class = 0;
nvoids = 0;
for (i = 1; i <= cur; i++) {
unsigned long c;
&c) == idn_success) {
/*
* Replace the top character with the composed one.
*/
ucs4[0] = c;
nvoids++;
} else {
last_class = cl;
}
}
/* Purge void characters, if any. */
if (nvoids > 0)
}
static idn_result_t
return (idn_buffer_overflow);
return (idn_success);
}
static void
}
static void
}
}
static idn_result_t
} else {
}
return (idn_nomemory);
else
return (idn_success);
}
static idn_result_t
idn_result_t r;
return (r);
return (idn_success);
}
static void
int nmove;
}
static void
int i, j;
for (i = j = 0; i < last; i++) {
if (j < i) {
}
j++;
}
}
}