about summary refs log tree commit diff
path: root/iconvdata/johab.c
diff options
context:
space:
mode:
Diffstat (limited to 'iconvdata/johab.c')
-rw-r--r--iconvdata/johab.c47
1 files changed, 10 insertions, 37 deletions
diff --git a/iconvdata/johab.c b/iconvdata/johab.c
index bde56ce1d3..51b235c924 100644
--- a/iconvdata/johab.c
+++ b/iconvdata/johab.c
@@ -19,24 +19,14 @@
    Boston, MA 02111-1307, USA.  */
 
 #include <gconv.h>
-#include <inttypes.h>
-#include <stdlib.h>
+#include <stdint.h>
 #include <string.h>
 #include <wchar.h>
 #include <ksc5601.h>
 
 /* Direction of the transformation.  */
-enum direction
-  {
-    illegal,
-    to_johab,
-    from_johab
-  };
-
-struct johab_data
-  {
-    enum direction dir;
-  };
+static int to_johab_object;
+static int from_johab_object;
 
 /* The table for Bit pattern to Hangul Jamo
    5 bits each are used to encode
@@ -242,36 +232,21 @@ int
 gconv_init (struct gconv_step *step)
 {
   /* Determine which direction.  */
-  struct johab_data *new_data;
-  enum direction dir;
-  int result;
-
   if (strcasestr (step->from_name, "JOHAB") != NULL)
-    dir = from_johab;
+    step->data = &from_johab_object;
   else if (strcasestr (step->to_name, "JOHAB") != NULL)
-    dir = to_johab;
+    step->data = &to_johab_object;
   else
-    dir = illegal;
+    return GCONV_NOCONV;
 
-  result = GCONV_NOCONV;
-  if (dir != illegal
-      && ((new_data
-	   = (struct johab_data *) malloc (sizeof (struct johab_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.  */
 }
 
 
@@ -308,15 +283,13 @@ gconv (struct gconv_step *step, struct gconv_step_data *data,
     }
   else
     {
-      enum direction dir = ((struct johab_data *) step->data)->dir;
-
       do_write = 0;
 
       do
 	{
 	  result = GCONV_OK;
 
-	  if (dir == from_johab)
+	  if (step->data == &from_johab_object)
 	    {
 	      size_t inchars = *inbufsize;
 	      size_t outwchars = data->outbufavail;
@@ -517,7 +490,7 @@ gconv (struct gconv_step *step, struct gconv_step_data *data,
 	  if (data->is_last)
 	    {
 	      /* This is the last step.  */
-	      result = (*inbufsize > (dir == from_johab
+	      result = (*inbufsize > (step->data == &from_johab_object
 				      ? 0 : sizeof (wchar_t) - 1)
 			? GCONV_FULL_OUTPUT : GCONV_EMPTY_INPUT);
 	      break;