aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-06-19 21:12:06 +0000
committerUlrich Drepper <drepper@redhat.com>2000-06-19 21:12:06 +0000
commitd620426811688301eb1cbe6e63773d6430b2706e (patch)
tree555eb9182298ec1e56db8a5de4f62daa2e654321
parent01da56ba764e6abc52bfe9a1feeb79d3d67346d1 (diff)
downloadglibc-d620426811688301eb1cbe6e63773d6430b2706e.tar.xz
glibc-d620426811688301eb1cbe6e63773d6430b2706e.zip
Update.
2000-06-19 Ulrich Drepper <drepper@redhat.com> * iconv/gconv.h (__gconv_trans_fct): Add new parameter. General namespace cleanup. (struct __gconv_trans_data): Add next field. (struct __gconv_step_data): Make __trans a pointer. * iconv/gconv_conf.c: Split out code to find gconv directories from __gconv_read_conf in new functions. * iconv/gconv_int.h: Define new data structure and declare new functions for handling of gconv directory list. * iconv/gconv_open.c: Allow more than one error handling step being used. Call function to load error handling module if it is none of the builtin transformations. * iconv/gconv_close.c: Add code to free transliteration data. * iconv/gconv_trans.c: Add functions to load and unload modules implementing transliteration etc. * iconv/skeleton.c: Call all context functions now that more than one module is allowed. * iconv/loop.c (STANDARD_ERR_HANDLING): New macro. * iconv/gconv_simple.c: Use STANDARD_ERR_HANDLING macro for places where the full error handling using transliteration is needed. * iconvdata/8bit-gap.c: Likewise. * iconvdata/8bit-generic.c: Likewise. * iconvdata/ansi_x3.110.c: Likewise. * iconvdata/big5.c: Likewise. * iconvdata/big5hkscs.c: Likewise. * iconvdata/euc-cn.c: Likewise. * iconvdata/euc-jp.c: Likewise. * iconvdata/euc-kr.c: Likewise. * iconvdata/euc-tw.c: Likewise. * iconvdata/gbgbk.c: Likewise. * iconvdata/gbk.c: Likewise. * iconvdata/iso-2022-cn.c: Likewise. * iconvdata/iso-2022-jp.c: Likewise. * iconvdata/iso-2022-kr.c: Likewise. * iconvdata/iso646.c: Likewise. * iconvdata/iso8859-1.c: Likewise. * iconvdata/iso_6937-2.c: Likewise. * iconvdata/iso_6937.c: Likewise. * iconvdata/johab.c: Likewise. * iconvdata/sjis.c: Likewise. * iconvdata/t.61.c: Likewise. * iconvdata/uhc.c: Likewise. * iconvdata/unicode.c: Likewise. * iconvdata/utf-16.c: Likewise. * libio/iofwide.c: Reset __trans member of __gconv_trans_data structure correctly after last change. * wcsmbs/btowc.c: Likewise. * wcsmbs/mbrtowc.c: Likewise. * wcsmbs/mbsnrtowcs.c: Likewise. * wcsmbs/mbsrtowcs.c: Likewise. * wcsmbs/wcrtomb.c: Likewise. * wcsmbs/wcsnrtombs.c: Likewise. * wcsmbs/wcsrtombs.c: Likewise. * wcsmbs/wctob.c: Likewise. * localedata/Makefile: Set -Wno-format for some files since gcc does not know all the format specifiers. 2000-06-18 Ulrich Drepper <drepper@redhat.com> * locale/loadlocale.c (_nl_unload_locale): Remove a bit of unneeded code. * locale/lc-time.c (_nl_init_era_entries): Likewise.
-rw-r--r--ChangeLog65
-rw-r--r--iconv/gconv.h12
-rw-r--r--iconv/gconv_close.c14
-rw-r--r--iconv/gconv_conf.c153
-rw-r--r--iconv/gconv_int.h36
-rw-r--r--iconv/gconv_open.c255
-rw-r--r--iconv/gconv_simple.c59
-rw-r--r--iconv/gconv_trans.c180
-rw-r--r--iconv/loop.c32
-rw-r--r--iconv/skeleton.c10
-rw-r--r--iconvdata/8bit-gap.c76
-rw-r--r--iconvdata/8bit-generic.c27
-rw-r--r--iconvdata/ansi_x3.110.c60
-rw-r--r--iconvdata/big5.c20
-rw-r--r--iconvdata/big5hkscs.c20
-rw-r--r--iconvdata/euc-cn.c20
-rw-r--r--iconvdata/euc-jp.c21
-rw-r--r--iconvdata/euc-kr.c20
-rw-r--r--iconvdata/euc-tw.c20
-rw-r--r--iconvdata/gbgbk.c29
-rw-r--r--iconvdata/gbk.c20
-rw-r--r--iconvdata/iso-2022-cn.c21
-rw-r--r--iconvdata/iso-2022-jp.c44
-rw-r--r--iconvdata/iso-2022-kr.c20
-rw-r--r--iconvdata/iso646.c25
-rw-r--r--iconvdata/iso8859-1.c20
-rw-r--r--iconvdata/iso_6937-2.c45
-rw-r--r--iconvdata/iso_6937.c41
-rw-r--r--iconvdata/johab.c42
-rw-r--r--iconvdata/sjis.c46
-rw-r--r--iconvdata/t.61.c42
-rw-r--r--iconvdata/uhc.c42
-rw-r--r--iconvdata/unicode.c21
-rw-r--r--iconvdata/utf-16.c42
-rw-r--r--libio/iofwide.c8
-rw-r--r--locale/loadlocale.c4
-rw-r--r--localedata/Makefile7
-rw-r--r--wcsmbs/btowc.c2
-rw-r--r--wcsmbs/mbrtowc.c2
-rw-r--r--wcsmbs/mbsnrtowcs.c2
-rw-r--r--wcsmbs/mbsrtowcs.c2
-rw-r--r--wcsmbs/wcrtomb.c2
-rw-r--r--wcsmbs/wcsnrtombs.c2
-rw-r--r--wcsmbs/wcsrtombs.c2
-rw-r--r--wcsmbs/wctob.c2
45 files changed, 727 insertions, 908 deletions
diff --git a/ChangeLog b/ChangeLog
index 4141af493e..8b8305a9ed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,68 @@
+2000-06-19 Ulrich Drepper <drepper@redhat.com>
+
+ * iconv/gconv.h (__gconv_trans_fct): Add new parameter.
+ General namespace cleanup.
+ (struct __gconv_trans_data): Add next field.
+ (struct __gconv_step_data): Make __trans a pointer.
+ * iconv/gconv_conf.c: Split out code to find gconv directories from
+ __gconv_read_conf in new functions.
+ * iconv/gconv_int.h: Define new data structure and declare new
+ functions for handling of gconv directory list.
+ * iconv/gconv_open.c: Allow more than one error handling step being
+ used. Call function to load error handling module if it is none
+ of the builtin transformations.
+ * iconv/gconv_close.c: Add code to free transliteration data.
+ * iconv/gconv_trans.c: Add functions to load and unload modules
+ implementing transliteration etc.
+ * iconv/skeleton.c: Call all context functions now that more than
+ one module is allowed.
+ * iconv/loop.c (STANDARD_ERR_HANDLING): New macro.
+ * iconv/gconv_simple.c: Use STANDARD_ERR_HANDLING macro for places
+ where the full error handling using transliteration is needed.
+ * iconvdata/8bit-gap.c: Likewise.
+ * iconvdata/8bit-generic.c: Likewise.
+ * iconvdata/ansi_x3.110.c: Likewise.
+ * iconvdata/big5.c: Likewise.
+ * iconvdata/big5hkscs.c: Likewise.
+ * iconvdata/euc-cn.c: Likewise.
+ * iconvdata/euc-jp.c: Likewise.
+ * iconvdata/euc-kr.c: Likewise.
+ * iconvdata/euc-tw.c: Likewise.
+ * iconvdata/gbgbk.c: Likewise.
+ * iconvdata/gbk.c: Likewise.
+ * iconvdata/iso-2022-cn.c: Likewise.
+ * iconvdata/iso-2022-jp.c: Likewise.
+ * iconvdata/iso-2022-kr.c: Likewise.
+ * iconvdata/iso646.c: Likewise.
+ * iconvdata/iso8859-1.c: Likewise.
+ * iconvdata/iso_6937-2.c: Likewise.
+ * iconvdata/iso_6937.c: Likewise.
+ * iconvdata/johab.c: Likewise.
+ * iconvdata/sjis.c: Likewise.
+ * iconvdata/t.61.c: Likewise.
+ * iconvdata/uhc.c: Likewise.
+ * iconvdata/unicode.c: Likewise.
+ * iconvdata/utf-16.c: Likewise.
+ * libio/iofwide.c: Reset __trans member of __gconv_trans_data
+ structure correctly after last change.
+ * wcsmbs/btowc.c: Likewise.
+ * wcsmbs/mbrtowc.c: Likewise.
+ * wcsmbs/mbsnrtowcs.c: Likewise.
+ * wcsmbs/mbsrtowcs.c: Likewise.
+ * wcsmbs/wcrtomb.c: Likewise.
+ * wcsmbs/wcsnrtombs.c: Likewise.
+ * wcsmbs/wcsrtombs.c: Likewise.
+ * wcsmbs/wctob.c: Likewise.
+
+ * localedata/Makefile: Set -Wno-format for some files since gcc does
+ not know all the format specifiers.
+
+2000-06-18 Ulrich Drepper <drepper@redhat.com>
+
+ * locale/loadlocale.c (_nl_unload_locale): Remove a bit of
+ unneeded code.
+ * locale/lc-time.c (_nl_init_era_entries): Likewise.
+
2000-06-18 Andreas Jaeger <aj@suse.de>
* sysdeps/mips/dl-machine.h: Always use $25 as jump register.
diff --git a/iconv/gconv.h b/iconv/gconv.h
index 0164b62c8b..50458e2aeb 100644
--- a/iconv/gconv.h
+++ b/iconv/gconv.h
@@ -76,21 +76,22 @@ typedef void (*__gconv_end_fct) (struct __gconv_step *);
/* Type of a transliteration/transscription function. */
-typedef int (*__gconv_trans_fct) (struct __gconv_step *step,
- struct __gconv_step_data *step_data,
+typedef int (*__gconv_trans_fct) (struct __gconv_step *,
+ struct __gconv_step_data *, void *,
__const unsigned char *,
__const unsigned char **,
__const unsigned char *, unsigned char **,
size_t *);
/* Function to call to provide transliteration module with context. */
-typedef int (*__gconv_trans_context_fct) (struct __gconv_trans_data *data,
+typedef int (*__gconv_trans_context_fct) (struct __gconv_trans_data *,
__const unsigned char *,
__const unsigned char *,
unsigned char *, unsigned char *);
/* Function to query module about supported encoded character sets. */
-typedef int (*__gconv_trans_query_fct) (__const char **, size_t *);
+typedef int (*__gconv_trans_query_fct) (__const char *, __const char ***,
+ size_t *);
/* Constructor and destructor for local data for transliteration. */
typedef int (*__gconv_trans_init_fct) (void **, const char *);
@@ -103,6 +104,7 @@ struct __gconv_trans_data
__gconv_trans_context_fct __trans_context_fct;
__gconv_trans_end_fct __trans_end_fct;
void *__data;
+ struct __gconv_trans_data *__next;
};
@@ -158,7 +160,7 @@ struct __gconv_step_data
any module; always use STATEP! */
/* Transliteration information. */
- struct __gconv_trans_data __trans;
+ struct __gconv_trans_data *__trans;
};
diff --git a/iconv/gconv_close.c b/iconv/gconv_close.c
index 79dcb0b3a1..002e2c4dce 100644
--- a/iconv/gconv_close.c
+++ b/iconv/gconv_close.c
@@ -38,6 +38,20 @@ __gconv_close (__gconv_t cd)
drunp = cd->__data;
do
{
+ struct __gconv_trans_data *transp;
+
+ transp = drunp->__trans;
+ while (transp != NULL)
+ {
+ struct __gconv_trans_data *curp = transp;
+ transp = transp->__next;
+
+ if (__builtin_expect (curp->__trans_end_fct != NULL, 0))
+ curp->__trans_end_fct (curp->__data);
+
+ free (curp);
+ }
+
if (!(drunp->__flags & __GCONV_IS_LAST) && drunp->__outbuf != NULL)
free (drunp->__outbuf);
}
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index 0d25c22416..480b459134 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -1,5 +1,5 @@
/* Handle configuration data.
- Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 1999, 2000 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 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
@@ -34,6 +35,14 @@
/* This is the default path where we look for module lists. */
static const char default_gconv_path[] = GCONV_PATH;
+/* The path element in use. */
+const struct path_elem *__gconv_path_elem;
+/* Maximum length of a single path element. */
+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;
+
/* Name of the file containing the module information in the directories
along the path. */
static const char gconv_conf_filename[] = "gconv-modules";
@@ -497,48 +506,125 @@ read_conf_file (const char *filename, const char *directory, size_t dir_len,
/* Otherwise ignore the line. */
}
- if (line != NULL)
- free (line);
+ free (line);
+
fclose (fp);
}
+/* Determine the directories we are looking for data in. */
+void
+__gconv_get_path (void)
+{
+ struct path_elem *result;
+ __libc_lock_define_initialized (static, lock);
+
+ __libc_lock_lock (lock);
+
+ /* Make sure there wasn't a second thread doing it already. */
+ result = (struct path_elem *) __gconv_path_elem;
+ if (result == NULL)
+ {
+ /* Determine the complete path first. */
+ const char *user_path;
+ char *gconv_path;
+ size_t gconv_path_len;
+ char *elem;
+ char *oldp;
+ char *cp;
+ int nelems;
+
+ user_path = __secure_getenv ("GCONV_PATH");
+ if (user_path == NULL)
+ {
+ /* No user-defined path. Make a modifiable copy of the
+ default path. */
+ gconv_path = strdupa (default_gconv_path);
+ gconv_path_len = sizeof (default_gconv_path);
+ }
+ else
+ {
+ /* Append the default path to the user-defined path. */
+ size_t user_len = strlen (user_path);
+
+ gconv_path_len = user_len + 1 + sizeof (default_gconv_path);
+ gconv_path = alloca (gconv_path_len);
+ __mempcpy (__mempcpy (__mempcpy (gconv_path, user_path, user_len),
+ ":", 1),
+ default_gconv_path, sizeof (default_gconv_path));
+ }
+
+ /* In a first pass we calculate the number of elements. */
+ oldp = NULL;
+ cp = strchr (gconv_path, ':');
+ nelems = 1;
+ while (cp != NULL)
+ {
+ if (cp != oldp + 1)
+ ++nelems;
+ oldp = cp;
+ cp = strchr (cp + 1, ':');
+ }
+
+ /* Allocate the memory for the result. */
+ result = (struct path_elem *) malloc ((nelems + 1)
+ * sizeof (struct path_elem)
+ + gconv_path_len + nelems);
+ if (result != NULL)
+ {
+ char *strspace = (char *) &result[nelems + 1];
+ int n = 0;
+
+ /* Separate the individual parts. */
+ __gconv_max_path_elem_len = 0;
+ elem = __strtok_r (gconv_path, ":", &gconv_path);
+ assert (elem != NULL);
+ do
+ {
+ result[n].name = strspace;
+ strspace = __stpcpy (strspace, elem);
+ if (strspace[-1] != '/')
+ *strspace++ = '/';
+
+ result[n].len = strspace - result[n].name;
+ if (result[n].len > __gconv_max_path_elem_len)
+ __gconv_max_path_elem_len = result[n].len;
+
+ *strspace++ = '\0';
+ ++n;
+ }
+ while ((elem = __strtok_r (NULL, ":", &gconv_path)) != NULL);
+
+ result[n].name = NULL;
+ result[n].len = 0;
+ }
+
+ __gconv_path_elem = result ?: &empty_path_elem;
+ }
+
+ __libc_lock_unlock (lock);
+}
+
+
/* Read all configuration files found in the user-specified and the default
path. */
void
__gconv_read_conf (void)
{
- const char *user_path = __secure_getenv ("GCONV_PATH");
- char *gconv_path, *elem;
void *modules = NULL;
size_t nmodules = 0;
int save_errno = errno;
size_t cnt;
- if (user_path == NULL)
- /* No user-defined path. Make a modifiable copy of the default path. */
- gconv_path = strdupa (default_gconv_path);
- else
- {
- /* Append the default path to the user-defined path. */
- size_t user_len = strlen (user_path);
-
- gconv_path = alloca (user_len + 1 + sizeof (default_gconv_path));
- __mempcpy (__mempcpy (__mempcpy (gconv_path, user_path, user_len),
- ":", 1),
- default_gconv_path, sizeof (default_gconv_path));
- }
+ /* Find out where we have to look. */
+ if (__gconv_path_elem == NULL)
+ __gconv_get_path ();
- elem = __strtok_r (gconv_path, ":", &gconv_path);
- while (elem != NULL)
+ for (cnt = 0; __gconv_path_elem[cnt].name != NULL; ++cnt)
{
-#ifndef MAXPATHLEN
- /* We define a reasonable limit. */
-# define MAXPATHLEN 4096
-#endif
- char real_elem[MAXPATHLEN];
+ char real_elem[__gconv_max_path_elem_len + sizeof (gconv_conf_filename)];
- if (__realpath (elem, real_elem) != NULL)
+ if (__realpath (__gconv_path_elem[cnt].name, real_elem) != NULL)
{
size_t elem_len = strlen (real_elem);
char *filename;
@@ -551,9 +637,6 @@ __gconv_read_conf (void)
/* Read the next configuration file. */
read_conf_file (filename, real_elem, elem_len, &modules, &nmodules);
}
-
- /* Get next element in the path. */
- elem = __strtok_r (NULL, ":", &gconv_path);
}
/* Add the internal modules. */
@@ -586,3 +669,15 @@ __gconv_read_conf (void)
/* Restore the error number. */
__set_errno (save_errno);
}
+
+
+
+/* Free all resources if necessary. */
+static void __attribute__ ((unused))
+free_mem (void)
+{
+ if (_