io.encodings: fix for read-until seps not containing \n.

db4
John Benediktsson 2014-10-31 09:33:59 -07:00
parent 632ee276e1
commit 5961cfb7b9
2 changed files with 22 additions and 5 deletions

View File

@ -87,3 +87,15 @@ unit-test
"\r\n" read-until
] with-byte-reader
] unit-test
{
"! lol"
"! wa"
116
} [
"! lol\r\n! wat\r\n" utf8 encode
utf8 [
readln
"t" read-until
] with-byte-reader
] unit-test

View File

@ -163,13 +163,18 @@ M: decoder stream-contents*
M: decoder stream-read-until
dup cr>> [
2dup
dup cr- 2dup
>decoder< decode-until
2dup [ empty? ] [ CHAR: \n = ] bi* and [
2drop stream-read-until
over [
dup CHAR: \n = [
2drop stream-read-until
] [
[ 2drop ] 2dip
] if
] [
[ cr- drop ] 2dip
] if
first-unsafe CHAR: \n = [ [ rest ] dip ] when
[ 2drop ] 2dip
] if-empty
] [
>decoder< decode-until
] if ;