From 17ecba77edb767ff3e46a5b3a80b031b7c335829 Mon Sep 17 00:00:00 2001 From: jgarcia Date: Wed, 1 Nov 2006 17:46:33 +0000 Subject: [PATCH] Reorganized argument checks for READ-SEQUENCE and WRITE-SEQUENCE. --- src/c/file.d | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/c/file.d b/src/c/file.d index d63b757e5..456f11de1 100644 --- a/src/c/file.d +++ b/src/c/file.d @@ -1440,21 +1440,23 @@ writestr_stream(const char *s, cl_object strm) cl_object si_do_write_sequence(cl_object seq, cl_object stream, cl_object s, cl_object e) { - cl_fixnum start = fixnnint(s); - cl_fixnum limit = length(seq); - cl_fixnum end = (e == Cnil)? limit : fixnnint(e); - cl_type t = type_of(seq); + cl_fixnum start,limit,end; + cl_type t; /* Since we have called length(), we know that SEQ is a valid sequence. Therefore, we only need to check the type of the object, and seq == Cnil i.f.f. t = t_symbol */ - if (start > limit) { - FEtype_error_index(seq, MAKE_FIXNUM(start)); - } else if (end > limit) { - FEtype_error_index(seq, MAKE_FIXNUM(end)); - } else if (end <= start) { + limit = length(seq); + start = ecl_fixnum_in_range(@'write-sequence',"start",s,0,limit); + if (e == Cnil) { + end = limit; + } else { + end = ecl_fixnum_in_range(@'write-sequence',"end",e,0,limit); + } + if (end <= start) { goto OUTPUT; } + t = type_of(seq); if (t == t_cons || t == t_symbol) { bool ischar = cl_stream_element_type(stream) == @'base-char'; cl_object s = nthcdr(start, seq); @@ -1511,21 +1513,23 @@ si_do_write_sequence(cl_object seq, cl_object stream, cl_object s, cl_object e) cl_object si_do_read_sequence(cl_object seq, cl_object stream, cl_object s, cl_object e) { - cl_fixnum start = fixnnint(s); - cl_fixnum limit = length(seq); - cl_fixnum end = (e == Cnil)? limit : fixnnint(e); - cl_type t = type_of(seq); + cl_fixnum start,limit,end; + cl_type t; /* Since we have called length(), we know that SEQ is a valid sequence. Therefore, we only need to check the type of the object, and seq == Cnil i.f.f. t = t_symbol */ - if (start > limit) { - FEtype_error_index(seq, MAKE_FIXNUM(start)); - } else if (end > limit) { - FEtype_error_index(seq, MAKE_FIXNUM(end)); - } else if (end <= start) { + limit = length(seq); + start = ecl_fixnum_in_range(@'read-sequence',"start",s,0,limit); + if (e == Cnil) { + end = limit; + } else { + end = ecl_fixnum_in_range(@'read-sequence',"end",e,0,limit); + } + if (end <= start) { goto OUTPUT; } + t = type_of(seq); if (t == t_cons || t == t_symbol) { bool ischar = cl_stream_element_type(stream) == @'base-char'; seq = nthcdr(start, seq);