summaryrefslogtreecommitdiffstats
path: root/stream.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-03-06 16:09:52 -0800
committerKaz Kylheku <kaz@kylheku.com>2016-03-06 16:26:59 -0800
commit0947babd7882a64843889357c789f238c5be0afa (patch)
treeac04fe46ebcc5bdb6ad68a63d0a9469ae0d488e6 /stream.c
parent06691c2d75d27d6ac9d3bb1d3671f9626d41ee80 (diff)
downloadtxr-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.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/stream.c b/stream.c
index 05c6ee77..d112c71e 100644
--- a/stream.c
+++ b/stream.c
@@ -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);
}