io.buffers: fix buffer-until for iota (reported by Sascha Matzke)
parent
8c8818b00b
commit
dd0571e69a
|
@ -58,3 +58,7 @@ strings accessors destructors ;
|
|||
100 <buffer> "b" set
|
||||
[ 1000 "b" get n>buffer >string ] must-fail
|
||||
"b" get dispose
|
||||
|
||||
"hello world" string>buffer "b" set
|
||||
[ "hello" CHAR: \s ] [ " " "b" get buffer-until [ >string ] dip ] unit-test
|
||||
"b" get dispose
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
! 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
|
||||
|
@ -73,7 +73,9 @@ HINTS: >buffer byte-array buffer ;
|
|||
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 )
|
||||
[
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
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
|
||||
|
@ -23,6 +23,20 @@ IN: io.files.tests
|
|||
[ 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
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
This is a text file
|
Loading…
Reference in New Issue