diff --git a/src/c/streams/strm_sequence.d b/src/c/streams/strm_sequence.d index 32aa2b15d..eac0c0f3e 100644 --- a/src/c/streams/strm_sequence.d +++ b/src/c/streams/strm_sequence.d @@ -315,7 +315,7 @@ make_sequence_input_stream(cl_object vector, cl_index istart, cl_index iend, } SEQ_STREAM_VECTOR(strm) = vector; SEQ_STREAM_POSITION(strm) = istart; - SEQ_INPUT_LIMIT(strm) = iend; + SEQ_INPUT_VECTOR_END(strm) = iend; return strm; } @@ -324,11 +324,15 @@ make_sequence_input_stream(cl_object vector, cl_index istart, cl_index iend, (end ECL_NIL) (external_format ECL_NIL)) cl_index_pair p; + cl_object strm; @ p = ecl_vector_start_end(@[ext::make-sequence-input-stream], vector, start, end); - @(return make_sequence_input_stream(vector, p.start, p.end, - external_format)) + strm = make_sequence_input_stream(vector, p.start, p.end, + external_format); + if (Null(end)) + strm->stream.flags |= ECL_STREAM_USE_VECTOR_FILLP; + @(return strm) @) /********************************************************************** diff --git a/src/doc/manual/standards/streams.txi b/src/doc/manual/standards/streams.txi index 99bddf9ee..33ba10a2d 100644 --- a/src/doc/manual/standards/streams.txi +++ b/src/doc/manual/standards/streams.txi @@ -318,6 +318,9 @@ bytes comprising the character in the given external format. @defun ext:make-sequence-input-stream vector &key (start 0) (end nil) (external-format nil) Create a sequence input stream with the subsequence bounded by @var{start} and @var{end} of the given vector. + +When @var{end} is @code{nil}, then the end bound is the vector's length. +When the vector is adjusted the end bound is updated as well. @end defun @lspdef ext:make-sequence-output-stream @defun ext:make-sequence-output-stream vector &key (external-format nil) diff --git a/src/h/internal.h b/src/h/internal.h index 6d5cd3fda..bfb56863c 100755 --- a/src/h/internal.h +++ b/src/h/internal.h @@ -533,7 +533,13 @@ write_char_increment_column(cl_object strm, ecl_character c) #define SEQ_STREAM_ELT_TYPE(strm) (strm)->stream.object0 #define SEQ_STREAM_VECTOR(strm) (strm)->stream.object1 #define SEQ_STREAM_POSITION(strm) (strm)->stream.int0 -#define SEQ_INPUT_LIMIT(strm) (strm)->stream.int1 + +#define SEQ_INPUT_VECTOR_END(strm) (strm)->stream.int1 +#define SEQ_INPUT_LIMIT(strm) \ + ((strm)->stream.flags & ECL_STREAM_USE_VECTOR_FILLP \ + ? SEQ_STREAM_VECTOR(strm)->vector.fillp \ + : SEQ_INPUT_VECTOR_END(strm)) + #ifndef HAVE_FSEEKO #define ecl_off_t int diff --git a/src/h/object.h b/src/h/object.h index 791fad775..1f482100e 100644 --- a/src/h/object.h +++ b/src/h/object.h @@ -645,15 +645,19 @@ enum { ECL_STREAM_USER_FORMAT = 8, ECL_STREAM_US_ASCII = 10, #endif + /* External Format */ ECL_STREAM_CR = 16, ECL_STREAM_LF = 32, ECL_STREAM_SIGNED_BYTES = 64, ECL_STREAM_LITTLE_ENDIAN = 128, + /* OS Streams */ ECL_STREAM_C_STREAM = 256, ECL_STREAM_MIGHT_SEEK = 512, - ECL_STREAM_CLOSE_COMPONENTS = 1024, - ECL_STREAM_CLOSE_ON_EXEC = 2048, - ECL_STREAM_NONBLOCK = 4096 + ECL_STREAM_CLOSE_ON_EXEC = 1024, + ECL_STREAM_NONBLOCK = 2048, + /* Lisp Streams */ + ECL_STREAM_CLOSE_COMPONENTS = 4096, + ECL_STREAM_USE_VECTOR_FILLP = 8192 }; /* buffer points to an array of bytes ending at buffer_end. Decode one