diff options
Diffstat (limited to 'iconvdata/eucjp.c')
-rw-r--r-- | iconvdata/eucjp.c | 45 |
1 files changed, 9 insertions, 36 deletions
diff --git a/iconvdata/eucjp.c b/iconvdata/eucjp.c index caf24e27e0..4e82904c8f 100644 --- a/iconvdata/eucjp.c +++ b/iconvdata/eucjp.c @@ -20,7 +20,6 @@ #include <gconv.h> #include <stdint.h> -#include <stdlib.h> #include <string.h> #include <wchar.h> #include <jis0201.h> @@ -28,53 +27,29 @@ #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. */ } @@ -111,15 +86,13 @@ gconv (struct gconv_step *step, struct gconv_step_data *data, } 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; @@ -311,7 +284,7 @@ gconv (struct gconv_step *step, struct gconv_step_data *data, 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; |