Re: g_io_channel_read_chars() loop



On Thu, Aug 09, 2001 at 05:33:51PM +0100, Joel Becker wrote:
>    1676       do
>    1677         {
>    1678           prevchar = nextchar;
>    1679           nextchar = g_utf8_next_char (nextchar);
>    1680         }
>    1681       while (nextchar < channel->encoded_read_buf->str + got_bytes);
> 
> 	Much gdbing later, I discover that got_bytes == 17,
> channel->encoded_read_buf->len == 17, but channel->encoded_read_buf->str
> == "\0garbage".  So g_utf8_next_char() will never walk to the end of the
> string, and the while expression will never return false.

	More debugging and hunting.  It looks like some sort of race or
something, because I cannot make it trigger while stepping through the
code.  I have to 'continue' until it is looping, then C-c it.
	Why is g_utf8_skip[0] == 1?  If \0 is the end of a string, this
skips beyond the end.  I noticed this while debugging, because when this
situation occurs, you have channel->encoded_read_buf->str== "\0garbage".
nextchar = g_utf8_next_char("\0garbage"); should not move the nextchar
pointer to "garbage" IMHO.  If there is a reason for it, let me know.
	This is still not the entire problem, as got_bytes == 17 (or 22,
or whatever) guarantees that even with nextchar walking past \0 the
first garbage character the while() will not be FALSE.

Still puzzled
Joel

-- 

"Born under a bad sign.
 I been down since I began to crawl.
 If it wasn't for bad luck,
 I wouldn't have no luck at all."

			http://www.jlbec.org/
			jlbec evilplan org




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