diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-03-06 16:09:52 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-03-06 16:26:59 -0800 |
commit | 0947babd7882a64843889357c789f238c5be0afa (patch) | |
tree | ac04fe46ebcc5bdb6ad68a63d0a9469ae0d488e6 /stream.c | |
parent | 06691c2d75d27d6ac9d3bb1d3671f9626d41ee80 (diff) | |
download | txr-0947babd7882a64843889357c789f238c5be0afa.tar.gz txr-0947babd7882a64843889357c789f238c5be0afa.tar.bz2 txr-0947babd7882a64843889357c789f238c5be0afa.zip |
Move error check from operation to wrapper.
* stream.c (stdio_unget_char): Remove not-a-character check
from character argument.
(unget_char): Perform check here, thus for all stream types.
Diffstat (limited to 'stream.c')
-rw-r--r-- | stream.c | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -690,9 +690,6 @@ static val stdio_unget_char(val stream, val ch) { struct stdio_handle *h = coerce(struct stdio_handle *, stream->co.handle); - if (!is_chr(ch)) - type_mismatch(lit("unget-char: ~s is not a character"), ch, nao); - if (h->unget_c) uw_throwf(file_error_s, lit("unget-char overflow on ~a: "), stream, nao); @@ -2314,6 +2311,8 @@ val unget_char(val ch, val stream_in) { val stream = default_arg(stream_in, std_input); struct strm_ops *ops = coerce(struct strm_ops *, cobj_ops(stream, stream_s)); + if (!is_chr(ch)) + type_mismatch(lit("unget-char: ~s is not a character"), ch, nao); return ops->unget_char(stream, ch); } |