diff options
author | Andy Wingo <wingo@pobox.com> | 2010-12-18 12:15:12 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2010-12-18 12:17:46 +0100 |
commit | 3d56118c502a9906bd69aaf8d824c3a3e539178e (patch) | |
tree | b6ce800633bf2eae6a1e095295a31acaa0aaf573 | |
parent | 2ce77e6cf6bfb5dbb54947377ddd743a2c1a1bb6 (diff) | |
download | guile-3d56118c502a9906bd69aaf8d824c3a3e539178e.tar.gz |
inline format:format into format
* module/ice-9/format.scm (format): Inline format:format body.
-rw-r--r-- | module/ice-9/format.scm | 64 |
1 files changed, 24 insertions, 40 deletions
diff --git a/module/ice-9/format.scm b/module/ice-9/format.scm index 41013ca9a..e2cb1b40c 100644 --- a/module/ice-9/format.scm +++ b/module/ice-9/format.scm @@ -131,45 +131,6 @@ (define format:error-save #f) - (define (format:format . args) ; the formatter entry - (set! format:args args) - (set! format:arg-pos 0) - (set! format:pos 0) - (if (< (length args) 1) - (format:error "not enough arguments")) - - ;; If the first argument is a string, then that's the format string. - ;; (Scheme->C) - ;; In this case, put the argument list in canonical form. - (let ((args (if (string? (car args)) - (cons #f args) - args))) - ;; Use this canonicalized version when reporting errors. - (set! format:args args) - - (let ((destination (car args)) - (arglist (cdr args))) - (cond - ((or (and (boolean? destination) ; port output - destination) - (output-port? destination)) - (format:out (cond - ((boolean? destination) (current-output-port)) - ((output-port? destination) destination) - ((number? destination) (current-error-port))) - (car arglist) (cdr arglist))) - ((number? destination) - (issue-deprecation-warning - "Passing a number to format as the destination is deprecated." - "Pass (current-error-port) instead.") - (format:out (current-error-port) (car arglist) (cdr arglist))) - ((and (boolean? destination) ; string output - (not destination)) - (call-with-output-string - (lambda (port) (format:out port (car arglist) (cdr arglist))))) - (else - (format:error "illegal destination `~a'" destination)))))) - (define (format:out port fmt args) ; the output handler for a port (set! format:port port) ; global port for ; output routines @@ -1645,7 +1606,30 @@ (set! format:fn-str (make-string format:fn-max)) ; number buffer (set! format:en-str (make-string format:en-max)) ; exponent buffer - (apply format:format port format-string args)) + (set! format:args (cons* port format-string args)) + (set! format:arg-pos 0) + (set! format:pos 0) + + (cond + ((or (and (boolean? port) ; port output + port) + (output-port? port)) + (format:out (cond + ((boolean? port) (current-output-port)) + ((output-port? port) port) + ((number? port) (current-error-port))) + format-string args)) + ((number? port) + (issue-deprecation-warning + "Passing a number to format as the port is deprecated." + "Pass (current-error-port) instead.") + (format:out (current-error-port) format-string args)) + ((and (boolean? port) ; string output + (not port)) + (call-with-output-string + (lambda (port) (format:out port format-string args)))) + (else + (format:error "bad destination `~a'" port)))) (begin-deprecated (set! format |