about summary refs log tree commit diff
path: root/iconv/gconv_conf.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-07-22 17:47:08 +0000
committerUlrich Drepper <drepper@redhat.com>2001-07-22 17:47:08 +0000
commit6b98979fc9e48f7627068426c49780f74f482750 (patch)
treed268769299237c3e7a3daa824289f1063b9a4fd1 /iconv/gconv_conf.c
parent2c4223669598910462717212b583ef0be08dc2bb (diff)
downloadglibc-6b98979fc9e48f7627068426c49780f74f482750.tar.gz
glibc-6b98979fc9e48f7627068426c49780f74f482750.tar.xz
glibc-6b98979fc9e48f7627068426c49780f74f482750.zip
Update.
2001-07-22  Ulrich Drepper  <drepper@redhat.com>

	* iconv/gconv_builtin.c (struct builtin_map): Remove init and end
	elements.
	(BUILTIN_TRANSFORMATION): Remove Init and End parameters.
	(__gconv_get_builtin_trans): Initialize __init_fct and __end_fct to
	NULL.
	* iconv/gconv_builtin.h: Remove NULL parameters for Init and End in
	all BUILTIN_TRANSFORMATION calls.
	* iconv/gconv_conf.c (BUILTIN_TRANSFORMATION): Remove Init and End
	parameters.
	* iconv/gconv_simple.c: Likewise.
	* iconv/gconv_db.c (gen_steps): Internal converters don't have
	initializers, move the code accordingly.

	* iconv/gconv_conf.c (__gconv_read_conf): Don't read configuration
	file if STATIC_GCONV is defined.

	* iconv/gconv_conf.c (__gconv_path_envvar): New global variable.
	(__gconv_get_path): Use it instead of call getenv.
	(__gconv_read_conf): First see whether cache can be used.  If yes,
	don't do any work here.
	* iconv/gconv_db.c (__gconv_release_step): Renamed from release_step
	and exported.  Change callers.
	(__gconv_find_transform): First call __gconv_lookup_cache and only
	continue if it signals no cache available.  Remove some unnecessary
	tests.
	* iconv/gconv_int.h: Declare __gconv_path_envvar, __gconv_lookup_cache,
	__gconv_release_step, and __gconv_loaded_cache.
	* iconv/gconv_cache.c: New file.
	* iconv/iconvconfig.c: New file.
	* iconv/iconvconfig.h: New file.
	* iconv/strtab.c: New file.
	* iconv/Makefile: Add rules to build new files and programs.
Diffstat (limited to 'iconv/gconv_conf.c')
-rw-r--r--iconv/gconv_conf.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index 9cedbb8406..db5bb476fd 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -60,8 +60,8 @@ static const char gconv_module_ext[] = MODULE_EXT;
 /* We have a few builtin transformations.  */
 static struct gconv_module builtin_modules[] =
 {
-#define BUILTIN_TRANSFORMATION(From, To, Cost, Name, Fct, Init, End, MinF, \
-			       MaxF, MinT, MaxT) \
+#define BUILTIN_TRANSFORMATION(From, To, Cost, Name, Fct, MinF, MaxF, \
+			       MinT, MaxT) \
   {									      \
     from_string: From,							      \
     to_string: To,							      \
@@ -79,8 +79,8 @@ static struct gconv_module builtin_modules[] =
 
 static const char *builtin_aliases[] =
 {
-#define BUILTIN_TRANSFORMATION(From, To, Cost, Name, Fct, Init, End, MinF, \
-			       MaxF, MinT, MaxT)
+#define BUILTIN_TRANSFORMATION(From, To, Cost, Name, Fct, MinF, MaxF, \
+			       MinT, MaxT)
 #define BUILTIN_ALIAS(From, To) From " " To,
 
 #include "gconv_builtin.h"
@@ -92,6 +92,10 @@ static const char *builtin_aliases[] =
 #endif
 
 
+/* Value of the GCONV_PATH environment variable.  */
+const char *__gconv_path_envvar;
+
+
 /* Test whether there is already a matching module known.  */
 static int
 internal_function
@@ -423,7 +427,6 @@ __gconv_get_path (void)
   if (result == NULL)
     {
       /* Determine the complete path first.  */
-      const char *user_path;
       char *gconv_path;
       size_t gconv_path_len;
       char *elem;
@@ -433,8 +436,7 @@ __gconv_get_path (void)
       char *cwd;
       size_t cwdlen;
 
-      user_path = getenv ("GCONV_PATH");
-      if (user_path == NULL)
+      if (__gconv_path_envvar == NULL)
 	{
 	  /* No user-defined path.  Make a modifiable copy of the
 	     default path.  */
@@ -446,11 +448,12 @@ __gconv_get_path (void)
       else
 	{
 	  /* Append the default path to the user-defined path.  */
-	  size_t user_len = strlen (user_path);
+	  size_t user_len = strlen (__gconv_path_envvar);
 
 	  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),
+	  __mempcpy (__mempcpy (__mempcpy (gconv_path, __gconv_path_envvar,
+					   user_len),
 				":", 1),
 		     default_gconv_path, sizeof (default_gconv_path));
 	  cwd = __getcwd (NULL, 0);
@@ -530,6 +533,15 @@ __gconv_read_conf (void)
   int save_errno = errno;
   size_t cnt;
 
+  /* First see whether we should use the cache.  */
+  if (__gconv_load_cache () == 0)
+    {
+      /* Yes, we are done.  */
+      __set_errno (save_errno);
+      return;
+    }
+
+#ifndef STATIC_GCONV
   /* Find out where we have to look.  */
   if (__gconv_path_elem == NULL)
     __gconv_get_path ();
@@ -549,6 +561,7 @@ __gconv_read_conf (void)
       /* Read the next configuration file.  */
       read_conf_file (filename, elem, elem_len, &modules, &nmodules);
     }
+#endif
 
   /* Add the internal modules.  */
   for (cnt = 0; cnt < sizeof (builtin_modules) / sizeof (builtin_modules[0]);