comparison src/print.c @ 13147:bd9ff4ee6cd4

(print): Handle chartables and boolvectors. (print_boolvector): New function.
author Richard M. Stallman <rms@gnu.org>
date Sat, 07 Oct 1995 22:02:20 +0000
parents 029baa39289d
children 851452bdbc3f
comparison
equal deleted inserted replaced
13146:6182d95acd14 13147:bd9ff4ee6cd4
292 while (ptr[i]) 292 while (ptr[i])
293 PRINTCHAR (ptr[i++]); 293 PRINTCHAR (ptr[i++]);
294 } 294 }
295 295
296 /* Print the contents of a string STRING using PRINTCHARFUN. 296 /* Print the contents of a string STRING using PRINTCHARFUN.
297 It isn't safe to use strout, because printing one char can relocate. */ 297 It isn't safe to use strout in many cases,
298 because printing one char can relocate. */
298 299
299 print_string (string, printcharfun) 300 print_string (string, printcharfun)
300 Lisp_Object string; 301 Lisp_Object string;
301 Lisp_Object printcharfun; 302 Lisp_Object printcharfun;
302 { 303 {
924 PRINTCHAR ('>'); 925 PRINTCHAR ('>');
925 } 926 }
926 else 927 else
927 print_string (XPROCESS (obj)->name, printcharfun); 928 print_string (XPROCESS (obj)->name, printcharfun);
928 } 929 }
930 else if (BOOL_VECTOR_P (obj))
931 {
932 register int i;
933 register unsigned char c;
934 struct gcpro gcpro1;
935 int bits_per_char = INTBITS / sizeof (int);
936 int size_in_chars
937 = (XBOOL_VECTOR (obj)->size + bits_per_char) / bits_per_char;
938
939 GCPRO1 (obj);
940
941 PRINTCHAR ('#');
942 PRINTCHAR ('&');
943 sprintf (buf, "%d", XBOOL_VECTOR (obj)->size);
944 strout (buf, -1, printcharfun);
945 PRINTCHAR ('\"');
946 for (i = 0; i < size_in_chars; i++)
947 {
948 QUIT;
949 c = XBOOL_VECTOR (obj)->data[i];
950 if (c == '\n' && print_escape_newlines)
951 {
952 PRINTCHAR ('\\');
953 PRINTCHAR ('n');
954 }
955 else if (c == '\f' && print_escape_newlines)
956 {
957 PRINTCHAR ('\\');
958 PRINTCHAR ('f');
959 }
960 else
961 {
962 if (c == '\"' || c == '\\')
963 PRINTCHAR ('\\');
964 PRINTCHAR (c);
965 }
966 }
967 PRINTCHAR ('\"');
968
969 UNGCPRO;
970 }
929 else if (SUBRP (obj)) 971 else if (SUBRP (obj))
930 { 972 {
931 strout ("#<subr ", -1, printcharfun); 973 strout ("#<subr ", -1, printcharfun);
932 strout (XSUBR (obj)->symbol_name, -1, printcharfun); 974 strout (XSUBR (obj)->symbol_name, -1, printcharfun);
933 PRINTCHAR ('>'); 975 PRINTCHAR ('>');
979 { 1021 {
980 int size = XVECTOR (obj)->size; 1022 int size = XVECTOR (obj)->size;
981 if (COMPILEDP (obj)) 1023 if (COMPILEDP (obj))
982 { 1024 {
983 PRINTCHAR ('#'); 1025 PRINTCHAR ('#');
1026 size &= PSEUDOVECTOR_SIZE_MASK;
1027 }
1028 if (CHAR_TABLE_P (obj))
1029 {
1030 /* We print a char-table as if it were a vector,
1031 lumping the parent and default slots in with the
1032 character slots. But we add #^ as a prefix. */
1033 PRINTCHAR ('#');
1034 PRINTCHAR ('^');
984 size &= PSEUDOVECTOR_SIZE_MASK; 1035 size &= PSEUDOVECTOR_SIZE_MASK;
985 } 1036 }
986 if (size & PSEUDOVECTOR_FLAG) 1037 if (size & PSEUDOVECTOR_FLAG)
987 goto badtype; 1038 goto badtype;
988 1039