glib r7695 - in branches/glib-2-18/gio: . tests



Author: matthiasc
Date: Fri Nov 28 07:45:48 2008
New Revision: 7695
URL: http://svn.gnome.org/viewvc/glib?rev=7695&view=rev

Log:
2008-11-28  Matthias Clasen  <mclasen redhat com>

        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.



Modified:
   branches/glib-2-18/gio/ChangeLog
   branches/glib-2-18/gio/gdatainputstream.c
   branches/glib-2-18/gio/tests/data-input-stream.c

Modified: branches/glib-2-18/gio/gdatainputstream.c
==============================================================================
--- branches/glib-2-18/gio/gdatainputstream.c	(original)
+++ branches/glib-2-18/gio/gdatainputstream.c	Fri Nov 28 07:45:48 2008
@@ -801,7 +801,7 @@
   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;
 }

Modified: branches/glib-2-18/gio/tests/data-input-stream.c
==============================================================================
--- branches/glib-2-18/gio/tests/data-input-stream.c	(original)
+++ branches/glib-2-18/gio/tests/data-input-stream.c	Fri Nov 28 07:45:48 2008
@@ -87,8 +87,12 @@
       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], ends[newline_type], NULL);
+	  g_assert_cmpstr (data, ==, expected);
 	  g_assert (error == NULL);
+          g_free (expected);
 	  line++;
 	}
     }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]