After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 652758 - GDataInputStream: Clarify g_data_input_stream_read_line docs(), mark as byte array
GDataInputStream: Clarify g_data_input_stream_read_line docs(), mark as byte ...
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2011-06-16 17:15 UTC by Colin Walters
Modified: 2011-06-17 12:52 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GDataInputStream: Clarify g_data_input_stream_read_line docs(), mark as byte array (2.10 KB, patch)
2011-06-16 17:15 UTC, Colin Walters
none Details | Review
GDataInputStream: Clarify read_line() docs, mark as byte array (2.99 KB, patch)
2011-06-16 18:01 UTC, Colin Walters
committed Details | Review
GDataInputStream: Add _utf8() variants of _read_line (8.82 KB, patch)
2011-06-16 18:01 UTC, Colin Walters
committed Details | Review

Description Colin Walters 2011-06-16 17:15:24 UTC
This function doesn't do any encoding checks, so we shouldn't call the returned
value a "string" (which I'd like to mean UTF-8).
Comment 1 Colin Walters 2011-06-16 17:15:26 UTC
Created attachment 190058 [details] [review]
GDataInputStream: Clarify g_data_input_stream_read_line docs(), mark as byte array
Comment 2 Colin Walters 2011-06-16 18:01:37 UTC
Created attachment 190066 [details] [review]
GDataInputStream: Clarify read_line() docs, mark as byte array

g_data_input_stream_read_line() and
g_data_input_stream_read_line_finish() don't do any encoding checks,
so we shouldn't call the returned value a "string" (which I'd like to
mean UTF-8).  Annotate them as byte arrays and add encoding warnings
to the docstrings.
Comment 3 Colin Walters 2011-06-16 18:01:43 UTC
Created attachment 190067 [details] [review]
GDataInputStream: Add _utf8() variants of _read_line

These will validate the resulting line, and throw a conversion error.
In practice these will likely be used by bindings, but it's good
for even C apps too that don't want to explode if that text file
they're reading into Pango actually has invalid UTF-8.
Comment 4 Matthias Clasen 2011-06-16 22:10:46 UTC
Review of attachment 190066 [details] [review]:

Good idea
Comment 5 Matthias Clasen 2011-06-16 22:13:21 UTC
Review of attachment 190067 [details] [review]:

Thanks for adding tests.
Don't forget to add the new functions to gio.symbols and gio-sections.txt and add Since: tags.

::: gio/gdatainputstream.c
@@ +825,3 @@
+ * If @cancellable is not %NULL, then the operation can be cancelled by
+ * triggering the cancellable object from another thread. If the operation
+ * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

Might be good to say here: 
If non-UTF-8 content is encountered, a  %G_CONVERT_ERROR is returned.
Comment 6 Matthias Clasen 2011-06-16 22:13:22 UTC
Review of attachment 190067 [details] [review]:

Thanks for adding tests.
Don't forget to add the new functions to gio.symbols and gio-sections.txt and add Since: tags.

::: gio/gdatainputstream.c
@@ +825,3 @@
+ * If @cancellable is not %NULL, then the operation can be cancelled by
+ * triggering the cancellable object from another thread. If the operation
+ * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.

Might be good to say here: 
If non-UTF-8 content is encountered, a  %G_CONVERT_ERROR is returned.
Comment 7 Colin Walters 2011-06-17 00:02:47 UTC
Attachment 190066 [details] pushed as ff2f46a - GDataInputStream: Clarify read_line() docs, mark as byte array
Attachment 190067 [details] pushed as 28254a3 - GDataInputStream: Add _utf8() variants of _read_line
Comment 8 David Zeuthen (not reading bugmail) 2011-06-17 12:16:01 UTC
Colin: you forgot Since tags and gio-sections.txt
Comment 9 Colin Walters 2011-06-17 12:52:36 UTC
(In reply to comment #8)
> Colin: you forgot Since tags and gio-sections.txt

Fixed, thanks.