aboutsummaryrefslogtreecommitdiff
path: root/iconvdata/utf-16.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-12-21 18:45:50 -0500
committerUlrich Drepper <drepper@gmail.com>2011-12-21 18:45:50 -0500
commitee190f67cc00b958a667af75dc68f3fc21611c9f (patch)
treeba36a28e53719d191b6e0afa9a8d55757a40c123 /iconvdata/utf-16.c
parent707f25dfc0a63d264e9da00368cbab5bd0f6a8c9 (diff)
downloadglibc-ee190f67cc00b958a667af75dc68f3fc21611c9f.zip
glibc-ee190f67cc00b958a667af75dc68f3fc21611c9f.tar.gz
glibc-ee190f67cc00b958a667af75dc68f3fc21611c9f.tar.bz2
Store invocation-specific data of conversion modules in __gconv_step_data
Diffstat (limited to 'iconvdata/utf-16.c')
-rw-r--r--iconvdata/utf-16.c57
1 files changed, 30 insertions, 27 deletions
diff --git a/iconvdata/utf-16.c b/iconvdata/utf-16.c
index 7f6c760..e34d23f 100644
--- a/iconvdata/utf-16.c
+++ b/iconvdata/utf-16.c
@@ -1,5 +1,5 @@
/* Conversion module for UTF-16.
- Copyright (C) 1999, 2000-2002, 2003, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000-2002, 2003, 2005, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
@@ -44,35 +44,42 @@
#define PREPARE_LOOP \
enum direction dir = ((struct utf16_data *) step->__data)->dir; \
enum variant var = ((struct utf16_data *) step->__data)->var; \
- if (__builtin_expect (data->__invocation_counter == 0, 0) && var == UTF_16) \
+ if (__builtin_expect (data->__invocation_counter == 0, 0)) \
{ \
- if (FROM_DIRECTION) \
+ if (var == UTF_16) \
{ \
- /* We have to find out which byte order the file is encoded in. */ \
- if (inptr + 2 > inend) \
- return (inptr == inend \
- ? __GCONV_EMPTY_INPUT : __GCONV_INCOMPLETE_INPUT); \
- \
- if (get16u (inptr) == BOM) \
- /* Simply ignore the BOM character. */ \
- *inptrp = inptr += 2; \
- else if (get16u (inptr) == BOM_OE) \
+ if (FROM_DIRECTION) \
{ \
- ((struct utf16_data *) step->__data)->swap = 1; \
- *inptrp = inptr += 2; \
+ /* We have to find out which byte order the file is \
+ encoded in. */ \
+ if (inptr + 2 > inend) \
+ return (inptr == inend \
+ ? __GCONV_EMPTY_INPUT : __GCONV_INCOMPLETE_INPUT); \
+ \
+ if (get16u (inptr) == BOM) \
+ /* Simply ignore the BOM character. */ \
+ *inptrp = inptr += 2; \
+ else if (get16u (inptr) == BOM_OE) \
+ { \
+ data->__flags |= __GCONV_SWAP; \
+ *inptrp = inptr += 2; \
+ } \
} \
- } \
- else if (!FROM_DIRECTION && !data->__internal_use) \
- { \
- /* Emit the Byte Order Mark. */ \
- if (__builtin_expect (outbuf + 2 > outend, 0)) \
- return __GCONV_FULL_OUTPUT; \
+ else if (!FROM_DIRECTION && !data->__internal_use) \
+ { \
+ /* Emit the Byte Order Mark. */ \
+ if (__builtin_expect (outbuf + 2 > outend, 0)) \
+ return __GCONV_FULL_OUTPUT; \
\
- put16u (outbuf, BOM); \
- outbuf += 2; \
+ put16u (outbuf, BOM); \
+ outbuf += 2; \
+ } \
} \
+ else if ((var == UTF_16LE && BYTE_ORDER == BIG_ENDIAN) \
+ || (var == UTF_16BE && BYTE_ORDER == LITTLE_ENDIAN)) \
+ data->__flags |= __GCONV_SWAP; \
} \
- int swap = ((struct utf16_data *) step->__data)->swap;
+ const int swap = data->__flags & __GCONV_SWAP;
#define EXTRA_LOOP_ARGS , swap
@@ -96,7 +103,6 @@ struct utf16_data
{
enum direction dir;
enum variant var;
- int swap;
};
@@ -151,9 +157,6 @@ gconv_init (struct __gconv_step *step)
{
new_data->dir = dir;
new_data->var = var;
- new_data->swap = ((var == UTF_16LE && BYTE_ORDER == BIG_ENDIAN)
- || (var == UTF_16BE
- && BYTE_ORDER == LITTLE_ENDIAN));
step->__data = new_data;
if (dir == from_utf16)