] { } make
] with-destructors
] unit-test
+
+! Issue #1317
+{ "Red" } [
+ "resource:license.txt" binary [
+ input-stream [ <peek-stream> ] change
+ peek1 drop
+ 3 read >string
+ ] with-file-reader
+] unit-test
+
+{ "ist" } [
+ "resource:license.txt" binary [
+ input-stream [ <peek-stream> ] change
+ peek1 drop
+ 3 read drop
+ 2 peek drop
+ 3 read >string
+ ] with-file-reader
+] unit-test
! Copyright (C) 2011 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors combinators combinators.short-circuit
-destructors io io.private kernel locals math namespaces
+USING: accessors alien combinators combinators.short-circuit
+destructors io io.ports io.private kernel locals math namespaces
sequences vectors ;
IN: io.streams.peek
peeked <reversed> 0 buf copy
0 peeked shorten
n #peeked - :> n'
- buf #peeked tail-slice :> buf'
+ stream stream>> input-port? [
+ #peeked buf <displaced-alien>
+ ] [
+ buf #peeked tail-slice
+ ] if :> buf'
n' buf' stream stream-read-unsafe #peeked +
] if
] if ;