summaryrefslogtreecommitdiffstats
path: root/stream.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-08-02 18:07:35 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-08-02 18:07:35 -0700
commit8917924aa32cdd300895e02ebc3472f273dfa411 (patch)
treeb9c2ed16fd030b3344e12e06076e85ca1c999b6b /stream.c
parent905ef292831beda398fb9bc0e5aaf83878d348e0 (diff)
downloadtxr-8917924aa32cdd300895e02ebc3472f273dfa411.tar.gz
txr-8917924aa32cdd300895e02ebc3472f273dfa411.tar.bz2
txr-8917924aa32cdd300895e02ebc3472f273dfa411.zip
streams: bad argument defaulting in close-stream.
* stream.c (stdio_close, pipe_close): Fix throw_on_error argument not being defaulted correctly, so that errors are thrown even when the argument is omitted. * strudel.c (strudel_close): Here, we also must default the argument. The corresponding close method does not have an optional argument; it is mandatory. The documentation is bungled for it, though. * txr.1: Fix documentation of structure delegate streams with regard to the close method. It does not take offs and whence parametrs, but throw-on-error-p, which is mandatory.
Diffstat (limited to 'stream.c')
-rw-r--r--stream.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/stream.c b/stream.c
index 00e0228d..a1f5ead2 100644
--- a/stream.c
+++ b/stream.c
@@ -978,7 +978,7 @@ static val stdio_close(val stream, val throw_on_error)
if (h->f != 0 && h->f != stdin && h->f != stdout && h->f != stderr) {
int result = fclose(h->f);
h->f = 0;
- if (result == EOF && throw_on_error) {
+ if (result == EOF && default_null_arg(throw_on_error)) {
h->err = num(errno);
uw_throwf(file_error_s, lit("error closing ~s: ~d/~s"),
stream, num(errno), errno_to_str(errno), nao);
@@ -1378,7 +1378,7 @@ static val pipe_close(val stream, val throw_on_error)
stream, num(errno), errno_to_str(errno), nao);
} else {
#if HAVE_SYS_WAIT
- if (throw_on_error) {
+ if (default_null_arg(throw_on_error)) {
if (WIFSIGNALED(status)) {
int termsig = WTERMSIG(status);
uw_throwf(process_error_s, lit("pipe ~s terminated by signal ~a"),
@@ -1397,7 +1397,7 @@ static val pipe_close(val stream, val throw_on_error)
return num(exitstatus);
}
#else
- if (status != 0 && throw_on_error)
+ if (status != 0 && default_null_arg(throw_on_error))
uw_throwf(process_error_s, lit("closing pipe ~s failed"), stream, nao);
#endif
return status == 0 ? zero : nil;