aboutsummaryrefslogtreecommitdiff
path: root/iconv
diff options
context:
space:
mode:
Diffstat (limited to 'iconv')
-rw-r--r--iconv/gconv.c2
-rw-r--r--iconv/gconv.h4
-rw-r--r--iconv/gconv_builtin.h22
-rw-r--r--iconv/gconv_conf.c23
-rw-r--r--iconv/gconv_db.c8
-rw-r--r--iconv/gconv_dl.c4
-rw-r--r--iconv/gconv_int.h6
-rw-r--r--iconv/gconv_simple.c35
-rw-r--r--iconv/gconv_trans.c42
-rw-r--r--iconv/loop.c4
-rw-r--r--iconv/skeleton.c11
11 files changed, 95 insertions, 66 deletions
diff --git a/iconv/gconv.c b/iconv/gconv.c
index 0b7b917b6a..88d76056c8 100644
--- a/iconv/gconv.c
+++ b/iconv/gconv.c
@@ -20,7 +20,7 @@
Boston, MA 02111-1307, USA. */
#include <assert.h>
-#include <gconv.h>
+#include <gconv_int.h>
#include <sys/param.h>
#include <dlfcn.h>
#include <stddef.h>
diff --git a/iconv/gconv.h b/iconv/gconv.h
index c2fdf83a25..03574d859e 100644
--- a/iconv/gconv.h
+++ b/iconv/gconv.h
@@ -115,8 +115,8 @@ struct __gconv_step
int __counter;
- __const char *__from_name;
- __const char *__to_name;
+ char *__from_name;
+ char *__to_name;
__gconv_fct __fct;
__gconv_init_fct __init_fct;
diff --git a/iconv/gconv_builtin.h b/iconv/gconv_builtin.h
index e6c7b5fac3..246bb95ae7 100644
--- a/iconv/gconv_builtin.h
+++ b/iconv/gconv_builtin.h
@@ -76,6 +76,28 @@ BUILTIN_TRANSFORMATION ("INTERNAL", "ISO-10646/UCS2/", 1, "=INTERNAL->ucs2",
4, 4, 2, 2)
+BUILTIN_ALIAS ("ANSI_X3.4//", "ANSI_X3.4-1968//")
+BUILTIN_ALIAS ("ISO-IR-6//", "ANSI_X3.4-1968//")
+BUILTIN_ALIAS ("ANSI_X3.4-1986//", "ANSI_X3.4-1968//")
+BUILTIN_ALIAS ("ISO_646.IRV:1991//", "ANSI_X3.4-1968//")
+BUILTIN_ALIAS ("ASCII//", "ANSI_X3.4-1968//")
+BUILTIN_ALIAS ("ISO646-US//", "ANSI_X3.4-1968//")
+BUILTIN_ALIAS ("US-ASCII//", "ANSI_X3.4-1968//")
+BUILTIN_ALIAS ("US//", "ANSI_X3.4-1968//")
+BUILTIN_ALIAS ("IBM367//", "ANSI_X3.4-1968//")
+BUILTIN_ALIAS ("CP367//", "ANSI_X3.4-1968//")
+BUILTIN_ALIAS ("CSASCII//", "ANSI_X3.4-1968//")
+BUILTIN_ALIAS ("OSF00010020//", "ANSI_X3.4-1968//")
+
+BUILTIN_TRANSFORMATION ("ANSI_X3.4-1968//", "INTERNAL", 1, "=ascii->INTERNAL",
+ __gconv_transform_ascii_internal, NULL, NULL,
+ 4, 4, 1, 1)
+
+BUILTIN_TRANSFORMATION ("INTERNAL", "ANSI_X3.4-1968//", 1, "=INTERNAL->ascii",
+ __gconv_transform_internal_ascii, NULL, NULL,
+ 4, 4, 1, 1)
+
+
#if BYTE_ORDER == BIG_ENDIAN
BUILTIN_ALIAS ("UNICODEBIG//", "ISO-10646/UCS2/")
BUILTIN_ALIAS ("UCS-2BE//", "ISO-10646/UCS2/")
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index 57c832d6a9..a9b458130a 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -23,6 +23,7 @@
#include <errno.h>
#include <limits.h>
#include <search.h>
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -38,7 +39,7 @@ static const char default_gconv_path[] = GCONV_PATH;
/* The path elements, as determined by the __gconv_get_path function.
All path elements end in a slash. */
-const struct path_elem *__gconv_path_elem;
+struct path_elem *__gconv_path_elem;
/* Maximum length of a single path element in __gconv_path_elem. */
size_t __gconv_max_path_elem_len;
@@ -283,7 +284,7 @@ add_module (char *rp, const char *directory, size_t dir_len, void **modules,
/* See whether we must add the ending. */
need_ext = 0;
- if (wp - module < sizeof (gconv_module_ext)
+ if (wp - module < (ptrdiff_t) sizeof (gconv_module_ext)
|| memcmp (wp - sizeof (gconv_module_ext), gconv_module_ext,
sizeof (gconv_module_ext)) != 0)
/* We must add the module extension. */
@@ -304,23 +305,19 @@ add_module (char *rp, const char *directory, size_t dir_len, void **modules,
{
char *tmp;
- new_module->from_string = memcpy ((char *) new_module
- + sizeof (struct gconv_module),
- from, to - from);
+ new_module->from_string = tmp = (char *) (new_module + 1);
+ tmp = __mempcpy (tmp, from, to - from);
- new_module->to_string = memcpy ((char *) new_module->from_string
- + (to - from), to, module - to);
+ new_module->to_string = tmp;
+ tmp = __mempcpy (tmp, to, module - to);
new_module->cost_hi = cost_hi;
new_module->cost_lo = modcounter;
- new_module->module_name = (char *) new_module->to_string + (module - to);
+ new_module->module_name = tmp;
- if (dir_len == 0)
- tmp = (char *) new_module->module_name;
- else
- tmp = __mempcpy ((char *) new_module->module_name,
- directory, dir_len);
+ if (dir_len != 0)
+ tmp = __mempcpy (tmp, directory, dir_len);
tmp = __mempcpy (tmp, module, wp - module);
diff --git a/iconv/gconv_db.c b/iconv/gconv_db.c
index dd51670af1..d003981d3e 100644
--- a/iconv/gconv_db.c
+++ b/iconv/gconv_db.c
@@ -44,8 +44,8 @@ __libc_lock_define_initialized (static, lock)
int
__gconv_alias_compare (const void *p1, const void *p2)
{
- struct gconv_alias *s1 = (struct gconv_alias *) p1;
- struct gconv_alias *s2 = (struct gconv_alias *) p2;
+ const struct gconv_alias *s1 = (const struct gconv_alias *) p1;
+ const struct gconv_alias *s2 = (const struct gconv_alias *) p2;
return strcmp (s1->fromname, s2->fromname);
}
@@ -90,8 +90,8 @@ struct known_derivation
static int
derivation_compare (const void *p1, const void *p2)
{
- struct known_derivation *s1 = (struct known_derivation *) p1;
- struct known_derivation *s2 = (struct known_derivation *) p2;
+ const struct known_derivation *s1 = (const struct known_derivation *) p1;
+ const struct known_derivation *s2 = (const struct known_derivation *) p2;
int result;
result = strcmp (s1->from, s2->from);
diff --git a/iconv/gconv_dl.c b/iconv/gconv_dl.c
index 114619ec11..720ae4836b 100644
--- a/iconv/gconv_dl.c
+++ b/iconv/gconv_dl.c
@@ -149,7 +149,7 @@ __gconv_find_shlib (const char *name)
static struct __gconv_loaded_object *release_handle;
static void
-do_release_shlib (const void *nodep, VISIT value, int level)
+do_release_shlib (void *nodep, VISIT value, int level)
{
struct __gconv_loaded_object *obj = *(struct __gconv_loaded_object **) nodep;
@@ -184,7 +184,7 @@ __gconv_release_shlib (struct __gconv_loaded_object *handle)
/* Process all entries. Please note that we also visit entries
with release counts <= 0. This way we can finally unload them
if necessary. */
- __twalk (loaded, do_release_shlib);
+ __twalk (loaded, (__action_fn_t) do_release_shlib);
}
diff --git a/iconv/gconv_int.h b/iconv/gconv_int.h
index ad2d6e7d4a..0c7a422e2e 100644
--- a/iconv/gconv_int.h
+++ b/iconv/gconv_int.h
@@ -33,7 +33,7 @@ struct path_elem
};
/* Variable with search path for `gconv' implementation. */
-extern const struct path_elem *__gconv_path_elem;
+extern struct path_elem *__gconv_path_elem;
/* Maximum length of a single path element. */
extern size_t __gconv_max_path_elem_len;
@@ -41,8 +41,8 @@ extern size_t __gconv_max_path_elem_len;
/* Structure for alias definition. Simply to strings. */
struct gconv_alias
{
- const char *fromname;
- const char *toname;
+ char *fromname;
+ char *toname;
};
diff --git a/iconv/gconv_simple.c b/iconv/gconv_simple.c
index 70c43c8fe8..ab9f46a9b3 100644
--- a/iconv/gconv_simple.c
+++ b/iconv/gconv_simple.c
@@ -29,6 +29,15 @@
#include <wchar.h>
#include <sys/param.h>
+#define BUILTIN_ALIAS(s1, s2) /* nothing */
+#define BUILTIN_TRANSFORMATION(From, To, Cost, Name, Fct, Init, End, MinF, \
+ MaxF, MinT, MaxT) \
+ extern int Fct (struct __gconv_step *, struct __gconv_step_data *, \
+ __const unsigned char **, __const unsigned char *, \
+ unsigned char **, size_t *, int, int);
+#include "gconv_builtin.h"
+
+
#ifndef EILSEQ
# define EILSEQ EINVAL
#endif
@@ -66,7 +75,7 @@ internal_ucs4_loop (struct __gconv_step *step,
size_t cnt;
for (cnt = 0; cnt < n_convert; ++cnt, inptr += 4)
- *((uint32_t *) outptr)++ = bswap_32 (*(uint32_t *) inptr);
+ *((uint32_t *) outptr)++ = bswap_32 (*(const uint32_t *) inptr);
*inptrp = inptr;
*outptrp = outptr;
@@ -215,9 +224,9 @@ ucs4_internal_loop (struct __gconv_step *step,
uint32_t inval;
#if __BYTE_ORDER == __LITTLE_ENDIAN
- inval = bswap_32 (*(uint32_t *) inptr);
+ inval = bswap_32 (*(const uint32_t *) inptr);
#else
- inval = *(uint32_t *) inptr;
+ inval = *(const uint32_t *) inptr;
#endif
if (__builtin_expect (inval, 0) > 0x7fffffff)
@@ -420,7 +429,7 @@ internal_ucs4le_loop (struct __gconv_step *step,
size_t cnt;
for (cnt = 0; cnt < n_convert; ++cnt, inptr += 4)
- *((uint32_t *) outptr)++ = bswap_32 (*(uint32_t *) inptr);
+ *((uint32_t *) outptr)++ = bswap_32 (*(const uint32_t *) inptr);
*inptrp = inptr;
*outptrp = outptr;
@@ -566,9 +575,9 @@ ucs4le_internal_loop (struct __gconv_step *step,
uint32_t inval;
#if __BYTE_ORDER == __BIG_ENDIAN
- inval = bswap_32 (*(uint32_t *) inptr);
+ inval = bswap_32 (*(const uint32_t *) inptr);
#else
- inval = *(uint32_t *) inptr;
+ inval = *(const uint32_t *) inptr;
#endif
if (__builtin_expect (inval, 0) > 0x7fffffff)
@@ -796,13 +805,13 @@ ucs4le_internal_loop_single (struct __gconv_step *step,
#define LOOPFCT FROM_LOOP
#define BODY \
{ \
- if (__builtin_expect (*((uint32_t *) inptr), 0) > 0x7f) \
+ if (__builtin_expect (*((const uint32_t *) inptr), 0) > 0x7f) \
{ \
STANDARD_ERR_HANDLER (4); \
} \
else \
/* It's an one byte sequence. */ \
- *outptr++ = *((uint32_t *) inptr)++; \
+ *outptr++ = *((const uint32_t *) inptr)++; \
}
#define LOOP_NEED_FLAGS
#include <iconv/loop.c>
@@ -827,7 +836,7 @@ ucs4le_internal_loop_single (struct __gconv_step *step,
#define LOOPFCT FROM_LOOP
#define BODY \
{ \
- uint32_t wc = *((uint32_t *) inptr); \
+ uint32_t wc = *((const uint32_t *) inptr); \
\
/* Since we control every character we read this cannot happen. */ \
assert (wc <= 0x7fffffff); \
@@ -1146,7 +1155,7 @@ ucs4le_internal_loop_single (struct __gconv_step *step,
#define LOOPFCT FROM_LOOP
#define BODY \
{ \
- uint16_t u1 = *((uint16_t *) inptr); \
+ uint16_t u1 = *((const uint16_t *) inptr); \
\
if (__builtin_expect (u1 >= 0xd800 && u1 < 0xe000, 0)) \
{ \
@@ -1186,7 +1195,7 @@ ucs4le_internal_loop_single (struct __gconv_step *step,
#define LOOPFCT FROM_LOOP
#define BODY \
{ \
- uint32_t val = *((uint32_t *) inptr); \
+ uint32_t val = *((const uint32_t *) inptr); \
\
if (__builtin_expect (val, 0) >= 0x10000) \
{ \
@@ -1236,7 +1245,7 @@ ucs4le_internal_loop_single (struct __gconv_step *step,
#define LOOPFCT FROM_LOOP
#define BODY \
{ \
- uint16_t u1 = bswap_16 (*((uint16_t *) inptr)); \
+ uint16_t u1 = bswap_16 (*((const uint16_t *) inptr)); \
\
if (__builtin_expect (u1 >= 0xd800 && u1 < 0xe000, 0)) \
{ \
@@ -1276,7 +1285,7 @@ ucs4le_internal_loop_single (struct __gconv_step *step,
#define LOOPFCT FROM_LOOP
#define BODY \
{ \
- uint32_t val = *((uint32_t *) inptr); \
+ uint32_t val = *((const uint32_t *) inptr); \
if (__builtin_expect (val, 0) >= 0x10000) \
{ \
STANDARD_ERR_HANDLER (4); \
diff --git a/iconv/gconv_trans.c b/iconv/gconv_trans.c
index 4a42a35afd..919d438abe 100644
--- a/iconv/gconv_trans.c
+++ b/iconv/gconv_trans.c
@@ -41,18 +41,18 @@ __gconv_transliterate (struct __gconv_step *step,
{
/* Find out about the locale's transliteration. */
uint_fast32_t size;
- uint32_t *from_idx;
- uint32_t *from_tbl;
- uint32_t *to_idx;
- uint32_t *to_tbl;
- uint32_t *winbuf;
- uint32_t *winbufend;
+ const uint32_t *from_idx;
+ const uint32_t *from_tbl;
+ const uint32_t *to_idx;
+ const uint32_t *to_tbl;
+ const uint32_t *winbuf;
+ const uint32_t *winbufend;
uint_fast32_t low;
uint_fast32_t high;
/* The input buffer. There are actually 4-byte values. */
- winbuf = (uint32_t *) *inbufp;
- winbufend = (uint32_t *) inbufend;
+ winbuf = (const uint32_t *) *inbufp;
+ winbufend = (const uint32_t *) inbufend;
/* If there is no transliteration information in the locale don't do
anything and return the error. */
@@ -61,10 +61,14 @@ __gconv_transliterate (struct __gconv_step *step,
goto no_rules;
/* Get the rest of the values. */
- from_idx = (uint32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TRANSLIT_FROM_IDX);
- from_tbl = (uint32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TRANSLIT_FROM_TBL);
- to_idx = (uint32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TRANSLIT_TO_IDX);
- to_tbl = (uint32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TRANSLIT_TO_TBL);
+ from_idx =
+ (const uint32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TRANSLIT_FROM_IDX);
+ from_tbl =
+ (const uint32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TRANSLIT_FROM_TBL);
+ to_idx =
+ (const uint32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TRANSLIT_TO_IDX);
+ to_tbl =
+ (const uint32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TRANSLIT_TO_TBL);
/* Test whether there is enough input. */
if (winbuf + 1 > winbufend)
@@ -156,9 +160,9 @@ __gconv_transliterate (struct __gconv_step *step,
if (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_TRANSLIT_IGNORE_LEN) != 0)
{
int n = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_TRANSLIT_IGNORE_LEN);
- uint32_t *ranges = (uint32_t *) _NL_CURRENT (LC_CTYPE,
- _NL_CTYPE_TRANSLIT_IGNORE);
- uint32_t wc = *(uint32_t *) (*inbufp);
+ const uint32_t *ranges =
+ (const uint32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TRANSLIT_IGNORE);
+ const uint32_t wc = *(const uint32_t *) (*inbufp);
int i;
/* Test whether there is enough input. */
@@ -184,7 +188,7 @@ __gconv_transliterate (struct __gconv_step *step,
/* One last chance: use the default replacement. */
if (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_TRANSLIT_DEFAULT_MISSING_LEN) != 0)
{
- uint32_t *default_missing = (uint32_t *)
+ const uint32_t *default_missing = (const uint32_t *)
_NL_CURRENT (LC_CTYPE, _NL_CTYPE_TRANSLIT_DEFAULT_MISSING);
const unsigned char *toinptr = (const unsigned char *) default_missing;
uint32_t len = _NL_CURRENT_WORD (LC_CTYPE,
@@ -230,7 +234,7 @@ struct known_trans
/* This structure must remain the first member. */
struct trans_struct info;
- const char *fname;
+ char *fname;
void *handle;
int open_count;
};
@@ -247,8 +251,8 @@ __libc_lock_define_initialized (static, lock);
static int
trans_compare (const void *p1, const void *p2)
{
- struct known_trans *s1 = (struct known_trans *) p1;
- struct known_trans *s2 = (struct known_trans *) p2;
+ const struct known_trans *s1 = (const struct known_trans *) p1;
+ const struct known_trans *s2 = (const struct known_trans *) p2;
return strcmp (s1->info.name, s2->info.name);
}
diff --git a/iconv/loop.c b/iconv/loop.c
index 3a2779ed4a..7b5ef0030f 100644
--- a/iconv/loop.c
+++ b/iconv/loop.c
@@ -217,7 +217,7 @@ static inline int
FCTNAME (LOOPFCT) (struct __gconv_step *step,
struct __gconv_step_data *step_data,
const unsigned char **inptrp, const unsigned char *inend,
- unsigned char **outptrp, unsigned char *outend,
+ unsigned char **outptrp, const unsigned char *outend,
size_t *irreversible EXTRA_LOOP_DECLS)
{
#ifdef LOOP_NEED_STATE
@@ -326,7 +326,7 @@ SINGLE(LOOPFCT) (struct __gconv_step *step,
UNPACK_BYTES
#else
/* Add the bytes from the state to the input buffer. */
- for (inlen = 0; inlen < (state->__count & 7); ++ inlen)
+ for (inlen = 0; inlen < (size_t) (state->__count & 7); ++inlen)
bytebuf[inlen] = state->__value.__wchb[inlen];
#endif
diff --git a/iconv/skeleton.c b/iconv/skeleton.c
index 43d5d9e4a9..58f381295f 100644
--- a/iconv/skeleton.c
+++ b/iconv/skeleton.c
@@ -502,15 +502,13 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data,
if (FROM_DIRECTION)
/* Run the conversion loop. */
nstatus = FROM_LOOP (step, data, inptrp, inend,
- &outbuf,
- (unsigned char *) outerr,
+ &outbuf, outerr,
lirreversiblep
EXTRA_LOOP_ARGS);
else
/* Run the conversion loop. */
nstatus = TO_LOOP (step, data, inptrp, inend,
- &outbuf,
- (unsigned char *) outerr,
+ &outbuf, outerr,
lirreversiblep
EXTRA_LOOP_ARGS);
}
@@ -524,15 +522,14 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data,
nstatus = GEN_unaligned (FROM_LOOP) (step, data,
inptrp, inend,
&outbuf,
- (unsigned char *) outerr,
+ outerr,
lirreversiblep
EXTRA_LOOP_ARGS);
else
/* Run the conversion loop. */
nstatus = GEN_unaligned (TO_LOOP) (step, data,
inptrp, inend,
- &outbuf,
- (unsigned char *) outerr,
+ &outbuf, outerr,
lirreversiblep
EXTRA_LOOP_ARGS);
}