]> code.delx.au - gnu-emacs/blobdiff - src/print.c
(Fbyte_code): Use BEFORE_POTENTIAL_GC and
[gnu-emacs] / src / print.c
index dc28ed0ce1117f11f0be532a65031a62772c33a9..fe6ec51039999b7ecf1db2d500df9ca082ee2b34 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.
@@ -60,7 +60,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.  */
@@ -389,7 +388,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;
@@ -960,6 +959,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,42 +1122,47 @@ 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))
        {