diff options
Diffstat (limited to 'iconv')
-rw-r--r-- | iconv/gconv_int.h | 2 | ||||
-rw-r--r-- | iconv/gconv_simple.c | 65 | ||||
-rw-r--r-- | iconv/iconv_prog.c | 8 | ||||
-rw-r--r-- | iconv/skeleton.c | 4 |
4 files changed, 74 insertions, 5 deletions
diff --git a/iconv/gconv_int.h b/iconv/gconv_int.h index 86e892f874..80cced4d4a 100644 --- a/iconv/gconv_int.h +++ b/iconv/gconv_int.h @@ -158,6 +158,8 @@ __BUILTIN_TRANS (__gconv_transform_utf8_internal); __BUILTIN_TRANS (__gconv_transform_internal_utf8); __BUILTIN_TRANS (__gconv_transform_ucs2_internal); __BUILTIN_TRANS (__gconv_transform_internal_ucs2); +__BUILTIN_TRANS (__gconv_transform_ucs2little_internal); +__BUILTIN_TRANS (__gconv_transform_internal_ucs2little); __BUILTIN_TRANS (__gconv_transform_internal_ucs4); # undef __BUITLIN_TRANS diff --git a/iconv/gconv_simple.c b/iconv/gconv_simple.c index 95b4a66daf..c491c97ccd 100644 --- a/iconv/gconv_simple.c +++ b/iconv/gconv_simple.c @@ -418,3 +418,68 @@ internal_ucs4_loop (const unsigned char **inptrp, const unsigned char *inend, #endif #include <iconv/loop.c> #include <iconv/skeleton.c> + + +/* Convert from UCS2 in little endian to the internal (UCS4-like) format. */ +#define DEFINE_INIT 0 +#define DEFINE_FINI 0 +#define MIN_NEEDED_FROM 2 +#define MIN_NEEDED_TO 4 +#define FROM_DIRECTION 1 +#define FROM_LOOP ucs2little_internal_loop +#define TO_LOOP ucs2little_internal_loop /* This is not used.*/ +#define FUNCTION_NAME __gconv_transform_ucs2little_internal + +#define MIN_NEEDED_INPUT MIN_NEEDED_FROM +#define MIN_NEEDED_OUTPUT MIN_NEEDED_TO +#define LOOPFCT FROM_LOOP +#if __BYTE_ORDER == __LITTLE_ENDIAN +# define BODY \ + *((uint32_t *) outptr)++ = *((uint16_t *) inptr)++; +#else +# define BODY \ + *((uint32_t *) outptr)++ = bswap_16 (*((uint16_t *) inptr)++); +#endif +#include <iconv/loop.c> +#include <iconv/skeleton.c> + + +/* Convert from the internal (UCS4-like) format to UCS2 in little endian. */ +#define DEFINE_INIT 0 +#define DEFINE_FINI 0 +#define MIN_NEEDED_FROM 4 +#define MIN_NEEDED_TO 2 +#define FROM_DIRECTION 1 +#define FROM_LOOP internal_ucs2little_loop +#define TO_LOOP internal_ucs2little_loop /* This is not used.*/ +#define FUNCTION_NAME __gconv_transform_internal_ucs2little + +#define MIN_NEEDED_INPUT MIN_NEEDED_FROM +#define MIN_NEEDED_OUTPUT MIN_NEEDED_TO +#define LOOPFCT FROM_LOOP +#if __BYTE_ORDER == __LITTLE_ENDIAN +# define BODY \ + { \ + if (*((uint32_t *) inptr) >= 0x10000) \ + { \ + result = GCONV_ILLEGAL_INPUT; \ + break; \ + } \ + *((uint16_t *) outptr)++ = *((uint32_t *) inptr)++; \ + } +#else +# define BODY \ + { \ + if (*((uint32_t *) inptr) >= 0x10000) \ + { \ + result = GCONV_ILLEGAL_INPUT; \ + break; \ + } \ + /* Please note that we use the `uint32_t' from-pointer as an `uint16_t' \ + pointer which works since we are on a little endian machine. */ \ + *((uint16_t *) outptr)++ = bswap_16 (*((uint16_t *) inptr)); \ + inptr += 4; \ + } +#endif +#include <iconv/loop.c> +#include <iconv/skeleton.c> diff --git a/iconv/iconv_prog.c b/iconv/iconv_prog.c index 2452a88c5e..5a08a21819 100644 --- a/iconv/iconv_prog.c +++ b/iconv/iconv_prog.c @@ -298,6 +298,7 @@ static int process_block (iconv_t cd, const char *addr, size_t len, FILE *output) { #define OUTBUF_SIZE 32768 + const char *start = addr; char outbuf[OUTBUF_SIZE]; char *outptr; size_t outlen; @@ -332,7 +333,8 @@ conversion stopped due to problem in writing the output")); switch (errno) { case EILSEQ: - error (0, 0, _("illegal input sequence")); + error (0, 0, _("illegal input sequence at position %ld"), + addr - start); break; case EINVAL: error (0, 0, _("\ @@ -448,7 +450,7 @@ insert_print_list (const void *nodep, VISIT value, int level) if (value == leaf || value == postorder) { const struct gconv_alias *s = *(const struct gconv_alias **) nodep; - tsearch (s->fromname, &printlist, (__compar_fn_t) strcoll); + tsearch (s->fromname, &printlist, (__compar_fn_t) strverscmp); } } @@ -487,7 +489,7 @@ do_print (const void *nodep, VISIT value, int level) } } else - not_first = 1; + not_first = 1; fwrite (s, len, 1, stdout); column += len; diff --git a/iconv/skeleton.c b/iconv/skeleton.c index 8421941a1e..78f584e9fe 100644 --- a/iconv/skeleton.c +++ b/iconv/skeleton.c @@ -137,9 +137,9 @@ int gconv_init (struct gconv_step *step) { /* Determine which direction. */ - if (__strcasestr (step->from_name, CHARSET_NAME) != NULL) + if (__strcasecmp (step->from_name, CHARSET_NAME) == 0) step->data = &from_object; - else if (__strcasestr (step->to_name, CHARSET_NAME) != NULL) + else if (__strcasecmp (step->to_name, CHARSET_NAME) == 0) step->data = &to_object; else return GCONV_NOCONV; |