From a1f43475baae66ef0d4527c0172bac21793cdf9d Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Mon, 16 Apr 2012 23:50:13 +0900 Subject: [PATCH] output-port? returns #t for input+output ports --- include/chibi/sexp.h | 1 + opcodes.c | 2 +- sexp.c | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/chibi/sexp.h b/include/chibi/sexp.h index 135eedee..13025024 100755 --- a/include/chibi/sexp.h +++ b/include/chibi/sexp.h @@ -1271,6 +1271,7 @@ SEXP_API sexp sexp_make_output_port (sexp ctx, FILE* out, sexp name); SEXP_API sexp sexp_make_non_null_input_port (sexp ctx, FILE* in, sexp name); SEXP_API sexp sexp_make_non_null_output_port (sexp ctx, FILE* out, sexp name); SEXP_API sexp sexp_make_non_null_input_output_port (sexp ctx, FILE* io, sexp name); +SEXP_API sexp sexp_port_outputp_op (sexp ctx, sexp self, sexp_sint_t n, sexp port); SEXP_API sexp sexp_port_binaryp_op (sexp ctx, sexp self, sexp_sint_t n, sexp port); SEXP_API sexp sexp_port_openp_op (sexp ctx, sexp self, sexp_sint_t n, sexp port); #if SEXP_USE_FOLD_CASE_SYMS diff --git a/opcodes.c b/opcodes.c index 92b67921..42bf7aaa 100644 --- a/opcodes.c +++ b/opcodes.c @@ -109,7 +109,7 @@ _FN1(_I(SEXP_NUMBER), _I(SEXP_COMPLEX), "complex-imag", 0, sexp_complex_imag_op) _OP(SEXP_OPC_TYPE_PREDICATE, SEXP_OP_TYPEP, 1, 0, _I(SEXP_BOOLEAN), _I(SEXP_OBJECT), SEXP_FALSE, SEXP_FALSE, 0, "closure?", _I(SEXP_PROCEDURE), 0), _OP(SEXP_OPC_TYPE_PREDICATE, SEXP_OP_TYPEP, 1, 0, _I(SEXP_BOOLEAN), _I(SEXP_OBJECT), SEXP_FALSE, SEXP_FALSE, 0, "opcode?", _I(SEXP_OPCODE), 0), _OP(SEXP_OPC_TYPE_PREDICATE, SEXP_OP_TYPEP, 1, 0, _I(SEXP_BOOLEAN), _I(SEXP_OBJECT), SEXP_FALSE, SEXP_FALSE, 0, "input-port?", _I(SEXP_IPORT), 0), -_OP(SEXP_OPC_TYPE_PREDICATE, SEXP_OP_TYPEP, 1, 0, _I(SEXP_BOOLEAN), _I(SEXP_OBJECT), SEXP_FALSE, SEXP_FALSE, 0, "output-port?", _I(SEXP_OPORT), 0), +_FN1(_I(SEXP_BOOLEAN), _I(SEXP_IPORT), "output-port?", 0, sexp_port_outputp_op), _FN1(_I(SEXP_BOOLEAN), _I(SEXP_IPORT), "binary-port?", 0, sexp_port_binaryp_op), _FN1(_I(SEXP_BOOLEAN), _I(SEXP_IPORT), "port-open?", 0, sexp_port_openp_op), _OP(SEXP_OPC_GENERIC, SEXP_OP_APPLY1, 2, 0, _I(SEXP_OBJECT), _I(SEXP_PROCEDURE), SEXP_NULL, SEXP_FALSE, 0, "apply1", 0, NULL), diff --git a/sexp.c b/sexp.c index c067b301..70f50bd0 100644 --- a/sexp.c +++ b/sexp.c @@ -1464,6 +1464,11 @@ sexp sexp_make_non_null_input_output_port (sexp ctx, FILE* io, sexp name) { #define sexp_make_non_null_input_output_port sexp_make_non_null_input_port #endif +sexp sexp_port_outputp_op (sexp ctx, sexp self, sexp_sint_t n, sexp port) { + sexp_assert_type(ctx, sexp_portp, SEXP_OPORT, port); + return sexp_make_boolean(sexp_oportp(port)); +} + sexp sexp_port_binaryp_op (sexp ctx, sexp self, sexp_sint_t n, sexp port) { sexp_assert_type(ctx, sexp_portp, SEXP_IPORT, port); return sexp_make_boolean(sexp_port_binaryp(port));