gdatainputstream: Deprecate read_until() in favour of read_upto()

g_data_input_stream_read_upto() was introduced in 2.26; now it’s GLib
2.56, we can probably deprecate the old versions (since the handling of
consuming the stop character differs between the sync and async versions
of it).

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=584284
This commit is contained in:
Philip Withnall 2018-02-01 16:50:46 +00:00
parent 3a88ab6c25
commit 5ed77c1104
3 changed files with 13 additions and 3 deletions

View File

@ -915,6 +915,8 @@ scan_for_chars (GDataInputStream *stream,
* before encountering any of the stop characters. Set @length to * before encountering any of the stop characters. Set @length to
* a #gsize to get the length of the string. This function will * a #gsize to get the length of the string. This function will
* return %NULL on an error. * return %NULL on an error.
* Deprecated: 2.56: Use g_data_input_stream_read_upto() instead, which has more
* consistent behaviour regarding the stop character.
*/ */
char * char *
g_data_input_stream_read_until (GDataInputStream *stream, g_data_input_stream_read_until (GDataInputStream *stream,
@ -1170,6 +1172,8 @@ g_data_input_stream_read_line_async (GDataInputStream *stream,
* g_data_input_stream_read_upto_async() instead. * g_data_input_stream_read_upto_async() instead.
* *
* Since: 2.20 * Since: 2.20
* Deprecated: 2.56: Use g_data_input_stream_read_upto_async() instead, which
* has more consistent behaviour regarding the stop character.
*/ */
void void
g_data_input_stream_read_until_async (GDataInputStream *stream, g_data_input_stream_read_until_async (GDataInputStream *stream,
@ -1277,6 +1281,8 @@ g_data_input_stream_read_line_finish_utf8 (GDataInputStream *stream,
* before encountering any of the stop characters. Set @length to * before encountering any of the stop characters. Set @length to
* a #gsize to get the length of the string. This function will * a #gsize to get the length of the string. This function will
* return %NULL on an error. * return %NULL on an error.
* Deprecated: 2.56: Use g_data_input_stream_read_upto_finish() instead, which
* has more consistent behaviour regarding the stop character.
*/ */
gchar * gchar *
g_data_input_stream_read_until_finish (GDataInputStream *stream, g_data_input_stream_read_until_finish (GDataInputStream *stream,

View File

@ -135,20 +135,20 @@ char * g_data_input_stream_read_line_finish_utf8(GDataInputStrea
GAsyncResult *result, GAsyncResult *result,
gsize *length, gsize *length,
GError **error); GError **error);
GLIB_AVAILABLE_IN_ALL GLIB_DEPRECATED_IN_2_56_FOR (g_data_input_stream_read_upto)
char * g_data_input_stream_read_until (GDataInputStream *stream, char * g_data_input_stream_read_until (GDataInputStream *stream,
const gchar *stop_chars, const gchar *stop_chars,
gsize *length, gsize *length,
GCancellable *cancellable, GCancellable *cancellable,
GError **error); GError **error);
GLIB_AVAILABLE_IN_ALL GLIB_DEPRECATED_IN_2_56_FOR (g_data_input_stream_read_upto_async)
void g_data_input_stream_read_until_async (GDataInputStream *stream, void g_data_input_stream_read_until_async (GDataInputStream *stream,
const gchar *stop_chars, const gchar *stop_chars,
gint io_priority, gint io_priority,
GCancellable *cancellable, GCancellable *cancellable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data); gpointer user_data);
GLIB_AVAILABLE_IN_ALL GLIB_DEPRECATED_IN_2_56_FOR (g_data_input_stream_read_upto_finish)
char * g_data_input_stream_read_until_finish (GDataInputStream *stream, char * g_data_input_stream_read_until_finish (GDataInputStream *stream,
GAsyncResult *result, GAsyncResult *result,
gsize *length, gsize *length,

View File

@ -222,6 +222,8 @@ test_read_lines_LF_invalid_utf8 (void)
g_object_unref (stream); g_object_unref (stream);
} }
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static void static void
test_read_until (void) test_read_until (void)
{ {
@ -268,6 +270,8 @@ test_read_until (void)
g_object_unref (stream); g_object_unref (stream);
} }
G_GNUC_END_IGNORE_DEPRECATIONS
static void static void
test_read_upto (void) test_read_upto (void)
{ {