#include "libguile/strings.h"
#include "libguile/strports.h"
#include "libguile/vectors.h"
+#include "libguile/lang.h"
#include "libguile/validate.h"
#include "libguile/print.h"
char *scm_isymnames[] =
{
- /* This table must agree with the declarations */
+ /* This table must agree with the list of SCM_IM_ constants in tags.h */
"#@and",
"#@begin",
"#@case",
/* Multi-language support */
"#@nil-cond",
- "#@nil-ify",
- "#@t-ify",
- "#@0-cond",
- "#@0-ify",
- "#@1-ify",
"#@bind",
"#@delay",
"#@call-with-values",
- "#<unbound>"
+ "#<unbound>",
+
+ /* Elisp nil value. This is its Scheme name; whenever it's printed
+ in Elisp, it should appear as the symbol `nil'. */
+
+ "#nil"
};
scm_t_option scm_print_opts[] = {
= scm_make_struct (scm_print_state_vtable, SCM_INUM0, SCM_EOL);
scm_print_state *pstate = SCM_PRINT_STATE (print_state);
pstate->ref_vect = scm_c_make_vector (PSTATE_SIZE, SCM_UNDEFINED);
- pstate->ref_stack = SCM_VELTS (pstate->ref_vect);
+ pstate->ref_stack = SCM_WRITABLE_VELTS (pstate->ref_vect);
pstate->ceiling = SCM_VECTOR_LENGTH (pstate->ref_vect);
return print_state;
}
*/
pstate->fancyp = 0;
pstate->revealed = 0;
- SCM_NEWCELL (handle);
SCM_DEFER_INTS;
- SCM_SET_CELL_WORD_0 (handle, print_state);
- SCM_SET_CELL_WORD_1 (handle, print_state_pool);
+ handle = scm_cons (print_state, print_state_pool);
print_state_pool = handle;
SCM_ALLOW_INTS;
}
grow_ref_stack (scm_print_state *pstate)
{
unsigned long int old_size = SCM_VECTOR_LENGTH (pstate->ref_vect);
- SCM *old_elts = SCM_VELTS (pstate->ref_vect);
+ SCM const *old_elts = SCM_VELTS (pstate->ref_vect);
unsigned long int new_size = 2 * pstate->ceiling;
SCM new_vect = scm_c_make_vector (new_size, SCM_UNDEFINED);
- SCM *new_elts = SCM_VELTS (new_vect);
unsigned long int i;
for (i = 0; i != old_size; ++i)
- new_elts [i] = old_elts [i];
+ SCM_VECTOR_SET (new_vect, i, old_elts [i]);
pstate->ref_vect = new_vect;
- pstate->ref_stack = new_elts;
+ pstate->ref_stack = SCM_WRITABLE_VELTS(new_vect);
pstate->ceiling = new_size;
}
static void
-print_circref (SCM port,scm_print_state *pstate,SCM ref)
+print_circref (SCM port, scm_print_state *pstate, SCM ref)
{
register long i;
long self = pstate->top - 1;
SCM_NEWSMOB (pwps,
scm_tc16_port_with_ps,
SCM_UNPACK (scm_cons (port, pstate->handle)));
+ pstate->revealed = 1;
scm_call_generic_2 (print, exp, pwps);
}
else
scm_lfwrite (SCM_STRING_CHARS (exp), SCM_STRING_LENGTH (exp), port);
break;
case scm_tc7_symbol:
- scm_print_symbol_name (SCM_SYMBOL_CHARS (exp),
- SCM_SYMBOL_LENGTH (exp),
- port);
- scm_remember_upto_here_1 (exp);
+ if (SCM_SYMBOL_INTERNED_P (exp))
+ {
+ scm_print_symbol_name (SCM_SYMBOL_CHARS (exp),
+ SCM_SYMBOL_LENGTH (exp),
+ port);
+ scm_remember_upto_here_1 (exp);
+ }
+ else
+ {
+ scm_puts ("#<uninterned-symbol ", port);
+ scm_print_symbol_name (SCM_SYMBOL_CHARS (exp),
+ SCM_SYMBOL_LENGTH (exp),
+ port);
+ scm_putc (' ', port);
+ scm_intprint ((long)exp, 16, port);
+ scm_putc ('>', port);
+ }
break;
case scm_tc7_variable:
scm_i_variable_print (exp, port, pstate);
/* Print a list.
*/
void
-scm_iprlist (char *hdr,SCM exp,int tlr,SCM port,scm_print_state *pstate)
+scm_iprlist (char *hdr, SCM exp, int tlr, SCM port, scm_print_state *pstate)
{
register SCM hare, tortoise;
long floor = pstate->top - 2;
/* CHECK_INTS; */
scm_iprin1 (SCM_CAR (exp), port, pstate);
}
- if (!SCM_NULLP (exp))
+ if (!SCM_NULL_OR_NIL_P (exp))
{
scm_puts (" . ", port);
scm_iprin1 (exp, port, pstate);
scm_iprin1 (SCM_CAR (exp), port, pstate);
}
}
- if (!SCM_NULLP (exp))
+ if (!SCM_NULL_OR_NIL_P (exp))
{
scm_puts (" . ", port);
scm_iprin1 (exp, port, pstate);
start = p + 1;
continue;
case '%':
+ scm_lfwrite (start, p - start - 1, destination);
scm_newline (destination);
start = p + 1;
continue;
SCM_DEFINE (scm_newline, "newline", 0, 1, 0,
(SCM port),
- "Send a newline to @var{port}.")
+ "Send a newline to @var{port}.\n"
+ "If @var{port} is omitted, send to the current output port.")
#define FUNC_NAME s_scm_newline
{
if (SCM_UNBNDP (port))
port = scm_cur_outp;
- SCM_VALIDATE_OPORT_VALUE (1,port);
+ SCM_VALIDATE_OPORT_VALUE (1, port);
scm_putc ('\n', SCM_COERCE_OUTPORT (port));
return SCM_UNSPECIFIED;
if (SCM_UNBNDP (port))
port = scm_cur_outp;
- SCM_VALIDATE_CHAR (1,chr);
- SCM_VALIDATE_OPORT_VALUE (2,port);
+ SCM_VALIDATE_CHAR (1, chr);
+ SCM_VALIDATE_OPORT_VALUE (2, port);
scm_putc ((int) SCM_CHAR (chr), SCM_COERCE_OUTPORT (port));
#ifdef HAVE_PIPE
#define FUNC_NAME s_scm_port_with_print_state
{
SCM pwps;
- SCM_VALIDATE_OPORT_VALUE (1,port);
- SCM_VALIDATE_PRINTSTATE (2,pstate);
+ SCM_VALIDATE_OPORT_VALUE (1, port);
+ SCM_VALIDATE_PRINTSTATE (2, pstate);
port = SCM_COERCE_OUTPORT (port);
SCM_NEWSMOB (pwps, scm_tc16_port_with_ps, SCM_UNPACK (scm_cons (port, pstate)));
return pwps;
scm_set_smob_mark (scm_tc16_port_with_ps, scm_markcdr);
scm_set_smob_print (scm_tc16_port_with_ps, port_with_ps_print);
-#ifndef SCM_MAGIC_SNARFER
#include "libguile/print.x"
-#endif
}
/*