]> code.delx.au - gnu-emacs/blobdiff - src/print.c
RET bound in Rmail summary.
[gnu-emacs] / src / print.c
index dc28ed0ce1117f11f0be532a65031a62772c33a9..32ee03050b321d3427e9e9254e990bc11f208546 100644 (file)
@@ -1,5 +1,5 @@
 /* Lisp object printing and output streams.
-   Copyright (C) 1985, 86, 88, 93, 94, 95, 97, 1998
+   Copyright (C) 1985, 86, 88, 93, 94, 95, 97, 98, 1999
        Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -31,10 +31,7 @@ Boston, MA 02111-1307, USA.  */
 #include "dispextern.h"
 #include "termchar.h"
 #include "keyboard.h"
-
-#ifdef USE_TEXT_PROPERTIES
 #include "intervals.h"
-#endif
 
 Lisp_Object Vstandard_output, Qstandard_output;
 
@@ -60,7 +57,6 @@ Lisp_Object Vfloat_output_format, Qfloat_output_format;
 
 #if STDC_HEADERS
 #include <float.h>
-#include <stdlib.h>
 #endif
 
 /* Default to values appropriate for IEEE floating point.  */
@@ -252,7 +248,7 @@ void print_interval ();
        print_buffer_pos = 0;                                           \
        print_buffer_pos_byte = 0;                                      \
      }                                                                 \
-   if (EQ (printcharfun, Qt))                                          \
+   if (EQ (printcharfun, Qt) && ! noninteractive)                      \
      setup_echo_area_for_printing (multibyte);
 
 #define PRINTFINISH                                                    \
@@ -389,7 +385,7 @@ strout (ptr, size, size_byte, printcharfun, multibyte)
         print_chars += size;
 #endif /* MAX_PRINT_CHARS */
     }
-  else if (noninteractive)
+  else if (noninteractive && EQ (printcharfun, Qt))
     {
       fwrite (ptr, 1, size_byte, stdout);
       noninteractive_need_newline = 1;
@@ -670,9 +666,7 @@ buffer and calling the hook.  It gets one argument, the buffer to display.")
 \f
 static void print ();
 static void print_preprocess ();
-#ifdef USE_TEXT_PROPERTIES
 static void print_preprocess_string ();
-#endif /* USE_TEXT_PROPERTIES */
 static void print_object ();
 
 DEFUN ("terpri", Fterpri, Sterpri, 0, 1, 0,
@@ -960,6 +954,19 @@ float_to_string (buf, data)
   /* Check for NaN in a way that won't fail if there are no NaNs.  */
   if (! (data * 0.0 >= 0.0))
     {
+      /* Prepend "-" if the NaN's sign bit is negative.
+        The sign bit of a double is the bit that is 1 in -0.0.  */
+      int i;
+      union { double d; char c[sizeof (double)]; } u_data, u_minus_zero;
+      u_data.d = data;
+      u_minus_zero.d = - 0.0;
+      for (i = 0; i < sizeof (double); i++)
+       if (u_data.c[i] & u_minus_zero.c[i])
+         {
+           *buf++ = '-';
+           break;
+         }
+      
       strcpy (buf, "0.0e+NaN");
       return;
     }
@@ -1110,51 +1117,54 @@ print_preprocess (obj)
       || (! NILP (Vprint_gensym)
          && SYMBOLP (obj) && NILP (XSYMBOL (obj)->obarray)))
     {
-      for (i = 0; i < print_number_index; i++)
-       if (PRINT_NUMBER_OBJECT (Vprint_number_table, i) == obj)
-         {
-           /* OBJ appears more than once.  Let's remember that.  */
-           PRINT_NUMBER_STATUS (Vprint_number_table, i) = Qt;
-           return;
-         }
-
-      /* OBJ is not yet recorded.  Let's add to the table.  */
-      if (print_number_index == 0)
-       {
-         /* Initialize the table.  */
-         Vprint_number_table = Fmake_vector (make_number (40), Qnil);
-       }
-      else if (XVECTOR (Vprint_number_table)->size == print_number_index * 2)
+      /* In case print-circle is nil and print-gensym is t,
+        add OBJ to Vprint_number_table only when OBJ is a symbol.  */
+      if (! NILP (Vprint_circle) || SYMBOLP (obj))
        {
-         /* Reallocate the table.  */
-         int i = print_number_index * 4;
-         Lisp_Object old_table = Vprint_number_table;
-         Vprint_number_table = Fmake_vector (make_number (i), Qnil);
          for (i = 0; i < print_number_index; i++)
+           if (PRINT_NUMBER_OBJECT (Vprint_number_table, i) == obj)
+             {
+               /* OBJ appears more than once.  Let's remember that.  */
+               PRINT_NUMBER_STATUS (Vprint_number_table, i) = Qt;
+               return;
+             }
+
+         /* OBJ is not yet recorded.  Let's add to the table.  */
+         if (print_number_index == 0)
            {
-             PRINT_NUMBER_OBJECT (Vprint_number_table, i)
-               = PRINT_NUMBER_OBJECT (old_table, i);
-             PRINT_NUMBER_STATUS (Vprint_number_table, i)
-               = PRINT_NUMBER_STATUS (old_table, i);
+             /* Initialize the table.  */
+             Vprint_number_table = Fmake_vector (make_number (40), Qnil);
            }
+         else if (XVECTOR (Vprint_number_table)->size == print_number_index * 2)
+           {
+             /* Reallocate the table.  */
+             int i = print_number_index * 4;
+             Lisp_Object old_table = Vprint_number_table;
+             Vprint_number_table = Fmake_vector (make_number (i), Qnil);
+             for (i = 0; i < print_number_index; i++)
+               {
+                 PRINT_NUMBER_OBJECT (Vprint_number_table, i)
+                   = PRINT_NUMBER_OBJECT (old_table, i);
+                 PRINT_NUMBER_STATUS (Vprint_number_table, i)
+                   = PRINT_NUMBER_STATUS (old_table, i);
+               }
+           }
+         PRINT_NUMBER_OBJECT (Vprint_number_table, print_number_index) = obj;
+         /* If Vprint_continuous_numbering is non-nil and OBJ is a gensym,
+            always print the gensym with a number.  This is a special for
+            the lisp function byte-compile-output-docform.  */
+         if (! NILP (Vprint_continuous_numbering) && SYMBOLP (obj)
+             && NILP (XSYMBOL (obj)->obarray))
+           PRINT_NUMBER_STATUS (Vprint_number_table, print_number_index) = Qt;
+         print_number_index++;
        }
-      PRINT_NUMBER_OBJECT (Vprint_number_table, print_number_index) = obj;
-      /* If Vprint_continuous_numbering is non-nil and OBJ is a gensym,
-        always print the gensym with a number.  This is a special for
-        the lisp function byte-compile-output-docform.  */
-      if (! NILP (Vprint_continuous_numbering) && SYMBOLP (obj)
-         && NILP (XSYMBOL (obj)->obarray))
-       PRINT_NUMBER_STATUS (Vprint_number_table, print_number_index) = Qt;
-      print_number_index++;
 
       switch (XGCTYPE (obj))
        {
        case Lisp_String:
-#ifdef USE_TEXT_PROPERTIES
          /* A string may have text properties, which can be circular.  */
          traverse_intervals (XSTRING (obj)->intervals, 0, 0,
                              print_preprocess_string, Qnil);
-#endif /* USE_TEXT_PROPERTIES */
          break;
 
        case Lisp_Cons:
@@ -1170,7 +1180,6 @@ print_preprocess (obj)
     }
 }
 
-#ifdef USE_TEXT_PROPERTIES
 static void
 print_preprocess_string (interval, arg)
      INTERVAL interval;
@@ -1178,7 +1187,6 @@ print_preprocess_string (interval, arg)
 {
   print_preprocess (interval->plist);
 }
-#endif /* USE_TEXT_PROPERTIES */
 
 static void
 print_object (obj, printcharfun, escapeflag)
@@ -1287,13 +1295,11 @@ print_object (obj, printcharfun, escapeflag)
 
          GCPRO1 (obj);
 
-#ifdef USE_TEXT_PROPERTIES
          if (!NULL_INTERVAL_P (XSTRING (obj)->intervals))
            {
              PRINTCHAR ('#');
              PRINTCHAR ('(');
            }
-#endif
 
          PRINTCHAR ('\"');
          str = XSTRING (obj)->data;
@@ -1371,14 +1377,12 @@ print_object (obj, printcharfun, escapeflag)
            }
          PRINTCHAR ('\"');
 
-#ifdef USE_TEXT_PROPERTIES
          if (!NULL_INTERVAL_P (XSTRING (obj)->intervals))
            {
              traverse_intervals (XSTRING (obj)->intervals,
                                  0, 0, print_interval, printcharfun);
              PRINTCHAR (')');
            }
-#endif
 
          UNGCPRO;
        }
@@ -1847,7 +1851,6 @@ print_object (obj, printcharfun, escapeflag)
   print_depth--;
 }
 \f
-#ifdef USE_TEXT_PROPERTIES
 
 /* Print a description of INTERVAL using PRINTCHARFUN.
    This is part of printing a string that has text properties.  */
@@ -1866,7 +1869,6 @@ print_interval (interval, printcharfun)
   print_object (interval->plist, printcharfun, 1);
 }
 
-#endif /* USE_TEXT_PROPERTIES */
 \f
 void
 syms_of_print ()