1.0.23.18: SET-[DISPATCH-]MACRO-CHARACTER fixes
authorNikodemus Siivola <nikodemus@random-state.net>
Thu, 4 Dec 2008 16:50:14 +0000 (16:50 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Thu, 4 Dec 2008 16:50:14 +0000 (16:50 +0000)
 * Patch by Tobias Ritterweiler, plus tests and making S-D-M-C return T.

NEWS
src/code/reader.lisp
src/compiler/fndb.lisp
tests/reader.impure.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index ea6743c..18ebf92 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,11 @@
     using UTF-8 as external format. (thanks to Luis Oliveira)
   * bug fix: errors from invalid fill-pointer values to (SETF FILL-POINTER)
     are signalled correctly. (thanks to Stas Boukarev)
+  * bug fix: SET-MACRO-CHARACTER accepts NIL as the readtable
+    designator. (thanks to Tobias Ritterweiler)
+  * bug fix: SET-DISPATCH-MACRO-CHARACTER accepts NIL as the readtable
+    designator, and returns T instead of the function. (thanks to
+    Tobias Ritterweiler)
 
 changes in sbcl-1.0.23 relative to 1.0.22:
   * enhancement: when disassembling method functions, disassembly
index 2eb433a..9cd525b 100644 (file)
         #'read-token)))
 
 (defun set-cmt-entry (char new-value-designator &optional (rt *readtable*))
-  (if (typep char 'base-char)
-      (setf (svref (character-macro-array rt) (char-code char))
-            (and new-value-designator
-                 (%coerce-callable-to-fun new-value-designator)))
-      (setf (gethash char (character-macro-hash-table rt))
-        (and new-value-designator
-                 (%coerce-callable-to-fun new-value-designator)))))
+  (let ((new (when new-value-designator
+               (%coerce-callable-to-fun new-value-designator))))
+    (if (typep char 'base-char)
+        (setf (svref (character-macro-array rt) (char-code char)) new)
+        (setf (gethash char (character-macro-hash-table rt)) new))))
 
 (defun undefined-macro-char (stream char)
   (unless *read-suppress*
@@ -1470,7 +1468,8 @@ variables to allow for nested and thread safe reading."
                       :test #'char= :key #'car)))
     (if dpair
         (setf (gethash sub-char (cdr dpair)) (coerce function 'function))
-        (error "~S is not a dispatch char." disp-char))))
+        (error "~S is not a dispatch char." disp-char))
+    t))
 
 (defun get-dispatch-macro-character (disp-char sub-char
                                      &optional (rt *readtable*))
index a7d9537..e6390c4 100644 (file)
   (character character &optional readtable (or readtable null)) (eql t)
   ())
 
-(defknown set-macro-character (character callable &optional t readtable)
+(defknown set-macro-character (character callable &optional t (or readtable null))
   (eql t)
   (unsafe))
 (defknown get-macro-character (character &optional (or readtable null))
 (defknown make-dispatch-macro-character (character &optional t readtable)
   (eql t) ())
 (defknown set-dispatch-macro-character
-  (character character callable &optional readtable) function
+  (character character callable &optional (or readtable null)) (eql t)
   (unsafe))
 (defknown get-dispatch-macro-character
   (character character &optional (or readtable null)) (or callable null)
index bb37bdf..02f202d 100644 (file)
   (funcall fun)
   (assert (equal '(:ok) (read-from-string "{:ok)"))))
 
+;;; THIS SHOULD BE LAST as it frobs the standard readtable
+(with-test (:name set-macro-character-nil)
+  (let ((fun (lambda (&rest args) 'ok)))
+    ;; NIL means the standard readtable.
+    (assert (eq t (set-macro-character #\~ fun nil nil)))
+    (assert (eq fun (get-macro-character #\~ nil)))
+    (assert (eq t (set-dispatch-macro-character #\# #\~ fun nil)))
+    (assert (eq fun (get-dispatch-macro-character #\# #\~ nil)))))
+
 ;;; success
index ef774c5..87780c0 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".)
-"1.0.23.17"
+"1.0.23.18"