Port close functions return void

* libguile/ports.h (scm_t_ptob_descriptor): The port close function now
  returns void.
  (scm_set_port_close): Adapt prototype.
* libguile/ports.c (scm_close_port): Always return true if we managed to
  call the close function.  There's no other sensible result; exceptions
  are handled, well, exceptionally.

* libguile/fports.c (fport_close)
* libguile/r6rs-ports.c (custom_binary_port_close, transcoded_port_close):
* libguile/vports.c (soft_port_close): Adapt.

* doc/ref/api-io.texi (Port Implementation): Update.
This commit is contained in:
Andy Wingo 2016-04-05 15:13:36 +02:00
commit e8eeeeb1d4
6 changed files with 14 additions and 23 deletions

View file

@ -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