diff options
| author | Ulrich Drepper <drepper@redhat.com> | 1998-04-13 17:54:00 +0000 |
|---|---|---|
| committer | Ulrich Drepper <drepper@redhat.com> | 1998-04-13 17:54:00 +0000 |
| commit | 2aea1d796ea60b9e49d12257dc2a94bf3dd4ef26 (patch) | |
| tree | a783a384cc0f7cfcc8225c407e8255a6c25e5816 /iconvdata | |
| parent | 40c0dc53b080fd3e1ace4fbe2cb79007babec6c3 (diff) | |
| download | glibc-2aea1d796ea60b9e49d12257dc2a94bf3dd4ef26.tar.xz glibc-2aea1d796ea60b9e49d12257dc2a94bf3dd4ef26.zip | |
Update.
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.
Diffstat (limited to 'iconvdata')
| -rw-r--r-- | iconvdata/8bit-gap.c | 49 | ||||
| -rw-r--r-- | iconvdata/8bit-generic.c | 47 | ||||
| -rw-r--r-- | iconvdata/big5.c | 46 | ||||
| -rw-r--r-- | iconvdata/euccn.c | 45 | ||||
| -rw-r--r-- | iconvdata/eucjp.c | 45 | ||||
| -rw-r--r-- | iconvdata/euckr.c | 45 | ||||
| -rw-r--r-- | iconvdata/euctw.c | 45 | ||||
| -rw-r--r-- | iconvdata/iso6937.c | 45 | ||||
| -rw-r--r-- | iconvdata/iso8859-1.c | 45 | ||||
| -rw-r--r-- | iconvdata/jis0208.h | 2 | ||||
| -rw-r--r-- | iconvdata/jis0212.c | 4 | ||||
| -rw-r--r-- | iconvdata/jis0212.h | 2 | ||||
| -rw-r--r-- | iconvdata/johab.c | 47 | ||||
| -rw-r--r-- | iconvdata/ksc5601.h | 2 | ||||
| -rw-r--r-- | iconvdata/sjis.c | 47 | ||||
| -rw-r--r-- | iconvdata/t61.c | 45 | ||||
| -rw-r--r-- | iconvdata/uhc.c | 45 |
17 files changed, 129 insertions, 477 deletions
diff --git a/iconvdata/8bit-gap.c b/iconvdata/8bit-gap.c index 1528cb6bf7..6c78ce5c24 100644 --- a/iconvdata/8bit-gap.c +++ b/iconvdata/8bit-gap.c @@ -20,8 +20,7 @@ Boston, MA 02111-1307, USA. */ #include <gconv.h> -#include <inttypes.h> -#include <stdlib.h> +#include <stdint.h> #include <string.h> @@ -35,54 +34,30 @@ struct gap /* 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. */ } @@ -119,15 +94,13 @@ gconv (struct gconv_step *step, struct gconv_step_data *data, } 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; @@ -213,7 +186,7 @@ gconv (struct gconv_step *step, struct gconv_step_data *data, 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; diff --git a/iconvdata/8bit-generic.c b/iconvdata/8bit-generic.c index 7f0bbae6b0..52cd540fb7 100644 --- a/iconvdata/8bit-generic.c +++ b/iconvdata/8bit-generic.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_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. */ } @@ -106,15 +81,13 @@ gconv (struct gconv_step *step, struct gconv_step_data *data, } 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; @@ -191,7 +164,7 @@ gconv (struct gconv_step *step, struct gconv_step_data *data, 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; diff --git a/iconvdata/big5.c b/iconvdata/big5.c index 26ea6edc67..bfd14fd5bb 100644 --- a/iconvdata/big5.c +++ b/iconvdata/big5.c @@ -19,7 +19,7 @@ Boston, MA 02111-1307, USA. */ #include <gconv.h> -#include <inttypes.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> #include <wchar.h> @@ -8412,53 +8412,29 @@ static const char from_ucs4_tab13[][2] = /* 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. */ } @@ -8492,15 +8468,13 @@ gconv (struct gconv_step *step, struct gconv_step_data *data, } 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; @@ -8686,7 +8660,7 @@ gconv (struct gconv_step *step, struct gconv_step_data *data, 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; diff --git a/iconvdata/euccn.c b/iconvdata/euccn.c index 108974a972..e8d909768b 100644 --- a/iconvdata/euccn.c +++ b/iconvdata/euccn.c @@ -20,59 +20,34 @@ #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. */ } @@ -109,15 +84,13 @@ gconv (struct gconv_step *step, struct gconv_step_data *data, } 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; @@ -267,7 +240,7 @@ gconv (struct gconv_step *step, struct gconv_step_data *data, 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; 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; diff --git a/iconvdata/euckr.c b/iconvdata/euckr.c index 62dd2c47bf..1dfa42dbcc 100644 --- a/iconvdata/euckr.c +++ b/iconvdata/euckr.c @@ -26,18 +26,8 @@ #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 @@ -66,36 +56,21 @@ int 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. */ } @@ -132,15 +107,13 @@ gconv (struct gconv_step *step, struct gconv_step_data *data, } 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; @@ -281,7 +254,7 @@ gconv (struct gconv_step *step, struct gconv_step_data *data, 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; diff --git a/iconvdata/euctw.c b/iconvdata/euctw.c index 33da1ce84c..f38db47946 100644 --- a/iconvdata/euctw.c +++ b/iconvdata/euctw.c @@ -20,60 +20,35 @@ #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. */ } @@ -110,15 +85,13 @@ gconv (struct gconv_step *step, struct gconv_step_data *data, } 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; @@ -307,7 +280,7 @@ gconv (struct gconv_step *step, struct gconv_step_data *data, 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; diff --git a/iconvdata/iso6937.c b/iconvdata/iso6937.c index 377eef5afc..30c3831a29 100644 --- a/iconvdata/iso6937.c +++ b/iconvdata/iso6937.c @@ -19,7 +19,6 @@ Boston, MA |
