summaryrefslogtreecommitdiff
path: root/libguile/print.c
diff options
context:
space:
mode:
Diffstat (limited to 'libguile/print.c')
-rw-r--r--libguile/print.c140
1 files changed, 79 insertions, 61 deletions
diff --git a/libguile/print.c b/libguile/print.c
index 722caf593..b10f0f8a8 100644
--- a/libguile/print.c
+++ b/libguile/print.c
@@ -1,20 +1,21 @@
-/* Copyright (C) 1995-2004, 2006, 2008-2019 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 License
- * as published by the Free Software Foundation; either version 3 of
- * the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA
- */
+/* Copyright 1995-2004,2006,2008-2019
+ Free Software Foundation, Inc.
+
+ This file is part of Guile.
+
+ Guile is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Guile is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Guile. If not, see
+ <https://www.gnu.org/licenses/>. */
@@ -29,31 +30,48 @@
#include <uniconv.h>
#include <unictype.h>
-#include "libguile/_scm.h"
-#include "libguile/chars.h"
-#include "libguile/continuations.h"
-#include "libguile/smob.h"
-#include "libguile/control.h"
-#include "libguile/eval.h"
-#include "libguile/macros.h"
-#include "libguile/procprop.h"
-#include "libguile/read.h"
-#include "libguile/programs.h"
-#include "libguile/alist.h"
-#include "libguile/struct.h"
-#include "libguile/ports.h"
-#include "libguile/ports-internal.h"
-#include "libguile/strings.h"
-#include "libguile/strports.h"
-#include "libguile/syntax.h"
-#include "libguile/vectors.h"
-#include "libguile/numbers.h"
-#include "libguile/vm.h"
-
-#include "libguile/validate.h"
-#include "libguile/print.h"
-
-#include "libguile/private-options.h"
+#include "alist.h"
+#include "arrays.h"
+#include "atomic.h"
+#include "bitvectors.h"
+#include "boolean.h"
+#include "chars.h"
+#include "continuations.h"
+#include "control.h"
+#include "eval.h"
+#include "fluids.h"
+#include "foreign.h"
+#include "frames.h"
+#include "goops.h"
+#include "gsubr.h"
+#include "hashtab.h"
+#include "keywords.h"
+#include "macros.h"
+#include "numbers.h"
+#include "pairs.h"
+#include "ports-internal.h"
+#include "ports.h"
+#include "private-options.h"
+#include "procprop.h"
+#include "programs.h"
+#include "read.h"
+#include "smob.h"
+#include "strings.h"
+#include "strports.h"
+#include "struct.h"
+#include "symbols.h"
+#include "syntax.h"
+#include "threads.h"
+#include "values.h"
+#include "variable.h"
+#include "vectors.h"
+#include "vm.h"
+#include "weak-set.h"
+#include "weak-table.h"
+#include "weak-vector.h"
+
+#include "print.h"
+
@@ -69,7 +87,7 @@ static void write_character (scm_t_wchar, SCM);
* This table must agree with the declarations in scm.h: {Immediate Symbols}.
*/
-/* This table must agree with the list of flags in tags.h. */
+/* This table must agree with the list of flags in scm.h. */
static const char *iflagnames[] =
{
"#f",
@@ -251,8 +269,8 @@ scm_i_port_with_print_state (SCM port, SCM print_state)
}
else
port = SCM_COERCE_OUTPORT (port);
- SCM_RETURN_NEWSMOB (scm_tc16_port_with_ps,
- SCM_UNPACK (scm_cons (port, print_state)));
+ return scm_new_double_smob (scm_tc16_port_with_ps,
+ SCM_UNPACK (port), SCM_UNPACK (print_state), 0);
}
static void
@@ -422,12 +440,12 @@ print_normal_symbol (SCM sym, SCM port)
if (scm_i_is_narrow_symbol (sym))
{
const char *ptr = scm_i_symbol_chars (sym);
- scm_c_put_latin1_chars (port, (const scm_t_uint8 *) ptr, len);
+ scm_c_put_latin1_chars (port, (const uint8_t *) ptr, len);
}
else
{
const scm_t_wchar *ptr = scm_i_symbol_wide_chars (sym);
- scm_c_put_utf32_chars (port, (const scm_t_uint32 *) ptr, len);
+ scm_c_put_utf32_chars (port, (const uint32_t *) ptr, len);
}
}
@@ -688,6 +706,12 @@ iprin1 (SCM exp, SCM port, scm_print_state *pstate)
case scm_tc7_variable:
scm_i_variable_print (exp, port, pstate);
break;
+ case scm_tc7_values:
+ scm_puts ("#<values (", port);
+ print_vector_or_weak_vector (exp, scm_i_nvalues (exp),
+ scm_c_value_ref, port, pstate);
+ scm_puts (">", port);
+ break;
case scm_tc7_program:
scm_i_program_print (exp, port, pstate);
break;
@@ -833,7 +857,7 @@ write_string (const void *str, int narrow_p, size_t len, SCM port)
{
size_t i;
- scm_c_put_char (port, (scm_t_uint8) '"');
+ scm_c_put_char (port, (uint8_t) '"');
for (i = 0; i < len; ++i)
{
@@ -847,11 +871,11 @@ write_string (const void *str, int narrow_p, size_t len, SCM port)
representable in PORT's encoding. If CH needs to be escaped,
it is escaped using the in-string escape syntax. */
if (ch == '"')
- scm_c_put_latin1_chars (port, (const scm_t_uint8 *) "\\\"", 2);
+ scm_c_put_latin1_chars (port, (const uint8_t *) "\\\"", 2);
else if (ch == '\\')
- scm_c_put_latin1_chars (port, (const scm_t_uint8 *) "\\\\", 2);
+ scm_c_put_latin1_chars (port, (const uint8_t *) "\\\\", 2);
else if (ch == '\n' && SCM_PRINT_ESCAPE_NEWLINES_P)
- scm_c_put_latin1_chars (port, (const scm_t_uint8 *) "\\n", 2);
+ scm_c_put_latin1_chars (port, (const uint8_t *) "\\n", 2);
else if (ch == ' ' || ch == '\n'
|| (uc_is_general_category_withtable (ch,
UC_CATEGORY_MASK_L |
@@ -865,7 +889,7 @@ write_string (const void *str, int narrow_p, size_t len, SCM port)
scm_c_put_escaped_char (port, ch);
}
- scm_c_put_char (port, (scm_t_uint8) '"');
+ scm_c_put_char (port, (uint8_t) '"');
}
/* Write CH to PORT, escaping it if it's non-graphic or not
@@ -918,14 +942,14 @@ write_character (scm_t_wchar ch, SCM port)
*/
void
-scm_intprint (scm_t_intmax n, int radix, SCM port)
+scm_intprint (intmax_t n, int radix, SCM port)
{
char num_buf[SCM_INTBUFLEN];
scm_lfwrite (num_buf, scm_iint2str (n, radix, num_buf), port);
}
void
-scm_uintprint (scm_t_uintmax n, int radix, SCM port)
+scm_uintprint (uintmax_t n, int radix, SCM port)
{
char num_buf[SCM_INTBUFLEN];
scm_lfwrite (num_buf, scm_iuint2str (n, radix, num_buf), port);
@@ -1298,7 +1322,7 @@ scm_init_print ()
scm_tc16_port_with_ps = scm_make_smob_type (0, 0);
scm_set_smob_print (scm_tc16_port_with_ps, port_with_ps_print);
-#include "libguile/print.x"
+#include "print.x"
scm_init_opts (scm_print_options, scm_print_opts);
scm_print_opts[SCM_PRINT_HIGHLIGHT_PREFIX_I].val =
@@ -1307,9 +1331,3 @@ scm_init_print ()
SCM_UNPACK (scm_from_utf8_string ("}"));
scm_print_opts[SCM_PRINT_KEYWORD_STYLE_I].val = SCM_UNPACK (sym_reader);
}
-
-/*
- Local Variables:
- c-file-style: "gnu"
- End:
-*/