mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-22 04:50:07 +00:00
Update.
* iconv/gconv_db.c (gen_steps): Always initialize __data field of step. * iconv/gconv_open.c (__gconv_open): Reapply 2000-07-12 Bruno Haible <haible@clisp.cons.org> * iconv/gconv_open.c (__gconv_open): Merge duplicated code.
This commit is contained in:
parent
7039a4c912
commit
405b8c60d0
@ -1,5 +1,14 @@
|
|||||||
2000-07-12 Ulrich Drepper <drepper@redhat.com>
|
2000-07-12 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* iconv/gconv_db.c (gen_steps): Always initialize __data field of
|
||||||
|
step.
|
||||||
|
|
||||||
|
* iconv/gconv_open.c (__gconv_open): Reapply
|
||||||
|
2000-07-12 Bruno Haible <haible@clisp.cons.org>
|
||||||
|
|
||||||
|
* iconv/gconv_open.c (__gconv_open): Merge duplicated
|
||||||
|
code.
|
||||||
|
|
||||||
* iconv/gconv_open.c: Undo last two changes for now. They break
|
* iconv/gconv_open.c: Undo last two changes for now. They break
|
||||||
everything.
|
everything.
|
||||||
|
|
||||||
|
@ -234,6 +234,7 @@ gen_steps (struct derivation_step *best, const char *toset,
|
|||||||
&result[step_cnt]);
|
&result[step_cnt]);
|
||||||
|
|
||||||
/* Call the init function. */
|
/* Call the init function. */
|
||||||
|
result[step_cnt].__data = NULL;
|
||||||
if (result[step_cnt].__init_fct != NULL)
|
if (result[step_cnt].__init_fct != NULL)
|
||||||
{
|
{
|
||||||
status = DL_CALL_FCT (result[step_cnt].__init_fct,
|
status = DL_CALL_FCT (result[step_cnt].__init_fct,
|
||||||
|
@ -184,14 +184,10 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle,
|
|||||||
|
|
||||||
/* Call all initialization functions for the transformation
|
/* Call all initialization functions for the transformation
|
||||||
step implementations. */
|
step implementations. */
|
||||||
for (cnt = 0; cnt < nsteps - 1; ++cnt)
|
for (cnt = 0; cnt < nsteps; ++cnt)
|
||||||
{
|
{
|
||||||
size_t size;
|
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
|
/* Would have to be done if we would not clear the whole
|
||||||
array above. */
|
array above. */
|
||||||
#if 0
|
#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. */
|
/* We use the `mbstate_t' member in DATA. */
|
||||||
result->__data[cnt].__statep = &result->__data[cnt].__state;
|
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
|
/* Now see whether we can use any of the transliteration
|
||||||
modules for this step. */
|
modules for this step. */
|
||||||
for (runp = trans; runp != NULL; runp = runp->next)
|
for (runp = trans; runp != NULL; runp = runp->next)
|
||||||
@ -255,57 +241,31 @@ __gconv_open (const char *toset, const char *fromset, __gconv_t *handle,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Now handle the last entry. */
|
/* If this is the last step we must not allocate an
|
||||||
result->__data[cnt].__flags = conv_flags | __GCONV_IS_LAST;
|
output buffer. */
|
||||||
/* Would have to be done if we would not clear the whole
|
if (cnt < nsteps - 1)
|
||||||
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;
|
|
||||||
|
|
||||||
/* 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)
|
|
||||||
{
|
{
|
||||||
void *data = NULL;
|
result->__data[cnt].__flags = conv_flags;
|
||||||
|
|
||||||
/* Match! Now try the initializer. */
|
/* Allocate the buffer. */
|
||||||
if (runp->trans_init_fct == NULL
|
size = (GCONV_NCHAR_GOAL * steps[cnt].__max_needed_to);
|
||||||
|| (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;
|
|
||||||
|
|
||||||
newp = (struct __gconv_trans_data *)
|
result->__data[cnt].__outbuf = (char *) malloc (size);
|
||||||
malloc (sizeof (struct __gconv_trans_data));
|
if (result->__data[cnt].__outbuf == NULL)
|
||||||
if (newp == NULL)
|
goto bail;
|
||||||
goto bail;
|
|
||||||
|
|
||||||
newp->__trans_fct = runp->trans_fct;
|
result->__data[cnt].__outbufend =
|
||||||
newp->__trans_context_fct = runp->trans_context_fct;
|
result->__data[cnt].__outbuf + size;
|
||||||
newp->__trans_end_fct = runp->trans_end_fct;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Handle the last entry. */
|
||||||
|
result->__data[cnt].__flags = conv_flags | __GCONV_IS_LAST;
|
||||||
|
|
||||||
lastp = NULL;
|
|
||||||
for (endp = result->__data[cnt].__trans;
|
|
||||||
endp != NULL; endp = endp->__next)
|
|
||||||
lastp = endp;
|
|
||||||
|
|
||||||
if (lastp == NULL)
|
|
||||||
result->__data[cnt].__trans = newp;
|
|
||||||
else
|
|
||||||
lastp->__next = newp;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res != __GCONV_OK)
|
if (res != __GCONV_OK)
|
||||||
|
Loading…
Reference in New Issue
Block a user