diff options
| author | Richard M. Stallman | 1996-11-04 05:31:25 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-11-04 05:31:25 +0000 |
| commit | 08e8d2975c72feecc748a62320efe215d6b42eaf (patch) | |
| tree | dadd282a70548ceaa6d3d1a2d9af6c9aa8ab44d8 /src/print.c | |
| parent | 984322b6ac429dcdccf0ba059de6c1f710d57b01 (diff) | |
| download | emacs-08e8d2975c72feecc748a62320efe215d6b42eaf.tar.gz emacs-08e8d2975c72feecc748a62320efe215d6b42eaf.zip | |
(PRINTDECLARE): Declare specpdl_count and free_print_buffer.
(PRINTPREPARE): If print_buffer is nonzero,
save its contents in a string using record_unwind_protect.
(PRINTFINISH): Restore old print_buffer contents.
Free it only if this PRINTPREPARE malloc'd it.
(print): Don't call PRINTFULLP after all.
(print_unwind): New function.
Diffstat (limited to 'src/print.c')
| -rw-r--r-- | src/print.c | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/src/print.c b/src/print.c index 518f0205761..5d87c1ad612 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -169,42 +169,55 @@ glyph_to_str_cpy (glyphs, str) | |||
| 169 | #define PRINTDECLARE \ | 169 | #define PRINTDECLARE \ |
| 170 | struct buffer *old = current_buffer; \ | 170 | struct buffer *old = current_buffer; \ |
| 171 | int old_point = -1, start_point; \ | 171 | int old_point = -1, start_point; \ |
| 172 | int specpdl_count = specpdl_ptr - specpdl; \ | ||
| 173 | int free_print_buffer = 0; \ | ||
| 172 | Lisp_Object original | 174 | Lisp_Object original |
| 173 | 175 | ||
| 174 | #define PRINTPREPARE \ | 176 | #define PRINTPREPARE \ |
| 175 | original = printcharfun; \ | 177 | original = printcharfun; \ |
| 176 | if (NILP (printcharfun)) printcharfun = Qt; \ | 178 | if (NILP (printcharfun)) printcharfun = Qt; \ |
| 177 | if (BUFFERP (printcharfun)) \ | 179 | if (BUFFERP (printcharfun)) \ |
| 178 | { if (XBUFFER (printcharfun) != current_buffer) \ | 180 | { \ |
| 181 | if (XBUFFER (printcharfun) != current_buffer) \ | ||
| 179 | Fset_buffer (printcharfun); \ | 182 | Fset_buffer (printcharfun); \ |
| 180 | printcharfun = Qnil;} \ | 183 | printcharfun = Qnil; \ |
| 184 | } \ | ||
| 181 | if (MARKERP (printcharfun)) \ | 185 | if (MARKERP (printcharfun)) \ |
| 182 | { if (!(XMARKER (original)->buffer)) \ | 186 | { \ |
| 187 | if (!(XMARKER (original)->buffer)) \ | ||
| 183 | error ("Marker does not point anywhere"); \ | 188 | error ("Marker does not point anywhere"); \ |
| 184 | if (XMARKER (original)->buffer != current_buffer) \ | 189 | if (XMARKER (original)->buffer != current_buffer) \ |
| 185 | set_buffer_internal (XMARKER (original)->buffer); \ | 190 | set_buffer_internal (XMARKER (original)->buffer); \ |
| 186 | old_point = PT; \ | 191 | old_point = PT; \ |
| 187 | SET_PT (marker_position (printcharfun)); \ | 192 | SET_PT (marker_position (printcharfun)); \ |
| 188 | start_point = PT; \ | 193 | start_point = PT; \ |
| 189 | printcharfun = Qnil;} \ | 194 | printcharfun = Qnil; \ |
| 195 | } \ | ||
| 190 | if (NILP (printcharfun)) \ | 196 | if (NILP (printcharfun)) \ |
| 191 | { \ | 197 | { \ |
| 198 | if (print_buffer != 0) \ | ||
| 199 | record_unwind_protect (print_unwind, \ | ||
| 200 | make_string (print_buffer, \ | ||
| 201 | print_buffer_pos)); \ | ||
| 202 | else \ | ||
| 203 | { \ | ||
| 204 | print_buffer_size = 1000; \ | ||
| 205 | print_buffer = (char *) xmalloc (print_buffer_size); \ | ||
| 206 | free_print_buffer = 0; \ | ||
| 207 | } \ | ||
| 192 | print_buffer_pos = 0; \ | 208 | print_buffer_pos = 0; \ |
| 193 | print_buffer_size = 1000; \ | ||
| 194 | print_buffer = (char *) xmalloc (print_buffer_size); \ | ||
| 195 | } \ | 209 | } \ |
| 196 | else \ | ||
| 197 | print_buffer = 0; \ | ||
| 198 | printed_gensyms = Qnil | 210 | printed_gensyms = Qnil |
| 199 | 211 | ||
| 200 | #define PRINTFINISH \ | 212 | #define PRINTFINISH \ |
| 201 | if (NILP (printcharfun)) \ | 213 | if (NILP (printcharfun)) \ |
| 202 | insert (print_buffer, print_buffer_pos); \ | 214 | insert (print_buffer, print_buffer_pos); \ |
| 203 | if (print_buffer) \ | 215 | if (free_print_buffer) \ |
| 204 | { \ | 216 | { \ |
| 205 | free (print_buffer); \ | 217 | free (print_buffer); \ |
| 206 | print_buffer = 0; \ | 218 | print_buffer = 0; \ |
| 207 | } \ | 219 | } \ |
| 220 | unbind_to (specpdl_count, Qnil); \ | ||
| 208 | if (MARKERP (original)) \ | 221 | if (MARKERP (original)) \ |
| 209 | Fset_marker (original, make_number (PT), Qnil); \ | 222 | Fset_marker (original, make_number (PT), Qnil); \ |
| 210 | if (old_point >= 0) \ | 223 | if (old_point >= 0) \ |
| @@ -223,6 +236,15 @@ glyph_to_str_cpy (glyphs, str) | |||
| 223 | (EQ (printcharfun, Qt) && !noninteractive \ | 236 | (EQ (printcharfun, Qt) && !noninteractive \ |
| 224 | && printbufidx >= FRAME_WIDTH (XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window))))) | 237 | && printbufidx >= FRAME_WIDTH (XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window))))) |
| 225 | 238 | ||
| 239 | /* This is used to restore the saved contents of print_buffer | ||
| 240 | when there is a recursive call to print. */ | ||
| 241 | static Lisp_Object | ||
| 242 | print_unwind (saved_text) | ||
| 243 | Lisp_Object saved_text; | ||
| 244 | { | ||
| 245 | bcopy (XSTRING (saved_text)->data, print_buffer, XSTRING (saved_text)->size); | ||
| 246 | } | ||
| 247 | |||
| 226 | /* Index of first unused element of FRAME_MESSAGE_BUF (mini_frame). */ | 248 | /* Index of first unused element of FRAME_MESSAGE_BUF (mini_frame). */ |
| 227 | static int printbufidx; | 249 | static int printbufidx; |
| 228 | 250 | ||
| @@ -856,8 +878,6 @@ print (obj, printcharfun, escapeflag) | |||
| 856 | char buf[30]; | 878 | char buf[30]; |
| 857 | 879 | ||
| 858 | QUIT; | 880 | QUIT; |
| 859 | if (PRINTFULLP ()) | ||
| 860 | return; | ||
| 861 | 881 | ||
| 862 | #if 1 /* I'm not sure this is really worth doing. */ | 882 | #if 1 /* I'm not sure this is really worth doing. */ |
| 863 | /* Detect circularities and truncate them. | 883 | /* Detect circularities and truncate them. |