aboutsummaryrefslogtreecommitdiff
path: root/iconvdata/sjis.c
diff options
context:
space:
mode:
Diffstat (limited to 'iconvdata/sjis.c')
-rw-r--r--iconvdata/sjis.c47
1 files changed, 10 insertions, 37 deletions
diff --git a/iconvdata/sjis.c b/iconvdata/sjis.c
index b1320c1..7a81c01 100644
--- a/iconvdata/sjis.c
+++ b/iconvdata/sjis.c
@@ -19,8 +19,7 @@
Boston, MA 02111-1307, USA. */
#include <gconv.h>
-#include <inttypes.h>
-#include <stdlib.h>
+#include <stdint.h>
#include <string.h>
#include <wchar.h>
@@ -3983,53 +3982,29 @@ static const char from_ucs4_cjk[32657][2] =
/* 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. */
}
@@ -4063,15 +4038,13 @@ gconv (struct gconv_step *step, struct gconv_step_data *data,
}
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;
@@ -4236,7 +4209,7 @@ gconv (struct gconv_step *step, struct gconv_step_data *data,
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;