/* 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.
#include "dispextern.h"
#include "termchar.h"
#include "keyboard.h"
-
-#ifdef USE_TEXT_PROPERTIES
#include "intervals.h"
-#endif
Lisp_Object Vstandard_output, Qstandard_output;
#if STDC_HEADERS
#include <float.h>
-#include <stdlib.h>
#endif
/* Default to values appropriate for IEEE floating point. */
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 \
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;
\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,
/* 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;
}
|| (! 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:
}
}
-#ifdef USE_TEXT_PROPERTIES
static void
print_preprocess_string (interval, arg)
INTERVAL interval;
{
print_preprocess (interval->plist);
}
-#endif /* USE_TEXT_PROPERTIES */
static void
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;
}
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;
}
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. */
print_object (interval->plist, printcharfun, 1);
}
-#endif /* USE_TEXT_PROPERTIES */
\f
void
syms_of_print ()