diff --git a/contrib/algebra/tests.factor b/contrib/algebra/tests.factor
index ec1b73810c..9796296e76 100644
--- a/contrib/algebra/tests.factor
+++ b/contrib/algebra/tests.factor
@@ -9,4 +9,4 @@ USING: algebra test math kernel prettyprint io ;
[ [ + x 1/2 ] ] [ ([ x + 3 / 6 ]) fold-consts ] unit-test
[ 1 ] [ 5 3 [ x ] ([ sq x + 6 ]) install-mod eval-infix call ] unit-test
[ 1.0 -1.0 ] [ 1 0 -1 quadratic-formula ] unit-test
-[ "IN: algebra :| quadratic-formula a b c |:\n [ [ [ - b ] / 2 * a ] +- [ sqrt [ sq b ] - 4 * a * c ] / 2 * a ] ;\n" ] [ [ \ quadratic-formula see ] with-string ] unit-test
+[ "IN: algebra :| quadratic-formula a b c |:\n [ [ [ - b ] / 2 * a ] +- [ sqrt [ sq b ] - 4 * a * c ] / 2 * a ] ;\n" ] [ [ \ quadratic-formula see ] string-out ] unit-test
diff --git a/contrib/cont-responder/cont-examples.factor b/contrib/cont-responder/cont-examples.factor
index 0d94a61f1d..42303c101a 100644
--- a/contrib/cont-responder/cont-examples.factor
+++ b/contrib/cont-responder/cont-examples.factor
@@ -67,7 +67,7 @@ USE: sequences
: test-cont-responder2 ( - )
#! Test the cont-responder responder by displaying a few pages in a loop.
- [ "one" "two" "three" "four" ] [ display-page [ .s ] with-string display-page ] each
+ [ "one" "two" "three" "four" ] [ display-page [ .s ] string-out display-page ] each
"Done!" display-page ;
: test-cont-responder3 ( - )
@@ -79,7 +79,7 @@ USE: sequences
"Menu" [
- "Test responder1" [ test-cont-responder ] quot-href
- - "Test responder2" [ [ .s ] with-string display-page test-cont-responder2 [ .s ] with-string display-page ] quot-href
+ - "Test responder2" [ [ .s ] string-out display-page test-cont-responder2 [ .s ] string-out display-page ] quot-href
] html-document
] show drop ;
diff --git a/contrib/cont-responder/eval-responder.factor b/contrib/cont-responder/eval-responder.factor
index a1fe8e1e2d..d0bfa814cb 100644
--- a/contrib/cont-responder/eval-responder.factor
+++ b/contrib/cont-responder/eval-responder.factor
@@ -89,7 +89,7 @@ USE: sequences
#! Write out html to display the stack.
"Callstack" write |
- [ [ unparse write ] with-string write-eval-link |
] each
+ [ [ unparse write ] string-out write-eval-link |
] each
;
: display-clear-history-link ( -- )
diff --git a/contrib/cont-responder/todo-example.factor b/contrib/cont-responder/todo-example.factor
index 120e256105..287e22b5ac 100644
--- a/contrib/cont-responder/todo-example.factor
+++ b/contrib/cont-responder/todo-example.factor
@@ -114,7 +114,7 @@ USE: sequences
: show-stack-page ( -- )
#! Debug function to show a page containing the current call stack.
- [ .s ] with-string chars>entities show-message-page ;
+ [ .s ] string-out chars>entities show-message-page ;
: row ( list -- )
#! Output an html TR row with each element of the list
diff --git a/doc/handbook.tex b/doc/handbook.tex
index 3cea508d6a..7fe65dd47f 100644
--- a/doc/handbook.tex
+++ b/doc/handbook.tex
@@ -2528,7 +2528,7 @@ Tests if the object at the top of the stack is a string buffer.
}
Turns any type of sequence into a string buffer. Given a string buffer, this makes a fresh copy.
-String buffers support the stream output protocol (\ref{stream-protocol}).
+String buffers support the stream input and output protocol (\ref{string-streams}).
\section{Virtual sequences}\label{virtual-seq}
@@ -3725,7 +3725,7 @@ description={a stream that implements the \texttt{stream-write-attr}, \texttt{st
There are various subsets of the stream protocol that a class can implement so that its instances may be used as streams. The following generic word is mandatory.
\wordtable{
-\vocabulary{streams}
+\vocabulary{io}
\genericword{stream-close}{stream-close ( s -- )}
}
Releases any external resources associated with the stream, such as file handles and network connections. No further operations can be performed on the stream after this call.
@@ -3734,12 +3734,18 @@ You must close streams after you are finished working with them. A convenient wa
The following two words are optional, and should be implemented on input streams.
\wordtable{
-\vocabulary{streams}
+\vocabulary{io}
\genericword{stream-readln}{stream-readln ( s -- str/f )}
}
Reads a line of text and outputs it on the stack. If the end of the stream has been reached, outputs \texttt{f}. The precise meaning of a ``line'' depends on the stream; with file and network streams, it is a range of characters terminated by \verb|\n|, \verb|\r| or \verb|\r\n|.
\wordtable{
-\vocabulary{streams}
+\vocabulary{io}
+\genericword{stream-read1}{stream-read1 ( s -- char/f )}
+}
+Reads a character from the stream. If the end of the stream is reached, outputs \verb|f|.
+
+\wordtable{
+\vocabulary{io}
\genericword{stream-read}{stream-read ( n s -- str )}
}
Reads \texttt{n} characters from the stream. If less than \texttt{n} characters are available before the end of the stream, a shorter string is output.
@@ -3747,7 +3753,7 @@ Reads \texttt{n} characters from the stream. If less than \texttt{n} characters
The following three words are optional, and should be implemented on output streams.
\wordtable{
-\vocabulary{streams}
+\vocabulary{io}
\genericword{stream-write-attr}{stream-write-attr ( str/ch attrs s -- )}
}
Outputs a character or string to the stream. This might not result in immediate output to the underlying resource if the stream performs buffering, like all file and network streams do.
@@ -3755,13 +3761,13 @@ Outputs a character or string to the stream. This might not result in immediate
The \texttt{attrs} parameter is an association list holding style information, and it is ignored by most streams -- one exception is HTML streams (\ref{html}). Most of the time either the \texttt{stream-write} or \texttt{stream-print} word is used. They are described in the next section.
\wordtable{
-\vocabulary{streams}
+\vocabulary{io}
\genericword{stream-flush}{stream-flush ( s -- )}
}
Ensures all pending output operations are been complete. With many output streams, written output is buffered and not sent to the underlying resource until either the buffer is full, or an explicit call to \texttt{stream-flush} is made.
\wordtable{
-\vocabulary{streams}
+\vocabulary{io}
\genericword{stream-auto-flush}{stream-auto-flush ( s -- )}
}
Ensures the user sees prior output. It is not as strong as \texttt{stream-flush}. The contract is as follows: if the stream is connected to an interactive end-point such as a terminal, \texttt{stream-auto-flush} should execute \texttt{stream-flush}. If the stream is a file or network stream used for ``batch'' operations, this word should have an empty definition.
@@ -3774,13 +3780,13 @@ With some streams, the above operations may suspend the current thread and execu
The following three words are implemented in terms of the stream protocol, and should work with any stream supporting the required underlying operations.
\wordtable{
-\vocabulary{streams}
+\vocabulary{io}
\ordinaryword{stream-read1}{stream-read1 ( stream -- ch/f )}
}
Reads a single character using \texttt{stream-read} and outputs the character. If the end of the stream has been reached, outputs \texttt{f}.
\wordtable{
-\vocabulary{streams}
+\vocabulary{io}
\ordinaryword{stream-write}{stream-write ( string stream -- )}
}
@@ -3790,7 +3796,7 @@ Outputs a character or string to the stream, without any specific style informat
f swap stream-write-attr ;
\end{verbatim}
\wordtable{
-\vocabulary{streams}
+\vocabulary{io}
\ordinaryword{stream-print}{stream-print ( string stream -- )}
}
@@ -3803,7 +3809,7 @@ description={the value of the \texttt{stdio} variable, used by various words as
description={see default stream}}
Various words take an implicit stream parameter from the \texttt{stdio} variable to reduce stack shuffling.
\wordtable{
-\vocabulary{stdio}
+\vocabulary{io}
\ordinaryword{close}{close ( -- )}
}
@@ -3811,7 +3817,7 @@ Various words take an implicit stream parameter from the \texttt{stdio} variable
: close stdio get stream-close ;
\end{verbatim}
\wordtable{
-\vocabulary{stdio}
+\vocabulary{io}
\ordinaryword{read-line}{read-line ( -- str/f )}
}
@@ -3819,7 +3825,7 @@ Various words take an implicit stream parameter from the \texttt{stdio} variable
: read-line stdio get stream-readln ;
\end{verbatim}
\wordtable{
-\vocabulary{stdio}
+\vocabulary{io}
\ordinaryword{read}{read ( n -- str )}
}
@@ -3827,7 +3833,7 @@ Various words take an implicit stream parameter from the \texttt{stdio} variable
: read stdio get stream-read ;
\end{verbatim}
\wordtable{
-\vocabulary{stdio}
+\vocabulary{io}
\ordinaryword{read1}{read1 ( n -- str )}
}
@@ -3835,7 +3841,7 @@ Various words take an implicit stream parameter from the \texttt{stdio} variable
: read1 stdio get stream-read1 ;
\end{verbatim}
\wordtable{
-\vocabulary{stdio}
+\vocabulary{io}
\ordinaryword{write}{write ( str -- )}
}
@@ -3843,7 +3849,7 @@ Various words take an implicit stream parameter from the \texttt{stdio} variable
: write stdio get stream-write ;
\end{verbatim}
\wordtable{
-\vocabulary{stdio}
+\vocabulary{io}
\ordinaryword{write-attr}{write-attr ( str attrs -- )}
}
@@ -3851,7 +3857,7 @@ Various words take an implicit stream parameter from the \texttt{stdio} variable
: write-attr stdio get stream-write-attr ;
\end{verbatim}
\wordtable{
-\vocabulary{stdio}
+\vocabulary{io}
\ordinaryword{print}{print ( str -- )}
}
@@ -3859,7 +3865,7 @@ Various words take an implicit stream parameter from the \texttt{stdio} variable
: print stdio get stream-print ;
\end{verbatim}
\wordtable{
-\vocabulary{stdio}
+\vocabulary{io}
\ordinaryword{terpri}{terpri ( -- )}
}
@@ -3867,7 +3873,7 @@ Various words take an implicit stream parameter from the \texttt{stdio} variable
: terpri "\n" stdio get stream-write ;
\end{verbatim}
\wordtable{
-\vocabulary{stdio}
+\vocabulary{io}
\ordinaryword{flush}{flush ( -- )}
}
@@ -3878,25 +3884,42 @@ Various words take an implicit stream parameter from the \texttt{stdio} variable
The value of the \texttt{stdio} variable can be rebound inside a quotation with the following combinators.
\wordtable{
-\vocabulary{stdio}
+\vocabulary{io}
\ordinaryword{with-stream}{with-stream ( stream quot -- )}
}
Calls the quotation in a new dynamic scope, with the \texttt{stdio} variable set to \texttt{stream}. The stream is closed when the quotation returns or if an exception
is thrown.
\wordtable{
-\vocabulary{stdio}
+\vocabulary{io}
\ordinaryword{with-stream*}{with-stream* ( stream quot -- )}
}
Like \verb|with-stream| extend the stream is only closed in the case of an error.
-\wordtable{
-\vocabulary{stdio}
-\ordinaryword{with-string}{with-string ( quot -- string )}
+\section{String streams}\label{string-streams}
+Calling stream output words on a string buffer will append text to the string buffer.
+
+\wordtable{
+\vocabulary{io}
+\ordinaryword{string-out}{string-out ( quot -- string )}
}
Calls the quotation in a new dynamic scope, with the \texttt{stdio} variable set to a new string buffer. Executing \texttt{write}, \texttt{write-attr} or \texttt{print} will append text to the string buffer. When the quotation returns, the string buffer is coverted to
a string and returned.
+String buffers also support the input stream protocol, with the exception of \verb|stream-readln|. Characters are read in reverse. Usually, string buffers are not used as input streams directly, since lines cannot be read and the input string must be reversed. Instead, the following pair of words is used.
+
+\wordtable{
+\vocabulary{io}
+\ordinaryword{}{ ( string -- stream )}
+}
+Creates a new stream for reading the characters of the string in order. This converts the string to a string buffer, reverses it, and wraps it in a line stream (\ref{special-streams})..
+
+\wordtable{
+\vocabulary{io}
+\ordinaryword{string-in}{string-in ( string quot -- )}
+}
+Calls the quotation in a new dynamic scope, with the \texttt{stdio} variable set to a new string reader that reads from the given string. Executing \texttt{read1}, \texttt{read} or \texttt{read-line} will take text from the string reader.
+
\section{Reading and writing binary data}
\glossary{name=big endian,
@@ -3926,13 +3949,13 @@ Value:&\verb|ca|&\verb|fe|&\verb|ba|&\verb|be|\\
With the above explanation of byte ordering, the behavior of the following words should be clear.
\wordtable{
-\vocabulary{stdio}
+\vocabulary{io}
\ordinaryword{be>}{be> ( seq -- x )}
\ordinaryword{le>}{le> ( seq -- x )}
}
Converts a sequence of bytes in big or little endian order into an unsigned integer.
\wordtable{
-\vocabulary{stdio}
+\vocabulary{io}
\ordinaryword{>be}{>be ( x n -- string )}
\ordinaryword{>le}{>le ( x n -- string )}
}
@@ -3941,7 +3964,7 @@ Converts an integer into a string of $n$ bytes in big or little endian order. Tr
These words are then composed with \verb|read| and \verb|write| to form a set of words for reading and writing packed integers on the default stream (\ref{stdio}).
\wordtable{
-\vocabulary{stdio}
+\vocabulary{io}
\ordinaryword{read-be2}{read-be2 ( -- n )}
\ordinaryword{read-le2}{read-le2 ( -- n )}
\ordinaryword{read-be4}{read-be4 ( -- n )}
@@ -3965,13 +3988,13 @@ description=an input stream reading from a file}
\glossary{name=file writer,
description=an output stream writing to a file}
\wordtable{
-\vocabulary{streams}
+\vocabulary{io}
\ordinaryword{}{ ( path -- stream )}
}
Opens the file for reading and returns an input stream. An exception is thrown if the file could not be opened.
\wordtable{
-\vocabulary{streams}
+\vocabulary{io}
\ordinaryword{}{ ( path -- stream )}
}
@@ -3980,7 +4003,7 @@ Opens the file for writing and returns an output stream. An exception is thrown
The following set of words provide access to file system metadata.
\wordtable{
-\vocabulary{files}
+\vocabulary{io}
\ordinaryword{file-extension}{file-extension~( path -- string/f )}
}
@@ -3990,25 +4013,25 @@ Outputs the remainder of the file's name after the last occurrence of a period,
\textbf{"txt"}
\end{alltt}
\wordtable{
-\vocabulary{files}
+\vocabulary{io}
\ordinaryword{exists?}{exists?~( path -- ?~)}
}
Tests if a file exists.
\wordtable{
-\vocabulary{files}
+\vocabulary{io}
\ordinaryword{directory?}{directory?~( path -- ?~)}
}
Tests if a file is a directory. Outputs \texttt{f} if the file does not exist..
\wordtable{
-\vocabulary{files}
+\vocabulary{io}
\ordinaryword{file-length}{file-length~( path -- n/f~)}
}
Outputs the size of the file, or \texttt{f} if it does not exist.
\wordtable{
-\vocabulary{files}
+\vocabulary{io}
\ordinaryword{stat}{stat~( path -- list~)}
}
@@ -4027,32 +4050,32 @@ description=a stream listening on a TCP/IP socket}
\glossary{name=client stream,
description=a bidirectional stream for an to end-point of a TCP/IP connection}
\wordtable{
-\vocabulary{streams}
+\vocabulary{io}
\ordinaryword{}{~( host port -- stream~)}
}
Connects to TCP/IP port number \texttt{port} on the host named by \texttt{host}, and returns a bidirectional stream. An exception is thrown if the connection attempt fails.
\wordtable{
-\vocabulary{streams}
+\vocabulary{io}
\ordinaryword{}{~( port -- server~)}
}
Begins listening for connections to \texttt{port} on all network interfaces. An exception is thrown if the port cannot be opened. The returned object can be used as an input to the \texttt{stream-close} and \texttt{accept} words.
\wordtable{
-\vocabulary{streams}
+\vocabulary{io}
\ordinaryword{accept}{accept~( server -- stream~)}
}
Waits for a connection to the port number that \texttt{server} is listening on, and outputs a bidirectional stream when the connection has been established. An exception is thrown if an error occurs.
\wordtable{
-\vocabulary{streams}
+\vocabulary{io}
\ordinaryword{client-stream-host}{client-stream-host~( stream -- port~)}
\ordinaryword{client-stream-port}{client-stream-port~( stream -- port~)}
}
Outputs the IP address as a dotted-quad string, and the local port number, respectively, of a client socket returned from \texttt{accept}.
-\section{Special streams}
+\section{Special streams}\label{special-streams}
\glossary{name=null stream,
description=a bidirectional stream that ignores output and returns end of file on input}
@@ -4060,26 +4083,34 @@ description=a bidirectional stream that ignores output and returns end of file o
description=a bidirectional delegating to an input stream for input and an output stream for output}
\glossary{name=wrapper stream,
description=a bidirectional stream delegating to an underlying stream and providing a namespace where the delegated stream is the default stream}
+\glossary{name=line stream,
+description=an input stream that reads lines a character at a time from an underlying stream}
\wordtable{
-\vocabulary{streams}
+\vocabulary{io}
\ordinaryword{}{~( -- stream~)}
}
Creates a null stream, which ignores output written to it, and returns end of file if an attempt is made to read.
\wordtable{
-\vocabulary{streams}
+\vocabulary{io}
\ordinaryword{}{~( in out -- stream~)}
}
Creates a duplex stream. Writing to a duplex stream will write to \texttt{out}, and reading from a duplex stream will read from \texttt{in}. Closing a duplex stream closes both the input and output streams.
\wordtable{
-\vocabulary{streams}
+\vocabulary{io}
+\ordinaryword{}{~( stream -- stream~)}
+}
+Wrapping a stream in a line stream saves you from having to implement the \verb|stream-readln| generic word. Calling \verb|stream-readln| on a line stream reads a line a character at a time from the underlying stream. Lines are terminated by either \verb|\n|, \verb|\r| or \verb|\r\n|.
+
+\wordtable{
+\vocabulary{io}
\ordinaryword{}{~( stream -- stream~)}
}
Creates a stream wrapping \texttt{stream}. The given stream becomes the delegate of the new wrapper stream, so calling any stream operation on the wrapper passes it on to the delegate.
You can then define your own tuple class that delegates to a wrapper stream, then override methods on this new tuple class, and use the following combinator in your method definitions.
\wordtable{
-\vocabulary{streams}
+\vocabulary{io}
\ordinaryword{with-wrapper}{with-wrapper~( stream quot -- ~)}
}
Executes the quotation in a dynamic scope where the \texttt{stdio} variable is set to the wrapped stream.
diff --git a/library/bootstrap/boot-stage1.factor b/library/bootstrap/boot-stage1.factor
index 680164ee96..4742d80c58 100644
--- a/library/bootstrap/boot-stage1.factor
+++ b/library/bootstrap/boot-stage1.factor
@@ -51,9 +51,9 @@ parser prettyprint sequences io vectors words ;
"/library/io/stream.factor"
"/library/io/duplex-stream.factor"
- "/library/io/string-streams.factor"
"/library/io/stdio.factor"
"/library/io/lines.factor"
+ "/library/io/string-streams.factor"
"/library/io/c-streams.factor"
"/library/io/files.factor"
diff --git a/library/eval-catch.factor b/library/eval-catch.factor
index 53c0bf8f66..68b8833f8c 100644
--- a/library/eval-catch.factor
+++ b/library/eval-catch.factor
@@ -6,4 +6,4 @@ IN: parser USING: kernel errors io ;
[ eval ] [ [ print-error debug-help drop ] when* ] catch ;
: eval>string ( in -- out )
- [ eval-catch ] with-string ;
+ [ eval-catch ] string-out ;
diff --git a/library/httpd/browser-responder.factor b/library/httpd/browser-responder.factor
index 0322e95a0c..7a665b8525 100644
--- a/library/httpd/browser-responder.factor
+++ b/library/httpd/browser-responder.factor
@@ -72,7 +72,7 @@ sequences ;
"Accept" button ;
diff --git a/library/httpd/cont-responder.factor b/library/httpd/cont-responder.factor
index eb41b889fb..746e65364d 100644
--- a/library/httpd/cont-responder.factor
+++ b/library/httpd/cont-responder.factor
@@ -232,7 +232,7 @@ SYMBOL: callback-cc
store-callback-cc redirect-to-here
[
expirable register-continuation id>url swap
- \ serving-html swons with-string call-exit-continuation
+ \ serving-html swons string-out call-exit-continuation
] callcc1
nip ;
@@ -244,7 +244,7 @@ SYMBOL: callback-cc
#! use is an optimisation to save having to generate and save a continuation
#! in that special case.
store-callback-cc redirect-to-here
- \ serving-html swons with-string call-exit-continuation ;
+ \ serving-html swons string-out call-exit-continuation ;
#! Name of variable for holding initial continuation id that starts
#! the responder.
diff --git a/library/inference/test.factor b/library/inference/test.factor
index 1cfd98bd13..c15ddad68f 100644
--- a/library/inference/test.factor
+++ b/library/inference/test.factor
@@ -9,10 +9,10 @@ io strings unparser ;
: infer-fail ( quot error -- )
"! " , dup string? [ unparse ] unless , "\n" ,
- [ [ infer ] cons . \ unit-test-fails . ] with-string , ;
+ [ [ infer ] cons . \ unit-test-fails . ] string-out , ;
: infer-pass ( quot effect -- )
- [ unit . [ infer ] cons . \ unit-test . ] with-string , ;
+ [ unit . [ infer ] cons . \ unit-test . ] string-out , ;
: infer>test ( quot -- str )
#! Make a string representing a unit test for the stack
diff --git a/library/io/files.factor b/library/io/files.factor
index 99e64a9246..2543dbdab7 100644
--- a/library/io/files.factor
+++ b/library/io/files.factor
@@ -1,7 +1,7 @@
! Copyright (C) 2004, 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
IN: io
-USING: kernel lists sequences strings ;
+USING: kernel lists namespaces sequences strings ;
! Words for accessing filesystem meta-data.
@@ -12,3 +12,12 @@ USING: kernel lists sequences strings ;
: file-length ( file -- length ) stat third ;
: file-extension ( filename -- extension )
"." split cdr dup [ peek ] when ;
+
+DEFER:
+
+: resource-path ( -- path )
+ "resource-path" get [ "." ] unless* ;
+
+: ( path -- stream )
+ #! Open a file path relative to the Factor source code root.
+ resource-path swap path+ ;
diff --git a/library/io/lines.factor b/library/io/lines.factor
index 2ac316364d..5e2cb50bb0 100644
--- a/library/io/lines.factor
+++ b/library/io/lines.factor
@@ -1,6 +1,6 @@
! Copyright (C) 2004, 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
-USING: errors generic io kernel namespaces sequences ;
+USING: errors generic io kernel math namespaces sequences ;
TUPLE: line-reader cr ;
diff --git a/library/io/stream.factor b/library/io/stream.factor
index 5cbd703232..d08eff4ca1 100644
--- a/library/io/stream.factor
+++ b/library/io/stream.factor
@@ -64,12 +64,3 @@ C: wrapper-stream ( stream -- stream )
#! For each element of the alist, change the value to
#! path " " value
[ uncons >r swap " " r> append3 cons ] map-with ;
-
-DEFER:
-
-: resource-path ( -- path )
- "resource-path" get [ "." ] unless* ;
-
-: ( path -- stream )
- #! Open a file path relative to the Factor source code root.
- resource-path swap path+ ;
diff --git a/library/test/combinators.factor b/library/test/combinators.factor
index aa8b3c1822..4ed848bd37 100644
--- a/library/test/combinators.factor
+++ b/library/test/combinators.factor
@@ -27,8 +27,8 @@ USE: namespaces
[ 0 ] [ f [ 0 ] unless* ] unit-test
[ t ] [ t [ "Hello" ] unless* ] unit-test
-[ "2\n" ] [ [ 1 2 [ . ] [ sq . ] ?ifte ] with-string ] unit-test
-[ "9\n" ] [ [ 3 f [ . ] [ sq . ] ?ifte ] with-string ] unit-test
+[ "2\n" ] [ [ 1 2 [ . ] [ sq . ] ?ifte ] string-out ] unit-test
+[ "9\n" ] [ [ 3 f [ . ] [ sq . ] ?ifte ] string-out ] unit-test
[ [ 9 8 7 6 5 4 3 2 1 ] ]
[ [ 10 [ , ] [ 1 - dup dup 0 = [ drop f ] when ] while ] make-list nip ]
diff --git a/library/test/generic.factor b/library/test/generic.factor
index 056ba90e49..0cbecc6234 100644
--- a/library/test/generic.factor
+++ b/library/test/generic.factor
@@ -123,13 +123,13 @@ TUPLE: another-one ;
! Test generic see and parsing
[ "IN: temporary\nSYMBOL: bah \nUNION: bah fixnum alien ;\n" ]
-[ [ \ bah see ] with-string ] unit-test
+[ [ \ bah see ] string-out ] unit-test
[ t ] [
DEFER: not-fixnum
"IN: temporary\nSYMBOL: not-fixnum \nCOMPLEMENT: not-fixnum fixnum\n"
dup eval
- [ \ not-fixnum see ] with-string =
+ [ \ not-fixnum see ] string-out =
] unit-test
! Weird bug
diff --git a/library/test/httpd/html.factor b/library/test/httpd/html.factor
index 4f99890b0c..3d3a9100e6 100644
--- a/library/test/httpd/html.factor
+++ b/library/test/httpd/html.factor
@@ -24,14 +24,14 @@ USE: kernel
""
[ [[ "icon" "library/icons/File.png" ]] ]
[ drop ] icon-tag
- ] with-string
+ ] string-out
] unit-test
[ "" ]
[
[
[ ] [ drop ] span-tag
- ] with-string
+ ] string-out
] unit-test
[ "car" ]
@@ -40,7 +40,7 @@ USE: kernel
[ [ "fg" 255 0 255 ] [[ "font" "Monospaced" ]] ]
[ drop "car" write ]
span-tag
- ] with-string
+ ] string-out
] unit-test
: html-write-attr ( string style -- string )
@@ -48,7 +48,7 @@ USE: kernel
[ "hello world" ]
[
- [ "hello world" [ ] html-write-attr ] with-string
+ [ "hello world" [ ] html-write-attr ] string-out
] unit-test
[ "car" ]
@@ -57,7 +57,7 @@ USE: kernel
"car"
[ [ "fg" 255 0 255 ] [[ "font" "Monospaced" ]] ]
html-write-attr
- ] with-string
+ ] string-out
] unit-test
[
@@ -65,7 +65,7 @@ USE: kernel
] [
[
"Foo" [ ] html-document
- ] with-string
+ ] string-out
] unit-test
[
@@ -73,5 +73,5 @@ USE: kernel
] [
[
"Foo" [ "Hi" write ] simple-html-document
- ] with-string
+ ] string-out
] unit-test
diff --git a/library/test/httpd/httpd.factor b/library/test/httpd/httpd.factor
index 7475a68ea9..5289aa309c 100644
--- a/library/test/httpd/httpd.factor
+++ b/library/test/httpd/httpd.factor
@@ -10,7 +10,7 @@ USE: lists
[ "HTTP/1.0 200 OK\nContent-Length: 12\nContent-Type: text/html\n\n" ]
[
- [ "text/html" 12 file-response ] with-string
+ [ "text/html" 12 file-response ] string-out
] unit-test
[ 5430 ]
diff --git a/library/test/image.factor b/library/test/image.factor
index 309806caf5..25d1a9a1ec 100644
--- a/library/test/image.factor
+++ b/library/test/image.factor
@@ -23,7 +23,7 @@ USE: math
[ "\0\0\0\0\u000f\u000e\r\u000c" ]
[
- [ image-magic 8 >be write ] with-string
+ [ image-magic 8 >be write ] string-out
] unit-test
[
diff --git a/library/test/interpreter.factor b/library/test/interpreter.factor
index 5e11806098..7115d7bb1e 100644
--- a/library/test/interpreter.factor
+++ b/library/test/interpreter.factor
@@ -77,17 +77,17 @@ USE: sequences
] unit-test
[ { "hi\n" } ] [
- [ [ "hi" print ] with-string ] test-interpreter
+ [ [ "hi" print ] string-out ] test-interpreter
] unit-test
[ { "4\n" } ] [
- [ [ 2 2 + unparse print ] with-string ] test-interpreter
+ [ [ 2 2 + unparse print ] string-out ] test-interpreter
] unit-test
[ { "4" } ] [
- [ [ 0 2 2 + prettyprint* drop ] with-string ] test-interpreter
+ [ [ 0 2 2 + prettyprint* drop ] string-out ] test-interpreter
] unit-test
[ { "4\n" } ] [
- [ [ 2 2 + . ] with-string ] test-interpreter
+ [ [ 2 2 + . ] string-out ] test-interpreter
] unit-test
diff --git a/library/test/io/io.factor b/library/test/io/io.factor
index 87f7613489..6accf70501 100644
--- a/library/test/io/io.factor
+++ b/library/test/io/io.factor
@@ -1,5 +1,5 @@
IN: temporary
-USING: math parser io strings test ;
+USING: io kernel math parser strings test ;
[ 4 ] [ "/library/test/io/no-trailing-eol.factor" run-resource ] unit-test
@@ -49,3 +49,14 @@ USING: math parser io strings test ;
[ "" ] [ 0 read ] unit-test
[ ] [ "123" write 9000 CHAR: x fill write flush ] unit-test
+
+[ "line 1" CHAR: l ]
+[
+ "line 1\nline 2\nline 3"
+ dup stream-readln swap stream-read1
+]
+unit-test
+
+[ f ]
+[ "" stream-readln ]
+unit-test
diff --git a/library/test/stream.factor b/library/test/stream.factor
index fafa3c721e..7045359b62 100644
--- a/library/test/stream.factor
+++ b/library/test/stream.factor
@@ -5,4 +5,4 @@ USE: test
USE: generic
USE: kernel
-[ "xyzzy" ] [ [ "xyzzy" write ] with-string ] unit-test
+[ "xyzzy" ] [ [ "xyzzy" write ] string-out ] unit-test
diff --git a/library/tools/jedit-wire.factor b/library/tools/jedit-wire.factor
index ed23e65be3..bf35f2ffe9 100644
--- a/library/tools/jedit-wire.factor
+++ b/library/tools/jedit-wire.factor
@@ -11,7 +11,7 @@ prettyprint sequences io strings words ;
! bytes data
!
! jEdit sends a packet with code to eval, it receives the output
-! captured with with-string.
+! captured with string-out.
: write-len ( seq -- ) length 4 >be write ;
@@ -39,7 +39,7 @@ prettyprint sequences io strings words ;
! remaining -- input
: jedit-write-attr ( str style -- )
CHAR: w write
- [ swap . . ] with-string
+ [ swap . . ] string-out
dup write-len write ;
TUPLE: jedit-stream ;