projects
/
kopensolaris-gnu
/
glibc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Simplify step data handling.
[kopensolaris-gnu/glibc.git]
/
iconvdata
/
8bit-gap.c
diff --git
a/iconvdata/8bit-gap.c
b/iconvdata/8bit-gap.c
index
301bd6b
..
6c78ce5
100644
(file)
--- a/
iconvdata/8bit-gap.c
+++ b/
iconvdata/8bit-gap.c
@@
-20,8
+20,7
@@
Boston, MA 02111-1307, USA. */
#include <gconv.h>
Boston, MA 02111-1307, USA. */
#include <gconv.h>
-#include <inttypes.h>
-#include <stdlib.h>
+#include <stdint.h>
#include <string.h>
#include <string.h>
@@
-35,54
+34,30
@@
struct gap
/* Now we can include the tables. */
#include TABLES
/* 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
int
-gconv_init (struct gconv_step *step
, struct gconv_step_data *data
)
+gconv_init (struct gconv_step *step)
{
/* Determine which direction. */
{
/* Determine which direction. */
- struct s_8bit_data *new_data;
- enum direction dir;
- int result;
-
if (strcasestr (step->from_name, NAME) != NULL)
if (strcasestr (step->from_name, NAME) != NULL)
-
dir = from_8bi
t;
+
step->data = &from_8bit_objec
t;
else if (strcasestr (step->to_name, NAME) != NULL)
else if (strcasestr (step->to_name, NAME) != NULL)
-
dir = to_8bi
t;
+
step->data = &to_8bit_objec
t;
else
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;
- data->data = new_data;
- result = GCONV_OK;
- }
+ return GCONV_NOCONV;
- return
result
;
+ return
GCONV_OK
;
}
void
}
void
-gconv_end (struct gconv_step
_data
*data)
+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
{
}
else
{
- enum direction dir = ((struct s_8bit_data *) data->data)->dir;
-
do_write = 0;
do
{
result = GCONV_OK;
do_write = 0;
do
{
result = GCONV_OK;
- if (
dir == from_8bi
t)
+ if (
step->data == &from_8bit_objec
t)
{
size_t inchars = *inbufsize;
size_t outwchars = data->outbufavail;
{
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. */
if (data->is_last)
{
/* This is the last step. */
- result = (*inbufsize > (
dir == from_8bi
t
+ result = (*inbufsize > (
step->data == &from_8bit_objec
t
? 0 : sizeof (wchar_t) - 1)
? GCONV_FULL_OUTPUT : GCONV_EMPTY_INPUT);
break;
? 0 : sizeof (wchar_t) - 1)
? GCONV_FULL_OUTPUT : GCONV_EMPTY_INPUT);
break;