1 /* Generic conversion to and from 8bit charsets,
2 converting from UCS using gaps.
3 Copyright (C) 1997, 1998 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public License as
9 published by the Free Software Foundation; either version 2 of the
10 License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public
18 License along with the GNU C Library; see the file COPYING.LIB. If not,
19 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
31 /* Now we can include the tables. */
35 #define FROM_LOOP from_gap
36 #define TO_LOOP to_gap
39 #define MIN_NEEDED_FROM 1
40 #define MIN_NEEDED_TO 4
43 /* First define the conversion function from the 8bit charset to UCS4. */
44 #define MIN_NEEDED_INPUT MIN_NEEDED_FROM
45 #define MIN_NEEDED_OUTPUT MIN_NEEDED_TO
46 #define LOOPFCT FROM_LOOP
49 uint32_t ch = to_ucs4[*inptr]; \
51 if (HAS_HOLES && ch == L'\0' && *inptr != '\0') \
53 /* This is an illegal character. */ \
54 result = GCONV_ILLEGAL_INPUT; \
58 *((uint32_t *) outptr)++ = ch; \
61 #include <iconv/loop.c>
64 /* Next, define the other direction. */
65 #define MIN_NEEDED_INPUT MIN_NEEDED_TO
66 #define MIN_NEEDED_OUTPUT MIN_NEEDED_FROM
67 #define LOOPFCT TO_LOOP
70 const struct gap *rp = from_idx; \
71 uint32_t ch = *((uint32_t *) inptr); \
76 /* This is an illegal character. */ \
77 result = GCONV_ILLEGAL_INPUT; \
80 while (ch > rp->end) \
84 /* This is an illegal character. */ \
85 result = GCONV_ILLEGAL_INPUT; \
89 res = from_ucs4[ch + rp->idx]; \
90 if (ch != 0 && res == '\0') \
92 /* This is an illegal character. */ \
93 result = GCONV_ILLEGAL_INPUT; \
100 #include <iconv/loop.c>
103 /* Now define the toplevel functions. */
104 #include <iconv/skeleton.c>