mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-07-02 23:50:47 +02:00
Remove print state objects, and ports-with-print-state
The goal was that, as part of a print operation, all nested prints of contained data would be able to use the same parameters (e.g. write or not), and also detect cycles, highlight objects, etc. The mechanism was a heap-allocated data structure. However, given that: 1. Nobody accessed print states from Scheme 2. `write` and `display` should move to Scheme anyway, in order to be suspendable 3. The "fancyp" and "highlight" options were unused 4. A simple stack-allocated data structure with a per-thread key could do the trick just as well, without needing the weird freelist structure 5. Ports-with-print-states were a source of bugs In the end we switch print states to be something completely internal to print.c. There are no more SCM print-state objects, and no more ports-with-print-state. * libguile/print.h: Remove print state from API. * libguile/print.c (struct scm_print_state): Move definition here. (scm_print_opts): Remove "highlight-prefix" and "highlight-suffix" options, as they were not used. (ENTER_NESTED_DATA): Remove "fancyp" case. (init_print_state_key, get_print_state, push_print_state) (maybe_push_print_state, pop_print_state): New facility to manage stack of active print states. (scm_iprin1, print_vector): No more fancyp. (iprin1): Access "writingp" member directly. Don't make ports with print states. (scm_prin1): Manage print state stack. (scm_iprlist): No more fancyp. (scm_valid_oport_value_p): Remove; valid outports are SCM_OPOUTPORTP. * libguile/backtrace.c: * libguile/filesys.c: * libguile/fports.c: * libguile/goops.c: * libguile/ioext.c: * libguile/ports.c: * libguile/posix.c: * libguile/promises.c: * libguile/socket.c: * libguile/struct.c: Remove cases that dealt with ports-with-print-states. * libguile/private-options.h: Remove highlight options. * module/ice-9/ports.scm (inherit-print-state): Deprecate. * libguile/deprecated.c: * libguile/deprecated.h: Add deprecation shims for print states, as far as that is possible.
This commit is contained in:
parent
d1b548033c
commit
3cf4ca187c
16 changed files with 181 additions and 425 deletions
|
@ -163,8 +163,6 @@ SCM_DEFINE (scm_chown, "chown", 3, 0, 0,
|
|||
{
|
||||
int rv;
|
||||
|
||||
object = SCM_COERCE_OUTPORT (object);
|
||||
|
||||
#ifdef HAVE_FCHOWN
|
||||
if (scm_is_integer (object) || (SCM_OPFPORTP (object)))
|
||||
{
|
||||
|
@ -373,8 +371,6 @@ SCM_DEFINE (scm_close, "close", 1, 0, 0,
|
|||
int rv;
|
||||
int fd;
|
||||
|
||||
fd_or_port = SCM_COERCE_OUTPORT (fd_or_port);
|
||||
|
||||
if (SCM_PORTP (fd_or_port))
|
||||
return scm_close_port (fd_or_port);
|
||||
fd = scm_to_int (fd_or_port);
|
||||
|
@ -628,7 +624,6 @@ SCM_DEFINE (scm_stat, "stat", 1, 1, 0,
|
|||
}
|
||||
else
|
||||
{
|
||||
object = SCM_COERCE_OUTPORT (object);
|
||||
SCM_VALIDATE_OPFPORT (1, object);
|
||||
fdes = SCM_FPORT_FDES (object);
|
||||
SCM_SYSCALL (rv = fstat_or_fstat64 (fdes, &stat_temp));
|
||||
|
@ -795,7 +790,6 @@ set_element (fd_set *set, SCM *ports_ready, SCM element, int pos)
|
|||
int use_buf = 0;
|
||||
size_t cur;
|
||||
|
||||
element = SCM_COERCE_OUTPORT (element);
|
||||
SCM_ASSERT (SCM_OPFPORTP (element), element, pos, "select");
|
||||
if (pos == SCM_ARG1)
|
||||
{
|
||||
|
@ -870,7 +864,7 @@ get_element (fd_set *set, SCM element, SCM list)
|
|||
}
|
||||
else
|
||||
{
|
||||
fd = SCM_FPORT_FDES (SCM_COERCE_OUTPORT (element));
|
||||
fd = SCM_FPORT_FDES (element);
|
||||
}
|
||||
if (FD_ISSET (fd, set))
|
||||
list = scm_cons (element, list);
|
||||
|
@ -1103,8 +1097,6 @@ SCM_DEFINE (scm_fcntl, "fcntl", 2, 1, 0,
|
|||
int fdes;
|
||||
int ivalue;
|
||||
|
||||
object = SCM_COERCE_OUTPORT (object);
|
||||
|
||||
if (SCM_OPFPORTP (object))
|
||||
fdes = SCM_FPORT_FDES (object);
|
||||
else
|
||||
|
@ -1133,8 +1125,6 @@ SCM_DEFINE (scm_fsync, "fsync", 1, 0, 0,
|
|||
{
|
||||
int fdes;
|
||||
|
||||
object = SCM_COERCE_OUTPORT (object);
|
||||
|
||||
if (SCM_OPFPORTP (object))
|
||||
{
|
||||
scm_flush (object);
|
||||
|
@ -1758,8 +1748,6 @@ SCM_DEFINE (scm_chmod, "chmod", 2, 0, 0,
|
|||
{
|
||||
int rv;
|
||||
|
||||
object = SCM_COERCE_OUTPORT (object);
|
||||
|
||||
#if HAVE_FCHMOD
|
||||
if (scm_is_integer (object) || SCM_OPFPORTP (object))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue