]> code.delx.au - gnu-emacs/blobdiff - src/print.c
Merge from emacs-24; up to 2012-12-06T01:39:03Z!monnier@iro.umontreal.ca
[gnu-emacs] / src / print.c
index ba4057a36617a850922249e484aa8c6564d5ce06..e87bbcce0e7974144789f39b2a69fd893d26c260 100644 (file)
@@ -798,7 +798,7 @@ safe_debug_print (Lisp_Object arg)
   else
     fprintf (stderr, "#<%s_LISP_OBJECT 0x%08"pI"x>\r\n",
             !valid ? "INVALID" : "SOME",
-            XHASH (arg));
+            XLI (arg));
 }
 
 \f
@@ -1815,14 +1815,14 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
 #endif
          /* Implement a readable output, e.g.:
            #s(hash-table size 2 test equal data (k1 v1 k2 v2)) */
-         /* Always print the size. */
+         /* Always print the size.  */
          len = sprintf (buf, "#s(hash-table size %"pD"d", ASIZE (h->next));
          strout (buf, len, len, printcharfun);
 
-         if (!NILP (h->test))
+         if (!NILP (h->test.name))
            {
              strout (" test ", -1, -1, printcharfun);
-             print_object (h->test, printcharfun, escapeflag);
+             print_object (h->test.name, printcharfun, escapeflag);
            }
 
          if (!NILP (h->weak))
@@ -2034,14 +2034,44 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
          break;
 
        case Lisp_Misc_Save_Value:
-         strout ("#<save_value ", -1, -1, printcharfun);
          {
-           int len = sprintf (buf, "ptr=%p int=%"pD"d",
-                              XSAVE_VALUE (obj)->pointer,
-                              XSAVE_VALUE (obj)->integer);
-           strout (buf, len, len, printcharfun);
+           int i;
+           struct Lisp_Save_Value *v = XSAVE_VALUE (obj);
+
+           strout ("#<save-value ", -1, -1, printcharfun);
+           if (v->dogc)
+             {
+               int lim = min (v->integer, 8);
+               
+               /* Try to print up to 8 objects we have saved.  Although
+                  valid_lisp_object_p is slow, this shouldn't be a real
+                  bottleneck because such a saved values are quite rare.  */
+
+               i = sprintf (buf, "with %"pD"d objects", v->integer);
+               strout (buf, i, i, printcharfun);
+
+               for (i = 0; i < lim; i++)
+                 {
+                   Lisp_Object maybe = ((Lisp_Object *) v->pointer)[i];
+
+                   if (valid_lisp_object_p (maybe) > 0)
+                     {
+                       PRINTCHAR (' ');
+                       print_object (maybe, printcharfun, escapeflag);
+                     }
+                   else
+                     strout (" <invalid>", -1, -1, printcharfun);
+                 }
+               if (i == lim && i < v->integer)
+                 strout (" ...", 4, 4, printcharfun);
+             }
+           else
+             {
+               i = sprintf (buf, "ptr=%p int=%"pD"d", v->pointer, v->integer);
+               strout (buf, i, i, printcharfun);
+             }
+           PRINTCHAR ('>');
          }
-         PRINTCHAR ('>');
          break;
 
        default: