/* Generic conversion to and from T.61.
- Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ 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.
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <dlfcn.h>
#include <gconv.h>
uint32_t ch = *inptr; \
int increment = 1; \
\
- if (__builtin_expect (ch, 0x20) >= 0xc1 && ch <= 0xcf) \
+ if (__builtin_expect (ch >= 0xc1, 0) && ch <= 0xcf) \
{ \
- /* Composed character. First test whether the next character \
+ /* Composed character. First test whether the next byte \
is also available. */ \
uint32_t ch2; \
\
\
ch2 = inptr[1]; \
\
- if (__builtin_expect (ch2, 0x20) < 0x20 \
- || __builtin_expect (ch2, 0x20) >= 0x80) \
+ if (__builtin_expect (ch2 < 0x20, 0) \
+ || __builtin_expect (ch2 >= 0x80, 0)) \
{ \
/* This is illegal. */ \
- if (! ignore_errors_p ()) \
- { \
- /* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
- } \
- \
- ++inptr; \
- ++*irreversible; \
- continue; \
+ STANDARD_FROM_LOOP_ERR_HANDLER (1); \
} \
\
ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20]; \
else \
ch = to_ucs4[ch]; \
\
- if (__builtin_expect (ch, 1) == 0 && *inptr != '\0') \
+ if (__builtin_expect (ch == 0, 0) && *inptr != '\0') \
{ \
/* This is an illegal character. */ \
- if (! ignore_errors_p ()) \
- { \
- /* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
- } \
- \
- ++*irreversible; \
+ STANDARD_FROM_LOOP_ERR_HANDLER (increment); \
} \
else \
{ \
inptr += increment; \
}
#define LOOP_NEED_FLAGS
+#define ONEBYTE_BODY \
+ { \
+ uint32_t ch = to_ucs4[c]; \
+ if (ch == 0 && c != '\0') \
+ return WEOF; \
+ return ch; \
+ }
#include <iconv/loop.c>
uint32_t ch = get32 (inptr); \
const char *cp; \
\
- if ((size_t) __builtin_expect (ch, 0) \
- >= sizeof (from_ucs4) / sizeof (from_ucs4[0])) \
+ if (__builtin_expect (ch >= sizeof (from_ucs4) / sizeof (from_ucs4[0]), \
+ 0)) \
{ \
if (__builtin_expect (ch, 0) == 0x2126) \
cp = "\xe0"; \
else if (__builtin_expect (ch, 0) == 0x2c7) \
cp = "\xcf\x20"; \
- else if (__builtin_expect (ch, 0x2d8) < 0x2d8 \
- || __builtin_expect (ch, 0x2d8) > 0x2dd \
- || __builtin_expect (ch, 0x2d8) == 0x02dc) \
+ else if (__builtin_expect (ch < 0x2d8, 0) \
+ || __builtin_expect (ch > 0x2dd, 0) \
+ || __builtin_expect (ch == 0x2dc, 0)) \
{ \
UNICODE_TAG_HANDLER (ch, 4); \
\
/* Illegal characters. */ \
- STANDARD_ERR_HANDLER (4); \
+ STANDARD_TO_LOOP_ERR_HANDLER (4); \
} \
else \
{ \
{ \
cp = from_ucs4[ch]; \
\
- if (__builtin_expect (cp[0], '\1') == '\0' && ch != 0) \
+ if (__builtin_expect (cp[0] == '\0', 0) && ch != 0) \
{ \
/* Illegal. */ \
- STANDARD_ERR_HANDLER (4); \
+ STANDARD_TO_LOOP_ERR_HANDLER (4); \
} \
} \
\