b86773d
--- src/lsp/format.lsp.orig	2016-12-19 03:25:00.000000000 -0700
b86773d
+++ src/lsp/format.lsp	2019-01-17 09:14:41.580994625 -0700
b86773d
@@ -308,11 +308,13 @@
b86773d
                   :start (format-directive-start struct)
b86773d
                   :end (format-directive-end struct))))
b86773d
 
b86773d
+(defconstant +format-directive-limit+ (1+ (char-code #\~)))
b86773d
+
b86773d
 #+formatter
b86773d
 (defparameter *format-directive-expanders*
b86773d
-  (make-array char-code-limit :initial-element nil))
b86773d
+  (make-array +format-directive-limit+ :initial-element nil))
b86773d
 (defparameter *format-directive-interpreters*
b86773d
-  (make-array char-code-limit :initial-element nil))
b86773d
+  (make-array +format-directive-limit+ :initial-element nil))
b86773d
 
b86773d
 (defparameter *default-format-error-control-string* nil)
b86773d
 (defparameter *default-format-error-offset* nil)
b86773d
@@ -545,24 +547,24 @@
b86773d
            (write-string directive stream)
b86773d
            (interpret-directive-list stream (cdr directives) orig-args args))
b86773d
           (#-ecl format-directive #+ecl vector
b86773d
+           (multiple-value-bind
b86773d
+                 (new-directives new-args)
b86773d
+               (let* ((code (char-code (format-directive-character directive)))
b86773d
+                      (function
b86773d
+                        (and (< code +format-directive-limit+)
b86773d
+                             (svref *format-directive-interpreters* code)))
b86773d
+                      (*default-format-error-offset*
b86773d
+                        (1- (format-directive-end directive))))
b86773d
+                 (unless function
b86773d
+                   (error 'format-error
b86773d
+                          :complaint "Unknown format directive."))
b86773d
                  (multiple-value-bind
b86773d
                        (new-directives new-args)
b86773d
-                     (let ((function
b86773d
-                            (svref *format-directive-interpreters*
b86773d
-                                   (char-code (format-directive-character
b86773d
-                                               directive))))
b86773d
-                           (*default-format-error-offset*
b86773d
-                            (1- (format-directive-end directive))))
b86773d
-                       (unless function
b86773d
-                         (error 'format-error
b86773d
-                                :complaint "Unknown format directive."))
b86773d
-                       (multiple-value-bind
b86773d
-                             (new-directives new-args)
b86773d
-                           (funcall function stream directive
b86773d
-                                    (cdr directives) orig-args args)
b86773d
-                         (values new-directives new-args)))
b86773d
-                   (interpret-directive-list stream new-directives
b86773d
-                                             orig-args new-args)))))
b86773d
+                     (funcall function stream directive
b86773d
+                              (cdr directives) orig-args args)
b86773d
+                   (values new-directives new-args)))
b86773d
+             (interpret-directive-list stream new-directives
b86773d
+                                       orig-args new-args)))))
b86773d
       args))
b86773d
 
b86773d
 
b86773d
@@ -634,11 +636,12 @@
b86773d
        (values `(write-string ,directive stream)
b86773d
                more-directives))
b86773d
       (format-directive
b86773d
-       (let ((expander
b86773d
-              (aref *format-directive-expanders*
b86773d
-                    (char-code (format-directive-character directive))))
b86773d
-             (*default-format-error-offset*
b86773d
-              (1- (format-directive-end directive))))
b86773d
+       (let* ((code (char-code (format-directive-character directive)))
b86773d
+              (expander
b86773d
+                (and (< code +format-directive-limit+)
b86773d
+                     (svref *format-directive-expanders* code)))
b86773d
+              (*default-format-error-offset*
b86773d
+                (1- (format-directive-end directive))))
b86773d
          (if expander
b86773d
              (funcall expander directive more-directives)
b86773d
              (error 'format-error