aboutsummaryrefslogtreecommitdiff
path: root/iconv
diff options
context:
space:
mode:
Diffstat (limited to 'iconv')
-rw-r--r--iconv/dummy-repertoire.c22
-rw-r--r--iconv/gconv.c19
-rw-r--r--iconv/gconv_builtin.c13
-rw-r--r--iconv/gconv_builtin.h5
-rw-r--r--iconv/gconv_cache.c17
-rw-r--r--iconv/gconv_charset.h10
-rw-r--r--iconv/gconv_conf.c101
-rw-r--r--iconv/gconv_db.c71
-rw-r--r--iconv/gconv_dl.c11
-rw-r--r--iconv/gconv_int.h8
-rw-r--r--iconv/gconv_open.c18
-rw-r--r--iconv/gconv_simple.c4
-rw-r--r--iconv/gconv_trans.c10
-rw-r--r--iconv/iconv_charmap.c48
-rw-r--r--iconv/iconv_open.c4
-rw-r--r--iconv/iconv_prog.c42
-rw-r--r--iconv/iconvconfig.c94
-rw-r--r--iconv/loop.c6
-rw-r--r--iconv/skeleton.c45
-rw-r--r--iconv/strtab.c4
20 files changed, 328 insertions, 224 deletions
diff --git a/iconv/dummy-repertoire.c b/iconv/dummy-repertoire.c
index a195460f9a..a87685c505 100644
--- a/iconv/dummy-repertoire.c
+++ b/iconv/dummy-repertoire.c
@@ -1,21 +1,19 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License version 2 as
+ published by the Free Software Foundation.
- The GNU C Library is distributed in the hope that it will be useful,
+ This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* For iconv we don't have to handle repertoire maps. Provide dummy
definitions to allow the use of linereader.c unchanged. */
diff --git a/iconv/gconv.c b/iconv/gconv.c
index f3f49b7db3..cd43d3d6fb 100644
--- a/iconv/gconv.c
+++ b/iconv/gconv.c
@@ -1,6 +1,6 @@
/* Convert characters in input buffer using conversion descriptor to
output buffer.
- Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1997-2001, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -20,10 +20,13 @@
02111-1307 USA. */
#include <assert.h>
-#include <gconv_int.h>
-#include <sys/param.h>
#include <dlfcn.h>
#include <stddef.h>
+#include <sys/param.h>
+
+#include <gconv_int.h>
+#include <sysdep.h>
+
int
internal_function
@@ -45,9 +48,15 @@ __gconv (__gconv_t cd, const unsigned char **inbuf,
cd->__data[last_step].__outbuf = outbuf != NULL ? *outbuf : NULL;
cd->__data[last_step].__outbufend = outbufend;
+ __gconv_fct fct = cd->__steps->__fct;
+#ifdef PTR_DEMANGLE
+ if (cd->__steps->__shlib_handle != NULL)
+ PTR_DEMANGLE (fct);
+#endif
+
if (inbuf == NULL || *inbuf == NULL)
/* We just flush. */
- result = DL_CALL_FCT (cd->__steps->__fct,
+ result = DL_CALL_FCT (fct,
(cd->__steps, cd->__data, NULL, NULL, NULL,
irreversible,
cd->__data[last_step].__outbuf == NULL ? 2 : 1, 0));
@@ -60,7 +69,7 @@ __gconv (__gconv_t cd, const unsigned char **inbuf,
do
{
last_start = *inbuf;
- result = DL_CALL_FCT (cd->__steps->__fct,
+ result = DL_CALL_FCT (fct,
(cd->__steps, cd->__data, inbuf, inbufend,
NULL, irreversible, 0, 0));
}
diff --git a/iconv/gconv_builtin.c b/iconv/gconv_builtin.c
index f653d6c7f3..d8beabd416 100644
--- a/iconv/gconv_builtin.c
+++ b/iconv/gconv_builtin.c
@@ -1,5 +1,5 @@
/* Table for builtin transformation mapping.
- Copyright (C) 1997-1999, 2000-2002 Free Software Foundation, Inc.
+ Copyright (C) 1997-1999, 2000-2002, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -20,6 +20,7 @@
#include <endian.h>
#include <limits.h>
+#include <stdint.h>
#include <string.h>
#include <gconv_int.h>
@@ -27,16 +28,16 @@
#include <assert.h>
-static struct builtin_map
+static const struct builtin_map
{
const char *name;
__gconv_fct fct;
__gconv_btowc_fct btowc_fct;
- int min_needed_from;
- int max_needed_from;
- int min_needed_to;
- int max_needed_to;
+ int8_t min_needed_from;
+ int8_t max_needed_from;
+ int8_t min_needed_to;
+ int8_t max_needed_to;
} map[] =
{
diff --git a/iconv/gconv_builtin.h b/iconv/gconv_builtin.h
index bd34c256dc..ef9ab8d7cf 100644
--- a/iconv/gconv_builtin.h
+++ b/iconv/gconv_builtin.h
@@ -1,5 +1,5 @@
/* Builtin transformations.
- Copyright (C) 1997-1999, 2000-2002 Free Software Foundation, Inc.
+ Copyright (C) 1997-1999, 2000-2002, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -18,6 +18,9 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+/* All encoding named must be in upper case. There must be no extra
+ spaces. */
+
BUILTIN_ALIAS ("UCS4//", "ISO-10646/UCS4/")
BUILTIN_ALIAS ("UCS-4//", "ISO-10646/UCS4/")
BUILTIN_ALIAS ("UCS-4BE//", "ISO-10646/UCS4/")
diff --git a/iconv/gconv_cache.c b/iconv/gconv_cache.c
index 9b695c377d..716c384de2 100644
--- a/iconv/gconv_cache.c
+++ b/iconv/gconv_cache.c
@@ -1,5 +1,5 @@
/* Cache handling for iconv modules.
- Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 2001.
@@ -209,7 +209,18 @@ find_module (const char *directory, const char *filename,
/* Call the init function. */
if (result->__init_fct != NULL)
- status = DL_CALL_FCT (result->__init_fct, (result));
+ {
+ __gconv_init_fct init_fct = result->__init_fct;
+#ifdef PTR_DEMANGLE
+ PTR_DEMANGLE (init_fct);
+#endif
+ status = DL_CALL_FCT (init_fct, (result));
+
+#ifdef PTR_MANGLE
+ if (result->__btowc_fct != NULL)
+ PTR_MANGLE (result->__btowc_fct);
+#endif
+ }
}
return status;
@@ -456,7 +467,7 @@ libc_freeres_fn (free_mem)
if (cache_malloced)
free (gconv_cache);
#ifdef _POSIX_MAPPED_FILES
- else
+ else if (gconv_cache != NULL)
__munmap (gconv_cache, cache_size);
#endif
}
diff --git a/iconv/gconv_charset.h b/iconv/gconv_charset.h
index 4a3db73118..8882f4319f 100644
--- a/iconv/gconv_charset.h
+++ b/iconv/gconv_charset.h
@@ -1,5 +1,5 @@
/* Charset name normalization.
- Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2001,2002,2003,2004,2005,2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 2001.
@@ -29,9 +29,9 @@ strip (char *wp, const char *s)
while (*s != '\0')
{
- if (__isalnum_l (*s, &_nl_C_locobj)
- || *s == '_' || *s == '-' || *s == '.' || *s == ',')
- *wp++ = __toupper_l (*s, &_nl_C_locobj);
+ if (__isalnum_l (*s, _nl_C_locobj_ptr)
+ || *s == '_' || *s == '-' || *s == '.' || *s == ',' || *s == ':')
+ *wp++ = __toupper_l (*s, _nl_C_locobj_ptr);
else if (*s == '/')
{
if (++slash_count == 3)
@@ -52,7 +52,7 @@ static inline char * __attribute__ ((unused, always_inline))
upstr (char *dst, const char *str)
{
char *cp = dst;
- while ((*cp++ = __toupper_l (*str++, &_nl_C_locobj)) != '\0')
+ while ((*cp++ = __toupper_l (*str++, _nl_C_locobj_ptr)) != '\0')
/* nothing */;
return dst;
}
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index 858d40998b..22ffa4f41c 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -1,5 +1,5 @@
/* Handle configuration data.
- Copyright (C) 1997,98,99,2000,2001,2002,2003 Free Software Foundation, Inc.
+ Copyright (C) 1997-2003, 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -46,7 +46,7 @@ struct path_elem *__gconv_path_elem;
size_t __gconv_max_path_elem_len;
/* We use the following struct if we couldn't allocate memory. */
-static const struct path_elem empty_path_elem;
+static const struct path_elem empty_path_elem = { NULL, 0 };
/* Name of the file containing the module information in the directories
along the path. */
@@ -78,11 +78,11 @@ static struct gconv_module builtin_modules[] =
#undef BUILTIN_ALIAS
};
-static const char *builtin_aliases[] =
+static const char builtin_aliases[] =
{
#define BUILTIN_TRANSFORMATION(From, To, Cost, Name, Fct, BtowcFct, \
MinF, MaxF, MinT, MaxT)
-#define BUILTIN_ALIAS(From, To) From " " To,
+#define BUILTIN_ALIAS(From, To) From "\0" To "\0"
#include "gconv_builtin.h"
@@ -124,40 +124,16 @@ detect_conflict (const char *alias)
}
-/* Add new alias. */
+/* The actual code to add aliases. */
static void
-add_alias (char *rp, void *modules)
+add_alias2 (const char *from, const char *to, const char *wp, void *modules)
{
- /* We now expect two more string. The strings are normalized
- (converted to UPPER case) and strored in the alias database. */
- struct gconv_alias *new_alias;
- char *from, *to, *wp;
-
- while (__isspace_l (*rp, &_nl_C_locobj))
- ++rp;
- from = wp = rp;
- while (*rp != '\0' && !__isspace_l (*rp, &_nl_C_locobj))
- *wp++ = __toupper_l (*rp++, &_nl_C_locobj);
- if (*rp == '\0')
- /* There is no `to' string on the line. Ignore it. */
- return;
- *wp++ = '\0';
- to = ++rp;
- while (__isspace_l (*rp, &_nl_C_locobj))
- ++rp;
- while (*rp != '\0' && !__isspace_l (*rp, &_nl_C_locobj))
- *wp++ = __toupper_l (*rp++, &_nl_C_locobj);
- if (to == wp)
- /* No `to' string, ignore the line. */
- return;
- *wp++ = '\0';
-
/* Test whether this alias conflicts with any available module. */
if (detect_conflict (from))
/* It does conflict, don't add the alias. */
return;
- new_alias = (struct gconv_alias *)
+ struct gconv_alias *new_alias = (struct gconv_alias *)
malloc (sizeof (struct gconv_alias) + (wp - from));
if (new_alias != NULL)
{
@@ -177,6 +153,37 @@ add_alias (char *rp, void *modules)
}
+/* Add new alias. */
+static void
+add_alias (char *rp, void *modules)
+{
+ /* We now expect two more string. The strings are normalized
+ (converted to UPPER case) and strored in the alias database. */
+ char *from, *to, *wp;
+
+ while (__isspace_l (*rp, _nl_C_locobj_ptr))
+ ++rp;
+ from = wp = rp;
+ while (*rp != '\0' && !__isspace_l (*rp, _nl_C_locobj_ptr))
+ *wp++ = __toupper_l (*rp++, _nl_C_locobj_ptr);
+ if (*rp == '\0')
+ /* There is no `to' string on the line. Ignore it. */
+ return;
+ *wp++ = '\0';
+ to = ++rp;
+ while (__isspace_l (*rp, _nl_C_locobj_ptr))
+ ++rp;
+ while (*rp != '\0' && !__isspace_l (*rp, _nl_C_locobj_ptr))
+ *wp++ = __toupper_l (*rp++, _nl_C_locobj_ptr);
+ if (to == wp)
+ /* No `to' string, ignore the line. */
+ return;
+ *wp++ = '\0';
+
+ add_alias2 (from, to, wp, modules);
+}
+
+
/* Insert a data structure for a new module in the search tree. */
static void
internal_function
@@ -254,30 +261,30 @@ add_module (char *rp, const char *directory, size_t dir_len, void **modules,
int need_ext;
int cost_hi;
- while (__isspace_l (*rp, &_nl_C_locobj))
+ while (__isspace_l (*rp, _nl_C_locobj_ptr))
++rp;
from = rp;
- while (*rp != '\0' && !__isspace_l (*rp, &_nl_C_locobj))
+ while (*rp != '\0' && !__isspace_l (*rp, _nl_C_locobj_ptr))
{
- *rp = __toupper_l (*rp, &_nl_C_locobj);
+ *rp = __toupper_l (*rp, _nl_C_locobj_ptr);
++rp;
}
if (*rp == '\0')
return;
*rp++ = '\0';
to = wp = rp;
- while (__isspace_l (*rp, &_nl_C_locobj))
+ while (__isspace_l (*rp, _nl_C_locobj_ptr))
++rp;
- while (*rp != '\0' && !__isspace_l (*rp, &_nl_C_locobj))
- *wp++ = __toupper_l (*rp++, &_nl_C_locobj);
+ while (*rp != '\0' && !__isspace_l (*rp, _nl_C_locobj_ptr))
+ *wp++ = __toupper_l (*rp++, _nl_C_locobj_ptr);
if (*rp == '\0')
return;
*wp++ = '\0';
do
++rp;
- while (__isspace_l (*rp, &_nl_C_locobj));
+ while (__isspace_l (*rp, _nl_C_locobj_ptr));
module = wp;
- while (*rp != '\0' && !__isspace_l (*rp, &_nl_C_locobj))
+ while (*rp != '\0' && !__isspace_l (*rp, _nl_C_locobj_ptr))
*wp++ = *rp++;
if (*rp == '\0')
{
@@ -392,7 +399,7 @@ read_conf_file (const char *filename, const char *directory, size_t dir_len,
if (rp[n - 1] == '\n')
rp[n - 1] = '\0';
- while (__isspace_l (*rp, &_nl_C_locobj))
+ while (__isspace_l (*rp, _nl_C_locobj_ptr))
++rp;
/* If this is an empty line go on with the next one. */
@@ -400,7 +407,7 @@ read_conf_file (const char *filename, const char *directory, size_t dir_len,
continue;
word = rp;
- while (*rp != '\0' && !__isspace_l (*rp, &_nl_C_locobj))
+ while (*rp != '\0' && !__isspace_l (*rp, _nl_C_locobj_ptr))
++rp;
if (rp - word == sizeof ("alias") - 1
@@ -588,12 +595,16 @@ __gconv_read_conf (void)
}
/* Add aliases for builtin conversions. */
- cnt = sizeof (builtin_aliases) / sizeof (builtin_aliases[0]);
- while (cnt > 0)
+ const char *cp = builtin_aliases;
+ do
{
- char *copy = strdupa (builtin_aliases[--cnt]);
- add_alias (copy, modules);
+ const char *from = cp;
+ const char *to = __rawmemchr (from, '\0') + 1;
+ cp = __rawmemchr (to, '\0') + 1;
+
+ add_alias2 (from, to, cp, modules);
}
+ while (*cp != '\0');
/* Restore the error number. */
__set_errno (save_errno);
diff --git a/iconv/gconv_db.c b/iconv/gconv_db.c
index 8dc6b14d25..6540cc393c 100644
--- a/iconv/gconv_db.c
+++ b/iconv/gconv_db.c
@@ -1,5 +1,5 @@
/* Provide access to the collection of available transformation modules.
- Copyright (C) 1997-2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1997-2003, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -18,6 +18,7 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#include <assert.h>
#include <limits.h>
#include <search.h>
#include <stdlib.h>
@@ -28,6 +29,7 @@
#include <dlfcn.h>
#include <gconv_int.h>
+#include <sysdep.h>
/* Simple data structure for alias mapping. We have two names, `from'
@@ -180,7 +182,15 @@ free_derivation (void *p)
for (cnt = 0; cnt < deriv->nsteps; ++cnt)
if (deriv->steps[cnt].__counter > 0
&& deriv->steps[cnt].__end_fct != NULL)
- DL_CALL_FCT (deriv->steps[cnt].__end_fct, (&deriv->steps[cnt]));
+ {
+ assert (deriv->steps[cnt].__shlib_handle != NULL);
+
+ __gconv_end_fct end_fct = deriv->steps[cnt].__end_fct;
+#ifdef PTR_DEMANGLE
+ PTR_DEMANGLE (end_fct);
+#endif
+ DL_CALL_FCT (end_fct, (&deriv->steps[cnt]));
+ }
/* Free the name strings. */
free ((char *) deriv->steps[0].__from_name);
@@ -196,22 +206,30 @@ void
internal_function
__gconv_release_step (struct __gconv_step *step)
{
- if (--step->__counter == 0)
+ /* Skip builtin modules; they are not reference counted. */
+ if (step->__shlib_handle != NULL && --step->__counter == 0)
{
/* Call the destructor. */
if (step->__end_fct != NULL)
- DL_CALL_FCT (step->__end_fct, (step));
-
-#ifndef STATIC_GCONV
- /* Skip builtin modules; they are not reference counted. */
- if (step->__shlib_handle != NULL)
{
- /* Release the loaded module. */
- __gconv_release_shlib (step->__shlib_handle);
- step->__shlib_handle = NULL;
+ assert (step->__shlib_handle != NULL);
+
+ __gconv_end_fct end_fct = step->__end_fct;
+#ifdef PTR_DEMANGLE
+ PTR_DEMANGLE (end_fct);
+#endif
+ DL_CALL_FCT (end_fct, (step));
}
+
+#ifndef STATIC_GCONV
+ /* Release the loaded module. */
+ __gconv_release_shlib (step->__shlib_handle);
+ step->__shlib_handle = NULL;
#endif
}
+ else if (step->__shlib_handle == NULL)
+ /* Builtin modules should not have end functions. */
+ assert (step->__end_fct == NULL);
}
static int
@@ -272,10 +290,15 @@ gen_steps (struct derivation_step *best, const char *toset,
result[step_cnt].__btowc_fct = NULL;
/* Call the init function. */
- if (result[step_cnt].__init_fct != NULL)
+ __gconv_init_fct init_fct = result[step_cnt].__init_fct;
+ if (init_fct != NULL)
{
- status = DL_CALL_FCT (result[step_cnt].__init_fct,
- (&result[step_cnt]));
+ assert (result[step_cnt].__shlib_handle != NULL);
+
+# ifdef PTR_DEMANGLE
+ PTR_DEMANGLE (init_fct);
+# endif
+ status = DL_CALL_FCT (init_fct, (&result[step_cnt]));
if (__builtin_expect (status, __GCONV_OK) != __GCONV_OK)
{
@@ -285,6 +308,11 @@ gen_steps (struct derivation_step *best, const char *toset,
result[step_cnt].__end_fct = NULL;
break;
}
+
+# ifdef PTR_MANGLE
+ if (result[step_cnt].__btowc_fct != NULL)
+ PTR_MANGLE (result[step_cnt].__btowc_fct);
+# endif
}
}
else
@@ -362,8 +390,19 @@ increment_counter (struct __gconv_step *steps, size_t nsteps)
}
/* Call the init function. */
- if (step->__init_fct != NULL)
- DL_CALL_FCT (step->__init_fct, (step));
+ __gconv_init_fct init_fct = step->__init_fct;
+ if (init_fct != NULL)
+ {
+#ifdef PTR_DEMANGLE
+ PTR_DEMANGLE (init_fct);
+#endif
+ DL_CALL_FCT (init_fct, (step));
+
+#ifdef PTR_MANGLE
+ if (step->__btowc_fct != NULL)
+ PTR_MANGLE (step->__btowc_fct);
+#endif
+ }
}
}
return result;
diff --git a/iconv/gconv_dl.c b/iconv/gconv_dl.c
index 9504017210..8217b7e553 100644
--- a/iconv/gconv_dl.c
+++ b/iconv/gconv_dl.c
@@ -1,5 +1,5 @@
/* Handle loading/unloading of shared object for transformation.
- Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004
+ Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005
Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -29,6 +29,7 @@
#include <sys/param.h>
#include <gconv_int.h>
+#include <sysdep.h>
#ifdef DEBUG
@@ -130,6 +131,14 @@ __gconv_find_shlib (const char *name)
found->init_fct = __libc_dlsym (found->handle, "gconv_init");
found->end_fct = __libc_dlsym (found->handle, "gconv_end");
+#ifdef PTR_MANGLE
+ PTR_MANGLE (found->fct);
+ if (found->ini