mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-09 13:30:26 +02:00
Tweak R6RS transcoded ports flushing
* libguile/r6rs-ports.c (tp_flush): Only operate on the underlying port when it is open.
This commit is contained in:
parent
0687e826a1
commit
dfb572a7bf
1 changed files with 11 additions and 2 deletions
|
@ -1177,12 +1177,21 @@ tp_flush (SCM port)
|
||||||
scm_t_port *c_port = SCM_PTAB_ENTRY (port);
|
scm_t_port *c_port = SCM_PTAB_ENTRY (port);
|
||||||
size_t count = c_port->write_pos - c_port->write_buf;
|
size_t count = c_port->write_pos - c_port->write_buf;
|
||||||
|
|
||||||
scm_c_write (binary_port, c_port->write_buf, count);
|
/* As the runtime will try to flush all ports upon exit, we test for
|
||||||
|
the underlying port still being open here. Otherwise, when you
|
||||||
|
would explicitly close the underlying port and the transcoded port
|
||||||
|
still had data outstanding, you'd get an exception on Guile exit.
|
||||||
|
|
||||||
|
We just throw away the data when the underlying port is closed. */
|
||||||
|
|
||||||
|
if (SCM_OPOUTPORTP (binary_port))
|
||||||
|
scm_c_write (binary_port, c_port->write_buf, count);
|
||||||
|
|
||||||
c_port->write_pos = c_port->write_buf;
|
c_port->write_pos = c_port->write_buf;
|
||||||
c_port->rw_active = SCM_PORT_NEITHER;
|
c_port->rw_active = SCM_PORT_NEITHER;
|
||||||
|
|
||||||
scm_force_output (binary_port);
|
if (SCM_OPOUTPORTP (binary_port))
|
||||||
|
scm_force_output (binary_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue