Skip to content
Snippets Groups Projects
Commit 92877e99 authored by ram's avatar ram
Browse files

Fixed FORMAT-PRINT-NUMBER to correctly insert commas for negative numbers

(don't print -,123).
parent 19819687
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
;;; Scott Fahlman or slisp-group@cs.cmu.edu. ;;; Scott Fahlman or slisp-group@cs.cmu.edu.
;;; ;;;
(ext:file-comment (ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/format.lisp,v 1.8 1991/02/25 23:52:27 ram Exp $") "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/format.lisp,v 1.9 1991/07/08 13:09:36 ram Exp $")
;;; ;;;
;;; ********************************************************************** ;;; **********************************************************************
;;; ;;;
...@@ -984,7 +984,7 @@ ...@@ -984,7 +984,7 @@
:end2 pos)) :end2 pos))
(pos length (- pos 3)) (pos length (- pos 3))
(new-pos new-length (- new-pos 4))) (new-pos new-length (- new-pos 4)))
((not (plusp pos)) new-string) ((minusp pos) new-string)
(declare (fixnum length new-length pos new-pos)))) (declare (fixnum length new-length pos new-pos))))
...@@ -1019,19 +1019,20 @@ ...@@ -1019,19 +1019,20 @@
(defun format-print-number (number radix print-commas-p print-sign-p parms) (defun format-print-number (number radix print-commas-p print-sign-p parms)
(with-format-parameters parms (with-format-parameters parms
((mincol 0) (padchar #\space) (commachar #\,)) ((mincol 0) (padchar #\space) (commachar #\,))
(let* ((*print-base* radix) (let ((*print-base* radix))
(text (princ-to-string number)))
(if (integerp number) (if (integerp number)
(format-write-field (let* ((text (princ-to-string (abs number)))
(if (and (plusp number) print-sign-p) (commaed (if print-commas-p
(if print-commas-p (format-add-commas text commachar)
(concatenate 'string "+" (format-add-commas text commachar)) text))
(concatenate 'string "+" text)) (signed (cond ((minusp number)
(if print-commas-p (concatenate 'string "-" commaed))
(format-add-commas text commachar) (print-sign-p
text)) (concatenate 'string "+" commaed))
mincol 1 0 padchar t) ;colinc = 1, minpad = 0, padleft = t (t commaed))))
(write-string text))))) ;; colinc = 1, minpad = 0, padleft = t
(format-write-field signed mincol 1 0 padchar t))
(princ number)))))
;;;; Print a cardinal number in English ;;;; Print a cardinal number in English
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment