mirror of
https://github.com/Gnucash/gnucash.git
synced 2026-09-03 20:53:02 -05:00
Bug #615168: Replace calls to simple-format with calls to format
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. Patch by Andy Wingo. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19063 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -88,4 +88,4 @@
|
||||
(export qif-io:acct-table-make-gnc-acct-tree)
|
||||
|
||||
;; from main
|
||||
(export simple-format)
|
||||
(export format)
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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))))
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
+1
-8
@@ -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)))
|
||||
|
||||
@@ -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))))))
|
||||
|
||||
Reference in New Issue
Block a user