diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-02-23 19:20:40 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-02-23 19:20:40 -0800 |
commit | 3e44ef9ac4394e6868b583c12b2075193540c5e7 (patch) | |
tree | 4a987cb24da38f1bfb9b049ce8ce7e36b5875455 /stream.c | |
parent | a313d780ec41e52ad9b20842e56c553af6eb1a47 (diff) | |
download | txr-3e44ef9ac4394e6868b583c12b2075193540c5e7.tar.gz txr-3e44ef9ac4394e6868b583c12b2075193540c5e7.tar.bz2 txr-3e44ef9ac4394e6868b583c12b2075193540c5e7.zip |
* stream.c (get_string_from_stream): Bugfix: do not abort if
stream is not a string stream, but throw a proper error exception.
Diffstat (limited to 'stream.c')
-rw-r--r-- | stream.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -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; + } } } |