1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-11 14:21:10 +02:00

* print.h (scm_print_state): Added highlight_objects.

* print.c (make_print_state, scm_free_print_state): Initialize it
to SCM_EOL.
(scm_iprin1): Wrap output in '{...}' when object is contained in
highlight_objects.
This commit is contained in:
Marius Vollmer 2004-09-23 17:44:40 +00:00
parent d5ac9b2a8c
commit d232520a23
2 changed files with 21 additions and 2 deletions

View file

@ -160,6 +160,7 @@ make_print_state (void)
pstate->ref_vect = scm_c_make_vector (PSTATE_SIZE, SCM_UNDEFINED);
pstate->ref_stack = SCM_WRITABLE_VELTS (pstate->ref_vect);
pstate->ceiling = SCM_VECTOR_LENGTH (pstate->ref_vect);
pstate->highlight_objects = SCM_EOL;
return print_state;
}
@ -192,6 +193,7 @@ scm_free_print_state (SCM print_state)
*/
pstate->fancyp = 0;
pstate->revealed = 0;
pstate->highlight_objects = SCM_EOL;
scm_i_plugin_mutex_lock (&print_state_mutex);
handle = scm_cons (print_state, print_state_pool);
print_state_pool = handle;
@ -350,8 +352,24 @@ scm_print_symbol_name (const char *str, size_t len, SCM port)
SCM_GPROC(s_write, "write", 1, 1, 0, scm_write, g_write);
SCM_GPROC(s_display, "display", 1, 1, 0, scm_display, g_display);
static void iprin1 (SCM exp, SCM port, scm_print_state *pstate);
void
scm_iprin1 (SCM exp, SCM port, scm_print_state *pstate)
{
if (pstate->fancyp
&& scm_is_true (scm_memq (exp, pstate->highlight_objects)))
{
scm_lfwrite ("{", 1, port);
iprin1 (exp, port, pstate);
scm_lfwrite ("}", 1, port);
}
else
iprin1 (exp, port, pstate);
}
static void
iprin1 (SCM exp, SCM port, scm_print_state *pstate)
{
switch (SCM_ITAG3 (exp))
{

View file

@ -3,7 +3,7 @@
#ifndef SCM_PRINT_H
#define SCM_PRINT_H
/* Copyright (C) 1995,1996,1998,2000,2001, 2003 Free Software Foundation, Inc.
/* Copyright (C) 1995,1996,1998,2000,2001, 2003, 2004 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -55,7 +55,7 @@ do { \
#define SCM_COERCE_OUTPORT(p) \
(SCM_PORT_WITH_PS_P (p) ? SCM_PORT_WITH_PS_PORT (p) : p)
#define SCM_PRINT_STATE_LAYOUT "sruwuwuwuwuwpwuwuwuruopr"
#define SCM_PRINT_STATE_LAYOUT "sruwuwuwuwuwpwuwuwuruoprpw"
typedef struct scm_print_state {
SCM handle; /* Struct handle */
int revealed; /* Has the state escaped to Scheme? */
@ -70,6 +70,7 @@ typedef struct scm_print_state {
SCM *ref_stack; /* Stack of references used during
circular reference detection */
SCM ref_vect;
SCM highlight_objects; /* List of objects to be highlighted */
} scm_print_state;
SCM_API SCM scm_print_state_vtable;