diff options
| author | Richard M. Stallman | 1995-10-07 22:02:20 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-10-07 22:02:20 +0000 |
| commit | ed2c35efdaaf6fe4a4e404047d7aa29a1d6b1626 (patch) | |
| tree | 4bad0382c35e24c4ff809d1ba838bcd73803dd94 /src | |
| parent | c239093310e6bed6ffdf192e9515371e0135ccaa (diff) | |
| download | emacs-ed2c35efdaaf6fe4a4e404047d7aa29a1d6b1626.tar.gz emacs-ed2c35efdaaf6fe4a4e404047d7aa29a1d6b1626.zip | |
(print): Handle chartables and boolvectors.
(print_boolvector): New function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/print.c | 53 |
1 files changed, 52 insertions, 1 deletions
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) | |||
| 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; |
| @@ -926,6 +927,47 @@ print (obj, printcharfun, escapeflag) | |||
| 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); |
| @@ -983,6 +1025,15 @@ print (obj, printcharfun, escapeflag) | |||
| 983 | PRINTCHAR ('#'); | 1025 | PRINTCHAR ('#'); |
| 984 | size &= PSEUDOVECTOR_SIZE_MASK; | 1026 | size &= PSEUDOVECTOR_SIZE_MASK; |
| 985 | } | 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 ('^'); | ||
| 1035 | size &= PSEUDOVECTOR_SIZE_MASK; | ||
| 1036 | } | ||
| 986 | if (size & PSEUDOVECTOR_FLAG) | 1037 | if (size & PSEUDOVECTOR_FLAG) |
| 987 | goto badtype; | 1038 | goto badtype; |
| 988 | 1039 | ||