g_io_channel_read_line does not honour the line_term symbols set
The g_io_channel_read_line
function uses a normal g_strndup
function to return the result.
However, when the line_term symbols are explicitly set and do not contains the \0
symbol, the g_io_channel_read_line
returns the proper length of the string using the line_term
symbols set by g_io_channel_set_line_term
, but the returned string is truncated at the first \0
instead of the first line_term
symbol.
GIOChannel* myChannel;
gchar* returnStr = NULL;
gsize msgLen = 0;
int fd = 3;
myChannel = g_io_channel_unix_new (fd);
g_io_channel_set_line_term(myChannel, "\n", 1);
g_io_channel_read_line(myChannel, &returnStr, &msgLen, NULL, NULL);
When I now put the string "Hello\0Goodbye\n"
on fd=3, I get the following results:
returnStr="Hello\0"
msgLen=14
This is inconsistent. I would expect:
returnStr="Hello\0Goodbye\n\0"
msgLen=14
The latter is also what g_io_channel_read_line_string
is returning
Edited by Philip Withnall