glibc/iconvdata/tst-table-to.c
Ulrich Drepper 755104edc7 Update.
2000-09-18  Ulrich Drepper  <drepper@redhat.com>

	* version.h (VERSION): Bump to 2.1.94.

	* malloc/mtrace.c (mtrace): Mark stream as close on exec.

2000-09-17  Bruno Haible  <haible@clisp.cons.org>

	* iconvdata/utf-16.c (BODY for TO_LOOP): Reject UCS-4 input in the
	range 0xD800..0xDFFF.
	* iconvdata/unicode.c (BODY for TO_LOOP): Likewise.
	(BODY for FROM_LOOP): Likewise.
	* iconv/gconv_simple.c (ucs2_internal_loop): Likewise.
	(internal_ucs2_loop): Likewise.
	(ucs2reverse_internal_loop): Likewise.
	(internal_ucs2reverse_loop): Likewise.

2000-09-17  Bruno Haible  <haible@clisp.cons.org>

	* iconvdata/utf-16.c (gconv_init): Add missing slashes to encoding
	names.

2000-09-17  Bruno Haible  <haible@clisp.cons.org>

	* iconvdata/tst-table-from.c (main): Fix test for error on stdout.
	* iconvdata/tst-table-to.c (main): Likewise.

2000-09-17  Bruno Haible  <haible@clisp.cons.org>

	* iconvdata/iso-ir-165.c (__isoir165_from_tab): Renamed from
	__isoir165_tab.
	* iconvdata/cns11643.h (__cns11643l1_to_ucs4_tab): New declaration.
	* iconvdata/iso-2022-cn-ext.c: Include "cns11643.h".
	(GB7590_set, GB13132_set, CNS11643_3_set, CNS11643_4_set,
	CNS11643_5_set, CNS11643_6_set, CNS11643_7_set): Change enum values.
	(BODY for FROM_LOOP): Fix buffer overrun. Treat CNS11643 plane 3.
	Return __GCONV_INCOMPLETE_INPUT instead of __GCONV_EMPTY_INPUT.
	(BODY for TO_LOOP): Fix usage of `set' vs. `used'.  Fix typo that
	caused GB2312 to be used instead of ISO-IR-165. Treat CNS11643
	plane 3.  Fix shift sequences. Output announcement for SS2 and SS3
	encodings when needed.  When outputting an announcement, don't clear
	most other announcements.

2000-09-17  Bruno Haible  <haible@clisp.cons.org>

	* iconvdata/iso-2022-cn.c (BODY for FROM_LOOP): Fix buffer overrun.
	(BODY for TO_LOOP): Fix usage of `set' vs. `used'.

2000-09-14  Bruno Haible  <haible@clisp.cons.org>

	* intl/Versions: Add bind_textdomain_codeset.
2000-09-18 22:41:47 +00:00

108 lines
2.8 KiB
C

/* Copyright (C) 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Bruno Haible <haible@clisp.cons.org>, 2000.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* Create a table from Unicode to CHARSET.
This is a good test for CHARSET's iconv() module, in particular the
TO_LOOP BODY macro. */
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <iconv.h>
#include <errno.h>
int
main (int argc, char *argv[])
{
const char *charset;
iconv_t cd;
if (argc != 2)
{
fprintf (stderr, "Usage: tst-table-to charset\n");
exit (1);
}
charset = argv[1];
cd = iconv_open (charset, "UCS-2");
if (cd == (iconv_t)(-1))
{
perror ("iconv_open");
exit (1);
}
{
unsigned int i;
unsigned char buf[10];
for (i = 0; i < 0x10000; i++)
{
unsigned short in = i;
const char *inbuf = (const char *) &in;
size_t inbytesleft = sizeof (unsigned short);
char *outbuf = (char *) buf;
size_t outbytesleft = sizeof (buf);
size_t result = iconv (cd,
(char **) &inbuf, &inbytesleft,
&outbuf, &outbytesleft);
if (result == (size_t)(-1))
{
if (errno != EILSEQ)
{
int saved_errno = errno;
fprintf (stderr, "0x%02X: iconv error: ", i);
errno = saved_errno;
perror ("");
exit (1);
}
}
else if (result == 0) /* ignore conversions with transliteration */
{
unsigned int j, jmax;
if (inbytesleft != 0 || outbytesleft == sizeof (buf))
{
fprintf (stderr, "0x%02X: inbytes = %ld, outbytes = %ld\n", i,
(long) (sizeof (unsigned short) - inbytesleft),
(long) (sizeof (buf) - outbytesleft));
exit (1);
}
jmax = sizeof (buf) - outbytesleft;
printf ("0x");
for (j = 0; j < jmax; j++)
printf ("%02X", buf[j]);
printf ("\t0x%04X\n", i);
}
}
}
if (iconv_close (cd) < 0)
{
perror ("iconv_close");
exit (1);
}
if (ferror (stdin) || fflush (stdout) || ferror (stdout))
{
fprintf (stderr, "I/O error\n");
exit (1);
}
exit (0);
}