]> gitweb.factorcode.org Git - factor.git/commitdiff
merged streams, stdio and files into io vocabulary
authorSlava Pestov <slava@factorcode.org>
Sun, 19 Jun 2005 21:50:35 +0000 (21:50 +0000)
committerSlava Pestov <slava@factorcode.org>
Sun, 19 Jun 2005 21:50:35 +0000 (21:50 +0000)
112 files changed:
TODO.FACTOR.txt
contrib/algebra/infix.factor
contrib/algebra/repl.factor
contrib/algebra/tests.factor
contrib/cont-responder/cont-examples.factor
contrib/cont-responder/cont-numbers-game.factor
contrib/cont-responder/cont-testing.factor
contrib/cont-responder/eval-responder.factor
contrib/cont-responder/live-updater-responder.factor
contrib/cont-responder/live-updater.factor
contrib/cont-responder/load.factor
contrib/cont-responder/todo-example.factor
contrib/cont-responder/todo.factor
contrib/crypto/md5.factor
contrib/parser-combinators/lazy.factor
contrib/parser-combinators/parser-combinators.factor
contrib/postgresql/postgresql-test.factor
contrib/sqlite/test.factor
examples/dump.factor
examples/irc.factor
examples/lcd.factor
examples/mandel.factor
examples/numbers-game.factor
examples/timesheet.factor
examples/turing.factor
library/alien/aliens.factor
library/alien/compiler.factor
library/bootstrap/boot-stage1.factor
library/bootstrap/boot-stage2.factor
library/bootstrap/boot-stage3.factor
library/bootstrap/boot-stage4.factor
library/bootstrap/image.factor
library/bootstrap/init.factor
library/bootstrap/primitives.factor
library/bootstrap/win32-io.factor
library/cli.factor
library/compiler/compiler.factor
library/errors.factor
library/eval-catch.factor
library/httpd/browser-responder.factor
library/httpd/cont-responder.factor
library/httpd/file-responder.factor
library/httpd/html-tags.factor
library/httpd/html.factor
library/httpd/http-client.factor
library/httpd/http-common.factor
library/httpd/httpd.factor
library/httpd/load.factor
library/httpd/mime.factor
library/httpd/resource-responder.factor
library/httpd/responder.factor
library/inference/conditions.factor
library/inference/test.factor
library/io/ansi.factor
library/io/binary.factor
library/io/c-streams.factor
library/io/directories.factor
library/io/files.factor
library/io/lines.factor [new file with mode: 0644]
library/io/logging.factor
library/io/stdio.factor
library/io/stream.factor
library/sdl/load.factor
library/syntax/parse-stream.factor
library/syntax/parse-words.factor
library/syntax/prettyprint.factor
library/syntax/see.factor
library/test/binary.factor
library/test/combinators.factor
library/test/continuations.factor
library/test/errors.factor
library/test/files.factor
library/test/generic.factor
library/test/httpd/html.factor
library/test/httpd/httpd.factor
library/test/image.factor
library/test/interpreter.factor
library/test/io/io.factor
library/test/listener.factor
library/test/stream.factor
library/test/test.factor
library/test/threads.factor
library/tools/annotations.factor
library/tools/debugger.factor
library/tools/interpreter.factor
library/tools/jedit-wire.factor
library/tools/jedit.factor
library/tools/listener.factor
library/tools/memory.factor
library/tools/telnetd.factor
library/tools/walker.factor
library/tools/word-tools.factor
library/ui/buttons.factor
library/ui/hand.factor
library/ui/labels.factor
library/ui/load.factor
library/ui/paint.factor
library/ui/panes.factor
library/ui/presentations.factor
library/ui/text.factor
library/ui/tool-menus.factor
library/ui/world.factor
library/unix/files.factor
library/unix/io.factor
library/unix/sockets.factor
library/vocabularies.factor
library/win32/win32-io-internals.factor
library/win32/win32-server.factor
library/win32/win32-stream.factor
native/io.c
native/io.h
native/primitives.c

index 147ef93c1fa241bdb1852bc96282bfe4435e1ac5..dc81b720a594864d148c85314df1b1e325dbb73f 100644 (file)
@@ -10,6 +10,7 @@
 <magnus--> http://www.caddr.com/macho/archives/sbcl-devel/2005-3/4764.html\r
 <magnus--> http://clozure.com/cgi-bin/viewcvs.cgi/ccl/lisp-kernel/lisp-exceptions.c?rev=1.9&content-type=text/vnd.viewcvs-markup\r
 \r
+- set-length should not shorten the underlying sequence\r
 - there is a problem with hashcodes of words and bootstrapping\r
 - http keep alive, and range get\r
 - sleep word\r
index 879a3cc19f4be1463946bf28a76da2811e80134c..576eb0ccd431e5e2563f535b69ed199be2d9c07b 100644 (file)
@@ -1,5 +1,5 @@
 IN: algebra
-USING: kernel lists math namespaces test stdio words parser
+USING: kernel lists math namespaces test io words parser
     generic errors prettyprint vectors kernel-internals ;
 
 SYMBOL: variable?
index 555b48f80ff422d58dcaeaf40da5fb4a286ee5c6..12b44e8afc9225b6c3d0153a61e6c3170e2c6ae4 100644 (file)
@@ -1,4 +1,4 @@
-IN: algebra USING: prettyprint stdio kernel parser ;
+IN: algebra USING: prettyprint io kernel parser ;
 
 : algebra-repl ( -- )
     "ok " write flush
index 06a9900e69c913a815f0125dea74701face3c66f..ec1b73810cefdae3a9481bcebaf2fa28a009259c 100644 (file)
@@ -1,4 +1,4 @@
-USING: algebra test math kernel prettyprint stdio ;
+USING: algebra test math kernel prettyprint io ;
 
 [ [ - [ + x [ mod [ * 2 pi ] 4 ] ] ] ] [
     ([ - x + [ 2 * pi ] mod 4 ])
index 5ca77a1e76baf32cbd20650d1b7f4682d1df6892..0d94a61f1d320af5b17c4038c350881b324e94e3 100644 (file)
@@ -26,7 +26,7 @@ IN: cont-examples
 USE: cont-responder
 USE: html
 USE: kernel
-USE: stdio
+USE: io
 USE: html
 USE: lists
 USE: strings
index de8293aaba386a3489d246541d517dd1ad660708..ddde1ec541cc533a9dd6f3dcef35fcee8b380e40 100644 (file)
@@ -39,7 +39,7 @@ USE: random
 USE: parser
 USE: html
 USE: cont-responder
-USE: stdio
+USE: io
 USE: namespaces
 
 : web-print ( str -- )
index 899b8b37127412fd0c3cb910f9959a2c7c8ba247..5316f875894421523eb7641934106176d982e381 100644 (file)
@@ -88,7 +88,7 @@ IN: cont-responder
 USE: namespaces
 USE: kernel
 USE: combinators
-USE: stdio
+USE: io
 
 : <cont-test-state> ( -- <state> )
   #! Create a namespace holding data required
index 4442a236999a6abcb168a43e2e12a3b25ff65a64..a1fe8e1e2d7efa59a639d7175883f9147d6fb983 100644 (file)
@@ -27,9 +27,8 @@ IN: eval-responder
 USE: html
 USE: cont-responder
 USE: kernel
-USE: stdio
 USE: namespaces
-USE: streams
+USE: io
 USE: parser
 USE: lists
 USE: errors
index 04e7e4a8395dff0abc58c5fe6511f2cb197aed5e..db498ac73c9826fcec66e23f5d3a6b887a05c939 100644 (file)
@@ -29,7 +29,7 @@ USE: live-updater
 USE: namespaces
 USE: html
 USE: words
-USE: stdio
+USE: io
 USE: kernel
 USE: cont-responder
 USE: prettyprint
index 16c28921a14c4683c7cb559ca46ee2c5e4079ad1..1e4ca45178d034b8e1a1f88ce34fe2c649690ae2 100644 (file)
 ! and the 'liveUpdater.js' code.
 IN: live-updater
 USE: kernel
-USE: streams
+USE: io
 USE: strings
 USE: html
 USE: cont-responder
-USE: stdio
 USE: namespaces
 USE: lists
 
index 159689a19d904c23daea7876f6c88b94e750c6f6..21646b40d40846739d7646589e370aa0ea979e93 100644 (file)
@@ -28,7 +28,7 @@ USE: httpd
 USE: threads
 USE: prettyprint
 USE: errors
-USE: stdio
+USE: io
 
 USE: parser
 
index cafaa483ac90b640b276d54f76a8121c5814b20c..120e256105e78af109a1ad7086024aaa555bc40b 100644 (file)
@@ -29,8 +29,7 @@
 IN: todo-example
 USE: cont-responder
 USE: html
-USE: html
-USE: stdio
+USE: io
 USE: strings
 USE: namespaces
 USE: inspector
index 8c8a77a97d2121668419ea291c800bd88efecee2..cae2b2f0bf0c24f87825fed8395f8317f13e5e6e 100644 (file)
 IN: todo
 USE: parser
 USE: strings
-USE: streams
+USE: io
 USE: namespaces
 USE: lists
 USE: math
-USE: stdio
 USE: kernel
 USE: prettyprint
-USE: files
 USE: hashtables
 USE: sequences
 USE: http
index 04d19ade1ae92be259a81282d26b972f6f947a04..469931d993a070b0a3f1d433354ba6b798df6aa8 100644 (file)
@@ -1,5 +1,6 @@
 IN: crypto
-USING: kernel streams strings stdio sequences namespaces math prettyprint unparser test parser lists ;
+USING: kernel io strings sequences namespaces math prettyprint
+unparser test parser lists ;
 
 SYMBOL: a
 SYMBOL: b
index a85fb538824b0f829fe251dd437db424426988e0..62ee083370548bbd821a6de54566cf21b9a59074 100644 (file)
@@ -177,7 +177,7 @@ DEFER: lappend*
 DEFER: (lappend*)
 TUPLE: lappend*-state current rest ;
 
-USE: stdio 
+USE: io 
 
 : (lappend*-cdr) ( state -- llist )
   #! Given the state object, do the cdr portion of the
index d611c321a21c74d2a6ded7178f68483de323daf2..621491c63bd1ff45d484c041076ec76bbc8ddee5 100644 (file)
@@ -402,7 +402,7 @@ DEFER: <*>
 USE: prettyprint 
 USE: parser
 USE: unparser
-USE: stdio
+USE: io
 
 ! Testing <&>
 : test1 "abcd" "a" token "b" token <&> call [ . ] leach ;
index b5925dd82776d062c88e81d6315756df03a9945d..46fcab216abb675058a99dc58578147be3917612 100644 (file)
@@ -2,7 +2,7 @@
 ! Set username and password in  the 'connect' word.
 
 IN: postgresql-test
-USING: kernel postgresql alien errors stdio ;
+USING: kernel postgresql alien errors io ;
 
 
 : connect ( -- PGconn )
index 59be1583cfebd0246225b66c69fcafd86a04c127..f6044cc1d0e02107032b4ae7233927445fd72fa8 100644 (file)
@@ -34,7 +34,7 @@
 !  Then run this file.
 USE: sqlite
 USE: kernel
-USE: stdio
+USE: io
 USE: prettyprint
 
 : show-people ( statement -- )
index b570914ebb4001e8f12571768586da6142057ba4..536921fc4b2b21a9d15436d32a0f7a4978ff31f9 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: dump
 USING: alien assembler generic kernel kernel-internals lists
-math memory sequences stdio strings unparser ;
+math memory sequences io strings unparser ;
 
 : cell. >hex cell 2 * CHAR: 0 pad write ;
 
index 1fa67e7cc3bc070d9e2e4c263dd58ec1bc2ae384..ba53ff5c16bdf5e4e9ad1375e0c3471b25324837 100644 (file)
@@ -1,8 +1,7 @@
 ! A simple IRC client written in Factor.
 
 IN: irc
-USING: kernel lists math namespaces stdio streams strings
-threads words ;
+USING: kernel lists math namespaces io strings threads words ;
 
 SYMBOL: irc-stream
 SYMBOL: channels
index 21a5598300a67daa7ecb0857e53e8aef260f1610..0414501fb2ff885d3d585da8269dfd3d4a567ca2 100644 (file)
@@ -1,4 +1,4 @@
-USING: sequences kernel math stdio strings ;
+USING: sequences kernel math io strings ;
 
 : lcd-digit ( digit row -- str )
     {
index a50b61104d3ebd23efa45be094e7d60dc905e2d5..6f893bbb6f7ad087bdd5e3e397a5388ce47e7060 100644 (file)
@@ -28,7 +28,7 @@ USE: sdl-video
 USE: vectors
 USE: prettyprint
 USE: sequences
-USE: stdio
+USE: io
 USE: test
 
 : f_ ( h s v i -- f ) >r swap rot >r 2dup r> 6 * r> - ;
index da2fb7fc80d946ecbb350184c3a92cdf6da2d168..324f9ad287340725cb2510ef496a1702fd416b5f 100644 (file)
@@ -1,7 +1,7 @@
 ! Numbers game example
 
 IN: numbers-game
-USING: kernel math parser random stdio ;
+USING: kernel math parser random io ;
 
 : read-number ( -- n ) read parse-number ;
 
index cbf1fb016e158599968888e1c38ad08babb86e4b..75259ef698a2b89481d471a70405e57cc93978f0 100644 (file)
@@ -1,7 +1,7 @@
 ! Contractor timesheet example
 
 IN: timesheet
-USING: errors kernel lists math namespaces sequences stdio
+USING: errors kernel lists math namespaces sequences io
 strings unparser vectors ;
 
 ! Adding a new entry to the time sheet.
index b4a1821e9c22d98c40f31f327006907b3f669ca8..970e669b33b7b5015b31612ff0ea9765ed22b9e7 100644 (file)
@@ -1,6 +1,6 @@
 IN: turing
 USING: hashtables kernel lists namespaces sequences vectors math
-prettyprint stdio strings words ;
+prettyprint io strings words ;
 
 ! A turing machine simulator.
 
index 3c30e778de1c8b5a7872c0d5a4380b951b970985..c3e930c0cecdc0082719820ff43f1de0e5708536 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2004, 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: alien
-USING: hashtables kernel lists math namespaces parser stdio ;
+USING: hashtables kernel lists math namespaces parser io ;
 
 DEFER: dll?
 BUILTIN: dll 15 dll? [ 1 "dll-path" f ] ;
index 495d6c3624045a11427ef7f753011bac37daebd4..0a4afea1dbed38ecafe66e2c13d443360b815d9d 100644 (file)
@@ -3,7 +3,7 @@
 IN: alien
 USING: assembler compiler compiler-backend compiler-frontend
 errors generic hashtables inference kernel lists math namespaces
-sequences stdio strings unparser words ;
+sequences io strings unparser words ;
 
 ! ! ! WARNING ! ! !
 ! Reloading this file into a running Factor instance on Win32
index 64a61dd9e9268965a8845edeef1a36e26f9b6506..0708e33a0633b4fe8e01849f199d1d7aa02713ac 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: image
 USING: generic hashtables kernel lists math memory namespaces
-parser prettyprint sequences stdio vectors words ;
+parser prettyprint sequences io vectors words ;
 
 "Bootstrap stage 1..." print
 
@@ -51,6 +51,7 @@ parser prettyprint sequences stdio vectors words ;
 
         "/library/io/stream.factor"
         "/library/io/stdio.factor"
+        "/library/io/lines.factor"
         "/library/io/c-streams.factor"
         "/library/io/files.factor"
 
index fe85882fcc5e2543ac1bb6691e4a730d73288aa6..3e3ba54c6fcbabcc34ee00df2254addf2df0b063 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2004, 2005 Slava Pestov.\r
 ! See http://factor.sf.net/license.txt for BSD license.\r
 USING: alien assembler command-line compiler generic hashtables\r
-kernel lists memory namespaces parser sequences stdio unparser\r
+kernel lists memory namespaces parser sequences io unparser\r
 words ;\r
 \r
 : pull-in ( ? list -- )\r
index 8c81ec9e8a2aa806f8c281a94c3b749f5b9501f8..46c4764d0459a267b2d01e8e7edb5ff6cd47ab15 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 USING: alien assembler command-line compiler compiler-backend
 compiler-frontend io-internals kernel lists math namespaces
-parser sequences stdio unparser words ;
+parser sequences io unparser words ;
 
 "Compiling base..." print
 
index 9c8d3ec5a093c49eef9084bbf72ea7fb5710acc8..96809a3b1a3dec9a127a43024ff6e92dbbcbc228 100644 (file)
@@ -3,7 +3,7 @@
 IN: kernel
 USING: alien assembler command-line compiler console errors
 generic inference kernel-internals listener lists math memory
-namespaces parser presentation prettyprint random stdio streams
+namespaces parser presentation prettyprint random io
 unparser words ;
 
 "Bootstrap stage 4..." print
index d870e86feed5aef6c4b82416806e6cbbefcff772..4a3ad8e7417abe782e6d67d4ff00b191dced2aa2 100644 (file)
@@ -16,8 +16,8 @@
 
 IN: image
 USING: errors generic hashtables kernel lists
-math namespaces parser prettyprint sequences sequences stdio
-streams strings vectors words ;
+math namespaces parser prettyprint sequences sequences io
+strings vectors words ;
 
 ! The image being constructed; a vector of word-size integers
 SYMBOL: image
index 9007933bbdcc9f1cb509af9142f502c63c6065c5..ad568c73c79fefa9c2111664fefcb1ace0f8e983 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2004, 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: kernel
-USING: io-internals namespaces parser stdio threads words ;
+USING: io-internals namespaces parser io threads words ;
 
 : boot ( -- )
     #! Initialize an interpreter with the basic services.
index 5cbd8cd5c5fa5f70d18d0c83aa914b2467183ce3..3af6bc766ab460ab70e04b49028d1228b6a94176 100644 (file)
@@ -127,8 +127,8 @@ vocabularies get [
     [ "eq?" "kernel"                          [ [ object object ] [ boolean ] ] ]
     [ "getenv" "kernel-internals"             [ [ fixnum ] [ object ] ] ]
     [ "setenv" "kernel-internals"             [ [ object fixnum ] [ ] ] ]
-    [ "stat" "files"                          [ [ string ] [ general-list ] ] ]
-    [ "(directory)" "files"                   [ [ string ] [ general-list ] ] ]
+    [ "stat" "io"                             [ [ string ] [ general-list ] ] ]
+    [ "(directory)" "io"                      [ [ string ] [ general-list ] ] ]
     [ "gc" "memory"                           [ [ fixnum ] [ ] ] ]
     [ "gc-time" "memory"                      [ [ string ] [ ] ] ]
     [ "save-image" "memory"                   [ [ string ] [ ] ] ]
@@ -142,8 +142,8 @@ vocabularies get [
     [ "millis" "kernel"                       [ [ ] [ integer ] ] ]
     [ "(random-int)" "math"                   [ [ ] [ integer ] ] ]
     [ "type" "kernel"                         [ [ object ] [ fixnum ] ] ]
-    [ "cwd" "files"                           [ [ ] [ string ] ] ]
-    [ "cd" "files"                            [ [ string ] [ ] ] ]
+    [ "cwd" "io"                              [ [ ] [ string ] ] ]
+    [ "cd" "io"                               [ [ string ] [ ] ] ]
     [ "compiled-offset" "assembler"           [ [ ] [ integer ] ] ]
     [ "set-compiled-offset" "assembler"       [ [ integer ] [ ] ] ]
     [ "literal-top" "assembler"               [ [ ] [ integer ] ] ]
index aae707f0078ad55819356d235947c652887e796c..c51094e12c529ffea8e7ebb277d3a0a3bcfdb9a0 100644 (file)
 ! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 ! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-IN: streams
+IN: io
 USE: compiler
 USE: namespaces
-USE: stdio
 USE: kernel
 USE: win32-io-internals
 USE: win32-stream
index 2ded75a6c60aaaed29b1ee103d15d827615c4a8f..59521fc017e19f7e7f2ef21664a4e14a29d161f5 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2003, 2004 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: command-line
-USING: files kernel kernel-internals lists namespaces parser
+USING: io kernel kernel-internals lists namespaces parser
 sequences strings ;
 
 ! This file is run as the last stage of boot.factor; it relies
index 2229c8e93d2d6ad4bcc4317579debd9b27677283..9aac8d5edcd15c011cfb16c2d39a0bc0c12182c6 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2004, 2005 Slava Pestov.
 IN: compiler
 USING: compiler-backend compiler-frontend errors inference
-kernel lists math namespaces prettyprint stdio words ;
+kernel lists math namespaces prettyprint io words ;
 
 : supported-cpu? ( -- ? )
     cpu "unknown" = not ;
index f29bcbb3e5bb09996ad9dd132f873850143fa2bb..9c374e70855d17d9ce7d7b888b61dae5104b9ff0 100644 (file)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2004, 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: kernel
+USING: kernel-internals lists ;
 DEFER: callcc1
 IN: errors
-USING: kernel-internals lists namespaces streams ;
 
 TUPLE: no-method object generic ;
 
index 5a210241481c95389ceefc6fd6311b01286dd1c5..53c0bf8f6632fab48b8d49fa92509802eec17070 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2004, 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
-IN: parser USING: kernel errors stdio ;
+IN: parser USING: kernel errors io ;
 
 : eval-catch ( str -- )
     [ eval ] [ [ print-error debug-help drop ] when* ] catch ;
index b4a5130cf954b5e596b6d83611d9cdf919cc4061..0322e95a0cb5647613bfa1c79c9fae9b9e7b7893 100644 (file)
@@ -25,8 +25,8 @@
 ! cont-responder facilities.
 !
 IN: browser-responder
-USING: html cont-responder kernel stdio namespaces words lists
-streams strings inspector kernel prettyprint words http parser
+USING: html cont-responder kernel io namespaces words lists
+io strings inspector kernel prettyprint words http parser
 errors unparser listener hashtables memory
 sequences ;
 
index d9f5bd9d4a060adbb89abc700a0c4ad8802e6d4f..eb41b889fb9d60091592a4af52bda6a4aa2ce4d8 100644 (file)
@@ -21,7 +21,7 @@
 ! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 ! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 IN: cont-responder
-USING: stdio http httpd math random namespaces streams
+USING: http httpd math random namespaces io
        lists strings kernel html unparser hashtables
        parser generic sequences ;
 
index 5a272003c15e39a7a35ab10ad5ae56e59504dd0a..b0c171e006110f27f9fe3bf71d16298877cbaac2 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2004,2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: file-responder
-USING: files html httpd kernel lists namespaces parser sequences
-stdio streams strings unparser ;
+USING: html httpd kernel lists namespaces parser sequences
+io strings unparser ;
 
 : serving-path ( filename -- filename )
     [ "" ] unless* "doc-root" get swap append ;
index a253da5b6606b22cf3beb6eb6b54bc038df9e570..5f9f55698d4c6f841cfac43093cafaf994bec3e9 100644 (file)
@@ -27,7 +27,7 @@ IN: html
 USE: strings
 USE: lists
 USE: kernel
-USE: stdio
+USE: io
 USE: namespaces
 USE: words
 USE: sequences
index 79ef06ab8f29918464187964fd8bdf6ec765fcc1..bf270ec3ff65b352c19dec8412efa6ea48118cd2 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: html
 USING: generic kernel lists namespaces presentation sequences
-stdio streams strings unparser http ;
+io strings unparser http ;
 
 : html-entities ( -- alist )
     [
index 574a18a0f44f172456c36c13eeb73c6154ac3eea..98003c4fc0337c9d1a192ea2c144cf13fe4b8b76 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: http-client
 USING: errors http kernel lists namespaces parser sequences
-stdio streams strings unparser ;
+io strings unparser ;
 
 : parse-host ( url -- host port )
     #! Extract the host name and port number from an HTTP URL.
index 9702aedeb559ca92ffafd9628d96e6fa6de8fa00..163d36f0224ad930995b5a655fb2838725856919 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2003, 2005 Slava Pestov
 IN: http
 USING: errors kernel lists math namespaces parser sequences
-stdio streams strings unparser ;
+io strings unparser ;
 
 : header-line ( alist line -- alist )
     ": " split1 dup [ cons swons ] [ 2drop ] ifte ;
index 5e10608d68f3f5dc9efd9e8f6846e6be0c3fda04..4646f76a2f43843efa66dc30c5dd9173610507ea 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2003, 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: httpd
-USING: errors kernel lists namespaces
-stdio streams strings threads http sequences ;
+USING: errors kernel lists namespaces io strings threads http
+sequences ;
 
 : (url>path) ( uri -- path )
     url-decode "http://" ?head [
index 33aefd0ce68fb5c4fbd1c3d2c28b4eec60fe0309..3d78266fc90cbea7bf5a925d95a4bc5f08a0bfee 100644 (file)
@@ -1,4 +1,4 @@
-USING: kernel parser sequences stdio ;
+USING: kernel parser sequences io ;
 [
     "/library/httpd/http-common.factor"
     "/library/httpd/mime.factor"
index 89e44c1b11188fa4d65cc705c5190d586c704e42..5965a2862449b8fbb31dbc884ba5f6d04bac63e5 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2004, 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: httpd
-USING: files hashtables kernel lists namespaces ;
+USING: io hashtables kernel lists namespaces ;
 
 : set-mime-types ( assoc -- )
     "mime-types" global set-hash ;
index 92c160e106d9491f228892d1dc29d0b66931c660..fa5f94150a12777f44f26c40c579aece0d0aa130 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2004, 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: resource-responder
-USING: httpd kernel lists namespaces stdio streams ;
+USING: httpd kernel lists namespaces io ;
 
 : resource-response ( mime-type -- )
     "Content-Type" swons unit "200 OK" response terpri ;
index d44c4eb27460d3ca5cc2e9c2bf5033b635fe31ec..da53518097396ec2f9b73c00bc0e6d5cbe8e63c7 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: httpd
 USING: hashtables http kernel lists namespaces parser sequences
-stdio streams strings ;
+io strings ;
 
 ! Variables
 SYMBOL: vhosts
index 7bc1b4dabb131d9a38bc48367a69b81c5bb846be..dad8880c332fac21a336a345248339de13b30eef 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: inference
 USING: errors interpreter kernel lists namespaces prettyprint
-sequences stdio ;
+sequences io ;
 
 DEFER: recursive-state
 
index a484a89cb39af959d5549f479f08186f7195d414..1cfd98bd136645e60f99bdde2a4dce221bc8fb42 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: test
 USING: errors inference kernel lists namespaces prettyprint
-stdio strings unparser ;
+io strings unparser ;
 
 : try-infer ( quot -- effect error )
     [ infer f ] [ [ >r drop f r> ] when* ] catch ;
index 09d29e25d860b40c6380fce33e9a70fd9fd434ef..6d80233cf36e1f4766d105e10e57f7f6cfa1e591 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2004, 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: ansi
-USING: lists kernel namespaces stdio streams strings
+USING: lists kernel namespaces io strings
 presentation generic sequences ;
 
 ! <ansi-stream> raps the given stream in an ANSI stream. ANSI
index fbd0918826be3fe4c1ad931cf4e8b7f6f0dd62c5..fbb28b44062413a7620b24aea7b945c8dbdb211e 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2003, 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
-IN: stdio
+IN: io
 USING: kernel lists math sequences strings ;
 
 : be> ( seq -- x ) 0 swap [ >r 8 shift r> bitor ] each ;
index 59dc4756e32dce1c4f16e334eb94f2d984e01f47..53ad13ad9407e2e624c94825f75b36d096b6ee88 100644 (file)
@@ -1,16 +1,12 @@
 ! Copyright (C) 2004, 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: io-internals
-USING: errors kernel kernel-internals namespaces stdio streams
+USING: errors kernel kernel-internals namespaces io
 strings threads ;
 
 ! Simple wrappers for ANSI C I/O functions, used for
 ! bootstrapping only.
 
-! Note that c-streams are pretty limited and broken. Namely,
-! there is a limit of 1024 characters per line, and lines
-! containing \0 are not read properly.
-
 ! More elaborate platform-specific I/O code is used on Unix and
 ! Windows; see library/unix and library/win32.
 
@@ -20,9 +16,6 @@ M: c-stream stream-write-attr ( str style stream -- )
     nip >r dup string? [ ch>string ] unless r>
     c-stream-out fwrite ;
 
-M: c-stream stream-readln ( stream -- str )
-    c-stream-in dup [ fgets ] when ;
-
 M: c-stream stream-read1 ( stream -- str )
     c-stream-in dup [ fgetc ] when ;
 
@@ -37,12 +30,12 @@ M: c-stream stream-close ( stream -- )
     c-stream-out [ fclose ] when* ;
 
 : init-io ( -- )
-    13 getenv  14 getenv  t <c-stream> stdio set ;
+    13 getenv  14 getenv  t <c-stream> <line-reader> stdio set ;
 
-IN: streams
+IN: io
 
 : <file-reader> ( path -- stream )
-    "rb" fopen f f <c-stream> ;
+    "rb" fopen f f <c-stream> <line-reader> ;
 
 : <file-writer> ( path -- stream )
     "wb" fopen f swap f <c-stream> ;
index f1df6619a77875d94b094c4a1c410f73d64b9ef5..f80fc03042b9871e0770f94ab73d9ccdc8c92a28 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2004, 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
-IN: files
+IN: io
 USING: kernel hashtables lists namespaces presentation
-sequences stdio streams strings unparser ;
+sequences strings unparser ;
 
 ! Hyperlinked directory listings.
 
index 55a7ca4da62838050dc128db5e8645bbbf0a6e3f..4b89651694d8ee8431769611fa158fe902d6b935 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2004, 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
-IN: files
+IN: io
 USING: kernel lists sequences strings ;
 
 ! Words for accessing filesystem meta-data.
diff --git a/library/io/lines.factor b/library/io/lines.factor
new file mode 100644 (file)
index 0000000..6ac5d6c
--- /dev/null
@@ -0,0 +1,38 @@
+! Copyright (C) 2004, 2005 Slava Pestov.
+! See http://factor.sf.net/license.txt for BSD license.
+USING: generic kernel namespaces sequences io ;
+
+TUPLE: line-reader cr ;
+
+C: line-reader ( stream -- line ) [ set-delegate ] keep ;
+
+: cr> dup line-reader-cr f rot set-line-reader-cr ;
+
+: (read-line) ( ? line -- ? )
+    #! The flag is set after the first character is read.
+    dup delegate stream-read1 dup [
+        >r >r drop t r> r> dup CHAR: \r = [
+            drop t swap set-line-reader-cr
+        ] [
+            dup CHAR: \n = [
+                drop dup cr> [ (read-line) ] [ drop ] ifte
+            ] [
+                , (read-line)
+            ] ifte
+        ] ifte
+    ] [
+        2drop
+    ] ifte ;
+
+M: line-reader stream-readln ( line -- string )
+    [ f swap (read-line) ] make-string
+    dup empty? [ f ? ] [ nip ] ifte ;
+
+M: line-reader stream-read ( count line -- string )
+    [ delegate stream-read ] keep dup cr> [
+        over empty?
+        [ drop ]
+        [ >r 1 swap tail r> stream-read1 [ append ] when* ] ifte
+    ] [
+        drop
+    ] ifte ;
index 3484cd43bccda4946c8064439c6eb1fc25b3fc89..64e8d7ea790ef36129c0934c6c2065680e00b486 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2003, 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
-IN: streams
-USING: kernel namespaces stdio sequences strings unparser ;
+IN: io
+USING: kernel namespaces io sequences strings unparser ;
 
 ! A simple logging framework.
 SYMBOL: log-stream
index 93edec8ca62bc78d63043ecc9b0c4d1739517402..b82431f0c55c70112429acc2c761a6567087767a 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2003, 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
-IN: stdio
-USING: errors kernel lists namespaces streams generic strings ;
+IN: io
+USING: errors kernel lists namespaces generic strings ;
 
 SYMBOL: stdio
 
index ee8f5604a4286b71f704694d04d9f9065ef034a4..075cca70ff31e802b09cd34ac87e7000aa7257b6 100644 (file)
@@ -1,19 +1,16 @@
 ! Copyright (C) 2003, 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
-IN: files
-USING: kernel strings sequences ;
+IN: io
+USING: errors generic kernel lists math namespaces sequences
+strings ;
 
 ! We need this early during bootstrap.
 : path+ ( path path -- path )
     #! Combine two paths. This will be implemented later.
     "/" swap append3 ;
 
-IN: stdio
 DEFER: stdio
 
-IN: streams
-USING: errors generic lists math namespaces sequences ;
-
 ! Stream protocol.
 GENERIC: stream-flush      ( stream -- )
 GENERIC: stream-auto-flush ( stream -- )
index af12c572d8934d002af61c6f2360d32abbf3ae9c..5454f72f058f17f81203d35c0248919263a17d07 100644 (file)
@@ -1,4 +1,4 @@
-USING: kernel parser sequences stdio ;
+USING: kernel parser sequences io ;
 [
     "/library/sdl/sdl.factor"
     "/library/sdl/sdl-video.factor"
index b8d2f56210cde62330cfcfef3daf732c3a511f7b..e9b13221c9cf276a02123287c8769637ea64c78c 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2004, 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: parser
-USING: kernel lists namespaces sequences streams strings ;
+USING: kernel lists namespaces sequences io ;
 
 : file-vocabs ( -- )
     "file-in" get "in" set
index f57b59b681272b5e5016222827446aea4f81b799..651b22fb3fc5c0a75bf5f7da1c1a25e28ef8a044 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: parser
-USING: errors kernel lists math namespaces sequences streams
+USING: errors kernel lists math namespaces sequences io
 strings unparser words ;
 
 ! The parser uses a number of variables:
index 6f55cf8351f27ae31913d07630c2fa5e122bde6c..683316f761ac9b10754bade60f5f82e25f9cbf2c 100644 (file)
@@ -2,8 +2,8 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: prettyprint
 USING: alien errors generic hashtables kernel lists math
-matrices memory namespaces parser presentation sequences stdio
-streams strings unparser vectors words ;
+matrices memory namespaces parser presentation sequences io
+strings unparser vectors words ;
 
 SYMBOL: prettyprint-limit
 SYMBOL: one-line
index b48a4b3586ee4f6d55cb4e22afd3636234b7e61b..4f97c6e5f0a37b2fb8f14f426ad742b549b4a054 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2003, 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: prettyprint
-USING: #<unknown> generic hashtables kernel lists math
-namespaces sequences stdio streams strings unparser words ;
+USING: generic hashtables io kernel lists namespaces sequences
+streams strings unparser words ;
 
 ! Prettyprinting words
 : vocab-actions ( search -- list )
index 49b64b38d3ab2c855eaf0f51a9138e7d4ac66819..986ea4506f9a81df0d9213eecc4bcfbe21cb78b8 100644 (file)
@@ -1,5 +1,5 @@
 IN: temporary
-USING: stdio test ;
+USING: io test ;
 
 [ "\0\0\u0004\u00d2" ] [ 1234 4 >be ] unit-test
 [ "\u00d2\u0004\0\0" ] [ 1234 4 >le ] unit-test
index 60e3162b692de50e155b94ed74690029ef91968b..aa8b3c18228d1eb9d411c9488cdabc84fbba979a 100644 (file)
@@ -2,7 +2,7 @@ IN: temporary
 USE: kernel
 USE: math
 USE: test
-USE: stdio
+USE: io
 USE: prettyprint
 USE: namespaces
 
index bfe560015261037dc99296fa73b29a99bd8a528c..755489f841ac93ead272a8dffc75f969eca9ecfe 100644 (file)
@@ -3,7 +3,7 @@ USE: kernel
 USE: lists
 USE: math
 USE: namespaces
-USE: stdio
+USE: io
 USE: test
 
 : (callcc1-test)
index 1f68a4f1af462ee40c67ed418c38a19973d1d90a..a1d224135b32111c3bb76464fad8ecf3f8052a70 100644 (file)
@@ -5,7 +5,7 @@ USE: namespaces
 USE: test
 USE: lists
 USE: parser
-USE: stdio
+USE: io
 
 [ f ] [ [ ] [ ] catch ] unit-test
 
index c09e91a43eb2dca75e5a02d413c012095fb3bab1..60ef9eddda2d319c59ddbf790742eccc0e923aee 100644 (file)
@@ -1,5 +1,5 @@
 IN: temporary
-USE: files
+USE: io
 USE: httpd
 USE: lists
 USE: test
index 4fcdde8f5c4cd86be51858ab1037bc9e96480244..056ba90e492d02f6044996e78fd2db4aa989ef26 100644 (file)
@@ -1,5 +1,5 @@
 IN: temporary
-USING: parser prettyprint sequences stdio strings unparser ;
+USING: parser prettyprint sequences io strings unparser ;
 
 USE: hashtables
 USE: namespaces
index 493a4a9cf112dabdd79500ff52d847c2a34db858..4f99890b0c24fbb5c1f6bc2e4b84fd0b56b2c879 100644 (file)
@@ -1,8 +1,7 @@
 IN: temporary
 USE: html
 USE: namespaces
-USE: stdio
-USE: streams
+USE: io
 USE: strings
 USE: test
 USE: kernel
index b68b8533d1f05efddc240c9f5aebdb01fc6060b3..7475a68ea976efb0cc5ee0224dc9e7f61921e770 100644 (file)
@@ -3,7 +3,7 @@ USE: file-responder
 USE: http
 USE: httpd
 USE: namespaces
-USE: stdio
+USE: io
 USE: test
 USE: strings
 USE: lists
index 0d67636622fd778dc998bccb89ad6ee188b5f882..309806caf5c2bf1674538004fe8f436923e3bc76 100644 (file)
@@ -1,7 +1,7 @@
 USE: test
 USE: image
 USE: namespaces
-USE: stdio
+USE: io
 USE: parser
 USE: kernel
 USE: generic
index 8dc2ea0d54a4d81d2da89bf4c1e66a83e8eb6110..5e118060987ec73ef60673cf334790b1f50ca095 100644 (file)
@@ -4,7 +4,7 @@ USE: vectors
 USE: interpreter
 USE: test
 USE: namespaces
-USE: stdio
+USE: io
 USE: prettyprint
 USE: math
 USE: math-internals
index 9166e62423b140077b32d64176ce599ab570ff7e..87f7613489a7717642e29cfd22b5e8ef47cdf4c7 100644 (file)
@@ -1,5 +1,5 @@
 IN: temporary
-USING: math parser stdio streams strings test ;
+USING: math parser io strings test ;
 
 [ 4 ] [ "/library/test/io/no-trailing-eol.factor" run-resource ] unit-test
 
index 14f2b17925d7921c7d2356c671a6b552d2003d8d..353728fbcf890a0ee897ee82b783ea2a5cfc8685 100644 (file)
@@ -1,6 +1,6 @@
 IN: temporary
 USE: namespaces
-USE: stdio
+USE: io
 USE: test
 USE: parser
 
index b4e2035bcd6bd52cc99f05673a3e9d6daefbfeef..fafa3c721e70a0104d59a409154a85b63d78e041 100644 (file)
@@ -1,7 +1,6 @@
 IN: temporary
 USE: namespaces
-USE: streams
-USE: stdio
+USE: io
 USE: test
 USE: generic
 USE: kernel
index fac6a012e780f169e02d1912ac54103ad866e2ab..1f16a5c5ff28c5edc47e443240d1911c448ccf50 100644 (file)
@@ -2,7 +2,7 @@
 
 IN: test
 USING: errors kernel lists math memory namespaces parser
-prettyprint sequences stdio strings unparser vectors words ;
+prettyprint sequences io strings unparser vectors words ;
 
 TUPLE: assert got expect ;
 
index c8a24a1d09b4f2f6e502ed6c58dc969ad22de5fc..955bc976d799b7f7b548ec318e0308cf6f18be27 100644 (file)
@@ -1,7 +1,7 @@
 IN: temporary
 
 USE: namespaces
-USE: stdio
+USE: io
 USE: test
 USE: threads
 USE: errors
index 553910c42047be134b0c9723642ce80326bb423e..5ff9e133a3997858956095b67facf7269f7e6280 100644 (file)
@@ -7,7 +7,7 @@ IN: words
 ! annotated words cannot be compiled; and annotating a word has
 ! no effect of compiled calls to that word.
 USING: interpreter kernel lists prettyprint sequences
-stdio strings test ;
+io strings test ;
 
 : annotate ( word quot -- | quot: word def -- def )
     over >r >r dup word-def r> call r> swap (define-compound) ;
index 87a5cf5650dcacb49dec744af469d971770f72c8..705d9f70c66d3a06252e651a2fbb8f431b9a2e92 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: errors
 USING: generic kernel kernel-internals lists math namespaces
-parser prettyprint sequences stdio streams strings unparser
+parser prettyprint sequences io strings unparser
 vectors words ;
 
 : expired-error. ( obj -- )
index aa0e41b8c7156b1d1381511d4863aa5a928c3a41..167a74da4c6a7e6ec673deba88f01d80034fbb81 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: interpreter
 USING: errors kernel kernel-internals lists math namespaces
-prettyprint sequences stdio strings vectors words ;
+prettyprint sequences io strings vectors words ;
 
 ! A Factor interpreter written in Factor. Used by compiler for
 ! partial evaluation, also by the walker.
index 60267a06c97901d07b409c1d12f70e5acd7fd597..ed23e65be3c0ad6e85bd6063d58c1beb230d03fd 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: jedit
 USING: generic kernel listener lists namespaces parser
-prettyprint sequences stdio streams strings words ;
+prettyprint sequences io strings words ;
 
 ! Wire protocol for jEdit to evaluate Factor code.
 ! Packets are of the form:
index 911335dbe793374eaebdc350f633dab53119f1c8..e7a6c0be04d93724b7addbb6859db0faf05434d5 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2004, 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: jedit
-USING: files kernel lists namespaces parser sequences stdio
-streams strings unparser words ;
+USING: kernel lists namespaces parser sequences io strings
+unparser words ;
 
 : jedit-server-file ( -- path )
     "jedit-server-file" get
index 8b70531eb9e3e0858d6f0d56af157800c1d86fa6..f57e255c113a58f279b2d121b7b539a1ab66d88b 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: listener
 USING: errors kernel lists math memory namespaces parser
-sequences stdio strings presentation words unparser vectors ansi ;
+sequences io strings presentation words unparser vectors ansi ;
 
 SYMBOL: cont-prompt
 SYMBOL: listener-prompt
index c13e4daa1bb93656821eeb50518cf14e27af70d6..4d29426d82c8ea08004547252b8e155195809c2b 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: memory
 USING: errors generic hashtables kernel kernel-internals lists
-math namespaces prettyprint sequences stdio strings unparser
+math namespaces prettyprint sequences io strings unparser
 vectors words ;
 
 : generations 15 getenv ;
index 1deffd0e262b1c8646f0e83bc60c17d3728fcf37..6b2582de989360b552598d2e73094d9cf72cf530 100644 (file)
@@ -1,8 +1,7 @@
 ! Copyright (C) 2003, 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: telnetd
-USING: errors listener kernel namespaces stdio streams
-threads parser ;
+USING: errors listener kernel namespaces io threads parser ;
 
 : telnet-client ( socket -- )
     dup [ log-client listener ] with-stream ;
index e92fef741ec2812068e0390e4525feed90a4f2c5..f956a878a400dd844e23c206919c9bad2427fde7 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: interpreter
 USING: errors kernel listener lists math namespaces prettyprint
-sequences stdio strings vectors words ;
+sequences io strings vectors words ;
 
 ! The single-stepper simulates Factor in Factor to allow
 ! single-stepping through the execution of a quotation. It can
index 28da9363344c8ddccee41a69490df19547bf394f..9b11506a8cf0b00b1febb3557f4e2b9fbb1719ea 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2003, 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: words
-USING: files generic inspector lists kernel namespaces
-prettyprint stdio streams strings sequences unparser math
+USING: generic inspector lists kernel namespaces
+prettyprint io strings sequences unparser math
 hashtables parser ;
 
 : vocab-apropos ( substring vocab -- list )
index 4e2c268f6ee550a4f2df2c635b56891bb94f652e..f805c85e0486db4ece038e3865d5d0b24f4392fb 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: gadgets
 USING: generic kernel lists math namespaces prettyprint sdl
-sequences stdio sequences ;
+sequences io sequences ;
 
 : button-down? ( n -- ? ) hand hand-buttons contains? ;
 
index 59151730fec5070d58cd5225944a7ee2adf123d4..d4f1b78800742da4ae446985fc950cf933d7426e 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: gadgets
 USING: alien generic kernel lists math namespaces prettyprint
-sequences sdl stdio ;
+sequences sdl io ;
 
 DEFER: pick-up
 
index 758c3d01420496a2377072d099e6b34d00bee7de..ff250c9f39de9e5643f61010693462c5a6b48b9d 100644 (file)
@@ -1,8 +1,7 @@
 ! Copyright (C) 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: gadgets
-USING: generic kernel lists math namespaces sdl stdio
-sequences ;
+USING: generic kernel lists math namespaces sdl io sequences ;
 
 ! A label gadget draws a string.
 TUPLE: label text ;
index d3e3c24033b98bb507f76979993b36d474201f51..94c541dcd07e1e8eb340aa2669c99d67e23471f0 100644 (file)
@@ -1,4 +1,4 @@
-USING: kernel parser sequences stdio ;
+USING: kernel parser sequences io ;
 [
     "/library/ui/shapes.factor"
     "/library/ui/points.factor"
index 55cefbc3a576a021cb711dab18d2b600dae22963..4056c6d183a068ed129f78b64577d6bb1c614930 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: gadgets
 USING: generic hashtables kernel lists math namespaces sdl
-stdio strings sequences ;
+io strings sequences ;
 
 ! Clipping
 
index 9dde10e3c568b5a49e2c4bd5bd51f348851aee56..ff9919781d0a32e927414d8d618ce6dfa1e22c0e 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: gadgets
 USING: generic kernel line-editor listener lists math namespaces
-sequences stdio streams strings threads ;
+sequences io strings threads ;
 
 ! A pane is an area that can display text.
 
index f46df9e1ec2dd0bcb833a0881b6f27b9129638bd..e2523070dba972b77b06ce8c52b2db85e1fa5ece 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: gadgets
-USING: kernel lists namespaces prettyprint stdio unparser ;
+USING: kernel lists namespaces prettyprint io unparser ;
 
 DEFER: inspect
 
index 6e9eedcd61a3f448af5ad52996f88a9820fd697e..b97a161b69f091c3f553aa9a7a098ff3e66fc287 100644 (file)
@@ -2,7 +2,7 @@
 ! do not have x/y co-ordinates.
 IN: gadgets
 USING: alien hashtables kernel lists namespaces sdl sequences
-streams strings ;
+io strings ;
 
 SYMBOL: fonts
 
index 599c93a95f82eb230e1ba66045c05adcdc0d1269..49f634f40aad84519d3b4138c263a8734b270229 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: gadgets
-USING: kernel memory namespaces stdio ;
+USING: kernel memory namespaces io ;
 
 SYMBOL: root-menu
 
index c55fdb8a106f9a52f866d8fb009c8cb0f7a40a3e..85b2cb5fa8dfc626b6ab63b8c08f6b8dd4865300 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: gadgets
 USING: alien errors generic kernel lists math
-memory namespaces prettyprint sdl sequences stdio strings
+memory namespaces prettyprint sdl sequences io strings
 threads sequences ;
 
 ! The world gadget is the top level gadget that all (visible)
index 2fdd880abcfd59676d1327112c71731f8f3e4ce3..e4a1228c2302b51e5a730f022d247f9769e95b14 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
-IN: streams
+IN: io
 USE: io-internals
 
 : <file-reader> ( path -- stream ) open-read <reader> ;
index 20b3f3f9f1ec3e9cf43dc613314c5df1dfc09d9d..a7d0f32a1471b172e6ecdc31b83c0988600904ee 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: io-internals
 USING: alien assembler errors generic hashtables kernel
-kernel-internals lists math sequences streams strings threads
+kernel-internals lists math sequences io strings threads
 unix-internals unparser vectors ;
 
 ! We want namespaces::bind to shadow the bind system call from
@@ -51,7 +51,7 @@ SYMBOL: write-tasks
 : init-handle ( fd -- ) F_SETFL O_NONBLOCK fcntl io-error ;
 
 ! Common delegate of native stream readers and writers
-TUPLE: port handle buffer error timeout cutoff ;
+TUPLE: port handle buffer error timeout cutoff output? sbuf ;
 
 : make-buffer ( n -- buffer/f )
     dup 0 > [ <buffer> ] [ drop f ] ifte ;
@@ -62,16 +62,9 @@ C: port ( handle buffer -- port )
     [ >r make-buffer r> set-delegate ] keep
     [ >r dup init-handle r> set-port-handle ] keep ;
 
-M: port stream-close ( port -- )
-    dup port-handle close
-    delegate [ buffer-free ] when* ;
-
 : touch-port ( port -- )
-    dup port-timeout dup 0 = [
-        2drop
-    ] [
-        millis + swap set-port-cutoff
-    ] ifte ;
+    dup port-timeout dup 0 =
+    [ 2drop ] [ millis + swap set-port-cutoff ] ifte ;
 
 M: port set-timeout ( timeout port -- )
     [ set-port-timeout ] keep touch-port ;
@@ -162,56 +155,22 @@ GENERIC: task-container ( task -- vector )
 
 ! Readers
 
+: <reader> ( fd -- stream )
+    buffered-port <line-reader> ;
+
 : open-read ( path -- fd )
     O_RDONLY file-mode open dup io-error ;
 
-! The cr slot is set to true by read-line-loop if the last
-! character read was \r.
-TUPLE: reader line cr ;
-
-C: reader ( handle -- reader )
-    [ >r buffered-port r> set-delegate ] keep ;
-
 : pop-line ( reader -- sbuf/f )
-    dup pending-error [ reader-line f ] keep set-reader-line ;
+    dup pending-error [ port-sbuf f ] keep set-port-sbuf ;
 
 : read-fin ( reader -- str ) pop-line dup [ >string ] when ;
 
-: reader-cr> ( reader -- ? )
-    dup reader-cr >r f swap set-reader-cr r> ;
-
-! Reading lines
-: read-line-char ( reader ch -- )
-    f pick set-reader-cr  swap reader-line push ;
-
-: read-line-loop ( reader -- ? )
-    dup buffer-length 0 = [
-        drop f
-    ] [
-        dup buffer-pop
-        dup CHAR: \r = [
-            drop t swap set-reader-cr t
-        ] [
-            dup CHAR: \n = [
-                drop dup reader-cr> [
-                    read-line-loop
-                ] [
-                    drop t
-                ] ifte
-            ] [
-                dupd read-line-char read-line-loop
-            ] ifte
-        ] ifte
-    ] ifte ;
-
-: init-reader ( count reader -- ) >r <sbuf> r> set-reader-line ;
-
-: can-read-line? ( reader -- ? )
-    dup pending-error 80 over init-reader read-line-loop ;
+: init-reader ( count reader -- ) >r <sbuf> r> set-port-sbuf ;
 
 : reader-eof ( reader -- )
-    dup reader-line empty? [
-        f swap set-reader-line
+    dup port-sbuf empty? [
+        f swap set-port-sbuf
     ] [
         drop
     ] ifte ;
@@ -231,55 +190,9 @@ C: reader ( handle -- reader )
         drop t
     ] ifte ;
 
-TUPLE: read-line-task ;
-
-C: read-line-task ( port -- task )
-    [ >r <io-task> r> set-delegate ] keep ;
-
-M: read-line-task do-io-task ( task -- ? )
-    io-task-port dup refill [
-        dup eof? [
-            reader-eof t
-        ] [
-            read-line-loop
-        ] ifte
-    ] [
-        drop f
-    ] ifte ;
-
-M: read-line-task task-container drop read-tasks get ;
-
-: wait-to-read-line ( port -- )
-    dup can-read-line? [
-        [ swap <read-line-task> add-io-task stop ] callcc0
-    ] unless drop ;
-
-M: reader stream-readln ( stream -- line )
-    dup wait-to-read-line read-fin ;
-
-: trailing-cr ( reader -- )
-    #! Handle a corner case. If the previous request was a line
-    #! read and the line ends with \r\n, the reader stopped
-    #! reading at \r and set the reader-cr flag to true. But we
-    #! must ignore the \n.
-    dup buffer-length 1 >= [
-        dup reader-cr [
-            dup buffer-peek CHAR: \n = [
-                1 swap buffer-consume
-            ] [
-                drop
-            ] ifte
-        ] [
-            drop
-        ] ifte
-    ] [
-        drop
-    ] ifte ;
-
 ! Reading character counts
 : read-step ( count reader -- ? )
-    dup trailing-cr
-    dup reader-line -rot >r over length - ( remaining) r>
+    dup port-sbuf -rot >r over length - ( remaining) r>
     2dup buffer-length <= [
         buffer> nappend t
     ] [
@@ -315,11 +228,11 @@ M: read-task task-container drop read-tasks get ;
         [ -rot <read-task> add-io-task stop ] callcc0 
     ] unless 2drop ;
 
-M: reader stream-read ( count stream -- string )
+M: port stream-read ( count stream -- string )
     [ wait-to-read ] keep read-fin ;
 
-M: reader stream-read1 ( stream -- string )
-    1 over wait-to-read reader-line first ;
+M: port stream-read1 ( stream -- string )
+    1 over wait-to-read port-sbuf first ;
 
 ! Writers
 
@@ -327,10 +240,8 @@ M: reader stream-read1 ( stream -- string )
     O_WRONLY O_CREAT bitor O_TRUNC bitor file-mode open
     dup io-error ;
 
-TUPLE: writer ;
-
-C: writer ( fd -- writer )
-    [ >r buffered-port r> set-delegate ] keep ;
+: <writer> ( fd -- writer )
+    buffered-port t over set-port-output? ;
 
 : write-step ( port -- )
     dup >port< dup buffer@ swap buffer-length write dup 0 >= [
@@ -378,10 +289,12 @@ M: write-task task-container drop write-tasks get ;
         add-io-task
     ] ifte* ;
 
-M: writer stream-flush ( stream -- )
-    [ swap <write-task> add-write-io-task stop ] callcc0 drop ;
+M: port stream-flush ( stream -- )
+    dup port-output? [
+        [ swap <write-task> add-write-io-task stop ] callcc0
+    ] when drop ;
 
-M: writer stream-auto-flush ( stream -- ) drop ;
+M: port stream-auto-flush ( stream -- ) drop ;
 
 : wait-to-write ( len port -- )
     tuck can-write? [ drop ] [ stream-flush ] ifte ;
@@ -389,13 +302,14 @@ M: writer stream-auto-flush ( stream -- ) drop ;
 : blocking-write ( str writer -- )
     over length over wait-to-write write-fin ;
 
-M: writer stream-write-attr ( string style writer -- )
+M: port stream-write-attr ( string style writer -- )
     nip >r dup string? [ ch>string ] unless r> blocking-write ;
 
-M: writer stream-close ( stream -- )
-    dup stream-flush delegate stream-close ;
+M: port stream-close ( stream -- )
+    dup stream-flush delegate [ buffer-free ] when* ;
 
 ! Make a duplex stream for reading/writing a pair of fds
+
 : <fd-stream> ( infd outfd flush? -- stream )
     >r >r <reader> r> <writer> r> <duplex-stream> ;
 
@@ -403,7 +317,7 @@ M: writer stream-close ( stream -- )
     [ schedule-thread 10 io-multiplex stop ] callcc0
     idle-io-task ;
 
-USE: stdio
+USE: io
 
 : init-io ( -- )
     #! Should only be called on startup. Calling this at any
index 7002c8757500e36ed575d649e1a1dfa36366abcc..7cd9fa8d3860fc22a0dbb729194ab8a35157cecc 100644 (file)
@@ -4,7 +4,7 @@
 ! We need to fiddle with the exact search order here, since
 ! unix-internals::accept shadows streams::accept.
 IN: io-internals
-USING: errors namespaces streams threads unparser alien generic
+USING: errors namespaces io threads unparser alien generic
 kernel math unix-internals ;
 
 : <socket-stream> ( fd -- stream )
@@ -52,7 +52,7 @@ kernel math unix-internals ;
         dup 0 >= [ drop 1 listen ] [ ( fd n - n) nip ] ifte
     ] with-socket-fd ;
 
-IN: streams
+IN: io
 
 C: client-stream ( host port fd -- stream )
     [ >r <socket-stream> r> set-delegate ] keep
@@ -111,7 +111,7 @@ M: accept-task task-container drop read-tasks get ;
 : timeout-opt ( fd level opt value -- )
     "timeval" c-size setsockopt io-error ;
 
-IN: streams
+IN: io
 
 : accept ( server -- client )
     #! Wait for a client connection.
index f8303d5e21fccc97ac43e3aa6503c5be9485f683..d62e7fac802a46ac591a2ba7861306f04eb3dccd 100644 (file)
@@ -93,10 +93,10 @@ SYMBOL: vocabularies
     ! For interactive
     "scratchpad" "in" set
     [
-        "compiler" "debugger" "errors" "files" "generic"
+        "compiler" "debugger" "errors" "generic"
         "hashtables" "inference" "interpreter" "jedit" "kernel"
-        "listener" "lists" "math" "memory" "namespaces" "parser"
-        "prettyprint" "processes" "profiler" "sequences"
-        "streams" "stdio" "strings" "syntax" "test" "threads"
+        "listener" "lists" "math" "matrices" "memory"
+        "namespaces" "parser" "prettyprint" "processes"
+        "sequences" "io" "strings" "syntax" "test" "threads"
         "unparser" "vectors" "words" "scratchpad"
     ] "use" set ;
index 7a9810c2a73c39332cd063d879cb8dc5f3e5a208..a838a33485bf05ab0c4a457fcb4bc5e76894f822 100644 (file)
@@ -25,7 +25,7 @@
 
 IN: win32-io-internals
 USING: alien errors kernel kernel-internals lists math namespaces threads 
-       vectors win32-api stdio streams generic io-internals sequences ;
+       vectors win32-api io generic io-internals sequences ;
 
 SYMBOL: completion-port
 SYMBOL: io-queue
index 3559ddc22340e93f96ba127646b61fa693d7c4ec..2d66efe595858fe55dc8b49edfd7040b909a23eb 100644 (file)
@@ -25,7 +25,7 @@
 
 IN: win32-stream
 USING: alien errors generic kernel kernel-internals lists math namespaces
-       prettyprint sequences stdio streams strings threads unparser win32-api
+       prettyprint sequences io strings threads unparser win32-api
        win32-io-internals io-internals ;
 
 TUPLE: win32-server this ;
@@ -88,7 +88,7 @@ C: win32-server ( port -- server )
 M: win32-server stream-close ( server -- )
     win32-server-this [ socket get CloseHandle drop ] bind ;
 
-IN: streams
+IN: io
 : accept ( server -- client )
     win32-server-this [
         new-socket 64 <buffer>
index 4b87da111dc1d134aa7d70c2b106f2a8958f9b9f..ba2b22846143fbc468fcf251fb97247852879241 100644 (file)
@@ -26,7 +26,7 @@
 IN: win32-stream
 USING: alien continuations generic io-internals kernel
 kernel-internals lists math namespaces prettyprint sequences
-stdio streams strings threads win32-api win32-io-internals ;
+io strings threads win32-api win32-io-internals ;
 
 TUPLE: win32-stream this ; ! FIXME: rewrite using tuples
 GENERIC: win32-stream-handle
index 5d7d4d565d4406b798a6db507f43a26f4f91bc18..34c2d7220a9906dc745cb82c641e8f5bd5502df9 100644 (file)
@@ -43,27 +43,6 @@ void primitive_fopen(void)
        box_alien(file);
 }
 
-#define FACTOR_LINE_LEN 1024
-
-void primitive_fgets(void)
-{
-       FILE* file;
-       char line[FACTOR_LINE_LEN];
-
-       maybe_gc(0);
-
-       file = (FILE*)unbox_alien();
-       if(fgets(line,FACTOR_LINE_LEN,file) == NULL) 
-       {
-               if(feof(file))
-                       dpush(F);
-               else
-                       io_error();
-       }
-       else
-               dpush(tag_object(from_c_string(line)));
-}
-
 void primitive_fgetc(void)
 {
        FILE* file = (FILE*)unbox_alien();
index 500a63c14403e98d348497295eecc3fbf3283b55..a0a69a4efcc06b1f9267c8bd5f4e98cf70301253 100644 (file)
@@ -5,5 +5,4 @@ void primitive_fopen(void);
 void primitive_fwrite(void);
 void primitive_fflush(void);
 void primitive_fclose(void);
-void primitive_fgets(void);
 void primitive_fgetc(void);
index a5b61b92819dd73b1797c8c333f74fff09d5210d..e99328a3888b473b5dd1834182001384a0eb3529 100644 (file)
@@ -169,7 +169,6 @@ void* primitives[] = {
        primitive_die,
        primitive_flush_icache,
        primitive_fopen,
-       primitive_fgets,
        primitive_fgetc,
        primitive_fwrite,
        primitive_fflush,