;;;; format interpreters and support functions for simple output
(defun format-write-field (stream string mincol colinc minpad padchar padleft)
+ (when (and colinc (<= colinc 0))
+ (error 'format-error
+ :complaint "The value of colinc is ~a, should be a positive integer"
+ :args (list colinc)))
+ (when (and mincol (< mincol 0))
+ (error 'format-error
+ :complaint "The value of mincol is ~a, should be a non-negative integer"
+ :args (list mincol)))
(unless padleft
(write-string string stream))
(dotimes (i minpad)
(when (and d (zerop d)) (setq tpoint nil))
(when w
(decf spaceleft flen)
- ;; See CLHS 22.3.3.2. "If the parameter d is
- ;; omitted, ... [and] if the fraction to be
- ;; printed is zero then a single zero digit should
- ;; appear after the decimal point." So we need to
- ;; subtract one from here because we're going to
- ;; add an extra 0 digit later. [rtoy]
- (when (and (zerop number) (null d))
- (decf spaceleft))
(when lpoint
(if (or (> spaceleft 0) tpoint)
(decf spaceleft)
(if atsign (write-char #\+ stream)))
(when lpoint (write-char #\0 stream))
(write-string fstr stream)
- (when (and (zerop number) (null d))
- ;; It's later and we're adding the zero
- ;; digit.
- (write-char #\0 stream))
(write-char (if marker
marker
(format-exponent-marker number))
:complaint
"cannot specify either colon or atsign for this directive"))
(interpret-bind-defaults ((count 1)) params
- (fresh-line stream)
- (dotimes (i (1- count))
- (terpri stream))))
+ (when (plusp count)
+ (fresh-line stream)
+ (dotimes (i (1- count))
+ (terpri stream)))))
(def-format-interpreter #\| (colonp atsignp params)
(when (or colonp atsignp)