diff options
author | Ulrich Drepper <drepper@gmail.com> | 2011-12-28 06:19:42 -0500 |
---|---|---|
committer | Ulrich Drepper <drepper@gmail.com> | 2012-01-01 07:17:22 -0500 |
commit | db6af3ebf46a83b885455dc03a3c2c1c2c2dedec (patch) | |
tree | 942a59c7de0033cf9ab3231523130c323fa4b80c /iconv/gconv_simple.c | |
parent | 8ea79a616e43093f403927e425c197afe39196b7 (diff) | |
download | glibc-db6af3ebf46a83b885455dc03a3c2c1c2c2dedec.tar.gz glibc-db6af3ebf46a83b885455dc03a3c2c1c2c2dedec.tar.xz glibc-db6af3ebf46a83b885455dc03a3c2c1c2c2dedec.zip |
Add uchar.h support, part 1
c16 support for locales other than the C locale is still missing.
Diffstat (limited to 'iconv/gconv_simple.c')
-rw-r--r-- | iconv/gconv_simple.c | 75 |
1 files changed, 72 insertions, 3 deletions
diff --git a/iconv/gconv_simple.c b/iconv/gconv_simple.c index e34f3770ad..b0ef3e67b0 100644 --- a/iconv/gconv_simple.c +++ b/iconv/gconv_simple.c @@ -1,5 +1,5 @@ /* Simple transformations functions. - Copyright (C) 1997-2005, 2007, 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 1997-2005, 2007, 2008, 2009, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -965,7 +965,7 @@ ucs4le_internal_loop_single (struct __gconv_step *step, cnt = 2; \ ch &= 0x1f; \ } \ - else if (__builtin_expect ((ch & 0xf0) == 0xe0, 1)) \ + else if (__builtin_expect ((ch & 0xf0) == 0xe0, 1)) \ { \ /* We expect three bytes. */ \ cnt = 3; \ @@ -1221,7 +1221,7 @@ ucs4le_internal_loop_single (struct __gconv_step *step, else \ { \ put16 (outptr, val); \ - outptr += sizeof (uint16_t); \ + outptr += sizeof (uint16_t); \ inptr += 4; \ } \ } @@ -1320,3 +1320,72 @@ ucs4le_internal_loop_single (struct __gconv_step *step, #define LOOP_NEED_FLAGS #include <iconv/loop.c> #include <iconv/skeleton.c> + + +/* Convert from ISO 646-IRV to UTF-16. */ +#define DEFINE_INIT 0 +#define DEFINE_FINI 0 +#define MIN_NEEDED_FROM 1 +#define MIN_NEEDED_TO 2 +#define FROM_DIRECTION 1 +#define FROM_LOOP ascii_utf16_loop +#define TO_LOOP ascii_utf16_loop /* This is not used. */ +#define FUNCTION_NAME __gconv_transform_ascii_utf16 +#define ONE_DIRECTION 1 + +#define MIN_NEEDED_INPUT MIN_NEEDED_FROM +#define MIN_NEEDED_OUTPUT MIN_NEEDED_TO +#define LOOPFCT FROM_LOOP +#define BODY \ + { \ + if (__builtin_expect (*inptr > '\x7f', 0)) \ + { \ + /* The value is too large. We don't try transliteration here since \ + this is not an error because of the lack of possibilities to \ + represent the result. This is a genuine bug in the input since \ + ASCII does not allow such values. */ \ + STANDARD_FROM_LOOP_ERR_HANDLER (1); \ + } \ + else \ + { \ + /* It's an one byte sequence. */ \ + *((uint16_t *) outptr) = *inptr++; \ + outptr += sizeof (uint16_t); \ + } \ + } +#define LOOP_NEED_FLAGS +#include <iconv/loop.c> +#include <iconv/skeleton.c> + + +/* Convert from UTF-16 to ISO 646-IRV. */ +#define DEFINE_INIT 0 +#define DEFINE_FINI 0 +#define MIN_NEEDED_FROM 2 +#define MIN_NEEDED_TO 1 +#define FROM_DIRECTION 1 +#define FROM_LOOP utf16_ascii_loop +#define TO_LOOP utf16_ascii_loop /* This is not used. */ +#define FUNCTION_NAME __gconv_transform_utf16_ascii +#define ONE_DIRECTION 1 + +#define MIN_NEEDED_INPUT MIN_NEEDED_FROM +#define MIN_NEEDED_OUTPUT MIN_NEEDED_TO +#define LOOPFCT FROM_LOOP +#define BODY \ + { \ + if (__builtin_expect (*((const uint16_t *) inptr) > 0x7f, 0)) \ + { \ + UNICODE_TAG_HANDLER (*((const uint16_t *) inptr), 2); \ + STANDARD_TO_LOOP_ERR_HANDLER (2); \ + } \ + else \ + { \ + /* It's an one byte sequence. */ \ + *outptr++ = *((const uint16_t *) inptr); \ + inptr += sizeof (uint16_t); \ + } \ + } +#define LOOP_NEED_FLAGS +#include <iconv/loop.c> +#include <iconv/skeleton.c> |