summary refs log tree commit diff
path: root/iconvdata/iso8859-1.c
diff options
context:
space:
mode:
Diffstat (limited to 'iconvdata/iso8859-1.c')
-rw-r--r--iconvdata/iso8859-1.c45
1 files changed, 9 insertions, 36 deletions
diff --git a/iconvdata/iso8859-1.c b/iconvdata/iso8859-1.c
index cdeb526d7a..ab69c4d1a4 100644
--- a/iconvdata/iso8859-1.c
+++ b/iconvdata/iso8859-1.c
@@ -19,57 +19,32 @@
    Boston, MA 02111-1307, USA.  */
 
 #include <gconv.h>
-#include <stdlib.h>
 #include <string.h>
 
 /* Direction of the transformation.  */
-enum direction
-{
-  illegal,
-  to_iso88591,
-  from_iso88591
-};
-
-struct iso88591_data
-{
-  enum direction dir;
-};
+static int to_iso88591_object;
+static int from_iso88591_object;
 
 
 int
 gconv_init (struct gconv_step *step)
 {
   /* Determine which direction.  */
-  struct iso88591_data *new_data;
-  enum direction dir;
-  int result;
-
   if (strcasestr (step->from_name, "ISO-8859-1") != NULL)
-    dir = from_iso88591;
+    step->data = &from_iso88591_object;
   else if (strcasestr (step->to_name, "ISO-8859-1") != NULL)
-    dir = to_iso88591;
+    step->data = &to_iso88591_object;
   else
-    dir = illegal;
+    return GCONV_NOCONV;
 
-  result = GCONV_NOCONV;
-  if (dir != illegal
-      && ((new_data
-	   = (struct iso88591_data *) malloc (sizeof (struct iso88591_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.  */
 }
 
 
@@ -106,15 +81,13 @@ gconv (struct gconv_step *step, struct gconv_step_data *data,
     }
   else
     {
-      enum direction dir = ((struct iso88591_data *) step->data)->dir;
-
       do_write = 0;
 
       do
 	{
 	  result = GCONV_OK;
 
-	  if (dir == from_iso88591)
+	  if (step->data == &from_iso88591_object)
 	    {
 	      size_t inchars = *inbufsize;
 	      size_t outwchars = data->outbufavail;
@@ -184,7 +157,7 @@ gconv (struct gconv_step *step, struct gconv_step_data *data,
 	  if (data->is_last)
 	    {
 	      /* This is the last step.  */
-	      result = (*inbufsize > (dir == from_iso88591
+	      result = (*inbufsize > (step->data == &from_iso88591_object
 				      ? 0 : sizeof (wchar_t) - 1)
 			? GCONV_FULL_OUTPUT : GCONV_EMPTY_INPUT);
 	      break;