USING: accessors io io.encodings io.encodings.ascii
-io.encodings.utf8 io.files io.streams.byte-array
-io.streams.string kernel namespaces tools.test ;
+io.encodings.string io.encodings.utf8 io.files
+io.streams.byte-array io.streams.string kernel namespaces
+tools.test ;
IN: io.encodings.tests
[ { } ]
output-stream get code>>
] with-byte-writer drop
] unit-test
+
+! Bug 1177.
+{
+ "! lol"
+ "! wat"
+ 13
+} [
+ "! lol\r\n! wat\r\n" utf8 encode
+ utf8 [
+ readln
+ "\r\n" read-until
+ ] with-byte-reader
+] unit-test
{ CHAR: \n [ line-ends\n ] }
} case ; inline
-M: decoder stream-read-until >decoder< decode-until ;
+M: decoder stream-read-until
+ dup cr>> [
+ 2dup
+ >decoder< decode-until
+ 2dup [ empty? ] [ CHAR: \n = ] bi* and [
+ 2drop stream-read-until
+ ] [
+ [ cr- drop ] 2dip
+ ] if
+ ] [
+ >decoder< decode-until
+ ] if ;
M: decoder stream-readln
"\r\n" over >decoder< decode-until handle-readln ;