]> code.delx.au - gnu-emacs/blobdiff - src/print.c
Remove #definition of HAVE_CLOSEDIR; autoconf figures this out.
[gnu-emacs] / src / print.c
index 0b6139a5c784d5aa68c4f0c668ab0139ffc7b228..3336a565b1d945d80dd337aa4e1029f8e6eaf411 100644 (file)
@@ -1,5 +1,5 @@
 /* Lisp object printing and output streams.
-   Copyright (C) 1985, 1986, 1988, 1992 Free Software Foundation, Inc.
+   Copyright (C) 1985, 1986, 1988, 1993 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -32,6 +32,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "termchar.h"
 #endif /* not standalone */
 
+#ifdef USE_TEXT_PROPERTIES
+#include "intervals.h"
+#endif
+
 Lisp_Object Vstandard_output, Qstandard_output;
 
 #ifdef LISP_FLOAT_TYPE
@@ -69,6 +73,8 @@ extern int noninteractive_need_newline;
 static int print_chars;
 static int max_print;
 #endif /* MAX_PRINT_CHARS */
+
+void print_interval ();
 \f
 #if 0
 /* Convert between chars and GLYPHs */
@@ -122,7 +128,7 @@ glyph_to_str_cpy (glyphs, str)
 }
 #endif
 \f
-/* Low level output routines for charaters and strings */
+/* Low level output routines for characters and strings */
 
 /* Lisp functions to do output using a stream
  must have the stream in a variable called printcharfun
@@ -135,26 +141,30 @@ glyph_to_str_cpy (glyphs, str)
    Lisp_Object original;
 */ 
 
-#define PRINTPREPARE \
-   original = printcharfun; \
-   if (NILP (printcharfun)) printcharfun = Qt; \
-   if (XTYPE (printcharfun) == Lisp_Buffer) \
-     { if (XBUFFER (printcharfun) != current_buffer) Fset_buffer (printcharfun); \
-       printcharfun = Qnil;}\
-   if (XTYPE (printcharfun) == Lisp_Marker) \
-     { if (XMARKER (original)->buffer != current_buffer) \
-         set_buffer_internal (XMARKER (original)->buffer); \
-       old_point = point; \
-       SET_PT (marker_position (printcharfun)); \
-       start_point = point; \
+#define PRINTPREPARE                                           \
+   original = printcharfun;                                    \
+   if (NILP (printcharfun)) printcharfun = Qt;                 \
+   if (XTYPE (printcharfun) == Lisp_Buffer)                    \
+     { if (XBUFFER (printcharfun) != current_buffer)           \
+        Fset_buffer (printcharfun);                            \
+       printcharfun = Qnil;}                                   \
+   if (XTYPE (printcharfun) == Lisp_Marker)                    \
+     { if (!(XMARKER (original)->buffer))                      \
+         error ("Marker does not point anywhere");             \
+       if (XMARKER (original)->buffer != current_buffer)       \
+         set_buffer_internal (XMARKER (original)->buffer);     \
+       old_point = point;                                      \
+       SET_PT (marker_position (printcharfun));                        \
+       start_point = point;                                    \
        printcharfun = Qnil;}
 
-#define PRINTFINISH \
-   if (XTYPE (original) == Lisp_Marker) \
-     Fset_marker (original, make_number (point), Qnil); \
-   if (old_point >= 0) \
-     SET_PT ((old_point >= start_point ? point - start_point : 0) + old_point); \
-   if (old != current_buffer) \
+#define PRINTFINISH                                    \
+   if (XTYPE (original) == Lisp_Marker)                        \
+     Fset_marker (original, make_number (point), Qnil);        \
+   if (old_point >= 0)                                 \
+     SET_PT (old_point + (old_point >= start_point     \
+                         ? point - start_point : 0));  \
+   if (old != current_buffer)                          \
      set_buffer_internal (old)
 
 #define PRINTCHAR(ch) printchar (ch, printcharfun)
@@ -399,7 +409,7 @@ All output done by BODY is inserted in that buffer by default.\n\
 The buffer is displayed in another window, but not selected.\n\
 The value of the last form in BODY is returned.\n\
 If BODY does not finish normally, the buffer BUFNAME is not displayed.\n\n\
-If variable `temp-buffer-show-hook' is non-nil, call it at the end\n\
+If variable `temp-buffer-show-function' is non-nil, call it at the end\n\
 to get the buffer displayed.  It gets one argument, the buffer to display.")
   (args)
      Lisp_Object args;
@@ -597,7 +607,7 @@ to make it write to the debugging output.\n")
 
 void
 float_to_string (buf, data)
-     char *buf;
+     unsigned char *buf;
      double data;
 {
   register unsigned char *cp, c;
@@ -640,12 +650,18 @@ float_to_string (buf, data)
       sprintf (buf, XSTRING (Vfloat_output_format)->data, data);
     }
 
-  /* Make sure there is a decimal point or an exponent,
+  /* Make sure there is a decimal point with digit after, or an exponent,
      so that the value is readable as a float.  */
   for (cp = buf; *cp; cp++)
-    if (*cp < '0' || *cp > '9')
+    if ((*cp < '0' || *cp > '9') && *cp != '-')
       break;
 
+  if (*cp == '.' && cp[1] == 0)
+    {
+      cp[1] = '0';
+      cp[2] = 0;
+    }
+
   if (*cp == 0)
     {
       *cp++ = '.';
@@ -657,11 +673,7 @@ float_to_string (buf, data)
 \f
 static void
 print (obj, printcharfun, escapeflag)
-#ifndef RTPC_REGISTER_BUG
-     register Lisp_Object obj;
-#else
      Lisp_Object obj;
-#endif
      register Lisp_Object printcharfun;
      int escapeflag;
 {
@@ -738,14 +750,17 @@ print (obj, printcharfun, escapeflag)
        {
          register int i;
          register unsigned char c;
-         Lisp_Object obj1;
          struct gcpro gcpro1;
 
-         /* You can't gcpro register variables, so copy obj to a
-            non-register variable so we can gcpro it without
-            making it non-register.  */
-         obj1 = obj;
-         GCPRO1 (obj1);
+         GCPRO1 (obj);
+
+#ifdef USE_TEXT_PROPERTIES
+         if (!NULL_INTERVAL_P (XSTRING (obj)->intervals))
+           {
+             PRINTCHAR ('#');
+             PRINTCHAR ('(');
+           }
+#endif
 
          PRINTCHAR ('\"');
          for (i = 0; i < XSTRING (obj)->size; i++)
@@ -765,6 +780,17 @@ print (obj, printcharfun, escapeflag)
                }
            }
          PRINTCHAR ('\"');
+
+#ifdef USE_TEXT_PROPERTIES
+         if (!NULL_INTERVAL_P (XSTRING (obj)->intervals))
+           {
+             PRINTCHAR (' ');
+             traverse_intervals (XSTRING (obj)->intervals,
+                                 0, 0, print_interval, printcharfun);
+             PRINTCHAR (')');
+           }
+#endif
+
          UNGCPRO;
        }
       break;
@@ -926,6 +952,23 @@ print (obj, printcharfun, escapeflag)
        }
       PRINTCHAR ('>');
       break;
+
+    case Lisp_Overlay:
+      strout ("#<overlay ", -1, printcharfun);
+      if (!(XMARKER (OVERLAY_START (obj))->buffer))
+       strout ("in no buffer", -1, printcharfun);
+      else
+       {
+         sprintf (buf, "from %d to %d in ",
+                  marker_position (OVERLAY_START (obj)),
+                  marker_position (OVERLAY_END   (obj)));
+         strout (buf, -1, printcharfun);
+         print_string (XMARKER (OVERLAY_START (obj))->buffer->name,
+                       printcharfun);
+       }
+      PRINTCHAR ('>');
+      break;
+
 #endif /* standalone */
 
     case Lisp_Subr:
@@ -938,6 +981,27 @@ print (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.  */
+
+void
+print_interval (interval, printcharfun)
+     INTERVAL interval;
+     Lisp_Object printcharfun;
+{
+  print (make_number (interval->position), printcharfun, 1);
+  PRINTCHAR (' ');
+  print (make_number (interval->position + LENGTH (interval)),
+        printcharfun, 1);
+  PRINTCHAR (' ');
+  print (interval->plist, printcharfun, 1);
+  PRINTCHAR (' ');
+}
+
+#endif /* USE_TEXT_PROPERTIES */
+\f
 void
 syms_of_print ()
 {