glibc/iconvdata/armscii-8.c
Ulrich Drepper e438a46845 Update.
2002-05-26  Bruno Haible  <bruno@clisp.org>
	* iconv/loop.c (STANDARD_FROM_LOOP_ERR_HANDLER): New macro.
	(STANDARD_TO_LOOP_ERR_HANDLER): Renamed from STANDARD_ERR_HANDLER.
	All callers changed.
	* iconv/gconv_simple.c (ascii_internal_loop): For error handling use
	STANDARD_FROM_LOOP_ERR_HANDLER.
	(utf8_internal_loop): Likewise.
	(ucs2_internal_loop): Likewise.
	(internal_ucs2_loop): Perform error handling like in
	STANDARD_FROM_LOOP_ERR_HANDLER.
	* iconvdata/unicode.c (BODY for TO_LOOP): Perform error handling like
	in STANDARD_FROM_LOOP_ERR_HANDLER.
	(BODY for FROM_LOOP): Use STANDARD_FROM_LOOP_ERR_HANDLER for error
	handling.
	* iconvdata/utf-16.c (BODY for TO_LOOP): Perform error handling like
	in STANDARD_FROM_LOOP_ERR_HANDLER.
	(BODY for FROM_LOOP): Use STANDARD_FROM_LOOP_ERR_HANDLER for error
	handling.
	* iconvdata/utf-32.c (BODY for TO_LOOP): Perform error handling like
	in STANDARD_FROM_LOOP_ERR_HANDLER.
	(BODY for FROM_LOOP): Use STANDARD_FROM_LOOP_ERR_HANDLER for error
	handling.
	* iconvdata/big5.c (BODY for FROM_LOOP): For error handling use
	STANDARD_FROM_LOOP_ERR_HANDLER.
	* iconvdata/iso-2022-jp.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/8bit-gap.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/8bit-generic.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/ansi_x3.110.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/armscii-8.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/cp1255.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/cp1258.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/euc-cn.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/euc-jisx0213.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/euc-jp.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/euc-kr.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/euc-tw.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/big5hkscs.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/gb18030.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/gbk.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/iso-2022-cn-ext.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/iso-2022-cn.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/iso-2022-jp-3.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/iso-2022-kr.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/iso646.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/iso_6937-2.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/iso_6937.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/johab.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/shift_jisx0213.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/sjis.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/t.61.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/uhc.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/utf-7.c (BODY for FROM_LOOP): Likewise.
	* iconvdata/gbbig5.c (BODY for FROM_LOOP): Likewise.  When ignoring
	an error, still set result = __GCONV_ILLEGAL_INPUT.
	(BODY for TO_LOOP): Likewise.
	* iconvdata/ibm930.c (BODY for FROM_LOOP): For error handling use
	STANDARD_FROM_LOOP_ERR_HANDLER.
	(BODY for TO_LOOP): Here use STANDARD_TO_LOOP_ERR_HANDLER.
	* iconvdata/ibm932.c: Include <dlfcn.h> and <stdint.h>.
	(BODY for FROM_LOOP): Use STANDARD_FROM_LOOP_ERR_HANDLER for error
	handling.
	(BODY for TO_LOOP): Here use STANDARD_TO_LOOP_ERR_HANDLER.
	* iconvdata/ibm933.c (BODY for FROM_LOOP): For error handling use
	STANDARD_FROM_LOOP_ERR_HANDLER.
	(BODY for TO_LOOP): Here use STANDARD_TO_LOOP_ERR_HANDLER.
	* iconvdata/ibm935.c (BODY for FROM_LOOP): For error handling use
	STANDARD_FROM_LOOP_ERR_HANDLER.
	(BODY for TO_LOOP): Here use STANDARD_TO_LOOP_ERR_HANDLER.
	* iconvdata/ibm937.c (BODY for FROM_LOOP): For error handling use
	STANDARD_FROM_LOOP_ERR_HANDLER.
	(BODY for TO_LOOP): Here use STANDARD_TO_LOOP_ERR_HANDLER.
	* iconvdata/ibm939.c (BODY for FROM_LOOP): For error handling use
	STANDARD_FROM_LOOP_ERR_HANDLER.
	(BODY for TO_LOOP): Here use STANDARD_TO_LOOP_ERR_HANDLER.
	* iconvdata/ibm943.c: Include <dlfcn.h> and <stdint.h>.
	(BODY for FROM_LOOP): Use STANDARD_FROM_LOOP_ERR_HANDLER for error
	handling.
	(BODY for TO_LOOP): Here use STANDARD_TO_LOOP_ERR_HANDLER.
	* iconvdata/gbgbk.c (BODY for FROM_LOOP): Update.
	* iconvdata/iso8859-1.c (BODY for TO_LOOP): Update.
	* iconvdata/tcvn5712-1.c (BODY for TO_LOOP): Update.

2002-06-28  Kaz Kojima  <kkojima@rr.iij4u.or.jp>

	* sysdeps/sh/dl-machine.h (elf_machine_load_address): Use local
	labels in assembler instructions.
2002-06-28 21:23:06 +00:00

140 lines
5.0 KiB
C

/* Conversion to and from ARMSCII-8
Copyright (C) 1997-1999, 2000-2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <dlfcn.h>
#include <stdint.h>
/* Definitions used in the body of the `gconv' function. */
#define CHARSET_NAME "ARMSCII-8//"
#define FROM_LOOP from_armscii_8
#define TO_LOOP to_armscii_8
#define DEFINE_INIT 1
#define DEFINE_FINI 1
#define MIN_NEEDED_FROM 1
#define MIN_NEEDED_TO 4
static const uint16_t map_from_armscii_8[0xfe - 0xa2 + 1] =
{
0x0587, 0x0589, 0x0029, 0x0028, 0x00bb, 0x00ab, 0x2014, 0x002e,
0x055d, 0x002c, 0x002d, 0x058a, 0x2026, 0x055c, 0x055b, 0x055e,
0x0531, 0x0561, 0x0532, 0x0562, 0x0533, 0x0563, 0x0534, 0x0564,
0x0535, 0x0565, 0x0536, 0x0566, 0x0537, 0x0567, 0x0538, 0x0568,
0x0539, 0x0569, 0x053a, 0x056a, 0x053b, 0x056b, 0x053c, 0x056c,
0x053d, 0x056d, 0x053e, 0x056e, 0x053f, 0x056f, 0x0540, 0x0570,
0x0541, 0x0571, 0x0542, 0x0572, 0x0543, 0x0573, 0x0544, 0x0574,
0x0545, 0x0575, 0x0546, 0x0576, 0x0547, 0x0577, 0x0548, 0x0578,
0x0549, 0x0579, 0x054a, 0x057a, 0x054b, 0x057b, 0x054c, 0x057c,
0x054d, 0x057d, 0x054e, 0x057e, 0x054f, 0x057f, 0x0550, 0x0580,
0x0551, 0x0581, 0x0552, 0x0582, 0x0553, 0x0583, 0x0554, 0x0584,
0x0555, 0x0585, 0x0556, 0x0586, 0x055a
};
/* First define the conversion function from ARMSCII-8 to UCS4. */
#define MIN_NEEDED_INPUT MIN_NEEDED_FROM
#define MIN_NEEDED_OUTPUT MIN_NEEDED_TO
#define LOOPFCT FROM_LOOP
#define BODY \
{ \
uint_fast8_t ch = *inptr; \
\
if (ch <= 0xa0) \
/* Upto and including 0xa0 the ARMSCII-8 corresponds to Unicode. */ \
*((uint32_t *) outptr)++ = ch; \
else if (ch >= 0xa2 && ch <= 0xfe) \
/* Use the table. */ \
*((uint32_t *) outptr)++ = map_from_armscii_8[ch - 0xa2]; \
else \
{ \
/* This is an illegal character. */ \
STANDARD_FROM_LOOP_ERR_HANDLER (1); \
} \
\
++inptr; \
}
#define LOOP_NEED_FLAGS
#include <iconv/loop.c>
static const unsigned char map_to_armscii_8[0x58a - 0x531 + 1] =
{
0xb2, 0xb4, 0xb6, 0xb8, 0xba, 0xbc, 0xbe, 0xc0,
0xc2, 0xc4, 0xc6, 0xc8, 0xca, 0xcc, 0xce, 0xd0,
0xd2, 0xd4, 0xd6, 0xd8, 0xda, 0xdc, 0xde, 0xe0,
0xe2, 0xe4, 0xe6, 0xe8, 0xea, 0xec, 0xee, 0xf0,
0xf2, 0xf4, 0xf6, 0xf8, 0xfa, 0xfc, 0x00, 0x00,
0x00, 0xfe, 0xb0, 0xaf, 0xaa, 0xb1, 0x00, 0x00,
0xb3, 0xb5, 0xb7, 0xb9, 0xbb, 0xbd, 0xbf, 0xc1,
0xc3, 0xc5, 0xc7, 0xc9, 0xcb, 0xcd, 0xcf, 0xd1,
0xd3, 0xd5, 0xd7, 0xd9, 0xdb, 0xdd, 0xdf, 0xe1,
0xe3, 0xe5, 0xe7, 0xe9, 0xeb, 0xed, 0xef, 0xf1,
0xf3, 0xf5, 0xf7, 0xf9, 0xfb, 0xfd, 0xa2, 0x00,
0xa3, 0xad
};
/* Next, define the other direction. */
#define MIN_NEEDED_INPUT MIN_NEEDED_TO
#define MIN_NEEDED_OUTPUT MIN_NEEDED_FROM
#define LOOPFCT TO_LOOP
#define BODY \
{ \
uint32_t ch = *((const uint32_t *) inptr); \
\
if (ch <= 0xa0) \
/* Upto and including 0xa0 the ARMSCII-8 corresponds to Unicode. */ \
*outptr = (unsigned char) ch; \
else if (ch == 0xab) \
*outptr = 0xa7; \
else if (ch == 0xbb) \
*outptr = 0xa6; \
else if (ch >= 0x531 && ch <= 0x58a) \
{ \
unsigned char oc = map_to_armscii_8[ch - 0x531]; \
\
if (oc == 0) \
/* No valid mapping. */ \
goto err; \
\
*outptr = oc; \
} \
else if (ch == 0x2014) \
*outptr = 0xa8; \
else if (ch == 0x2026) \
*outptr = 0xae; \
else \
{ \
UNICODE_TAG_HANDLER (ch, 4); \
\
/* We have an illegal character. */ \
err: \
STANDARD_TO_LOOP_ERR_HANDLER (4); \
} \
++outptr; \
inptr += 4; \
}
#define LOOP_NEED_FLAGS
#include <iconv/loop.c>
/* Now define the toplevel functions. */
#include <iconv/skeleton.c>