changeset 16496:a4e5a8ee32cc

(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.
author Richard M. Stallman <rms@gnu.org>
date Sat, 02 Nov 1996 00:00:20 +0000
parents 30c0ee43cc13
children 6ac6575b349d
files src/print.c
diffstat 1 files changed, 28 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/print.c	Fri Nov 01 20:18:08 1996 +0000
+++ b/src/print.c	Sat Nov 02 00:00:20 1996 +0000
@@ -200,7 +200,11 @@
 #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 @@
 
 #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 @@
       FRAME_PTR mini_frame
 	= XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window)));
 
+      QUIT;
+
       if (noninteractive)
 	{
 	  putchar (ch);
@@ -306,6 +319,8 @@
       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 @@
   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 @@
 	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 @@
 	    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);