[PATCH 03/13] replace calls to simple-format with calls to format
Andy Wingo
wingo at pobox.com
Mon Mar 29 14:49:57 EDT 2010
Guile 1.6 and up always provides simple-format, and defines it as a
restricted subset of the full format, so there's no harm in using the
construct's proper name.
---
src/import-export/qif-io-core/qif-file.scm | 28 ++++++++++----------
src/import-export/qif-io-core/qif-io-core.scm | 2 +-
src/import-export/qif-io-core/test/dump-qifobj.scm | 4 +-
.../qif-io-core/test/test-file-formats.scm | 6 ++--
.../qif-io-core/test/test-import-phase-1.scm | 14 +++++-----
src/import-export/qif-io-core/test/test-parser.scm | 6 ++--
src/import-export/qif-io-core/test/test-reader.scm | 10 +++---
src/report/report-system/eguile-gnc.scm | 4 +-
src/report/report-system/html-text.scm | 2 +-
src/report/report-system/report.scm | 12 ++++----
src/scm/main.scm | 9 +-----
src/scm/price-quotes.scm | 2 +-
12 files changed, 46 insertions(+), 53 deletions(-)
diff --git a/src/import-export/qif-io-core/qif-file.scm b/src/import-export/qif-io-core/qif-file.scm
index 9b52cd2..daaed88 100644
--- a/src/import-export/qif-io-core/qif-file.scm
+++ b/src/import-export/qif-io-core/qif-file.scm
@@ -56,9 +56,9 @@
(throw 'qif-io:arg-type 'output-port port))
(for-each
(lambda (kvp)
- (simple-format port "~A~A\n" (car kvp) (cdr kvp)))
+ (format port "~A~A\n" (car kvp) (cdr kvp)))
record-pairs)
- (simple-format port "^\n"))
+ (format port "^\n"))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -203,7 +203,7 @@
(#t
(set! record-type 'unknown)))))
((qif-io:record-error)
- (simple-format #t "record processing error ~S\n" args))
+ (format #t "record processing error ~S\n" args))
(else
(apply throw key args)))))
@@ -264,7 +264,7 @@
;; way)
(if (not (null? classes))
(begin
- (simple-format port "!Type:Class\n")
+ (format port "!Type:Class\n")
(for-each
(lambda (class)
(qif-io:write-record (qif-io:class->record class) port))
@@ -274,7 +274,7 @@
;; accounts)
(if (not (null? cats))
(begin
- (simple-format port "!Type:Cat\n")
+ (format port "!Type:Cat\n")
(for-each
(lambda (cat)
(qif-io:write-record (qif-io:category->record cat) port))
@@ -284,13 +284,13 @@
;; accounts)
(if (not (null? accts))
(begin
- (simple-format port "!Option:Autoswitch\n")
- (simple-format port "!Account\n")
+ (format port "!Option:Autoswitch\n")
+ (format port "!Account\n")
(for-each
(lambda (acct)
(qif-io:write-record (qif-io:account->record acct) port))
accts)
- (simple-format port "!Clear:Autoswitch\n")))
+ (format port "!Clear:Autoswitch\n")))
;; write out bank transactions. Make sure to preface each
;; section with the source-account record.
@@ -307,7 +307,7 @@
bank-xtns)
(if (not (null? this-acct))
(begin
- (simple-format port "!Type:Bank\n")
+ (format port "!Type:Bank\n")
(for-each
(lambda (xtn)
(qif-io:write-record (qif-io:bank-xtn->record xtn) port))
@@ -330,9 +330,9 @@
bank-xtns)
(if (not (null? this-acct))
(begin
- (simple-format port "!Account\n")
+ (format port "!Account\n")
(qif-io:write-record (qif-io:account->record acct) port)
- (simple-format port "!Type:~A\n"
+ (format port "!Type:~A\n"
(qif-io:account-type acct))
(set! this-acct (reverse this-acct))
(for-each
@@ -360,7 +360,7 @@
invst-xtns)
(if (not (null? this-acct))
(begin
- (simple-format port "!Type:Invst\n")
+ (format port "!Type:Invst\n")
(for-each
(lambda (xtn)
(qif-io:write-record (qif-io:invst-xtn->record xtn) port))
@@ -383,9 +383,9 @@
invst-xtns)
(if (not (null? this-acct))
(begin
- (simple-format port "!Account\n")
+ (format port "!Account\n")
(qif-io:write-record (qif-io:account->record acct) port)
- (simple-format port "!Type:~A\n"
+ (format port "!Type:~A\n"
(qif-io:account-type acct))
(set! this-acct (reverse this-acct))
(for-each
diff --git a/src/import-export/qif-io-core/qif-io-core.scm b/src/import-export/qif-io-core/qif-io-core.scm
index 49365df..f0ff4d4 100644
--- a/src/import-export/qif-io-core/qif-io-core.scm
+++ b/src/import-export/qif-io-core/qif-io-core.scm
@@ -88,4 +88,4 @@
(export qif-io:acct-table-make-gnc-acct-tree)
;; from main
-(export simple-format)
+(export format)
diff --git a/src/import-export/qif-io-core/test/dump-qifobj.scm b/src/import-export/qif-io-core/test/dump-qifobj.scm
index 44d9fd2..a114edb 100644
--- a/src/import-export/qif-io-core/test/dump-qifobj.scm
+++ b/src/import-export/qif-io-core/test/dump-qifobj.scm
@@ -11,9 +11,9 @@
(define (read-file-thunk infile)
(let ((qiffile (qif-io:make-file #f #f #f #f #f #f #f)))
- (simple-format #t "======= ~A ======\n" infile)
+ (format #t "======= ~A ======\n" infile)
(qif-io:read-file qiffile infile #f)
- (qif-io:write-file qiffile (simple-format #f "~A.out" infile))))
+ (qif-io:write-file qiffile (format #f "~A.out" infile))))
(gnc:module-load "qifiocore")
diff --git a/src/import-export/qif-io-core/test/test-file-formats.scm b/src/import-export/qif-io-core/test/test-file-formats.scm
index b3064bf..e921f70 100644
--- a/src/import-export/qif-io-core/test/test-file-formats.scm
+++ b/src/import-export/qif-io-core/test/test-file-formats.scm
@@ -36,12 +36,12 @@
(if ok?
(set! pass (+ 1 pass))
(begin
- (simple-format #t "[fail] received ~S\n" result)
- (simple-format #t " expected ~S\n"
+ (format #t "[fail] received ~S\n" result)
+ (format #t " expected ~S\n"
correct-result)
(set! fail (+ 1 fail))))
(loop (read)))))))
- (simple-format #t "test ~A: pass=~S fail=~S\n" title pass fail)
+ (format #t "test ~A: pass=~S fail=~S\n" title pass fail)
(= pass total)))
(let ((all-pass #t))
diff --git a/src/import-export/qif-io-core/test/test-import-phase-1.scm b/src/import-export/qif-io-core/test/test-import-phase-1.scm
index 3f949d9..42ae8e2 100644
--- a/src/import-export/qif-io-core/test/test-import-phase-1.scm
+++ b/src/import-export/qif-io-core/test/test-import-phase-1.scm
@@ -32,7 +32,7 @@
(lambda ()
(qif-io:setup-data-formats qiffile))
(lambda (key field-type field-name possible-formats continue-proc)
- (simple-format #t "field format: n='~S' t='~S' v='~S' u='~S'\n"
+ (format #t "field format: n='~S' t='~S' v='~S' u='~S'\n"
field-name field-type possible-formats
(car possible-formats))
(continue-proc (car possible-formats))))
@@ -60,8 +60,8 @@
(let ((root (qif-io:acct-table-make-gnc-acct-tree
acct-table qiffile commodity)))
;; write the file
- (let* ((name (simple-format #f "file:~A.gnc" filename)))
- (simple-format #t "using book name='~A'\n" name)
+ (let* ((name (format #f "file:~A.gnc" filename)))
+ (format #t "using book name='~A'\n" name)
(gnc-account-join-children (gnc-book-get-root book) root)
(xaccAccountDestroy root)
(gnc:session-begin session name #t #t)
@@ -96,13 +96,13 @@
(if ok?
(set! pass (+ 1 pass))
(begin
- (simple-format #t "[fail] test ~S\n" (car this-line))
- (simple-format #t " received ~S\n" result)
- (simple-format #t " expected ~S\n"
+ (format #t "[fail] test ~S\n" (car this-line))
+ (format #t " received ~S\n" result)
+ (format #t " expected ~S\n"
correct-result)
(set! fail (+ 1 fail))))
(loop (read)))))))
- (simple-format #t "test ~A: pass=~S fail=~S\n" title pass fail)
+ (format #t "test ~A: pass=~S fail=~S\n" title pass fail)
(= pass total)))
(let ((all-pass #t))
diff --git a/src/import-export/qif-io-core/test/test-parser.scm b/src/import-export/qif-io-core/test/test-parser.scm
index ba8ee08..2da2613 100644
--- a/src/import-export/qif-io-core/test/test-parser.scm
+++ b/src/import-export/qif-io-core/test/test-parser.scm
@@ -43,12 +43,12 @@
(if ok?
(set! pass (+ 1 pass))
(begin
- (simple-format #t "[fail] received ~S\n" result)
- (simple-format #t " expected ~S\n"
+ (format #t "[fail] received ~S\n" result)
+ (format #t " expected ~S\n"
correct-result)
(set! fail (+ 1 fail))))
(loop (read)))))))
- (simple-format #t "test ~A: pass=~S fail=~S\n" title pass fail)
+ (format #t "test ~A: pass=~S fail=~S\n" title pass fail)
(= pass total)))
(let ((all-pass #t))
diff --git a/src/import-export/qif-io-core/test/test-reader.scm b/src/import-export/qif-io-core/test/test-reader.scm
index 7724c7b..9e1911e 100644
--- a/src/import-export/qif-io-core/test/test-reader.scm
+++ b/src/import-export/qif-io-core/test/test-reader.scm
@@ -23,12 +23,12 @@
(if (not eof?)
(qif-io:write-record (car record) outport))))
(lambda (key new-state)
- (simple-format outport "!~A\n" new-state)))
+ (format outport "!~A\n" new-state)))
(if (not eof?)
(loop)))
(close-output-port outport)
(close-input-port inport)
- (system (simple-format #f "diff -b -I \"\\^*\" ~A /tmp/test-reader.tmp"
+ (system (format #f "diff -b -I \"\\^*\" ~A /tmp/test-reader.tmp"
qiffile))))
@@ -57,12 +57,12 @@
(if ok?
(set! pass (+ 1 pass))
(begin
- (simple-format #t "[fail] received ~S\n" result)
- (simple-format #t " expected ~S\n"
+ (format #t "[fail] received ~S\n" result)
+ (format #t " expected ~S\n"
correct-result)
(set! fail (+ 1 fail))))
(loop (read)))))))
- (simple-format #t "test ~A: pass=~S fail=~S\n" title pass fail)
+ (format #t "test ~A: pass=~S fail=~S\n" title pass fail)
(= pass total)))
(let ((all-pass #t))
diff --git a/src/report/report-system/eguile-gnc.scm b/src/report/report-system/eguile-gnc.scm
index 4bc7f87..3846d53 100644
--- a/src/report/report-system/eguile-gnc.scm
+++ b/src/report/report-system/eguile-gnc.scm
@@ -116,11 +116,11 @@
(define (template->script)
;; output text with double quotes escaped, but without the outer
- ;; enclosing quotes that (simple-format) insists on adding.
+ ;; enclosing quotes that (format) insists on adding.
;; (can't use (write) either because that wraps each line of output
;; in double quotes)
(define (display-text t)
- (let ((esct (simple-format #f "~s" t)))
+ (let ((esct (format #f "~s" t)))
(display (substring esct 1 (- (string-length esct) 1)))))
;; display either code or text
diff --git a/src/report/report-system/html-text.scm b/src/report/report-system/html-text.scm
index 30cedc4..2c512a1 100644
--- a/src/report/report-system/html-text.scm
+++ b/src/report/report-system/html-text.scm
@@ -135,7 +135,7 @@
(apply string-append
(gnc:html-document-tree-collapse rendered-elt)))
(#t
- (simple-format "hold on there podner. form='~s'\n" rendered-elt)
+ (format "hold on there podner. form='~s'\n" rendered-elt)
""))))
entities))))
diff --git a/src/report/report-system/report.scm b/src/report/report-system/report.scm
index bf212c8..77999f8 100644
--- a/src/report/report-system/report.scm
+++ b/src/report/report-system/report.scm
@@ -484,12 +484,12 @@
;; save them
(string-append
";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n"
- (simple-format #f ";; options for report ~S\n" (gnc:report-name report))
- (simple-format
+ (format #f ";; options for report ~S\n" (gnc:report-name report))
+ (format
#f "(let ((options (gnc:report-template-new-options/report-guid ~S ~S)))\n"
(gnc:report-type report) (gnc:report-template-name (hash-ref *gnc:_report-templates_* (gnc:report-type report))))
(gnc:generate-restore-forms (gnc:report-options report) "options")
- (simple-format
+ (format
#f " (gnc:restore-report-by-guid ~S ~S ~S options))\n"
(gnc:report-id report) (gnc:report-type report) (gnc:report-template-name (hash-ref *gnc:_report-templates_* (gnc:report-type report))))))
@@ -514,9 +514,9 @@
(define (gnc:report-generate-saved-forms-string name type templ-name options embedded-options guid)
(let ((result (string-append
";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n"
- (simple-format #f ";; Options for saved report ~S, based on template ~S\n"
+ (format #f ";; Options for saved report ~S, based on template ~S\n"
name type)
- (simple-format
+ (format
#f "(let ()\n (define (options-gen)\n (let ((options (gnc:report-template-new-options/report-guid ~S ~S)))\n"
type templ-name)
(gnc:generate-restore-forms options "options")
@@ -524,7 +524,7 @@
embedded-options
"")
" options))\n"
- (simple-format
+ (format
#f " (gnc:define-report \n 'version 1\n 'name ~S\n 'report-guid ~S\n 'parent-type ~S\n 'options-generator options-gen\n 'menu-path (list gnc:menuname-custom)\n 'renderer (gnc:report-template-renderer/report-guid ~S ~S)))\n\n"
name
(if guid
diff --git a/src/scm/main.scm b/src/scm/main.scm
index 2892feb..7459225 100644
--- a/src/scm/main.scm
+++ b/src/scm/main.scm
@@ -82,13 +82,6 @@
;; various utilities
-;; Test for simple-format
-(if (not (defined? 'simple-format))
- (begin
- (require 'format)
- (export simple-format)
- (define simple-format format)))
-
(define (gnc:safe-strcmp a b)
(cond
(if (and a b)
@@ -153,7 +146,7 @@
;;;; Status output functions.
(define (strify items)
- (string-join (map (lambda (x) (simple-format #f "~A" x)) items) ""))
+ (string-join (map (lambda (x) (format #f "~A" x)) items) ""))
(define (gnc:warn . items)
(gnc-scm-log-warn (strify items)))
diff --git a/src/scm/price-quotes.scm b/src/scm/price-quotes.scm
index 39c6a27..537f1fa 100644
--- a/src/scm/price-quotes.scm
+++ b/src/scm/price-quotes.scm
@@ -746,7 +746,7 @@ Run 'gnc-fq-update' as root to install them.") "\n")))
(let ((sources (gnc:fq-check-sources)))
(if (list? sources)
(begin
- (simple-format #t "Found Finance::Quote version ~A" (car sources))
+ (format #t "Found Finance::Quote version ~A" (car sources))
(newline)
(gnc:msg "Found Finance::Quote version " (car sources))
(gnc-quote-source-set-fq-installed (cdr sources))))))
--
1.6.2.5
--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment; filename=0004-remove-bundled-srfi-8.patch
More information about the gnucash-devel
mailing list