core: si:copy-stream has three arguments

argument `wait' denots, whenever we wait for EOF or yield when there
is no input available in the first stream.
This commit is contained in:
Daniel Kochmanski 2017-10-08 20:23:47 +02:00
parent 7cad2c8e7d
commit 2a98ce10fe
4 changed files with 11 additions and 5 deletions

View file

@ -4993,14 +4993,20 @@ cl_streamp(cl_object strm)
*/
cl_object
si_copy_stream(cl_object in, cl_object out)
si_copy_stream(cl_object in, cl_object out, cl_object wait)
{
ecl_character c;
if ((wait == ECL_NIL) && !ecl_listen_stream(in)) {
return ECL_NIL;
}
for (c = ecl_read_char(in); c != EOF; c = ecl_read_char(in)) {
ecl_write_char(c, out);
if ((wait == ECL_NIL) && !ecl_listen_stream(in)) {
break;
}
}
ecl_force_output(out);
@(return ECL_T);
@(return c==EOF);
}

View file

@ -1141,7 +1141,7 @@ cl_symbols[] = {
{SYS_ "COPY-TO-SIMPLE-BASE-STRING", SI_ORDINARY, si_copy_to_simple_base_string, 1, OBJNULL},
{SYS_ "COMPILED-FUNCTION-BLOCK", SI_ORDINARY, si_compiled_function_block, 1, OBJNULL},
{EXT_ "COMPILED-FUNCTION-NAME", EXT_ORDINARY, si_compiled_function_name, 1, OBJNULL},
{SYS_ "COPY-STREAM", SI_ORDINARY, si_copy_stream, 1, OBJNULL},
{SYS_ "COPY-STREAM", SI_ORDINARY, si_copy_stream, 3, OBJNULL},
{SYS_ "DESTRUCTURE", SI_ORDINARY, NULL, -1, OBJNULL},
{SYS_ "DO-READ-SEQUENCE", SI_ORDINARY, si_do_read_sequence, 4, OBJNULL},
{SYS_ "DO-WRITE-SEQUENCE", SI_ORDINARY, si_do_write_sequence, 4, OBJNULL},

View file

@ -1152,7 +1152,7 @@
(proclamation si:open-unix-socket-stream (string) stream)
#+wants-sockets
(proclamation si:lookup-host-entry (t) (values (or null string) list list))
(proclamation si:copy-stream (stream stream) t)
(proclamation si:copy-stream (stream stream wait) t)
(proclamation si:make-encoding (t) hash-table)
(proclamation si:load-encoding (t) t)

View file

@ -690,7 +690,7 @@ extern ECL_API cl_object cl_stream_external_format(cl_object strm);
extern ECL_API cl_object cl_file_length(cl_object strm);
extern ECL_API cl_object si_get_string_input_stream_index(cl_object strm);
extern ECL_API cl_object si_make_string_output_stream_from_string(cl_object strng);
extern ECL_API cl_object si_copy_stream(cl_object in, cl_object out);
extern ECL_API cl_object si_copy_stream(cl_object in, cl_object out, cl_object wait);
extern ECL_API cl_object cl_open_stream_p(cl_object strm);
extern ECL_API cl_object cl_make_broadcast_stream _ECL_ARGS((cl_narg narg, ...));
extern ECL_API cl_object cl_broadcast_stream_streams(cl_object strm);