about summary refs log tree commit diff
path: root/iconv/gconv_open.c
diff options
context:
space:
mode:
Diffstat (limited to 'iconv/gconv_open.c')
-rw-r--r--iconv/gconv_open.c152
1 files changed, 9 insertions, 143 deletions
diff --git a/iconv/gconv_open.c b/iconv/gconv_open.c
index bfbe22bff6..615f33dfd2 100644
--- a/iconv/gconv_open.c
+++ b/iconv/gconv_open.c
@@ -39,7 +39,7 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle,
   int conv_flags = 0;
   const char *errhand;
   const char *ignore;
-  struct trans_struct *trans = NULL;
+  bool translit = false;
 
   /* Find out whether any error handling method is specified.  */
   errhand = strchr (toset, '/');
@@ -66,72 +66,10 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle,
 	  while (tok != NULL)
 	    {
 	      if (__strcasecmp_l (tok, "TRANSLIT", _nl_C_locobj_ptr) == 0)
-		{
-		  /* It's the builtin transliteration handling.  We only
-		     support it for working on the internal encoding.  */
-		  static const char *const internal_trans_names[1]
-		    = { "INTERNAL" };
-		  struct trans_struct *lastp = NULL;
-		  struct trans_struct *runp;
-
-		  for (runp = trans; runp != NULL; runp = runp->next)
-		    if (runp->trans_fct == __gconv_transliterate)
-		      break;
-		    else
-		      lastp = runp;
-
-		  if (runp == NULL)
-		    {
-		      struct trans_struct *newp;
-
-		      newp = (struct trans_struct *) alloca (sizeof (*newp));
-		      memset (newp, '\0', sizeof (*newp));
-
-		      /* We leave the `name' field zero to signal that
-			 this is an internal transliteration step.  */
-		      newp->csnames = (const char **) internal_trans_names;
-		      newp->ncsnames = 1;
-		      newp->trans_fct = __gconv_transliterate;
-
-		      if (lastp == NULL)
-			trans = newp;
-		      else
-			lastp->next = newp;
-		    }
-		}
+		translit = true;
 	      else if (__strcasecmp_l (tok, "IGNORE", _nl_C_locobj_ptr) == 0)
 		/* Set the flag to ignore all errors.  */
 		conv_flags |= __GCONV_IGNORE_ERRORS;
-	      else
-		{
-		  /* `tok' is possibly a module name.  We'll see later
-		     whether we can find it.  But first see that we do
-		     not already a module of this name.  */
-		  struct trans_struct *lastp = NULL;
-		  struct trans_struct *runp;
-
-		  for (runp = trans; runp != NULL; runp = runp->next)
-		    if (runp->name != NULL
-			&& __strcasecmp_l (tok, runp->name,
-					   _nl_C_locobj_ptr) == 0)
-		      break;
-		    else
-		      lastp = runp;
-
-		  if (runp == NULL)
-		    {
-		      struct trans_struct *newp;
-
-		      newp = (struct trans_struct *) alloca (sizeof (*newp));
-		      memset (newp, '\0', sizeof (*newp));
-		      newp->name = tok;
-
-		      if (lastp == NULL)
-			trans = newp;
-		      else
-			lastp->next = newp;
-		    }
-		}
 
 	      tok = __strtok_r (NULL, ",", &ptr);
 	    }
@@ -172,25 +110,6 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle,
   res = __gconv_find_transform (toset, fromset, &steps, &nsteps, flags);
   if (res == __GCONV_OK)
     {
-      /* Find the modules.  */
-      struct trans_struct *lastp = NULL;
-      struct trans_struct *runp;
-
-      for (runp = trans; runp != NULL; runp = runp->next)
-	{
-	  if (runp->name == NULL
-	      || __builtin_expect (__gconv_translit_find (runp), 0) == 0)
-	    lastp = runp;
-	  else
-	    {
-	      /* This means we haven't found the module.  Remove it.  */
-	      if (lastp == NULL)
-		trans  = runp->next;
-	      else
-		lastp->next  = runp->next;
-	    }
-	}
-
       /* Allocate room for handle.  */
       result = (__gconv_t) malloc (sizeof (struct __gconv_info)
 				   + (nsteps
@@ -199,8 +118,6 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle,
 	res = __GCONV_NOMEM;
       else
 	{
-	  size_t n;
-
 	  /* Remember the list of steps.  */
 	  result->__steps = steps;
 	  result->__nsteps = nsteps;
@@ -228,47 +145,12 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle,
 	      /* We use the `mbstate_t' member in DATA.  */
 	      result->__data[cnt].__statep = &result->__data[cnt].__state;
 
-	      /* Now see whether we can use any of the transliteration
-		 modules for this step.  */
-	      for (runp = trans; runp != NULL; runp = runp->next)
-		for (n = 0; n < runp->ncsnames; ++n)
-		  if (__strcasecmp_l (steps[cnt].__from_name,
-				      runp->csnames[n], _nl_C_locobj_ptr) == 0)
-		    {
-		      void *data = NULL;
-
-		      /* Match!  Now try the initializer.  */
-		      if (runp->trans_init_fct == NULL
-			  || (runp->trans_init_fct (&data,
-						    steps[cnt].__to_name)
-			      == __GCONV_OK))
-			{
-			  /* Append at the end of the list.  */
-			  struct __gconv_trans_data *newp;
-			  struct __gconv_trans_data **lastp;
-
-			  newp = (struct __gconv_trans_data *)
-			    malloc (sizeof (struct __gconv_trans_data));
-			  if (newp == NULL)
-			    {
-			      res = __GCONV_NOMEM;
-			      goto bail;
-			    }
-
-			  newp->__trans_fct = runp->trans_fct;
-			  newp->__trans_context_fct = runp->trans_context_fct;
-			  newp->__trans_end_fct = runp->trans_end_fct;
-			  newp->__data = data;
-			  newp->__next = NULL;
-
-			  lastp = &result->__data[cnt].__trans;
-			  while (*lastp != NULL)
-			    lastp = &(*lastp)->__next;
-
-			  *lastp = newp;
-			}
-		      break;
-		    }
+	      /* The builtin transliteration handling only
+		 supports the internal encoding.  */
+	      if (translit
+		  && __strcasecmp_l (steps[cnt].__from_name,
+				     "INTERNAL", _nl_C_locobj_ptr) == 0)
+		conv_flags |= __GCONV_TRANSLIT;
 
 	      /* If this is the last step we must not allocate an
 		 output buffer.  */
@@ -309,23 +191,7 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle,
 	  if (result != NULL)
 	    {
 	      while (cnt-- > 0)
-		{
-		  struct __gconv_trans_data *transp;
-
-		  transp = result->__data[cnt].__trans;
-		  while (transp != NULL)
-		    {
-		      struct __gconv_trans_data *curp = transp;
-		      transp = transp->__next;
-
-		      if (__glibc_unlikely (curp->__trans_end_fct != NULL))
-			curp->__trans_end_fct (curp->__data);
-
-		      free (curp);
-		    }
-
-		  free (result->__data[cnt].__outbuf);
-		}
+		free (result->__data[cnt].__outbuf);
 
 	      free (result);
 	      result = NULL;