diff options
-rw-r--r-- | doc/ref/api-io.texi | 2 | ||||
-rw-r--r-- | libguile/fports.c | 8 | ||||
-rw-r--r-- | libguile/ports.c | 8 | ||||
-rw-r--r-- | libguile/ports.h | 4 | ||||
-rw-r--r-- | libguile/r6rs-ports.c | 8 | ||||
-rw-r--r-- | libguile/vports.c | 7 |
6 files changed, 14 insertions, 23 deletions
diff --git a/doc/ref/api-io.texi b/doc/ref/api-io.texi index 759d33940..4e4d59b66 100644 --- a/doc/ref/api-io.texi +++ b/doc/ref/api-io.texi @@ -2317,7 +2317,7 @@ argument @var{dest_port} is where its description should go. Called when the port is closed. It should free any resources used by the port. Set using -@deftypefun void scm_set_port_close (scm_t_bits tc, int (*close) (SCM port)) +@deftypefun void scm_set_port_close (scm_t_bits tc, void (*close) (SCM port)) @end deftypefun By default, ports that are garbage collected just go away without diff --git a/libguile/fports.c b/libguile/fports.c index e33bfe58c..963c1eafd 100644 --- a/libguile/fports.c +++ b/libguile/fports.c @@ -794,11 +794,10 @@ close_the_fd (void *data) errno = 0; } -static int +static void fport_close (SCM port) { scm_t_fport *fp = SCM_FSTREAM (port); - int rv; scm_dynwind_begin (0); scm_dynwind_unwind_handler (close_the_fd, fp, 0); @@ -807,15 +806,12 @@ fport_close (SCM port) scm_port_non_buffer (SCM_PTAB_ENTRY (port)); - rv = close (fp->fdes); - if (rv) + if (close (fp->fdes) != 0) /* It's not useful to retry after EINTR, as the file descriptor is in an undefined state. See http://lwn.net/Articles/365294/. Instead just throw an error if close fails, trusting that the fd was cleaned up. */ scm_syserror ("fport_close"); - - return 0; } static scm_t_bits diff --git a/libguile/ports.c b/libguile/ports.c index 202f7f998..b8d2616c1 100644 --- a/libguile/ports.c +++ b/libguile/ports.c @@ -275,7 +275,7 @@ scm_set_port_print (scm_t_bits tc, int (*print) (SCM exp, SCM port, } void -scm_set_port_close (scm_t_bits tc, int (*close) (SCM)) +scm_set_port_close (scm_t_bits tc, void (*close) (SCM)) { scm_c_port_type_ref (SCM_TC2PTOBNUM (tc))->close = close; } @@ -834,9 +834,7 @@ SCM_DEFINE (scm_close_port, "close-port", 1, 0, 0, if (SCM_PORT_DESCRIPTOR (port)->close) /* Note! This may throw an exception. Anything after this point should be resilient to non-local exits. */ - rv = SCM_PORT_DESCRIPTOR (port)->close (port); - else - rv = 0; + SCM_PORT_DESCRIPTOR (port)->close (port); if (pti->iconv_descriptors) { @@ -846,7 +844,7 @@ SCM_DEFINE (scm_close_port, "close-port", 1, 0, 0, pti->iconv_descriptors = NULL; } - return scm_from_bool (rv >= 0); + return SCM_BOOL_T; } #undef FUNC_NAME diff --git a/libguile/ports.h b/libguile/ports.h index 6b9a006b8..0196753ae 100644 --- a/libguile/ports.h +++ b/libguile/ports.h @@ -187,7 +187,7 @@ typedef struct scm_t_ptob_descriptor { char *name; int (*print) (SCM exp, SCM port, scm_print_state *pstate); - int (*close) (SCM port); + void (*close) (SCM port); void (*write) (SCM port, const void *data, size_t size); void (*flush) (SCM port); @@ -227,7 +227,7 @@ SCM_API void scm_set_port_print (scm_t_bits tc, int (*print) (SCM exp, SCM port, scm_print_state *pstate)); -SCM_API void scm_set_port_close (scm_t_bits tc, int (*close) (SCM)); +SCM_API void scm_set_port_close (scm_t_bits tc, void (*close) (SCM)); SCM_API void scm_set_port_needs_close_on_gc (scm_t_bits tc, int needs_close_p); SCM_API void scm_set_port_flush (scm_t_bits tc, void (*flush) (SCM port)); diff --git a/libguile/r6rs-ports.c b/libguile/r6rs-ports.c index 5a752bbc5..9e12b5a52 100644 --- a/libguile/r6rs-ports.c +++ b/libguile/r6rs-ports.c @@ -257,7 +257,7 @@ custom_binary_port_seek (SCM port, scm_t_off offset, int whence) } #undef FUNC_NAME -static int +static void custom_binary_port_close (SCM port) { struct custom_binary_port *stream = (void *) SCM_STREAM (port); @@ -265,8 +265,6 @@ custom_binary_port_close (SCM port) if (scm_is_true (stream->close)) /* Invoke the `close' thunk. */ scm_call_0 (stream->close); - - return 1; } @@ -1238,13 +1236,13 @@ transcoded_port_flush (SCM port) scm_force_output (binary_port); } -static int +static void transcoded_port_close (SCM port) { SCM bport = SCM_TRANSCODED_PORT_BINARY_PORT (port); if (SCM_OUTPUT_PORT_P (port)) transcoded_port_flush (port); - return scm_is_true (scm_close_port (bport)) ? 0 : -1; + scm_close_port (bport); } static inline void diff --git a/libguile/vports.c b/libguile/vports.c index b46f9f75d..65041283d 100644 --- a/libguile/vports.c +++ b/libguile/vports.c @@ -128,13 +128,12 @@ soft_port_fill_input (SCM port) } -static int +static void soft_port_close (SCM port) { struct soft_port *stream = (void *) SCM_STREAM (port); - if (scm_is_false (stream->close)) - return 0; - return scm_is_false (scm_call_0 (stream->close)) ? EOF : 0; + if (scm_is_true (stream->close)) + scm_call_0 (stream->close); } |