/* Conversion module for ISO-2022-KR.
- Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
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.
+ 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
- Library General Public License for more details.
+ Lesser 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. */
+ 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 <gconv.h>
#include <stdint.h>
#include <string.h>
} \
else \
{ \
- unsigned char *outbuf = data->__outbuf; \
- \
/* We are not in the initial state. To switch back we have \
to emit `SI'. */ \
- if (__builtin_expect (outbuf == data->__outbufend, 0)) \
+ if (__builtin_expect (outbuf == outend, 0)) \
/* We don't have enough room in the output buffer. */ \
status = __GCONV_FULL_OUTPUT; \
else \
{ \
/* Write out the shift sequence. */ \
*outbuf++ = SI; \
- data->__outbuf = outbuf; \
data->__statep->__count = ASCII_set; \
} \
} \
uint32_t ch = *inptr; \
\
/* This is a 7bit character set, disallow all 8bit characters. */ \
- if (__builtin_expect (ch, 0) > 0x7f) \
+ if (__builtin_expect (ch > 0x7f, 0)) \
{ \
if (! ignore_errors_p ()) \
{ \
} \
\
++inptr; \
- ++*converted; \
+ ++*irreversible; \
continue; \
} \
\
switching is done using the SI and SO bytes. But we have to \
recognize `Esc $ ) C' since this is a kind of flag for this \
encoding. We simply ignore it. */ \
- if ((NEED_LENGTH_TEST && __builtin_expect (inptr + 1 > inend, 0)) \
+ if (__builtin_expect (inptr + 1 > inend, 0) \
|| (inptr[1] == '$' \
- && ((NEED_LENGTH_TEST \
- && __builtin_expect (inptr + 2 > inend, 0)) \
+ && (__builtin_expect (inptr + 2 > inend, 0) \
|| (inptr[2] == ')' \
&& __builtin_expect (inptr + 3 > inend, 0))))) \
\
{ \
- result = __GCONV_EMPTY_INPUT; \
+ result = __GCONV_INCOMPLETE_INPUT; \
break; \
} \
if (inptr[1] == '$' && inptr[2] == ')' && inptr[3] == 'C') \
assert (set == KSC5601_set); \
\
/* Use the KSC 5601 table. */ \
- ch = ksc5601_to_ucs4 (&inptr, \
- NEED_LENGTH_TEST ? inend - inptr : 2, 0); \
+ ch = ksc5601_to_ucs4 (&inptr, inend - inptr, 0); \
\
- if (NEED_LENGTH_TEST && __builtin_expect (ch, 1) == 0) \
+ if (__builtin_expect (ch, 1) == 0) \
{ \
- result = __GCONV_EMPTY_INPUT; \
+ result = __GCONV_INCOMPLETE_INPUT; \
break; \
} \
else if (__builtin_expect (ch, 0) == __UNKNOWN_10646_CHAR) \
break; \
} \
\
- ++*converted; \
+ ++*irreversible; \
++inptr; \
continue; \
} \
put32 (outptr, ch); \
outptr += 4; \
}
+#define LOOP_NEED_FLAGS
#define EXTRA_LOOP_DECLS , int *setp
#define INIT_PARAMS int set = *setp
#define UPDATE_PARAMS *setp = set
#define BODY \
{ \
uint32_t ch; \
- size_t written = 0; \
\
ch = get32 (inptr); \
\
{ \
*outptr++ = SI; \
set = ASCII_set; \
- if (NEED_LENGTH_TEST && outptr == outend) \
+ if (__builtin_expect (outptr == outend, 0)) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
} \
\
*outptr++ = ch; \
- written = 1; \
} \
else \
{ \
char buf[2]; \
+ size_t written; \
\
written = ucs4_to_ksc5601 (ch, buf, 2); \
\
if (__builtin_expect (written, 0) == __UNKNOWN_10646_CHAR) \
{ \
- /* Illegal character. */ \
- if (! ignore_errors_p ()) \
- { \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
- } \
+ UNICODE_TAG_HANDLER (ch, 4); \
\
- ++*converted; \
+ /* Illegal character. */ \
+ STANDARD_ERR_HANDLER (4); \
} \
else \
{ \
set = KSC5601_set; \
} \
\
- if (NEED_LENGTH_TEST && __builtin_expect (outptr + 2 > outend, 0))\
+ if (__builtin_expect (outptr + 2 > outend, 0)) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
/* Now that we wrote the output increment the input pointer. */ \
inptr += 4; \
}
+#define LOOP_NEED_FLAGS
#define EXTRA_LOOP_DECLS , int *setp
#define INIT_PARAMS int set = *setp
#define UPDATE_PARAMS *setp = set