0.9.11.3:
authorChristophe Rhodes <csr21@cam.ac.uk>
Mon, 27 Mar 2006 08:22:21 +0000 (08:22 +0000)
committerChristophe Rhodes <csr21@cam.ac.uk>
Mon, 27 Mar 2006 08:22:21 +0000 (08:22 +0000)
FORMAT ~:C and printing characters.  (PFD ansi-tests)

NEWS
src/code/target-format.lisp
tests/print.impure.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index 467a261..ea6333f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ changes in sbcl-0.9.12 relative to sbcl-0.9.11:
        the method is not one of the generic functions' methods.
     ** objects declared as MEMBER types can be admissible arguments to 
        structure accessors.
+    ** printing characters should simply be printed by the FORMAT ~:C
+       directive.
 
 changes in sbcl-0.9.11 relative to sbcl-0.9.10:
   * new platform: experimental support for SBCL x86/Darwin, including
index 91b8309..5a29fba 100644 (file)
             (prin1 (next-arg) stream)
             (write-char (next-arg) stream)))))
 
+;;; "printing" as defined in the ANSI CL glossary, which is normative.
+(defun char-printing-p (char)
+  (and (not (eql char #\Space))
+       (graphic-char-p char)))
+
 (defun format-print-named-character (char stream)
-  (let* ((name (char-name char)))
-    (cond (name
-           (write-string (string-capitalize name) stream))
-          (t
-           (write-char char stream)))))
+  (cond ((not (char-printing-p char))
+         (write-string (string-capitalize (char-name char)) stream))
+        (t
+         (write-char char stream))))
 
 (def-format-interpreter #\W (colonp atsignp params)
   (interpret-bind-defaults () params
index 5aca94f..6a18d72 100644 (file)
 (with-test (:name (:print-readable :character :iso-8859-1))
   (test-readable-character (code-char #xfffe) :iso-8859-1))
 
+(assert (string= (eval '(format nil "~:C" #\a)) "a"))
+(assert (string= (format nil (formatter "~:C") #\a) "a"))
 ;;; success
index 49019a0..18b84a1 100644 (file)
@@ -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".)
-"0.9.11.2"
+"0.9.11.3"