diff options
author | Andy Wingo <wingo@pobox.com> | 2010-12-18 11:27:19 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2010-12-18 11:27:19 +0100 |
commit | 9ebf1af3c135b44dae4a96bee2c75869293725a3 (patch) | |
tree | 140b21d1dc9ef4a3a5e783f57fd2e3b28a0e5b7b | |
parent | e3e3394374391486a19bc122057d80012348807b (diff) | |
download | guile-9ebf1af3c135b44dae4a96bee2c75869293725a3.tar.gz |
format.scm cleanups
* module/ice-9/format.scm (format:symbol-case-conv)
(format:iobj-case-conv): Remove these exports, they were not used.
(format:expch): Remove this one, though it was used.
(format:floats, format:complex-numbers, format:radix-pref): Inline
these "configuration variables" into the format body.
-rw-r--r-- | module/ice-9/format.scm | 76 |
1 files changed, 16 insertions, 60 deletions
diff --git a/module/ice-9/format.scm b/module/ice-9/format.scm index 63c5a9815..e0ed47882 100644 --- a/module/ice-9/format.scm +++ b/module/ice-9/format.scm @@ -32,35 +32,10 @@ (define-module (ice-9 format) #:use-module (ice-9 and-let-star) #:autoload (ice-9 pretty-print) (pretty-print truncated-print) - #:replace (format) - #:export (format:symbol-case-conv - format:iobj-case-conv - format:expch)) + #:replace (format)) ;;; Configuration ------------------------------------------------------------ -(define format:symbol-case-conv #f) -;; Symbols are converted by symbol->string so the case of the printed -;; symbols is implementation dependent. format:symbol-case-conv is a -;; one arg closure which is either #f (no conversion), string-upcase!, -;; string-downcase! or string-capitalize!. - -(define format:iobj-case-conv #f) -;; As format:symbol-case-conv but applies for the representation of -;; implementation internal objects. - -(define format:expch #\E) -;; The character prefixing the exponent value in ~e printing. - -(define format:floats (provided? 'inexact)) -;; Detects if the scheme system implements flonums (see at eof). - -(define format:complex-numbers (provided? 'complex)) -;; Detects if the scheme system implements complex numbers. - -(define format:radix-pref (char=? #\# (string-ref (number->string 8 8) 0))) -;; Detects if number->string adds a radix prefix. - (define format:ascii-non-printable-charnames '#("nul" "soh" "stx" "etx" "eot" "enq" "ack" "bel" "bs" "ht" "nl" "vt" "np" "cr" "so" "si" @@ -385,30 +360,19 @@ (format:out-num-padded ; any Radix modifier (next-arg) (cdr params) (car params))) (anychar-dispatch)) - ((#\F) ; Fixed-format floating-point - (if format:floats - (format:out-fixed modifier (next-arg) params) - (format:out-str (number->string (next-arg)))) - (anychar-dispatch)) - ((#\E) ; Exponential floating-point - (if format:floats - (format:out-expon modifier (next-arg) params) - (format:out-str (number->string (next-arg)))) - (anychar-dispatch)) - ((#\G) ; General floating-point - (if format:floats - (format:out-general modifier (next-arg) params) - (format:out-str (number->string (next-arg)))) - (anychar-dispatch)) - ((#\$) ; Dollars floating-point - (if format:floats - (format:out-dollar modifier (next-arg) params) - (format:out-str (number->string (next-arg)))) - (anychar-dispatch)) + ((#\F) ; Fixed-format floating-point + (format:out-fixed modifier (next-arg) params) + (anychar-dispatch)) + ((#\E) ; Exponential floating-point + (format:out-expon modifier (next-arg) params) + (anychar-dispatch)) + ((#\G) ; General floating-point + (format:out-general modifier (next-arg) params) + (anychar-dispatch)) + ((#\$) ; Dollars floating-point + (format:out-dollar modifier (next-arg) params) + (anychar-dispatch)) ((#\I) ; Complex numbers - (if (not format:complex-numbers) - (format:error - "complex numbers not supported by this scheme system")) (let ((z (next-arg))) (if (not (complex? z)) (format:error "argument not a complex number")) @@ -440,10 +404,7 @@ ((>= c #x7f) (format:out-str "#\\") (format:out-str - (if format:radix-pref - (let ((s (number->string c 8))) - (substring s 2 (string-length s))) - (number->string c 8)))) + (number->string c 8))) (else (format:out-char ch))))) (else (format:out-char ch)))) @@ -887,10 +848,7 @@ (vector-ref format:ascii-non-printable-charnames int-rep)) ((= int-rep 127) "del") ((>= int-rep 128) ; octal representation - (if format:radix-pref - (let ((s (number->string int-rep 8))) - (substring s 2 (string-length s))) - (number->string int-rep 8))) + (number->string int-rep 8)) (else (string ch))))))) (format:space-ch (char->integer #\space)) @@ -934,8 +892,6 @@ (lambda (modifier number pars radix) (if (not (integer? number)) (format:error "argument not an integer")) (let ((numstr (number->string number radix))) - (if (and format:radix-pref (not (= radix 10))) - (set! numstr (substring numstr 2 (string-length numstr)))) (if (and (null? pars) (not modifier)) (format:out-str numstr) (let ((l (length pars)) @@ -1676,7 +1632,7 @@ (format:en-out (lambda (edigits expch) - (format:out-char (if expch (integer->char expch) format:expch)) + (format:out-char (if expch (integer->char expch) #\E)) (format:out-char (if format:en-pos? #\+ #\-)) (if edigits (if (< format:en-len edigits) |