(t
`(prin1 ,(expand-next-arg) stream))))
-(def-format-directive #\C (colonp atsignp params)
+(def-format-directive #\C (colonp atsignp params string end)
(expand-bind-defaults () params
- (if colonp
- `(format-print-named-character ,(expand-next-arg) stream)
- (if atsignp
- `(prin1 ,(expand-next-arg) stream)
- `(write-char ,(expand-next-arg) stream)))))
+ (let ((n-arg (sb!xc:gensym "ARG")))
+ `(let ((,n-arg ,(expand-next-arg)))
+ (unless (typep ,n-arg 'character)
+ (error 'format-error
+ :complaint "~s is not of type CHARACTER."
+ :args (list ,n-arg)
+ :control-string ,string
+ :offset ,(1- end)))
+ ,(cond (colonp
+ `(format-print-named-character ,n-arg stream))
+ (atsignp
+ `(prin1 ,n-arg stream))
+ (t
+ `(write-char ,n-arg stream)))))))
(def-format-directive #\W (colonp atsignp params)
(expand-bind-defaults () params
(def-format-directive #\X (colonp atsignp params)
(expand-format-integer 16 colonp atsignp params))
-(def-format-directive #\R (colonp atsignp params)
+(def-format-directive #\R (colonp atsignp params string end)
(expand-bind-defaults
((base nil) (mincol 0) (padchar #\space) (commachar #\,)
(commainterval 3))
params
(let ((n-arg (sb!xc:gensym "ARG")))
`(let ((,n-arg ,(expand-next-arg)))
+ (unless (integerp ,n-arg)
+ (error 'format-error
+ :complaint "~s is not of type INTEGER."
+ :args (list ,n-arg)
+ :control-string ,string
+ :offset ,(1- end)))
(if ,base
(format-print-integer stream ,n-arg ,colonp ,atsignp
,base ,mincol
(def-format-interpreter #\C (colonp atsignp params)
(interpret-bind-defaults () params
- (if colonp
- (format-print-named-character (next-arg) stream)
- (if atsignp
- (prin1 (next-arg) stream)
- (write-char (next-arg) stream)))))
+ (let ((arg (next-arg)))
+ (unless (typep arg 'character)
+ (error 'format-error
+ :complaint "~s is not of type CHARACTER."
+ :args (list arg)))
+ (cond (colonp
+ (format-print-named-character arg stream))
+ (atsignp
+ (prin1 arg stream))
+ (t
+ (write-char arg stream))))))
;;; "printing" as defined in the ANSI CL glossary, which is normative.
(defun char-printing-p (char)
(commainterval 3))
params
(let ((arg (next-arg)))
+ (unless (integerp arg)
+ (error 'format-error
+ :complaint "~s is not of type INTEGER."
+ :args (list arg)))
(if base
(format-print-integer stream arg colonp atsignp base mincol
padchar commachar commainterval)