Try harder to reset shift state with AIX iconv(). (#467537)

2007-11-08  Matthias Clasen <mclasen@redhat.com>

        * glib/gconvert.c (g_convert_with_iconv): Try harder to reset
        shift state with AIX iconv().  (#467537)


svn path=/trunk/; revision=5821
This commit is contained in:
Matthias Clasen 2007-11-08 06:04:00 +00:00 committed by Matthias Clasen
parent e243169979
commit d303704549
2 changed files with 12 additions and 8 deletions

View File

@ -1,3 +1,8 @@
2007-11-08 Matthias Clasen <mclasen@redhat.com>
* glib/gconvert.c (g_convert_with_iconv): Try harder to reset
shift state with AIX iconv(). (#467537)
2007-11-08 Matthias Clasen <mclasen@redhat.com> 2007-11-08 Matthias Clasen <mclasen@redhat.com>
* configure.in: * configure.in:

View File

@ -573,13 +573,13 @@ g_convert_with_iconv (const gchar *str,
gchar *dest; gchar *dest;
gchar *outp; gchar *outp;
const gchar *p; const gchar *p;
const gchar *shift_p = NULL;
gsize inbytes_remaining; gsize inbytes_remaining;
gsize outbytes_remaining; gsize outbytes_remaining;
gsize err; gsize err;
gsize outbuf_size; gsize outbuf_size;
gboolean have_error = FALSE; gboolean have_error = FALSE;
gboolean done = FALSE; gboolean done = FALSE;
gboolean reset = FALSE;
g_return_val_if_fail (converter != (GIConv) -1, NULL); g_return_val_if_fail (converter != (GIConv) -1, NULL);
@ -595,7 +595,10 @@ g_convert_with_iconv (const gchar *str,
while (!done && !have_error) while (!done && !have_error)
{ {
err = g_iconv (converter, (char **)&p, &inbytes_remaining, &outp, &outbytes_remaining); if (reset)
err = g_iconv (converter, NULL, &inbytes_remaining, &outp, &outbytes_remaining);
else
err = g_iconv (converter, (char **)&p, &inbytes_remaining, &outp, &outbytes_remaining);
if (err == (gsize) -1) if (err == (gsize) -1)
{ {
@ -633,11 +636,10 @@ g_convert_with_iconv (const gchar *str,
} }
else else
{ {
if (!shift_p) if (!reset)
{ {
/* call g_iconv with NULL inbuf to cleanup shift state */ /* call g_iconv with NULL inbuf to cleanup shift state */
shift_p = p; reset = TRUE;
p = NULL;
inbytes_remaining = 0; inbytes_remaining = 0;
} }
else else
@ -645,9 +647,6 @@ g_convert_with_iconv (const gchar *str,
} }
} }
if (shift_p)
p = shift_p;
*outp = '\0'; *outp = '\0';
if (bytes_read) if (bytes_read)