about summary refs log tree commit diff
path: root/iconvdata/euctw.c
diff options
context:
space:
mode:
Diffstat (limited to 'iconvdata/euctw.c')
-rw-r--r--iconvdata/euctw.c45
1 files changed, 9 insertions, 36 deletions
diff --git a/iconvdata/euctw.c b/iconvdata/euctw.c
index 33da1ce84c..f38db47946 100644
--- a/iconvdata/euctw.c
+++ b/iconvdata/euctw.c
@@ -20,60 +20,35 @@
 
 #include <gconv.h>
 #include <stdint.h>
-#include <stdlib.h>
 #include <string.h>
 #include <wchar.h>
 #include <cns11643l1.h>
 #include <cns11643.h>
 
 /* Direction of the transformation.  */
-enum direction
-{
-  illegal,
-  to_euctw,
-  from_euctw
-};
-
-struct euctw_data
-{
-  enum direction dir;
-};
+static int to_euctw_object;
+static int from_euctw_object;
 
 
 int
 gconv_init (struct gconv_step *step)
 {
   /* Determine which direction.  */
-  struct euctw_data *new_data;
-  enum direction dir;
-  int result;
-
   if (strcasestr (step->from_name, "EUC-TW") != NULL)
-    dir = from_euctw;
+    step->data = &from_euctw_object;
   else if (strcasestr (step->to_name, "EUC-TW") != NULL)
-    dir = to_euctw;
+    step->data = &to_euctw_object;
   else
-    dir = illegal;
+    return GCONV_NOCONV;
 
-  result = GCONV_NOCONV;
-  if (dir != illegal
-      && ((new_data
-	   = (struct euctw_data *) malloc (sizeof (struct euctw_data)))
-	  != NULL))
-    {
-      new_data->dir = dir;
-      step->data = new_data;
-      result = GCONV_OK;
-    }
-
-  return result;
+  return GCONV_OK;
 }
 
 
 void
 gconv_end (struct gconv_step *data)
 {
-  free (data->data);
+  /* Nothing to do.  */
 }
 
 
@@ -110,15 +85,13 @@ gconv (struct gconv_step *step, struct gconv_step_data *data,
     }
   else
     {
-      enum direction dir = ((struct euctw_data *) step->data)->dir;
-
       do_write = 0;
 
       do
 	{
 	  result = GCONV_OK;
 
-	  if (dir == from_euctw)
+	  if (step->data == &from_euctw_object)
 	    {
 	      size_t inchars = *inbufsize;
 	      size_t outwchars = data->outbufavail;
@@ -307,7 +280,7 @@ gconv (struct gconv_step *step, struct gconv_step_data *data,
 	  if (data->is_last)
 	    {
 	      /* This is the last step.  */
-	      result = (*inbufsize > (dir == from_euctw
+	      result = (*inbufsize > (step->data == &from_euctw_object
 				      ? 0 : sizeof (wchar_t) - 1)
 			? GCONV_FULL_OUTPUT : GCONV_EMPTY_INPUT);
 	      break;