aboutsummaryrefslogtreecommitdiff
path: root/iconv/gconv_open.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-07-12 20:06:44 +0000
committerUlrich Drepper <drepper@redhat.com>2000-07-12 20:06:44 +0000
commit9f835f5fb48eb6e173a7ca3c678595dba28c5e7a (patch)
tree34f261d68fe97fc358f706dc8883ecfdfd450caf /iconv/gconv_open.c
parent50a6564365575ba9d20a6cfde261ec5fcbb9ff35 (diff)
downloadglibc-9f835f5fb48eb6e173a7ca3c678595dba28c5e7a.zip
glibc-9f835f5fb48eb6e173a7ca3c678595dba28c5e7a.tar.gz
glibc-9f835f5fb48eb6e173a7ca3c678595dba28c5e7a.tar.bz2
Update.
2000-07-12 Bruno Haible <haible@clisp.cons.org> * iconv/gconv_open.c (__gconv_open): Merge duplicated code. 2000-07-12 Bruno Haible <haible@clisp.cons.org> * iconv/gconv_builtin.c (__gconv_get_builtin_trans): Initialize __modname. 2000-07-12 Bruno Haible <haible@clisp.cons.org> * iconv/gconv_open.c (__gconv_open): Initialize result->__steps[cnt].__data. 2000-07-12 Mark Kettenis <kettenis@gnu.org> * nss/getent.c (services_keys): Pass port number in network byte order in call to getservbyport. 2000-07-11 Andreas Jaeger <aj@suse.de> * stdlib/Makefile (test-canon-ARGS): Fix for building in the source dir. * intl/Makefile (do-gettext-test): Likewise. * dirent/Makefile (opendir-tst1-ARGS): Likewise. 2000-07-11 Andreas Schwab <schwab@suse.de> * Makeconfig (run-program-prefix): New rule. (built-program-cmd): Use run-program-prefix.
Diffstat (limited to 'iconv/gconv_open.c')
-rw-r--r--iconv/gconv_open.c76
1 files changed, 19 insertions, 57 deletions
diff --git a/iconv/gconv_open.c b/iconv/gconv_open.c
index c54054a..7a17b70 100644
--- a/iconv/gconv_open.c
+++ b/iconv/gconv_open.c
@@ -184,14 +184,10 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle,
/* Call all initialization functions for the transformation
step implementations. */
- for (cnt = 0; cnt < nsteps - 1; ++cnt)
+ for (cnt = 0; cnt < nsteps; ++cnt)
{
size_t size;
- /* If this is the last step we must not allocate an
- output buffer. */
- result->__data[cnt].__flags = conv_flags;
-
/* Would have to be done if we would not clear the whole
array above. */
#if 0
@@ -205,16 +201,6 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle,
/* We use the `mbstate_t' member in DATA. */
result->__data[cnt].__statep = &result->__data[cnt].__state;
- /* Allocate the buffer. */
- size = (GCONV_NCHAR_GOAL * steps[cnt].__max_needed_to);
-
- result->__data[cnt].__outbuf = (char *) malloc (size);
- if (result->__data[cnt].__outbuf == NULL)
- goto bail;
-
- result->__data[cnt].__outbufend =
- result->__data[cnt].__outbuf + size;
-
/* Now see whether we can use any of the transliteration
modules for this step. */
for (runp = trans; runp != NULL; runp = runp->next)
@@ -255,57 +241,33 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle,
}
break;
}
- }
- /* Now handle the last entry. */
- result->__data[cnt].__flags = conv_flags | __GCONV_IS_LAST;
- /* Would have to be done if we would not clear the whole
- array above. */
-#if 0
- result->__data[cnt].__invocation_counter = 0;
- result->__data[cnt].__internal_use = 0;
-#endif
- result->__data[cnt].__statep = &result->__data[cnt].__state;
+ result->__steps[cnt].__data = &result->__data[cnt];
- /* Now see whether we can use the transliteration module
- for this step. */
- for (runp = trans; runp != NULL; runp = runp->next)
- for (n = 0; n < runp->ncsnames; ++n)
- if (__strcasecmp (steps[cnt].__from_name, runp->csnames[n]) == 0)
+ /* If this is the last step we must not allocate an
+ output buffer. */
+ if (cnt < nsteps - 1)
{
- void *data = NULL;
-
- /* Match! Now try the initializer. */
- if (runp->trans_init_fct == NULL
- || (runp->trans_init_fct (data, steps[cnt].__to_name)
- == __GCONV_OK))
- {
- /* Append at the end of the list. */
- struct __gconv_trans_data *newp;
- struct __gconv_trans_data *endp;
- struct __gconv_trans_data *lastp;
+ result->__data[cnt].__flags = conv_flags;
- newp = (struct __gconv_trans_data *)
- malloc (sizeof (struct __gconv_trans_data));
- if (newp == NULL)
- goto bail;
+ /* Allocate the buffer. */
+ size = (GCONV_NCHAR_GOAL * steps[cnt].__max_needed_to);
- newp->__trans_fct = runp->trans_fct;
- newp->__trans_context_fct = runp->trans_context_fct;
- newp->__trans_end_fct = runp->trans_end_fct;
+ result->__data[cnt].__outbuf = (char *) malloc (size);
+ if (result->__data[cnt].__outbuf == NULL)
+ goto bail;
- lastp = NULL;
- for (endp = result->__data[cnt].__trans;
- endp != NULL; endp = endp->__next)
- lastp = endp;
+ result->__data[cnt].__outbufend =
+ result->__data[cnt].__outbuf + size;
+ }
+ else
+ {
+ /* Handle the last entry. */
+ result->__data[cnt].__flags = conv_flags | __GCONV_IS_LAST;
- if (lastp == NULL)
- result->__data[cnt].__trans = newp;
- else
- lastp->__next = newp;
- }
break;
}
+ }
}
if (res != __GCONV_OK)