! Copyright (C) 2004, 2005 Mackenzie Straight.
-! Copyright (C) 2006, 2008 Slava Pestov.
+! Copyright (C) 2006, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien alien.accessors alien.c-types
alien.data alien.syntax kernel libc math sequences byte-arrays
bi ; inline
: search-buffer-until ( pos fill ptr separators -- n )
- [ [ swap alien-unsigned-1 ] dip member-eq? ] 2curry find-from drop ; inline
+ [ iota ] 2dip
+ [ [ swap alien-unsigned-1 ] dip member-eq? ] 2curry
+ find-from drop ; inline
: finish-buffer-until ( buffer n -- byte-array separator )
[
USING: arrays debugger.threads destructors io io.directories
-io.encodings.ascii io.encodings.binary
-io.files io.files.private io.files.temp io.files.unique kernel
-make math sequences system threads tools.test generic.single
-io.encodings.8-bit.latin1 ;
+io.encodings.ascii io.encodings.binary io.encodings.string
+io.encodings.8-bit.latin1 io.files io.files.private
+io.files.temp io.files.unique kernel make math sequences system
+threads tools.test generic.single ;
IN: io.files.tests
[ ] [ "append-test" temp-file dup exists? [ delete-file ] [ drop ] if ] unit-test
[ read1 ] with-file-reader >fixnum
] unit-test
+[
+ "This" CHAR: \s
+] [
+ "vocab:io/test/read-until-test.txt" ascii
+ [ " " read-until ] with-file-reader
+] unit-test
+
+[
+ "This" CHAR: \s
+] [
+ "vocab:io/test/read-until-test.txt" binary
+ [ " " read-until [ ascii decode ] dip ] with-file-reader
+] unit-test
+
[ ] [
"It seems Jobs has lost his grasp on reality again.\n"
"separator-test.txt" temp-file latin1 set-file-contents