summaryrefslogtreecommitdiff
path: root/libc/iconvdata
diff options
context:
space:
mode:
authorjoseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2011-12-22 19:27:39 +0000
committerjoseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2011-12-22 19:27:39 +0000
commit8a031172c235ab0def5763dd5f3a00f9ff10c053 (patch)
tree11ba9c29e8edc754174f18e6db425971144769c9 /libc/iconvdata
parenta179b968417641981213cfe422c741141d8394e4 (diff)
Merge changes between r16068 and r16332 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@16333 7b3dc134-2b1b-0410-93df-9e9f96275f8d
Diffstat (limited to 'libc/iconvdata')
-rw-r--r--libc/iconvdata/unicode.c8
-rw-r--r--libc/iconvdata/utf-16.c57
-rw-r--r--libc/iconvdata/utf-32.c21
3 files changed, 43 insertions, 43 deletions
diff --git a/libc/iconvdata/unicode.c b/libc/iconvdata/unicode.c
index df452d2a1..dba4c34d6 100644
--- a/libc/iconvdata/unicode.c
+++ b/libc/iconvdata/unicode.c
@@ -1,5 +1,5 @@
/* Conversion module for Unicode
- Copyright (C) 1999, 2000-2002 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000-2002, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
@@ -57,7 +57,7 @@
*inptrp = inptr += 2; \
else if (get16u (inptr) == BOM_OE) \
{ \
- ((struct unicode_data *) step->__data)->swap = 1; \
+ data->__flags |= __GCONV_SWAP; \
*inptrp = inptr += 2; \
} \
} \
@@ -71,7 +71,7 @@
put16u (outbuf, BOM); \
outbuf += 2; \
} \
- swap = ((struct unicode_data *) step->__data)->swap;
+ swap = data->__flags & __GCONV_SWAP;
#define EXTRA_LOOP_ARGS , swap
@@ -86,7 +86,6 @@ enum direction
struct unicode_data
{
enum direction dir;
- int swap;
};
@@ -110,7 +109,6 @@ gconv_init (struct __gconv_step *step)
if (new_data != NULL)
{
new_data->dir = dir;
- new_data->swap = 0;
step->__data = new_data;
if (dir == from_unicode)
diff --git a/libc/iconvdata/utf-16.c b/libc/iconvdata/utf-16.c
index 7f6c76090..e34d23fdf 100644
--- a/libc/iconvdata/utf-16.c
+++ b/libc/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)
diff --git a/libc/iconvdata/utf-32.c b/libc/iconvdata/utf-32.c
index cc0265137..27ea3db60 100644
--- a/libc/iconvdata/utf-32.c
+++ b/libc/iconvdata/utf-32.c
@@ -1,5 +1,5 @@
/* Conversion module for UTF-32.
- Copyright (C) 1999, 2000-2002 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000-2002, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -45,7 +45,7 @@
int swap; \
if (FROM_DIRECTION && var == UTF_32) \
{ \
- if (data->__invocation_counter == 0) \
+ if (__builtin_expect (data->__invocation_counter == 0, 0)) \
{ \
/* We have to find out which byte order the file is encoded in. */ \
if (inptr + 4 > inend) \
@@ -57,7 +57,7 @@
*inptrp = inptr += 4; \
else if (get32u (inptr) == BOM_OE) \
{ \
- ((struct utf32_data *) step->__data)->swap = 1; \
+ data->__flags |= __GCONV_SWAP; \
*inptrp = inptr += 4; \
} \
} \
@@ -72,7 +72,11 @@
put32u (outbuf, BOM); \
outbuf += 4; \
} \
- swap = ((struct utf32_data *) step->__data)->swap;
+ else if (__builtin_expect (data->__invocation_counter == 0, 0) \
+ && ((var == UTF_32LE && BYTE_ORDER == BIG_ENDIAN) \
+ || (var == UTF_32BE && BYTE_ORDER == LITTLE_ENDIAN))) \
+ data->__flags |= __GCONV_SWAP; \
+ swap = data->__flags & __GCONV_SWAP;
#define EXTRA_LOOP_ARGS , var, swap
@@ -96,7 +100,6 @@ struct utf32_data
{
enum direction dir;
enum variant var;
- int swap;
};
@@ -151,9 +154,6 @@ gconv_init (struct __gconv_step *step)
{
new_data->dir = dir;
new_data->var = var;
- new_data->swap = ((var == UTF_32LE && BYTE_ORDER == BIG_ENDIAN)
- || (var == UTF_32BE
- && BYTE_ORDER == LITTLE_ENDIAN));
step->__data = new_data;
if (dir == from_utf32)
@@ -216,9 +216,8 @@ gconv_end (struct __gconv_step *data)
} \
\
if (swap) \
- put32 (outptr, bswap_32 (c)); \
- else \
- put32 (outptr, c); \
+ c = bswap_32 (c); \
+ put32 (outptr, c); \
\
outptr += 4; \
inptr += 4; \