+1998-04-13 17:40 Ulrich Drepper <drepper@cygnus.com>
+
+ * iconvdata/8bit-gap.c: Simplify step data handling.
+ * iconvdata/8bit-generic.c: Likewise.
+ * iconvdata/big5.c: Likewise.
+ * iconvdata/euccn.c: Likewise.
+ * iconvdata/eucjp.c: Likewise.
+ * iconvdata/euckr.c: Likewise.
+ * iconvdata/euctw.c: Likewise.
+ * iconvdata/iso6937.c: Likewise.
+ * iconvdata/iso8859-1.c: Likewise.
+ * iconvdata/jis0208.h: Likewise.
+ * iconvdata/jis0212.c: Likewise.
+ * iconvdata/jis0212.h: Likewise.
+ * iconvdata/johab.c: Likewise.
+ * iconvdata/ksc5601.h: Likewise.
+ * iconvdata/sjis.c: Likewise.
+ * iconvdata/t61.c: Likewise.
+ * iconvdata/uhc.c: Likewise.
+
1998-04-13 16:36 Ulrich Drepper <drepper@cygnus.com>
* manual/texinfo.texi: Updated from last version.
Boston, MA 02111-1307, USA. */
#include <gconv.h>
-#include <inttypes.h>
-#include <stdlib.h>
+#include <stdint.h>
#include <string.h>
/* Now we can include the tables. */
#include TABLES
-/* Direction of the transformation. */
-enum direction
-{
- illegal,
- to_8bit,
- from_8bit
-};
-
-struct s_8bit_data
-{
- enum direction dir;
-};
+/* We use three objects to describe the operation mode. */
+static int from_8bit_object;
+static int to_8bit_object;
int
gconv_init (struct gconv_step *step)
{
/* Determine which direction. */
- struct s_8bit_data *new_data;
- enum direction dir;
- int result;
-
if (strcasestr (step->from_name, NAME) != NULL)
- dir = from_8bit;
+ step->data = &from_8bit_object;
else if (strcasestr (step->to_name, NAME) != NULL)
- dir = to_8bit;
+ step->data = &to_8bit_object;
else
- dir = illegal;
-
- result = GCONV_NOCONV;
- if (dir != illegal
- && ((new_data
- = (struct s_8bit_data *) malloc (sizeof (struct s_8bit_data)))
- != NULL))
- {
- new_data->dir = dir;
- step->data = new_data;
- result = GCONV_OK;
- }
+ return GCONV_NOCONV;
- return result;
+ return GCONV_OK;
}
void
gconv_end (struct gconv_step *data)
{
- free (data->data);
+ /* Nothing to do. */
}
}
else
{
- enum direction dir = ((struct s_8bit_data *) step->data)->dir;
-
do_write = 0;
do
{
result = GCONV_OK;
- if (dir == from_8bit)
+ if (step->data == &from_8bit_object)
{
size_t inchars = *inbufsize;
size_t outwchars = data->outbufavail;
if (data->is_last)
{
/* This is the last step. */
- result = (*inbufsize > (dir == from_8bit
+ result = (*inbufsize > (step->data == &from_8bit_object
? 0 : sizeof (wchar_t) - 1)
? GCONV_FULL_OUTPUT : GCONV_EMPTY_INPUT);
break;
Boston, MA 02111-1307, USA. */
#include <gconv.h>
-#include <stdlib.h>
#include <string.h>
-/* Direction of the transformation. */
-enum direction
-{
- illegal,
- to_8bit,
- from_8bit
-};
-
-struct s_8bit_data
-{
- enum direction dir;
-};
+/* We use three objects to describe the operation mode. */
+static int from_8bit_object;
+static int to_8bit_object;
int
gconv_init (struct gconv_step *step)
{
/* Determine which direction. */
- struct s_8bit_data *new_data;
- enum direction dir;
- int result;
-
if (strcasestr (step->from_name, NAME) != NULL)
- dir = from_8bit;
+ step->data = &from_8bit_object;
else if (strcasestr (step->to_name, NAME) != NULL)
- dir = to_8bit;
+ step->data = &to_8bit_object;
else
- dir = illegal;
+ return GCONV_NOCONV;
- result = GCONV_NOCONV;
- if (dir != illegal
- && ((new_data
- = (struct s_8bit_data *) malloc (sizeof (struct s_8bit_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. */
}
}
else
{
- enum direction dir = ((struct s_8bit_data *) step->data)->dir;
-
do_write = 0;
do
{
result = GCONV_OK;
- if (dir == from_8bit)
+ if (step->data == &from_8bit_object)
{
size_t inchars = *inbufsize;
size_t outwchars = data->outbufavail;
if (data->is_last)
{
/* This is the last step. */
- result = (*inbufsize > (dir == from_8bit
+ result = (*inbufsize > (step->data == &from_8bit_object
? 0 : sizeof (wchar_t) - 1)
? GCONV_FULL_OUTPUT : GCONV_EMPTY_INPUT);
break;
Boston, MA 02111-1307, USA. */
#include <gconv.h>
-#include <inttypes.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
/* Direction of the transformation. */
-enum direction
-{
- illegal,
- to_big5,
- from_big5
-};
-
-struct big5_data
-{
- enum direction dir;
-};
+static int to_big5_object;
+static int from_big5_object;
int
gconv_init (struct gconv_step *step)
{
/* Determine which direction. */
- struct big5_data *new_data;
- enum direction dir;
- int result;
-
if (strcasestr (step->from_name, "BIG5") != NULL)
- dir = from_big5;
+ step->data = &from_big5_object;
else if (strcasestr (step->to_name, "BIG5") != NULL)
- dir = to_big5;
+ step->data = &to_big5_object;
else
- dir = illegal;
-
- result = GCONV_NOCONV;
- if (dir != illegal
- && ((new_data
- = (struct big5_data *) malloc (sizeof (struct big5_data)))
- != NULL))
- {
- new_data->dir = dir;
- step->data = new_data;
- result = GCONV_OK;
- }
+ return GCONV_NOCONV;
- return result;
+ return GCONV_OK;
}
void
gconv_end (struct gconv_step *data)
{
- free (data->data);
+ /* Nothing to do. */
}
}
else
{
- enum direction dir = ((struct big5_data *) step->data)->dir;
-
do_write = 0;
do
{
result = GCONV_OK;
- if (dir == from_big5)
+ if (step->data == &from_big5_object)
{
size_t inchars = *inbufsize;
size_t outwchars = data->outbufavail;
if (data->is_last)
{
/* This is the last step. */
- result = (*inbufsize > (dir == from_big5
+ result = (*inbufsize > (step->data == &from_big5_object
? 0 : sizeof (wchar_t) - 1)
? GCONV_FULL_OUTPUT : GCONV_EMPTY_INPUT);
break;
#include <gconv.h>
#include <stdint.h>
-#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include <gb2312.h>
/* Direction of the transformation. */
-enum direction
-{
- illegal,
- to_euccn,
- from_euccn
-};
-
-struct euccn_data
-{
- enum direction dir;
-};
+static int to_euccn_object;
+static int from_euccn_object;
int
gconv_init (struct gconv_step *step)
{
/* Determine which direction. */
- struct euccn_data *new_data;
- enum direction dir;
- int result;
-
if (strcasestr (step->from_name, "EUC-CN") != NULL)
- dir = from_euccn;
+ step->data = &from_euccn_object;
else if (strcasestr (step->to_name, "EUC-CN") != NULL)
- dir = to_euccn;
+ step->data = &to_euccn_object;
else
- dir = illegal;
+ return GCONV_NOCONV;
- result = GCONV_NOCONV;
- if (dir != illegal
- && ((new_data
- = (struct euccn_data *) malloc (sizeof (struct euccn_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. */
}
}
else
{
- enum direction dir = ((struct euccn_data *) step->data)->dir;
-
do_write = 0;
do
{
result = GCONV_OK;
- if (dir == from_euccn)
+ if (step->data == &from_euccn_object)
{
size_t inchars = *inbufsize;
size_t outwchars = data->outbufavail;
if (data->is_last)
{
/* This is the last step. */
- result = (*inbufsize > (dir == from_euccn
+ result = (*inbufsize > (step->data == &from_euccn_object
? 0 : sizeof (wchar_t) - 1)
? GCONV_FULL_OUTPUT : GCONV_EMPTY_INPUT);
break;
#include <gconv.h>
#include <stdint.h>
-#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include <jis0201.h>
#include <jis0212.h>
/* Direction of the transformation. */
-enum direction
-{
- illegal,
- to_eucjp,
- from_eucjp
-};
-
-struct eucjp_data
-{
- enum direction dir;
-};
+static int to_eucjp_object;
+static int from_eucjp_object;
int
gconv_init (struct gconv_step *step)
{
/* Determine which direction. */
- struct eucjp_data *new_data;
- enum direction dir;
- int result;
-
if (strcasestr (step->from_name, "EUC-JP") != NULL)
- dir = from_eucjp;
+ step->data = &from_eucjp_object;
else if (strcasestr (step->to_name, "EUC-JP") != NULL)
- dir = to_eucjp;
+ step->data = &to_eucjp_object;
else
- dir = illegal;
+ return GCONV_NOCONV;
- result = GCONV_NOCONV;
- if (dir != illegal
- && ((new_data
- = (struct eucjp_data *) malloc (sizeof (struct eucjp_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. */
}
}
else
{
- enum direction dir = ((struct eucjp_data *) step->data)->dir;
-
do_write = 0;
do
{
result = GCONV_OK;
- if (dir == from_eucjp)
+ if (step->data == &from_eucjp_object)
{
size_t inchars = *inbufsize;
size_t outwchars = data->outbufavail;
if (data->is_last)
{
/* This is the last step. */
- result = (*inbufsize > (dir == from_eucjp
+ result = (*inbufsize > (step->data == &from_eucjp_object
? 0 : sizeof (wchar_t) - 1)
? GCONV_FULL_OUTPUT : GCONV_EMPTY_INPUT);
break;
#include <ksc5601.h>
/* Direction of the transformation. */
-enum direction
-{
- illegal,
- to_euckr,
- from_euckr
-};
-
-struct euckr_data
-{
- enum direction dir;
-};
-
+static int to_euckr_object;
+static int from_euckr_object;
static inline void
gconv_init (struct gconv_step *step)
{
/* Determine which direction. */
- struct euckr_data *new_data;
- enum direction dir;
- int result;
-
if (strcasestr (step->from_name, "EUC-KR") != NULL)
- dir = from_euckr;
+ step->data = &from_euckr_object;
else if (strcasestr (step->to_name, "EUC-KR") != NULL)
- dir = to_euckr;
+ step->data = &to_euckr_object;
else
- dir = illegal;
+ return GCONV_NOCONV;
- result = GCONV_NOCONV;
- if (dir != illegal
- && ((new_data
- = (struct euckr_data *) malloc (sizeof (struct euckr_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. */
}
}
else
{
- enum direction dir = ((struct euckr_data *) step->data)->dir;
-
do_write = 0;
do
{
result = GCONV_OK;
- if (dir == from_euckr)
+ if (step->data == &from_euckr_object)
{
size_t inchars = *inbufsize;
size_t outwchars = data->outbufavail;
if (data->is_last)
{
/* This is the last step. */
- result = (*inbufsize > (dir == from_euckr
+ result = (*inbufsize > (step->data == &from_euckr_object
? 0 : sizeof (wchar_t) - 1)
? GCONV_FULL_OUTPUT : GCONV_EMPTY_INPUT);
break;
#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. */
}
}
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;
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;
Boston, MA 02111-1307, USA. */
#include <gconv.h>
-#include <stdlib.h>
#include <string.h>
/* Data taken from the WG15 tables. */
};
/* Direction of the transformation. */
-enum direction
-{
- illegal,
- to_iso6937,
- from_iso6937
-};
-
-struct iso6937_data
-{
- enum direction dir;
-};
+static int to_iso6937_object;
+static int from_iso6937_object;
int
gconv_init (struct gconv_step *step)
{
/* Determine which direction. */
- struct iso6937_data *new_data;
- enum direction dir;
- int result;
-
if (strcasestr (step->from_name, "ISO_6937") != NULL)
- dir = from_iso6937;
+ step->data = &from_iso6937_object;
else if (strcasestr (step->to_name, "ISO_6937") != NULL)
- dir = to_iso6937;
+ step->data = &to_iso6937_object;
else
- dir = illegal;
-
- result = GCONV_NOCONV;
- if (dir != illegal
- && ((new_data
- = (struct iso6937_data *) malloc (sizeof (struct iso6937_data)))
- != NULL))
- {
- new_data->dir = dir;
- step->data = new_data;
- result = GCONV_OK;
- }
+ return GCONV_NOCONV;
- return result;
+ return GCONV_OK;
}
void
gconv_end (struct gconv_step *data)
{
- free (data->data);
+ /* Nothign to do. */
}
}
else
{
- enum direction dir = ((struct iso6937_data *) step->data)->dir;
-
do_write = 0;
do
{
result = GCONV_OK;
- if (dir == from_iso6937)
+ if (step->data == &from_iso6937_object)
{
size_t inchars = *inbufsize;
size_t outwchars = data->outbufavail;
if (data->is_last)
{
/* This is the last step. */
- result = (*inbufsize > (dir == from_iso6937
+ result = (*inbufsize > (step->data == &from_iso6937_object
? 0 : sizeof (wchar_t) - 1)
? GCONV_FULL_OUTPUT : GCONV_EMPTY_INPUT);
break;
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. */
}
}
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;
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;
#define _JIS0208_H 1
#include <gconv.h>
-#include <inttypes.h>
+#include <stdint.h>
/* Conversion table. */
extern const uint16_t jis0208_to_ucs[];
/* Mapping tables for JIS0212 handling.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <inttypes.h>
+#include <stdint.h>
#include <wchar.h>
#include <jis0212.h>
#define _JIS0212_H 1
#include <gconv.h>
-#include <inttypes.h>
+#include <stdint.h>
/* Struct for table with indeces in mapping table. */
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
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. */
}
}
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;
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;
#define KSC5601_SYMBOL 986
#include <gconv.h>
-#include <inttypes.h>
+#include <stdint.h>
/* Conversion table. */
extern const uint16_t ksc5601_hangul_to_ucs[KSC5601_HANGUL];
Boston, MA 02111-1307, USA. */
#include <gconv.h>
-#include <inttypes.h>
-#include <stdlib.h>
+#include <stdint.h>
#include <string.h>
#include <wchar.h>
/* Direction of the transformation. */
-enum direction
-{
- illegal,
- to_sjis,
- from_sjis
-};
-
-struct sjis_data
-{
- enum direction dir;
-};
+static int to_sjis_object;
+static int from_sjis_object;
int
gconv_init (struct gconv_step *step)
{
/* Determine which direction. */
- struct sjis_data *new_data;
- enum direction dir;
- int result;
-
if (strcasestr (step->from_name, "SJIS") != NULL)
- dir = from_sjis;
+ step->data = &from_sjis_object;
else if (strcasestr (step->to_name, "SJIS") != NULL)
- dir = to_sjis;
+ step->data = &to_sjis_object;
else
- dir = illegal;
-
- result = GCONV_NOCONV;
- if (dir != illegal
- && ((new_data
- = (struct sjis_data *) malloc (sizeof (struct sjis_data)))
- != NULL))
- {
- new_data->dir = dir;
- step->data = new_data;
- result = GCONV_OK;
- }
+ return GCONV_NOCONV;
- return result;
+ return GCONV_OK;
}
void
gconv_end (struct gconv_step *data)
{
- free (data->data);
+ /* Nothing to do. */
}
}
else
{
- enum direction dir = ((struct sjis_data *) step->data)->dir;
-
do_write = 0;
do
{
result = GCONV_OK;
- if (dir == from_sjis)
+ if (step->data == &from_sjis_object)
{
size_t inchars = *inbufsize;
size_t outwchars = data->outbufavail;
if (data->is_last)
{
/* This is the last step. */
- result = (*inbufsize > (dir == from_sjis
+ result = (*inbufsize > (step->data == &from_sjis_object
? 0 : sizeof (wchar_t) - 1)
? GCONV_FULL_OUTPUT : GCONV_EMPTY_INPUT);
break;
Boston, MA 02111-1307, USA. */
#include <gconv.h>
-#include <stdlib.h>
#include <string.h>
/* Data taken from the WG15 tables. */
};
/* Direction of the transformation. */
-enum direction
-{
- illegal,
- to_t61,
- from_t61
-};
-
-struct t61_data
-{
- enum direction dir;
-};
+static int to_t61_object;
+static int from_t61_object;
int
gconv_init (struct gconv_step *step)
{
/* Determine which direction. */
- struct t61_data *new_data;
- enum direction dir;
- int result;
-
if (strcasestr (step->from_name, "T.61") != NULL)
- dir = from_t61;
+ step->data = &from_t61_object;
else if (strcasestr (step->to_name, "T.61") != NULL)
- dir = to_t61;
+ step->data = &to_t61_object;
else
- dir = illegal;
-
- result = GCONV_NOCONV;
- if (dir != illegal
- && ((new_data
- = (struct t61_data *) malloc (sizeof (struct t61_data)))
- != NULL))
- {
- new_data->dir = dir;
- step->data = new_data;
- result = GCONV_OK;
- }
+ return GCONV_NOCONV;
- return result;
+ return GCONV_OK;
}
void
gconv_end (struct gconv_step *data)
{
- free (data->data);
+ /* Nothing to do. */
}
}
else
{
- enum direction dir = ((struct t61_data *) step->data)->dir;
-
do_write = 0;
do
{
result = GCONV_OK;
- if (dir == from_t61)
+ if (step->data == &from_t61_object)
{
size_t inchars = *inbufsize;
size_t outwchars = data->outbufavail;
if (data->is_last)
{
/* This is the last step. */
- result = (*inbufsize > (dir == from_t61
+ result = (*inbufsize > (step->data == &from_t61_object
? 0 : sizeof (wchar_t) - 1)
? GCONV_FULL_OUTPUT : GCONV_EMPTY_INPUT);
break;
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_uhc,
- from_uhc
-};
+static int to_uhc_object;
+static int from_uhc_object;
-struct uhc_data
-{
- enum direction dir;
-};
/*
egrep \
gconv_init (struct gconv_step *step)
{
/* Determine which direction. */
- struct uhc_data *new_data;
- enum direction dir;
- int result;
-
if (strcasestr (step->from_name, "UHC") != NULL)
- dir = from_uhc;
+ step->data = &from_uhc_object;
else if (strcasestr (step->to_name, "UHC") != NULL)
- dir = to_uhc;
+ step->data = &to_uhc_object;
else
- dir = illegal;
+ return GCONV_NOCONV;
- result = GCONV_NOCONV;
- if (dir != illegal
- && ((new_data
- = (struct uhc_data *) malloc (sizeof (struct uhc_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. */
}
}
else
{
- enum direction dir = ((struct uhc_data *) step->data)->dir;
-
do_write = 0;
do
{
result = GCONV_OK;
- if (dir == from_uhc)
+ if (step->data == &from_uhc_object)
{
size_t inchars = *inbufsize;
size_t outwchars = data->outbufavail;
if (data->is_last)
{
/* This is the last step. */
- result = (*inbufsize > (dir == from_uhc
+ result = (*inbufsize > (step->data == &from_uhc_object
? 0 : sizeof (wchar_t) - 1)
? GCONV_FULL_OUTPUT : GCONV_EMPTY_INPUT);
break;