mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-12 10:45:13 +01:00
Modified Files: glib/ChangeLog glib/glib/giochannel.c
Modified Files: glib/ChangeLog glib/glib/giochannel.c glib/tests/iochannel-test.c * glib/giochannel.c: Fixed g_io_channel_seek_position() so that G_SEEK_CUR can be used with UTF-8 encoding * glib/giochannel.c: Changed test to decide whether use_buf is encoded_read_buf or read_buf from "if (channel->do_encode)" to "if (channel->encoding)" to fix bug 58472 * tests/iochannel-test.c: Fixed so it doesn't output double newlines * glib/giochannel.c: Fixed g_io_channel_fill_buffer() so that encoded_read_buf is created for UTF-8 encoding
This commit is contained in:
parent
44e7362702
commit
1ff027aa2d
16
ChangeLog
16
ChangeLog
@ -1,3 +1,19 @@
|
|||||||
|
2001-08-03 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
|
* glib/giochannel.c: Fixed g_io_channel_seek_position()
|
||||||
|
so that G_SEEK_CUR can be used with UTF-8 encoding
|
||||||
|
|
||||||
|
* glib/giochannel.c: Changed test to decide whether
|
||||||
|
use_buf is encoded_read_buf or read_buf from
|
||||||
|
"if (channel->do_encode)" to "if (channel->encoding)" to
|
||||||
|
fix bug 58472
|
||||||
|
|
||||||
|
* tests/iochannel-test.c: Fixed so it doesn't output
|
||||||
|
double newlines
|
||||||
|
|
||||||
|
* glib/giochannel.c: Fixed g_io_channel_fill_buffer()
|
||||||
|
so that encoded_read_buf is created for UTF-8 encoding
|
||||||
|
|
||||||
2001-08-03 Darin Adler <darin@bentspoon.com>
|
2001-08-03 Darin Adler <darin@bentspoon.com>
|
||||||
|
|
||||||
* tests/strfunc-test.c: (strv_check), (main):
|
* tests/strfunc-test.c: (strv_check), (main):
|
||||||
|
@ -1,3 +1,19 @@
|
|||||||
|
2001-08-03 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
|
* glib/giochannel.c: Fixed g_io_channel_seek_position()
|
||||||
|
so that G_SEEK_CUR can be used with UTF-8 encoding
|
||||||
|
|
||||||
|
* glib/giochannel.c: Changed test to decide whether
|
||||||
|
use_buf is encoded_read_buf or read_buf from
|
||||||
|
"if (channel->do_encode)" to "if (channel->encoding)" to
|
||||||
|
fix bug 58472
|
||||||
|
|
||||||
|
* tests/iochannel-test.c: Fixed so it doesn't output
|
||||||
|
double newlines
|
||||||
|
|
||||||
|
* glib/giochannel.c: Fixed g_io_channel_fill_buffer()
|
||||||
|
so that encoded_read_buf is created for UTF-8 encoding
|
||||||
|
|
||||||
2001-08-03 Darin Adler <darin@bentspoon.com>
|
2001-08-03 Darin Adler <darin@bentspoon.com>
|
||||||
|
|
||||||
* tests/strfunc-test.c: (strv_check), (main):
|
* tests/strfunc-test.c: (strv_check), (main):
|
||||||
|
@ -1,3 +1,19 @@
|
|||||||
|
2001-08-03 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
|
* glib/giochannel.c: Fixed g_io_channel_seek_position()
|
||||||
|
so that G_SEEK_CUR can be used with UTF-8 encoding
|
||||||
|
|
||||||
|
* glib/giochannel.c: Changed test to decide whether
|
||||||
|
use_buf is encoded_read_buf or read_buf from
|
||||||
|
"if (channel->do_encode)" to "if (channel->encoding)" to
|
||||||
|
fix bug 58472
|
||||||
|
|
||||||
|
* tests/iochannel-test.c: Fixed so it doesn't output
|
||||||
|
double newlines
|
||||||
|
|
||||||
|
* glib/giochannel.c: Fixed g_io_channel_fill_buffer()
|
||||||
|
so that encoded_read_buf is created for UTF-8 encoding
|
||||||
|
|
||||||
2001-08-03 Darin Adler <darin@bentspoon.com>
|
2001-08-03 Darin Adler <darin@bentspoon.com>
|
||||||
|
|
||||||
* tests/strfunc-test.c: (strv_check), (main):
|
* tests/strfunc-test.c: (strv_check), (main):
|
||||||
|
@ -1,3 +1,19 @@
|
|||||||
|
2001-08-03 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
|
* glib/giochannel.c: Fixed g_io_channel_seek_position()
|
||||||
|
so that G_SEEK_CUR can be used with UTF-8 encoding
|
||||||
|
|
||||||
|
* glib/giochannel.c: Changed test to decide whether
|
||||||
|
use_buf is encoded_read_buf or read_buf from
|
||||||
|
"if (channel->do_encode)" to "if (channel->encoding)" to
|
||||||
|
fix bug 58472
|
||||||
|
|
||||||
|
* tests/iochannel-test.c: Fixed so it doesn't output
|
||||||
|
double newlines
|
||||||
|
|
||||||
|
* glib/giochannel.c: Fixed g_io_channel_fill_buffer()
|
||||||
|
so that encoded_read_buf is created for UTF-8 encoding
|
||||||
|
|
||||||
2001-08-03 Darin Adler <darin@bentspoon.com>
|
2001-08-03 Darin Adler <darin@bentspoon.com>
|
||||||
|
|
||||||
* tests/strfunc-test.c: (strv_check), (main):
|
* tests/strfunc-test.c: (strv_check), (main):
|
||||||
|
@ -1,3 +1,19 @@
|
|||||||
|
2001-08-03 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
|
* glib/giochannel.c: Fixed g_io_channel_seek_position()
|
||||||
|
so that G_SEEK_CUR can be used with UTF-8 encoding
|
||||||
|
|
||||||
|
* glib/giochannel.c: Changed test to decide whether
|
||||||
|
use_buf is encoded_read_buf or read_buf from
|
||||||
|
"if (channel->do_encode)" to "if (channel->encoding)" to
|
||||||
|
fix bug 58472
|
||||||
|
|
||||||
|
* tests/iochannel-test.c: Fixed so it doesn't output
|
||||||
|
double newlines
|
||||||
|
|
||||||
|
* glib/giochannel.c: Fixed g_io_channel_fill_buffer()
|
||||||
|
so that encoded_read_buf is created for UTF-8 encoding
|
||||||
|
|
||||||
2001-08-03 Darin Adler <darin@bentspoon.com>
|
2001-08-03 Darin Adler <darin@bentspoon.com>
|
||||||
|
|
||||||
* tests/strfunc-test.c: (strv_check), (main):
|
* tests/strfunc-test.c: (strv_check), (main):
|
||||||
|
@ -1,3 +1,19 @@
|
|||||||
|
2001-08-03 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
|
* glib/giochannel.c: Fixed g_io_channel_seek_position()
|
||||||
|
so that G_SEEK_CUR can be used with UTF-8 encoding
|
||||||
|
|
||||||
|
* glib/giochannel.c: Changed test to decide whether
|
||||||
|
use_buf is encoded_read_buf or read_buf from
|
||||||
|
"if (channel->do_encode)" to "if (channel->encoding)" to
|
||||||
|
fix bug 58472
|
||||||
|
|
||||||
|
* tests/iochannel-test.c: Fixed so it doesn't output
|
||||||
|
double newlines
|
||||||
|
|
||||||
|
* glib/giochannel.c: Fixed g_io_channel_fill_buffer()
|
||||||
|
so that encoded_read_buf is created for UTF-8 encoding
|
||||||
|
|
||||||
2001-08-03 Darin Adler <darin@bentspoon.com>
|
2001-08-03 Darin Adler <darin@bentspoon.com>
|
||||||
|
|
||||||
* tests/strfunc-test.c: (strv_check), (main):
|
* tests/strfunc-test.c: (strv_check), (main):
|
||||||
|
@ -1,3 +1,19 @@
|
|||||||
|
2001-08-03 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
|
* glib/giochannel.c: Fixed g_io_channel_seek_position()
|
||||||
|
so that G_SEEK_CUR can be used with UTF-8 encoding
|
||||||
|
|
||||||
|
* glib/giochannel.c: Changed test to decide whether
|
||||||
|
use_buf is encoded_read_buf or read_buf from
|
||||||
|
"if (channel->do_encode)" to "if (channel->encoding)" to
|
||||||
|
fix bug 58472
|
||||||
|
|
||||||
|
* tests/iochannel-test.c: Fixed so it doesn't output
|
||||||
|
double newlines
|
||||||
|
|
||||||
|
* glib/giochannel.c: Fixed g_io_channel_fill_buffer()
|
||||||
|
so that encoded_read_buf is created for UTF-8 encoding
|
||||||
|
|
||||||
2001-08-03 Darin Adler <darin@bentspoon.com>
|
2001-08-03 Darin Adler <darin@bentspoon.com>
|
||||||
|
|
||||||
* tests/strfunc-test.c: (strv_check), (main):
|
* tests/strfunc-test.c: (strv_check), (main):
|
||||||
|
@ -1,3 +1,19 @@
|
|||||||
|
2001-08-03 Ron Steinke <rsteinke@w-link.net>
|
||||||
|
|
||||||
|
* glib/giochannel.c: Fixed g_io_channel_seek_position()
|
||||||
|
so that G_SEEK_CUR can be used with UTF-8 encoding
|
||||||
|
|
||||||
|
* glib/giochannel.c: Changed test to decide whether
|
||||||
|
use_buf is encoded_read_buf or read_buf from
|
||||||
|
"if (channel->do_encode)" to "if (channel->encoding)" to
|
||||||
|
fix bug 58472
|
||||||
|
|
||||||
|
* tests/iochannel-test.c: Fixed so it doesn't output
|
||||||
|
double newlines
|
||||||
|
|
||||||
|
* glib/giochannel.c: Fixed g_io_channel_fill_buffer()
|
||||||
|
so that encoded_read_buf is created for UTF-8 encoding
|
||||||
|
|
||||||
2001-08-03 Darin Adler <darin@bentspoon.com>
|
2001-08-03 Darin Adler <darin@bentspoon.com>
|
||||||
|
|
||||||
* tests/strfunc-test.c: (strv_check), (main):
|
* tests/strfunc-test.c: (strv_check), (main):
|
||||||
|
@ -94,7 +94,7 @@ g_io_channel_unref (GIOChannel *channel)
|
|||||||
if (channel->ref_count == 0)
|
if (channel->ref_count == 0)
|
||||||
{
|
{
|
||||||
if (channel->close_on_unref)
|
if (channel->close_on_unref)
|
||||||
g_io_channel_close (channel);
|
g_io_channel_shutdown (channel, TRUE, NULL);
|
||||||
else
|
else
|
||||||
g_io_channel_purge (channel);
|
g_io_channel_purge (channel);
|
||||||
g_free (channel->encoding);
|
g_free (channel->encoding);
|
||||||
@ -408,7 +408,7 @@ g_io_channel_purge (GIOChannel *channel)
|
|||||||
g_string_truncate (channel->read_buf, 0);
|
g_string_truncate (channel->read_buf, 0);
|
||||||
if (channel->write_buf)
|
if (channel->write_buf)
|
||||||
g_string_truncate (channel->write_buf, 0);
|
g_string_truncate (channel->write_buf, 0);
|
||||||
if (channel->do_encode)
|
if (channel->encoding)
|
||||||
{
|
{
|
||||||
if (channel->encoded_read_buf)
|
if (channel->encoded_read_buf)
|
||||||
g_string_truncate (channel->encoded_read_buf, 0);
|
g_string_truncate (channel->encoded_read_buf, 0);
|
||||||
@ -931,7 +931,7 @@ g_io_channel_set_encoding (GIOChannel *channel,
|
|||||||
|
|
||||||
/* Make sure the encoded buffers are empty */
|
/* Make sure the encoded buffers are empty */
|
||||||
|
|
||||||
g_return_val_if_fail (!channel->encoded_read_buf ||
|
g_return_val_if_fail (!channel->do_encode || !channel->encoded_read_buf ||
|
||||||
channel->encoded_read_buf->len == 0, G_IO_STATUS_ERROR);
|
channel->encoded_read_buf->len == 0, G_IO_STATUS_ERROR);
|
||||||
g_return_val_if_fail (channel->partial_write_buf[0] == '\0', G_IO_STATUS_ERROR);
|
g_return_val_if_fail (channel->partial_write_buf[0] == '\0', G_IO_STATUS_ERROR);
|
||||||
|
|
||||||
@ -1015,6 +1015,19 @@ g_io_channel_set_encoding (GIOChannel *channel,
|
|||||||
if (channel->write_cd != (GIConv) -1)
|
if (channel->write_cd != (GIConv) -1)
|
||||||
g_iconv_close (channel->write_cd);
|
g_iconv_close (channel->write_cd);
|
||||||
|
|
||||||
|
if (channel->encoded_read_buf && channel->encoded_read_buf->len > 0)
|
||||||
|
{
|
||||||
|
g_assert (!did_encode); /* Encoding UTF-8, NULL doesn't use encoded_read_buf */
|
||||||
|
|
||||||
|
/* This is just validated UTF-8, so we can copy it back into read_buf
|
||||||
|
* so it can be encoded in whatever the new encoding is.
|
||||||
|
*/
|
||||||
|
|
||||||
|
g_string_prepend_len (channel->read_buf, channel->encoded_read_buf->str,
|
||||||
|
channel->encoded_read_buf->len);
|
||||||
|
g_string_truncate (channel->encoded_read_buf, 0);
|
||||||
|
}
|
||||||
|
|
||||||
channel->read_cd = read_cd;
|
channel->read_cd = read_cd;
|
||||||
channel->write_cd = write_cd;
|
channel->write_cd = write_cd;
|
||||||
|
|
||||||
@ -1087,16 +1100,16 @@ g_io_channel_fill_buffer (GIOChannel *channel,
|
|||||||
if (channel->encoded_read_buf)
|
if (channel->encoded_read_buf)
|
||||||
oldlen = channel->encoded_read_buf->len;
|
oldlen = channel->encoded_read_buf->len;
|
||||||
else
|
else
|
||||||
oldlen = 0;
|
{
|
||||||
|
oldlen = 0;
|
||||||
|
channel->encoded_read_buf = g_string_sized_new (channel->buf_size);
|
||||||
|
}
|
||||||
|
|
||||||
if (channel->do_encode)
|
if (channel->do_encode)
|
||||||
{
|
{
|
||||||
size_t errnum, inbytes_left, outbytes_left;
|
size_t errnum, inbytes_left, outbytes_left;
|
||||||
gchar *inbuf, *outbuf;
|
gchar *inbuf, *outbuf;
|
||||||
|
|
||||||
if (!channel->encoded_read_buf)
|
|
||||||
channel->encoded_read_buf = g_string_sized_new (channel->buf_size);
|
|
||||||
|
|
||||||
reencode:
|
reencode:
|
||||||
|
|
||||||
inbytes_left = channel->read_buf->len;
|
inbytes_left = channel->read_buf->len;
|
||||||
@ -1247,7 +1260,7 @@ g_io_channel_read_line (GIOChannel *channel,
|
|||||||
{
|
{
|
||||||
GString *use_buf;
|
GString *use_buf;
|
||||||
|
|
||||||
if (channel->do_encode)
|
if (channel->encoding)
|
||||||
use_buf = channel->encoded_read_buf;
|
use_buf = channel->encoded_read_buf;
|
||||||
else
|
else
|
||||||
use_buf = channel->read_buf;
|
use_buf = channel->read_buf;
|
||||||
@ -1301,7 +1314,7 @@ g_io_channel_read_line_string (GIOChannel *channel,
|
|||||||
{
|
{
|
||||||
GString *use_buf;
|
GString *use_buf;
|
||||||
|
|
||||||
if (channel->do_encode)
|
if (channel->encoding)
|
||||||
use_buf = channel->encoded_read_buf;
|
use_buf = channel->encoded_read_buf;
|
||||||
else
|
else
|
||||||
use_buf = channel->read_buf;
|
use_buf = channel->read_buf;
|
||||||
@ -1385,8 +1398,7 @@ read_again:
|
|||||||
{
|
{
|
||||||
*length = 0;
|
*length = 0;
|
||||||
|
|
||||||
if (channel->do_encode && channel->read_buf->len != 0)
|
if (channel->encoding && channel->read_buf->len != 0)
|
||||||
/* using GIConv conversion, unconverted chars */
|
|
||||||
{
|
{
|
||||||
g_set_error (error, G_CONVERT_ERROR,
|
g_set_error (error, G_CONVERT_ERROR,
|
||||||
G_CONVERT_ERROR_PARTIAL_INPUT,
|
G_CONVERT_ERROR_PARTIAL_INPUT,
|
||||||
|
@ -87,17 +87,7 @@ gint main (gint argc, gchar * argv[])
|
|||||||
if (length_out < buffer->len)
|
if (length_out < buffer->len)
|
||||||
g_warning ("Only wrote part of the line.");
|
g_warning ("Only wrote part of the line.");
|
||||||
|
|
||||||
do
|
g_print ("%s", buffer->str);
|
||||||
status = g_io_channel_write_chars (gio_w, line_term,
|
|
||||||
line_term_len, &length_out, &gerr);
|
|
||||||
while (status == G_IO_STATUS_AGAIN);
|
|
||||||
if (status != G_IO_STATUS_NORMAL)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (length_out < line_term_len)
|
|
||||||
g_warning ("Only wrote part of the line term.");
|
|
||||||
|
|
||||||
g_print (": %s\n", buffer->str);
|
|
||||||
g_string_truncate (buffer, 0);
|
g_string_truncate (buffer, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user