From 27844b49d7305379390dfbd78f114c46dcf74707 Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Fri, 8 Feb 2008 12:38:15 +0000 Subject: [PATCH] 1.0.14.0.23: hash-table printing improvements * Respect printer-control variables when printing readably. * Print non-null weakness when printing unreadably. --- NEWS | 4 ++++ src/code/target-hash-table.lisp | 14 +++++++------- tests/print.impure.lisp | 11 +++++++++++ version.lisp-expr | 2 +- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index 437d8d2..4e04b0e 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,10 @@ changes in sbcl-1.0.15 relative to sbcl-1.0.14: * enhancement: implement SB-POSIX:MKTEMP and SB-POSIX:MKDTEMP. * SB-DEBUG:PRINT-FRAME-CALL now prints the entry-point kind even when SB-DEBUG:*SHOW-ENTRY-POINT-DETAILS* is NIL. + * unreadably printed representation of hash-tables now includes + weakness if any. + * bug fix: readably printing hash-tables now respects other printer + control variables. * bug fix: compiler gave a bogus STYLE-WARNING for the :SYNCHRONIZED keyword with MAKE-HASH-TABLE. * bug fix: export SB-POSIX:MKSTEMP. diff --git a/src/code/target-hash-table.lisp b/src/code/target-hash-table.lisp index 1389875..a5720bc 100644 --- a/src/code/target-hash-table.lisp +++ b/src/code/target-hash-table.lisp @@ -943,16 +943,16 @@ to protect the MAPHASH call." (cond ((or (not *print-readably*) (not *read-eval*)) (print-unreadable-object (hash-table stream :type t :identity t) (format stream - ":TEST ~S :COUNT ~S" + ":TEST ~S :COUNT ~S~@[ :WEAKNESS ~S~]" (hash-table-test hash-table) - (hash-table-count hash-table)))) + (hash-table-count hash-table) + (hash-table-weakness hash-table)))) (t - (with-standard-io-syntax - (format stream - "#.~W" - `(%stuff-hash-table (make-hash-table ,@(%hash-table-ctor-args + (write-string "#." stream) + (write `(%stuff-hash-table (make-hash-table ,@(%hash-table-ctor-args hash-table)) - ',(%hash-table-alist hash-table))))))) + ',(%hash-table-alist hash-table)) + :stream stream)))) (def!method make-load-form ((hash-table hash-table) &optional environment) (declare (ignore environment)) diff --git a/tests/print.impure.lisp b/tests/print.impure.lisp index 6d8072f..608ce7f 100644 --- a/tests/print.impure.lisp +++ b/tests/print.impure.lisp @@ -416,4 +416,15 @@ ;;; This used to trigger an AVER instead. (assert (raises-error? (format t "~>") sb-format:format-error)) +;;; readably printing hash-tables, check for circularity +(let ((x (cons 1 2)) + (h (make-hash-table)) + (*print-readably* t) + (*print-circle* t) + (*read-eval* t)) + (setf (gethash x h) h) + (destructuring-bind (x2 . h2) (read-from-string (write-to-string (cons x h))) + (assert (equal x x2)) + (assert (eq h2 (gethash x2 h2))))) + ;;; success diff --git a/version.lisp-expr b/version.lisp-expr index ca674a0..5672a63 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"1.0.14.22" +"1.0.14.23" -- 1.7.10.4