From 0947babd7882a64843889357c789f238c5be0afa Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 6 Mar 2016 16:09:52 -0800 Subject: 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. --- stream.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'stream.c') 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); } -- cgit v1.2.3