From ed2c35efdaaf6fe4a4e404047d7aa29a1d6b1626 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Sat, 7 Oct 1995 22:02:20 +0000 Subject: [PATCH] (print): Handle chartables and boolvectors. (print_boolvector): New function. --- src/print.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/src/print.c b/src/print.c index fc3411fe290..9beac5b621c 100644 --- a/src/print.c +++ b/src/print.c @@ -294,7 +294,8 @@ strout (ptr, size, printcharfun) } /* Print the contents of a string STRING using PRINTCHARFUN. - It isn't safe to use strout, because printing one char can relocate. */ + It isn't safe to use strout in many cases, + because printing one char can relocate. */ print_string (string, printcharfun) Lisp_Object string; @@ -926,6 +927,47 @@ print (obj, printcharfun, escapeflag) else print_string (XPROCESS (obj)->name, printcharfun); } + else if (BOOL_VECTOR_P (obj)) + { + register int i; + register unsigned char c; + struct gcpro gcpro1; + int bits_per_char = INTBITS / sizeof (int); + int size_in_chars + = (XBOOL_VECTOR (obj)->size + bits_per_char) / bits_per_char; + + GCPRO1 (obj); + + PRINTCHAR ('#'); + PRINTCHAR ('&'); + sprintf (buf, "%d", XBOOL_VECTOR (obj)->size); + strout (buf, -1, printcharfun); + PRINTCHAR ('\"'); + for (i = 0; i < size_in_chars; i++) + { + QUIT; + c = XBOOL_VECTOR (obj)->data[i]; + if (c == '\n' && print_escape_newlines) + { + PRINTCHAR ('\\'); + PRINTCHAR ('n'); + } + else if (c == '\f' && print_escape_newlines) + { + PRINTCHAR ('\\'); + PRINTCHAR ('f'); + } + else + { + if (c == '\"' || c == '\\') + PRINTCHAR ('\\'); + PRINTCHAR (c); + } + } + PRINTCHAR ('\"'); + + UNGCPRO; + } else if (SUBRP (obj)) { strout ("#