From 09eddb56985c3ebb9752d7333592273949c4ac21 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Sat, 2 Nov 1996 00:00:20 +0000 Subject: [PATCH] (printchar, strout): Do QUIT for echo area output. (PRINTFULLP): New macro. (print): Exit if PRINTFULLP. When printing a symbol, don't save a pointer to the name. (PRINTFINISH): Null out print_buffer after freeing it. --- src/print.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/print.c b/src/print.c index bb4725a5ae7..518f0205761 100644 --- a/src/print.c +++ b/src/print.c @@ -200,7 +200,11 @@ glyph_to_str_cpy (glyphs, str) #define PRINTFINISH \ if (NILP (printcharfun)) \ insert (print_buffer, print_buffer_pos); \ - if (print_buffer) free (print_buffer); \ + if (print_buffer) \ + { \ + free (print_buffer); \ + print_buffer = 0; \ + } \ if (MARKERP (original)) \ Fset_marker (original, make_number (PT), Qnil); \ if (old_point >= 0) \ @@ -212,7 +216,14 @@ glyph_to_str_cpy (glyphs, str) #define PRINTCHAR(ch) printchar (ch, printcharfun) -/* Index of first unused element of FRAME_MESSAGE_BUF(mini_frame). */ +/* Nonzero if there is no room to print any more characters + so print might as well return right away. */ + +#define PRINTFULLP() \ + (EQ (printcharfun, Qt) && !noninteractive \ + && printbufidx >= FRAME_WIDTH (XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window))))) + +/* Index of first unused element of FRAME_MESSAGE_BUF (mini_frame). */ static int printbufidx; static void @@ -242,6 +253,8 @@ printchar (ch, fun) FRAME_PTR mini_frame = XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window))); + QUIT; + if (noninteractive) { putchar (ch); @@ -306,6 +319,8 @@ strout (ptr, size, printcharfun) FRAME_PTR mini_frame = XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window))); + QUIT; + i = size >= 0 ? size : strlen (ptr); #ifdef MAX_PRINT_CHARS if (max_print) @@ -841,6 +856,8 @@ print (obj, printcharfun, escapeflag) char buf[30]; QUIT; + if (PRINTFULLP ()) + return; #if 1 /* I'm not sure this is really worth doing. */ /* Detect circularities and truncate them. @@ -956,6 +973,7 @@ print (obj, printcharfun, escapeflag) register unsigned char *p = XSYMBOL (obj)->name->data; register unsigned char *end = p + XSYMBOL (obj)->name->size; register unsigned char c; + int i; if (p != end && (*p == '-' || *p == '+')) p++; if (p == end) @@ -1000,16 +1018,18 @@ print (obj, printcharfun, escapeflag) PRINTCHAR (':'); } - p = XSYMBOL (obj)->name->data; - while (p != end) + for (i = 0; i < XSYMBOL (obj)->name->size; i++) { QUIT; - c = *p++; + c = XSYMBOL (obj)->name->data[i]; + if (escapeflag) { - if (c == '\"' || c == '\\' || c == '\'' || c == ';' || c == '#' || - c == '(' || c == ')' || c == ',' || c =='.' || c == '`' || - c == '[' || c == ']' || c == '?' || c <= 040 || confusing) + if (c == '\"' || c == '\\' || c == '\'' + || c == ';' || c == '#' || c == '(' || c == ')' + || c == ',' || c =='.' || c == '`' + || c == '[' || c == ']' || c == '?' || c <= 040 + || confusing) PRINTCHAR ('\\'), confusing = 0; } PRINTCHAR (c); -- 2.39.2