about summary refs log tree commit diff
path: root/iconv/gconv_cache.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-07-23 09:10:36 +0000
committerUlrich Drepper <drepper@redhat.com>2001-07-23 09:10:36 +0000
commit281ebe7caea6c76ca7b00841bc8b23c2dcbc4cad (patch)
tree20780edb80136060b015c5ad20dba6a86682d45e /iconv/gconv_cache.c
parent514abd20feb847b3d2b0816f634a471c3c82c632 (diff)
downloadglibc-281ebe7caea6c76ca7b00841bc8b23c2dcbc4cad.tar.gz
glibc-281ebe7caea6c76ca7b00841bc8b23c2dcbc4cad.tar.xz
glibc-281ebe7caea6c76ca7b00841bc8b23c2dcbc4cad.zip
(__gconv_lookup_cache): Select correct module for conversion direction.
Diffstat (limited to 'iconv/gconv_cache.c')
-rw-r--r--iconv/gconv_cache.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/iconv/gconv_cache.c b/iconv/gconv_cache.c
index e204cf1377..42f41ef3d6 100644
--- a/iconv/gconv_cache.c
+++ b/iconv/gconv_cache.c
@@ -194,7 +194,6 @@ find_module (const char *directory, const char *filename,
   result->__fct = result->__shlib_handle->fct;
   result->__init_fct = result->__shlib_handle->init_fct;
   result->__end_fct = result->__shlib_handle->end_fct;
-  result->__counter = 1;
 
   result->__data = NULL;
   if (result->__init_fct != NULL)
@@ -283,6 +282,9 @@ __gconv_lookup_cache (const char *toset, const char *fromset,
 	      fromname = result[idx].__to_name =
 		(char *) strtab + modtab[extra->module[idx].outname_offset].canonname_offset;
 
+	      result[idx].__counter = 1;
+	      result[idx].__data = NULL;
+
 #ifndef STATIC_GCONV
 	      if (strtab[extra->module[idx].dir_offset] != '\0')
 		{
@@ -332,12 +334,15 @@ __gconv_lookup_cache (const char *toset, const char *fromset,
   result[0].__from_name = (char *) strtab + from_module->canonname_offset;
   result[0].__to_name = (char *) "INTERNAL";
 
+  result[0].__counter = 1;
+  result[0].__data = NULL;
+
 #ifndef STATIC_GCONV
-  if (strtab[from_module->fromdir_offset] != '\0')
+  if (strtab[from_module->todir_offset] != '\0')
     {
       /* Load the module, return handle for it.  */
-      int res = find_module (strtab + from_module->fromdir_offset,
-			     strtab + from_module->fromname_offset,
+      int res = find_module (strtab + from_module->todir_offset,
+			     strtab + from_module->toname_offset,
 			     &result[0]);
       if (__builtin_expect (res, __GCONV_OK) != __GCONV_OK)
 	{
@@ -349,19 +354,22 @@ __gconv_lookup_cache (const char *toset, const char *fromset,
   else
 #endif
     /* It's a builtin transformation.  */
-    __gconv_get_builtin_trans (strtab + from_module->fromname_offset,
+    __gconv_get_builtin_trans (strtab + from_module->toname_offset,
 			       &result[0]);
 
   /* Generate data structure for conversion from INTERNAL.  */
   result[1].__from_name = (char *) "INTERNAL";
   result[1].__to_name = (char *) strtab + to_module->canonname_offset;
 
+  result[1].__counter = 1;
+  result[1].__data = NULL;
+
 #ifndef STATIC_GCONV
-  if (strtab[to_module->todir_offset] != '\0')
+  if (strtab[to_module->fromdir_offset] != '\0')
     {
       /* Load the module, return handle for it.  */
-      int res = find_module (strtab + to_module->todir_offset,
-			     strtab + to_module->toname_offset,
+      int res = find_module (strtab + to_module->fromdir_offset,
+			     strtab + to_module->fromname_offset,
 			     &result[1]);
       if (__builtin_expect (res, __GCONV_OK) != __GCONV_OK)
 	{
@@ -374,7 +382,8 @@ __gconv_lookup_cache (const char *toset, const char *fromset,
   else
 #endif
     /* It's a builtin transformation.  */
-    __gconv_get_builtin_trans (strtab + to_module->toname_offset, &result[1]);
+    __gconv_get_builtin_trans (strtab + to_module->fromname_offset,
+			       &result[1]);
 
   return __GCONV_OK;
 }