Include <config.h> instead of "config.h".
[bpt/emacs.git] / src / print.c
index ba41e46..83dcb2a 100644 (file)
@@ -18,7 +18,7 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 
-#include "config.h"
+#include <config.h>
 #include <stdio.h>
 #undef NULL
 #include "lisp.h"
@@ -128,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
@@ -409,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;
@@ -610,13 +610,16 @@ float_to_string (buf, data)
      unsigned char *buf;
      double data;
 {
-  register unsigned char *cp, c;
-  register int width;
+  unsigned char *cp;
+  int width;
       
   if (NILP (Vfloat_output_format)
       || XTYPE (Vfloat_output_format) != Lisp_String)
   lose:
-    sprintf (buf, "%.20g", data);
+    {
+      sprintf (buf, "%.17g", data);
+      width = -1;
+    }
   else                 /* oink oink */
     {
       /* Check that the spec we have is fully valid.
@@ -630,18 +633,21 @@ float_to_string (buf, data)
        goto lose;
 
       cp += 2;
-      for (width = 0;
-          ((c = *cp) >= '0' && c <= '9');
-          cp++)
-       {
-         width *= 10;
-         width += c - '0';
-       }
+
+      /* Check the width specification.  */
+      width = -1;
+      if ('0' <= *cp && *cp <= '9')
+       for (width = 0; (*cp >= '0' && *cp <= '9'); cp++)
+         width = (width * 10) + (*cp - '0');
 
       if (*cp != 'e' && *cp != 'f' && *cp != 'g')
        goto lose;
 
-      if (width < (*cp != 'e') || width > DBL_DIG)
+      /* A precision of zero is valid for %f; everything else requires
+        at least one.  Width may be omitted anywhere.  */
+      if (width != -1
+         && (width < (*cp != 'f')
+             || width > DBL_DIG))
        goto lose;
 
       if (cp[1] != 0)
@@ -650,23 +656,28 @@ float_to_string (buf, data)
       sprintf (buf, XSTRING (Vfloat_output_format)->data, data);
     }
 
-  /* 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')
-      break;
-
-  if (*cp == '.' && cp[1] == 0)
+  /* Make sure there is a decimal point with digit after, or an
+     exponent, so that the value is readable as a float.  But don't do
+     this with "%.0f"; it's valid for that not to produce a decimal
+     point.  Note that width can be 0 only for %.0f.  */
+  if (width != 0)
     {
-      cp[1] = '0';
-      cp[2] = 0;
-    }
+      for (cp = buf; *cp; cp++)
+       if ((*cp < '0' || *cp > '9') && *cp != '-')
+         break;
 
-  if (*cp == 0)
-    {
-      *cp++ = '.';
-      *cp++ = '0';
-      *cp++ = 0;
+      if (*cp == '.' && cp[1] == 0)
+       {
+         cp[1] = '0';
+         cp[2] = 0;
+       }
+
+      if (*cp == 0)
+       {
+         *cp++ = '.';
+         *cp++ = '0';
+         *cp++ = 0;
+       }
     }
 }
 #endif /* LISP_FLOAT_TYPE */
@@ -784,7 +795,6 @@ print (obj, printcharfun, escapeflag)
 #ifdef USE_TEXT_PROPERTIES
          if (!NULL_INTERVAL_P (XSTRING (obj)->intervals))
            {
-             PRINTCHAR (' ');
              traverse_intervals (XSTRING (obj)->intervals,
                                  0, 0, print_interval, printcharfun);
              PRINTCHAR (')');
@@ -952,6 +962,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:
@@ -974,13 +1001,13 @@ print_interval (interval, printcharfun)
      INTERVAL interval;
      Lisp_Object printcharfun;
 {
+  PRINTCHAR (' ');
   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 */
@@ -1014,8 +1041,8 @@ Use `f' for decimal point notation \"DIGITS.DIGITS\".\n\
 Use `g' to choose the shorter of those two formats for the number at hand.\n\
 The precision in any of these cases is the number of digits following\n\
 the decimal point.  With `f', a precision of 0 means to omit the\n\
-decimal point.  0 is not allowed with `f' or `g'.\n\n\
-A value of nil means to use `%.20g'.");
+decimal point.  0 is not allowed with `e' or `g'.\n\n\
+A value of nil means to use `%.17g'.");
   Vfloat_output_format = Qnil;
   Qfloat_output_format = intern ("float-output-format");
   staticpro (&Qfloat_output_format);