charset.c (convert_using_iconv): Close out any shift states, returning to the initial state.
* charset.c (convert_using_iconv): Close out any shift states, returning to the initial state. From-SVN: r130785
This commit is contained in:
parent
a2b677873b
commit
675575f57a
2 changed files with 26 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2007-12-11 DJ Delorie <dj@redhat.com>
|
||||||
|
|
||||||
|
* charset.c (convert_using_iconv): Close out any shift states,
|
||||||
|
returning to the initial state.
|
||||||
|
|
||||||
2007-12-06 Tom Tromey <tromey@redhat.com>
|
2007-12-06 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
PR c/29172:
|
PR c/29172:
|
||||||
|
|
|
@ -548,6 +548,15 @@ convert_no_conversion (iconv_t cd ATTRIBUTE_UNUSED,
|
||||||
/* And this one uses the system iconv primitive. It's a little
|
/* And this one uses the system iconv primitive. It's a little
|
||||||
different, since iconv's interface is a little different. */
|
different, since iconv's interface is a little different. */
|
||||||
#if HAVE_ICONV
|
#if HAVE_ICONV
|
||||||
|
|
||||||
|
#define CONVERT_ICONV_GROW_BUFFER \
|
||||||
|
do { \
|
||||||
|
outbytesleft += OUTBUF_BLOCK_SIZE; \
|
||||||
|
to->asize += OUTBUF_BLOCK_SIZE; \
|
||||||
|
to->text = XRESIZEVEC (uchar, to->text, to->asize); \
|
||||||
|
outbuf = (char *)to->text + to->asize - outbytesleft; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
convert_using_iconv (iconv_t cd, const uchar *from, size_t flen,
|
convert_using_iconv (iconv_t cd, const uchar *from, size_t flen,
|
||||||
struct _cpp_strbuf *to)
|
struct _cpp_strbuf *to)
|
||||||
|
@ -570,16 +579,24 @@ convert_using_iconv (iconv_t cd, const uchar *from, size_t flen,
|
||||||
iconv (cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
|
iconv (cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
|
||||||
if (__builtin_expect (inbytesleft == 0, 1))
|
if (__builtin_expect (inbytesleft == 0, 1))
|
||||||
{
|
{
|
||||||
|
/* Close out any shift states, returning to the initial state. */
|
||||||
|
if (iconv (cd, 0, 0, &outbuf, &outbytesleft) == (size_t)-1)
|
||||||
|
{
|
||||||
|
if (errno != E2BIG)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
CONVERT_ICONV_GROW_BUFFER;
|
||||||
|
if (iconv (cd, 0, 0, &outbuf, &outbytesleft) == (size_t)-1)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
to->len = to->asize - outbytesleft;
|
to->len = to->asize - outbytesleft;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (errno != E2BIG)
|
if (errno != E2BIG)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
outbytesleft += OUTBUF_BLOCK_SIZE;
|
CONVERT_ICONV_GROW_BUFFER;
|
||||||
to->asize += OUTBUF_BLOCK_SIZE;
|
|
||||||
to->text = XRESIZEVEC (uchar, to->text, to->asize);
|
|
||||||
outbuf = (char *)to->text + to->asize - outbytesleft;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Add table
Reference in a new issue