io.encodings: fix for read-until seps not containing \n.
parent
632ee276e1
commit
5961cfb7b9
|
@ -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
|
||||
|
|
|
@ -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 ;
|
||||
|
|
Loading…
Reference in New Issue