From 3e44ef9ac4394e6868b583c12b2075193540c5e7 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 23 Feb 2014 19:20:40 -0800 Subject: * stream.c (get_string_from_stream): Bugfix: do not abort if stream is not a string stream, but throw a proper error exception. --- stream.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'stream.c') diff --git a/stream.c b/stream.c index a0bcf33e..95b84bc5 100644 --- a/stream.c +++ b/stream.c @@ -1228,7 +1228,8 @@ val get_string_from_stream(val stream) { type_check (stream, COBJ); type_assert (stream->co.cls == stream_s, - (lit("~a is not a stream"), stream, nao)); + (lit("~a is not a stream"), + stream, nao)); if (stream->co.ops == &string_out_ops.cobj_ops) { struct string_output *so = (struct string_output *) stream->co.handle; @@ -1247,11 +1248,13 @@ val get_string_from_stream(val stream) out = string_own(so->buf); free(so); return out; - } else if (stream->co.ops == &string_in_ops.cobj_ops) { - val pair = (val) stream->co.handle; - return pair ? car(pair) : nil; } else { - abort(); /* not a string input or output stream */ + type_assert (stream->co.ops == &string_in_ops.cobj_ops, + (lit("~a is not a string stream"), stream, nao)); + { + val pair = (val) stream->co.handle; + return pair ? car(pair) : nil; + } } } -- cgit v1.2.3