Fix left_len calculation in the from UTF-8 to UTF-8 case: left_len should

2002-11-02  Daniel Elstner  <daniel.elstner@gmx.net>

* glib/giochannel.c (g_io_channel_write_chars): Fix left_len calculation in the from UTF-8 to UTF-8 case: left_len should be the number of bytes left in the input buffer rather than channel->write_buf. (#96373)
This commit is contained in:
Daniel Elstner 2002-11-02 00:14:55 +00:00 committed by Daniel Elstner
parent a488638747
commit 8024c07a0e
8 changed files with 57 additions and 7 deletions

View File

@ -1,3 +1,10 @@
2002-11-02 Daniel Elstner <daniel.elstner@gmx.net>
* glib/giochannel.c (g_io_channel_write_chars): Fix left_len
calculation in the from UTF-8 to UTF-8 case: left_len should
be the number of bytes left in the input buffer rather than
channel->write_buf. (#96373)
2002-10-27 Tor Lillqvist <tml@iki.fi> 2002-10-27 Tor Lillqvist <tml@iki.fi>
* configure.in (G_MODULE_LDFLAGS): Don't set on Win32, only causes * configure.in (G_MODULE_LDFLAGS): Don't set on Win32, only causes

View File

@ -1,3 +1,10 @@
2002-11-02 Daniel Elstner <daniel.elstner@gmx.net>
* glib/giochannel.c (g_io_channel_write_chars): Fix left_len
calculation in the from UTF-8 to UTF-8 case: left_len should
be the number of bytes left in the input buffer rather than
channel->write_buf. (#96373)
2002-10-27 Tor Lillqvist <tml@iki.fi> 2002-10-27 Tor Lillqvist <tml@iki.fi>
* configure.in (G_MODULE_LDFLAGS): Don't set on Win32, only causes * configure.in (G_MODULE_LDFLAGS): Don't set on Win32, only causes

View File

@ -1,3 +1,10 @@
2002-11-02 Daniel Elstner <daniel.elstner@gmx.net>
* glib/giochannel.c (g_io_channel_write_chars): Fix left_len
calculation in the from UTF-8 to UTF-8 case: left_len should
be the number of bytes left in the input buffer rather than
channel->write_buf. (#96373)
2002-10-27 Tor Lillqvist <tml@iki.fi> 2002-10-27 Tor Lillqvist <tml@iki.fi>
* configure.in (G_MODULE_LDFLAGS): Don't set on Win32, only causes * configure.in (G_MODULE_LDFLAGS): Don't set on Win32, only causes

View File

@ -1,3 +1,10 @@
2002-11-02 Daniel Elstner <daniel.elstner@gmx.net>
* glib/giochannel.c (g_io_channel_write_chars): Fix left_len
calculation in the from UTF-8 to UTF-8 case: left_len should
be the number of bytes left in the input buffer rather than
channel->write_buf. (#96373)
2002-10-27 Tor Lillqvist <tml@iki.fi> 2002-10-27 Tor Lillqvist <tml@iki.fi>
* configure.in (G_MODULE_LDFLAGS): Don't set on Win32, only causes * configure.in (G_MODULE_LDFLAGS): Don't set on Win32, only causes

View File

@ -1,3 +1,10 @@
2002-11-02 Daniel Elstner <daniel.elstner@gmx.net>
* glib/giochannel.c (g_io_channel_write_chars): Fix left_len
calculation in the from UTF-8 to UTF-8 case: left_len should
be the number of bytes left in the input buffer rather than
channel->write_buf. (#96373)
2002-10-27 Tor Lillqvist <tml@iki.fi> 2002-10-27 Tor Lillqvist <tml@iki.fi>
* configure.in (G_MODULE_LDFLAGS): Don't set on Win32, only causes * configure.in (G_MODULE_LDFLAGS): Don't set on Win32, only causes

View File

@ -1,3 +1,10 @@
2002-11-02 Daniel Elstner <daniel.elstner@gmx.net>
* glib/giochannel.c (g_io_channel_write_chars): Fix left_len
calculation in the from UTF-8 to UTF-8 case: left_len should
be the number of bytes left in the input buffer rather than
channel->write_buf. (#96373)
2002-10-27 Tor Lillqvist <tml@iki.fi> 2002-10-27 Tor Lillqvist <tml@iki.fi>
* configure.in (G_MODULE_LDFLAGS): Don't set on Win32, only causes * configure.in (G_MODULE_LDFLAGS): Don't set on Win32, only causes

View File

@ -1,3 +1,10 @@
2002-11-02 Daniel Elstner <daniel.elstner@gmx.net>
* glib/giochannel.c (g_io_channel_write_chars): Fix left_len
calculation in the from UTF-8 to UTF-8 case: left_len should
be the number of bytes left in the input buffer rather than
channel->write_buf. (#96373)
2002-10-27 Tor Lillqvist <tml@iki.fi> 2002-10-27 Tor Lillqvist <tml@iki.fi>
* configure.in (G_MODULE_LDFLAGS): Don't set on Win32, only causes * configure.in (G_MODULE_LDFLAGS): Don't set on Win32, only causes

View File

@ -2058,15 +2058,16 @@ reconvert:
if (!g_utf8_validate (from_buf, try_len, &badchar)) if (!g_utf8_validate (from_buf, try_len, &badchar))
{ {
gunichar try_char; gunichar try_char;
gsize incomplete_len = from_buf + try_len - badchar;
left_len = from_buf + try_len - badchar; left_len = from_buf + from_buf_len - badchar;
try_char = g_utf8_get_char_validated (badchar, left_len); try_char = g_utf8_get_char_validated (badchar, incomplete_len);
switch (try_char) switch (try_char)
{ {
case -2: case -2:
g_assert (left_len < 6); g_assert (incomplete_len < 6);
if (try_len == from_buf_len) if (try_len == from_buf_len)
{ {
errnum = EINVAL; errnum = EINVAL;
@ -2075,7 +2076,7 @@ reconvert:
else else
{ {
errnum = 0; errnum = 0;
err = (size_t) -1; err = (size_t) 0;
} }
break; break;
case -1: case -1:
@ -2094,12 +2095,12 @@ reconvert:
{ {
err = (size_t) 0; err = (size_t) 0;
errnum = 0; errnum = 0;
left_len = 0; left_len = from_buf_len - try_len;
} }
g_string_append_len (channel->write_buf, from_buf, g_string_append_len (channel->write_buf, from_buf,
try_len - left_len); from_buf_len - left_len);
from_buf += try_len - left_len; from_buf += from_buf_len - left_len;
} }
else else
{ {