id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc,lang,patch,platform
52,Parrot can't read from stdin,rgrjr,,"Copying this test code:

{{{
.sub test :main
	## Test reading five characters from stdin.
	.local string input_string
	.local int len
	input_string = read 5
	len = length input_string
	print ""[read '""
	print input_string
	print ""' len ""
	print len
	print ""]\n""
.end
}}}

into read-stdin.pir and running it in r33938 produces the following
result:

{{{
rogers@rgr> ./parrot read-stdin.pir < read-stdin.pir 
[read '^@^@^@^@^@' len 5]
rogers@rgr> 
}}}

We've told Parrot to read five characters, but the five characters it
reports are ASCII nuls (which I've replaced with '!^@' to make them
readable), rather than the expected "".sub "".  Terminal input has the
same problem.

I've tracked this to somewhere between Parrot_io_read_buffer and
Parrot_io_read_unix, which is called in the ""if (len >=
Parrot_io_get_buffer_size(interp, filehandle)) { ... }"" case.  I do not
understand why Parrot_io_read_unix calls Parrot_io_make_string on the
passed buffer arg; doesn't that just reallocate strstart?

FWIW, the logic in Parrot_io_read_win32 is somewhat different, so the
bug might not be present on Windows; I can't check that.

-- Bob Rogers, http://www.rgrjr.com/
",bug,closed,normal,,core,,medium,fixed,,,,,
