From e449a91b987beb218ebea6b2aa5a5ae574f3b204 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 28 Nov 2008 07:42:48 +0000 Subject: [PATCH] =?UTF-8?q?Bug=20547481=20=E2=80=93=20g=5Fdata=5Finput=5Fs?= =?UTF-8?q?tream=5Fread=5Fline=20behaves=20not=20as=20stated=20in=20the?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2008-11-28 Matthias Clasen Bug 547481 – g_data_input_stream_read_line behaves not as stated in the docs * gdatainputstream.c (g_data_input_stream_read_line): Behave as documented and include the line end in the returned string. Pointed out by Paul Pogonyshev. * tests/data-input-stream.c: Fix the read_line test to test the documented behaviour. svn path=/trunk/; revision=7694 --- gio/ChangeLog | 12 ++++++++++++ gio/gdatainputstream.c | 2 +- gio/tests/data-input-stream.c | 6 +++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/gio/ChangeLog b/gio/ChangeLog index b4a408e95..e3bd9b60e 100644 --- a/gio/ChangeLog +++ b/gio/ChangeLog @@ -1,3 +1,15 @@ +2008-11-28 Matthias Clasen + + Bug 547481 – g_data_input_stream_read_line behaves not as stated in + the docs + + * gdatainputstream.c (g_data_input_stream_read_line): Behave as + documented and include the line end in the returned string. + Pointed out by Paul Pogonyshev. + + * tests/data-input-stream.c: Fix the read_line test to test the + documented behaviour. + 2008-11-28 Matthias Clasen * gdesktopappinfo.c (g_app_info_can_delete): Only allow deleting diff --git a/gio/gdatainputstream.c b/gio/gdatainputstream.c index 2c8bcdee3..967c67bb4 100644 --- a/gio/gdatainputstream.c +++ b/gio/gdatainputstream.c @@ -803,7 +803,7 @@ g_data_input_stream_read_line (GDataInputStream *stream, if (length) *length = (gsize)found_pos; g_warn_if_fail (res == found_pos + newline_len); - line[found_pos] = 0; + line[found_pos + newline_len] = 0; return line; } diff --git a/gio/tests/data-input-stream.c b/gio/tests/data-input-stream.c index d1385caf7..5a44148ae 100644 --- a/gio/tests/data-input-stream.c +++ b/gio/tests/data-input-stream.c @@ -87,8 +87,12 @@ test_read_lines (GDataStreamNewlineType newline_type) data = g_data_input_stream_read_line (G_DATA_INPUT_STREAM (stream), &length, NULL, &error); if (data) { - g_assert_cmpstr (data, ==, lines[line]); + char *expected; + + expected = g_strconcat (lines[line], endl[newline_type], NULL); + g_assert_cmpstr (data, ==, expected); g_assert_no_error (error); + g_free (expected); line++; } }