harmony:~/Projects/parrot ezekiel$ cat test.pir
.sub main @MAIN
$P0 = open "test.pir", "<"
$S0 = readline $P0
print $S0
$S1 = read $P0, 3
print $S1
print "\n"
.end
harmony:~/Projects/parrot ezekiel$ parrot test.pir
.sub main @MAIN
readline: buffer too short
harmony:~/Projects/parrot ezekiel$
The docs say that read is a quick hack (see #33915), so I'm not sure
this is a surprise.
--
matt diephouse
http://matt.diephouse.com
Mixing readline and read isn't really a good idea. Did you try to turn
on/off buffering before changing read modes? See PIO.setbuf().
leo
Regardless of whether or not it's a good idea, the documentation for
read says it should work:
"Read up to N bytes from standard input stream If stream is
linebuffered, will return at EOL, for files it will read
MIN(MAX(avail, N), 65535) bytes. Warning: This is a quick hack."
Unless I'm reading that incorrectly?
> harmony:~/Projects/parrot ezekiel$ cat test.pir
> .sub main @MAIN
> $P0 = open "test.pir", "<"
> $S0 = readline $P0
> print $S0
> $S1 = read $P0, 3
> print $S1
> print "\n"
> .end
> harmony:~/Projects/parrot ezekiel$ parrot test.pir
> .sub main @MAIN
> readline: buffer too short
Should be fixed now. Tests are welcome.
leo