Audit all .scm files for cases where null objects were assumed to be #f.

In most of these cases, I know the value is always returned from C, so we
can use "null?".  In cases where I wasn't sure, I make it check for either
#f or null?.  Hopefully, I got 'em all.  But, really, what are the chances?



git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15060 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Chris Shoemaker 2006-10-29 03:12:49 +00:00
parent 9618429b17
commit e4ebb3eb1b
23 changed files with 69 additions and 66 deletions

View File

@ -637,7 +637,8 @@
(gnc:make-option
section name sort-tag 'account-list documentation-string getter
(lambda (account-list)
(if (not account-list) (set! account-list (default-getter)))
(if (or (not account-list) (null? account-list))
(set! account-list (default-getter)))
(set! account-list
(filter (lambda (x) (if (string? x)
(xaccAccountLookup
@ -760,7 +761,7 @@
(gnc:make-option
section name sort-tag 'account-sel documentation-string getter
(lambda (account)
(if (not account) (set! account (get-default)))
(if (or (not account) (null? account)) (set! account (get-default)))
(set! account (convert-to-account account))
(let* ((result (validator account))
(valid (car result))

View File

@ -91,20 +91,20 @@
(let* ((trans (xaccSplitGetParent split))
(invoice (gncInvoiceGetInvoiceFromTxn trans))
(temp-owner (gncOwnerCreate))
(owner #f))
(owner '()))
(if invoice
(if (not (null? invoice))
(set! owner (gncInvoiceGetOwner invoice))
(let ((split-list (xaccTransGetSplitList trans)))
(define (check-splits splits)
(if (and splits (not (null? splits)))
(let* ((split (car splits))
(lot (xaccSplitGetLot split)))
(if lot
(if (not (null? lot))
(let* ((invoice (gncInvoiceGetInvoiceFromLot lot))
(owner? (gnc:owner-get-owner-from-lot
lot temp-owner)))
(if invoice
(if (not (null? invoice))
(set! owner (gncInvoiceGetOwner invoice))
(if owner?
(set! owner temp-owner)
@ -112,14 +112,14 @@
(check-splits (cdr splits))))))
(check-splits split-list)))
(if owner
(if (not (null? owner))
(begin
(gncOwnerCopy (gncOwnerGetEndOwner owner) result-owner)
(gncOwnerDestroy temp-owner)
result-owner)
(begin
(gncOwnerDestroy temp-owner)
#f)))) ;; FIXME!
'()))))
(export gnc:owner-get-address)

View File

@ -543,7 +543,7 @@ totals to report currency")
;; set default title
(gnc:html-document-set-title! document report-title)
;; maybe redefine better...
(if account
(if (not (null? account))
(begin
(gnc:html-document-set-title!
document (string-append report-title ": " (xaccAccountGetName account)))
@ -558,7 +558,7 @@ totals to report currency")
(gnc:html-table-set-col-headers! table heading-list)
(if account
(if (not (null? account))
(begin
(setup-query query account report-date)
;; get the appropriate splits

View File

@ -90,7 +90,7 @@
(if ref
(begin
(set! ref (string-append ref (gncOwnerReturnGUID end-owner)))
(if acc
(if (not (null? acc))
(set! ref (string-append ref "&acct="
(gncAccountGetGUID acc))))
(gnc-build-url URL-TYPE-OWNERREPORT ref ""))

View File

@ -473,7 +473,7 @@
(add-subtotal-row table used-columns tax-collector
"grand-total" (_ "Tax")))
(if (and show-payments lot)
(if (and show-payments (not (null? lot)))
(let ((splits (sort-list!
(gnc-lot-get-split-list lot)
(lambda (s1 s2)
@ -524,7 +524,7 @@
(gnc:gnc-monetary-amount (cdr entry-values)))
(let ((order (gncEntryGetOrder current)))
(if order (add-order order)))
(if (not (null? order)) (add-order order)))
(do-rows-with-subtotals rest
table
@ -683,7 +683,7 @@
(if (and references? (not (member o orders)))
(addto! orders o)))
(if invoice
(if (not (null? invoice))
(begin
(set! owner (gncInvoiceGetOwner invoice))
(let ((type (gncOwnerGetType
@ -707,7 +707,7 @@
(add-html! document "<tr><td align='left'>")
(if invoice
(if (not (null? invoice))
(begin
; invoice number and ID String table
(add-html! document "<table width='100%'><tr>")

View File

@ -500,7 +500,7 @@
(add-subtotal-row table used-columns tax-collector
"grand-total" (_ "Tax")))
(if (and show-payments lot)
(if (and show-payments (not (null? lot)))
(let ((splits (sort-list!
(gnc-lot-get-split-list lot)
(lambda (s1 s2)
@ -552,7 +552,7 @@
(gnc:gnc-monetary-amount (cdr entry-values)))
(let ((order (gncEntryGetOrder current)))
(if order (add-order order)))
(if (not (null? order)) (add-order order)))
(set! entries-added (+ entries-added 1))
@ -766,7 +766,7 @@
(if (and references? (not (member o orders)))
(addto! orders o)))
(if invoice
(if (not (null? invoice))
(begin
(set! owner (gncInvoiceGetOwner invoice))
(let ((type (gncOwnerGetType
@ -784,7 +784,7 @@
;; invoice number moved below
;;(gnc:html-document-set-title! document title)
(if invoice
(if (not (null? invoice))
(let* ((book (gncInvoiceGetBook invoice))
(slots (gnc-book-get-slots book))
(date-object #f)

View File

@ -636,7 +636,7 @@
(if (and references? (not (member o orders)))
(addto! orders o)))
(if invoice
(if (not (null? invoice))
(begin
(set! owner (gncInvoiceGetOwner invoice))
(let ((type (gncOwnerGetType
@ -653,7 +653,7 @@
(gnc:html-document-set-title! document title)
(if invoice
(if (not (null? invoice))
(let ((book (gncInvoiceGetBook invoice)))
(set! table (make-entry-table invoice
(gnc:report-options report-obj)

View File

@ -163,7 +163,7 @@
(begin
(if reverse?
(set! bal (gnc-numeric-neg bal)))
(if invoice
(if (not (null? invoice))
(begin
(apply-invoice post-date bal))
(apply-payment bal))))))
@ -202,7 +202,7 @@
(type-str
(cond
((equal? type gnc:transaction-type-invoice)
(if invoice
(if (not (null? invoice))
(gnc:make-html-text
(gnc:html-markup-anchor
(gnc:invoice-anchor-text invoice)
@ -255,7 +255,7 @@
)))
; Now print out the invoice row
(if invoice
(if (not (null? invoice))
(set! due-date (gncInvoiceGetDateDue invoice)))
(let ((row (make-row date due-date (xaccTransGetNum txn)
@ -575,7 +575,7 @@
(gnc:owner-anchor-text owner)
(gncOwnerGetName owner))))
(if account
(if (not (null? account))
(begin
(set! table (make-txn-table (gnc:report-options report-obj)
query account start-date end-date))
@ -709,7 +709,7 @@
(define (gnc:owner-report-create owner account)
; Figure out an account to use if nothing exists here.
(if (not account)
(if (null? account)
(set! account (find-first-account-for-owner owner)))
(owner-report-create owner account))
@ -722,7 +722,7 @@
(owner (gnc:owner-from-split split temp-owner))
(res #f))
(if owner
(if (not (null? owner))
(set! res (gnc:owner-report-create owner account)))
(gncOwnerDestroy temp-owner)

View File

@ -61,7 +61,7 @@
(gnc:make-option
section name sort-tag 'invoice documentation-string getter
(lambda (invoice) ;; setter
(if (not invoice) (set! invoice (default-getter)))
(if (null? invoice) (set! invoice (default-getter)))
(set! invoice (convert-to-invoice invoice))
(let* ((result (validator invoice))
(valid (car result))
@ -122,7 +122,7 @@
(gnc:make-option
section name sort-tag 'customer documentation-string getter
(lambda (customer)
(if (not customer) (set! customer (default-getter)))
(if (null? customer) (set! customer (default-getter)))
(set! customer (convert-to-customer customer))
(let* ((result (validator customer))
(valid (car result))
@ -183,7 +183,7 @@
(gnc:make-option
section name sort-tag 'vendor documentation-string getter
(lambda (vendor)
(if (not vendor) (set! vendor (default-getter)))
(if (null? vendor) (set! vendor (default-getter)))
(set! vendor (convert-to-vendor vendor))
(let* ((result (validator vendor))
(valid (car result))
@ -244,7 +244,7 @@
(gnc:make-option
section name sort-tag 'employee documentation-string getter
(lambda (employee)
(if (not employee) (set! employee (default-getter)))
(if (null? employee) (set! employee (default-getter)))
(set! employee (convert-to-employee employee))
(let* ((result (validator employee))
(valid (car result))
@ -343,7 +343,7 @@
(gnc:make-option
section name sort-tag 'owner documentation-string getter
(lambda (owner)
(if (not owner) (set! owner (default-getter)))
(if (null? owner) (set! owner (default-getter)))
(set! owner (convert-to-owner owner))
(let* ((result (validator owner))
(valid (car result))
@ -410,7 +410,7 @@
(gnc:make-option
section name sort-tag 'taxtable documentation-string getter
(lambda (taxtable)
(if (not taxtable) (set! taxtable (default-getter)))
(if (null? taxtable) (set! taxtable (default-getter)))
(set! taxtable (convert-to-taxtable taxtable))
(let* ((result (validator taxtable))
(valid (car result))

View File

@ -111,7 +111,7 @@
;; status and date are not copied. The C split's guid is,
;; of course, unchanged.
(define (gnc:split-scm-onto-split split-scm split book)
(if (not split)
(if (null? split)
#f
(begin
(let ((memo (gnc:split-scm-get-memo split-scm))
@ -125,7 +125,7 @@
(let ((account (xaccAccountLookup
(gnc:split-scm-get-account-guid split-scm)
book)))
(if account
(if (not (null? account))
(begin
(xaccAccountBeginEdit account)
(xaccSplitSetAccount split account)

View File

@ -26,7 +26,7 @@
(define (qif-import:load-map-prefs)
(define (extract-all-account-info agroup root-name)
(if (not agroup)
(if (null? agroup)
'()
(let ((children-list (xaccGroupGetAccountListSorted agroup))
(names '()))

View File

@ -53,7 +53,7 @@
(lambda (xtn)
(let ((query (qof-query-create-for-splits)))
(set! work-done (+ 1 work-done))
(if progress-dialog
(if (not (null? progress-dialog))
(begin
(gnc-progress-dialog-set-value
progress-dialog (/ work-done work-to-do))
@ -132,7 +132,7 @@
new-xtns)
;; get rid of the progress dialog
(if progress-dialog
(if (not (null? progress-dialog))
(gnc-progress-dialog-destroy progress-dialog))
;; return the matches

View File

@ -38,13 +38,13 @@
#t))))
(define (make-unique-name-variant long-name short-name)
(if (xaccGetAccountFromFullName old-group long-name)
(if (not (null? (xaccGetAccountFromFullName old-group long-name)))
(let loop ((count 2))
(let* ((test-name
(string-append long-name (sprintf #f " %a" count)))
(test-acct
(xaccGetAccountFromFullName old-group test-name)))
(if (and test-acct (not (compatible? test-acct)))
(if (and (not (null? test-acct)) (not (compatible? test-acct)))
(loop (+ 1 count))
(string-append short-name (sprintf #f " %a" count)))))
short-name))
@ -53,7 +53,7 @@
;; if the name is in use but the commodity, or type are
;; incompatible, we need to create a new account with a modified
;; name.
(if same-gnc-account
(if (and same-gnc-account (not (null? same-gnc-account)))
(if (compatible? same-gnc-account)
(begin
;; everything is ok, so we can just use the same
@ -77,7 +77,8 @@
;; here, existing-account means a previously *created* account
;; (possibly a new account, possibly a copy of an existing gnucash
;; acct)
(if (and existing-account (compatible? existing-account))
(if (and (and existing-account (not (null? existing-account)))
(compatible? existing-account))
existing-account
(let ((new-acct (xaccMallocAccount (gnc-get-current-book)))
(parent-acct #f)
@ -91,7 +92,7 @@
;; if this is a copy of an existing gnc account, copy the
;; account properties. For incompatible existing accts,
;; we'll do something different later.
(if same-gnc-account
(if (and same-gnc-account (not (null? same-gnc-account)))
(begin
(xaccAccountSetName
new-acct (xaccAccountGetName same-gnc-account))
@ -156,7 +157,7 @@
(set! parent-acct (qif-import:find-or-make-acct
pinfo #t default-currency #f default-currency
gnc-acct-hash old-group new-group))))
(if parent-acct
(if (and parent-acct (not (null? parent-acct)))
(xaccAccountInsertSubAccount parent-acct new-acct)
(xaccGroupInsertAccount new-group new-acct))
@ -308,7 +309,7 @@
(let xloop ((xtn (car markable-xtns))
(rest (cdr markable-xtns)))
(set! work-done (+ 1 work-done))
(if progress-dialog
(if (not (null? progress-dialog))
(begin
(gnc-progress-dialog-set-value
progress-dialog (/ work-done work-to-do))
@ -325,7 +326,7 @@
(for-each
(lambda (xtn)
(set! work-done (+ 1 work-done))
(if progress-dialog
(if (not (null? progress-dialog))
(begin
(gnc-progress-dialog-set-value
progress-dialog (/ work-done work-to-do))
@ -352,7 +353,7 @@
sorted-qif-files-list)
;; get rid of the progress dialog
(if progress-dialog
(if (not (null? progress-dialog))
(gnc-progress-dialog-destroy progress-dialog))
new-group))))

View File

@ -59,7 +59,7 @@
(type (qif-io:account-type qif-acct))
(desc (qif-io:account-description qif-acct))
(gnc-acct (hash-ref qif-acct-table name)))
(if gnc-acct
(if (and gnc-acct (not (null? gnc-acct)))
(let ((gnc-type (qif-io:parse-acct-type type)))
(xaccAccountBeginEdit gnc-acct)
(if gnc-type
@ -73,7 +73,7 @@
(hash-fold
(lambda (name acct p)
(let ((cmdty (xaccAccountGetCommodity acct)))
(if (not cmdty)
(if (null? cmdty)
(begin
(xaccAccountBeginEdit acct)
(xaccAccountSetCommodity acct commodity)
@ -94,7 +94,7 @@
(income? (qif-io:category-income-cat qif-cat))
(desc (qif-io:category-description qif-cat))
(gnc-acct (hash-ref qif-cat-table name)))
(if gnc-acct
(if (and gnc-acct (not (null? gnc-acct)))
(begin
(xaccAccountBeginEdit gnc-acct)
(cond (income?

View File

@ -660,7 +660,7 @@
(to-special #f) ; clear special-splits-period
(from-special #f)
(childrens-output
(if (not children)
(if (null? children)
(let* ((splits-period (txf-special-splits-period
account from-value to-value)))
(if splits-period
@ -736,7 +736,7 @@
(if tax-mode?
(list level-x-output
childrens-output)
(if (not children) ; swap for txf special splt
(if (null? children) ; swap for txf special splt
(list childrens-output level-x-output)
(list level-x-output childrens-output)))))))
;; Ignore

View File

@ -637,7 +637,7 @@
(to-special #f) ; clear special-splits-period
(from-special #f)
(childrens-output
(if (not children)
(if (null? children)
(let* ((splits-period (txf-special-splits-period
account from-value to-value)))
(if splits-period
@ -713,7 +713,7 @@
(if tax-mode?
(list level-x-output
childrens-output)
(if (not children) ; swap for txf special splt
(if (null? children) ; swap for txf special splt
(list childrens-output level-x-output)
(list level-x-output childrens-output)))))))
;; Ignore

View File

@ -34,7 +34,7 @@
;; instead, this function's side-effect is to set the report's editor widget.
(define (gnc:report-edit-options report)
(let* ((editor-widg (gnc:report-editor-widget report)))
(if editor-widg
(if (and editor-widg (not (null? editor-widg)))
(gnc-report-raise-editor report)
(begin
(if (gnc:report-options report)

View File

@ -38,6 +38,7 @@ gboolean gnc_run_report_id_string (const char * id_string, char **data);
**/
gchar* gnc_report_name( SCM report );
/* returns #f if the report id cannot be found */
SCM gnc_report_find(gint id);
void gnc_report_remove_by_id(gint id);
gint gnc_report_add(SCM report);

View File

@ -78,14 +78,14 @@
;; returns the account name as html-text and anchor to the register.
(define (gnc:html-account-anchor acct)
(gnc:make-html-text (if acct
(gnc:make-html-text (if (and acct (not (null? acct)))
(gnc:html-markup-anchor
(gnc:account-anchor-text acct)
(xaccAccountGetName acct))
"")))
(define (gnc:html-split-anchor split text)
(gnc:make-html-text (if (xaccSplitGetAccount split)
(gnc:make-html-text (if (not (null? (xaccSplitGetAccount split)))
(gnc:html-markup-anchor
(gnc:split-anchor-text split)
text)

View File

@ -185,7 +185,7 @@
(define (account-get-depth account)
(define (account-get-depth-internal account-internal depth)
(let ((parent (xaccAccountGetParentAccount account-internal)))
(if parent
(if (not (null? parent))
(account-get-depth-internal parent (+ depth 1))
depth)))
(account-get-depth-internal account 1))

View File

@ -116,7 +116,7 @@
(define (gnc:split-get-balance-display split)
(let ((account (xaccSplitGetAccount split))
(balance (xaccSplitGetBalance split)))
(if (and account (gnc-reverse-balance account))
(if (and (not (null? account)) (gnc-reverse-balance account))
(gnc-numeric-neg balance)
balance)))
@ -125,7 +125,7 @@
(let* ((row-contents '())
(parent (xaccSplitGetParent split))
(account (xaccSplitGetAccount split))
(currency (if account
(currency (if (not (null? account))
(xaccAccountGetCommodity account)
(gnc-default-currency)))
(damount (xaccSplitGetAmount split))
@ -157,7 +157,7 @@
(if transaction-info?
(let ((other-split
(xaccSplitGetOtherSplit split)))
(if other-split
(if (not (null? other-split))
(gnc-account-get-full-name
(xaccSplitGetAccount other-split))
(_ "-- Split Transaction --")))
@ -343,7 +343,7 @@
(define (display-subtotal monetary)
(if (amount-single-col used-columns)
(if (and leader (gnc-reverse-balance leader))
(if (and (not (null? leader)) (gnc-reverse-balance leader))
(gnc:monetary-neg monetary)
monetary)
(if (gnc-numeric-negative-p (gnc:gnc-monetary-amount monetary))
@ -453,11 +453,11 @@
(define (splits-leader splits)
(let ((accounts (map xaccSplitGetAccount splits)))
(if (null? accounts) #f
(if (null? accounts) '()
(begin
(set! accounts (cons (car accounts)
(delete (car accounts) (cdr accounts))))
(if (not (null? (cdr accounts))) #f
(if (not (null? (cdr accounts))) '()
(car accounts))))))
(let* ((table (gnc:make-html-table))

View File

@ -61,7 +61,7 @@
(gnc:debug "hash: " gnc:*register-report-hash*)
(gnc:debug "split: " split)
(if type-info
(if split
(if (not (null? split))
(begin (gnc:debug "get-split...") (get-split type-info))
(begin (gnc:debug "get-non-split...") (get-non-split type-info)))
#f)))

View File

@ -108,7 +108,7 @@
(payee-stub-text "")
(memo-stub-text ""))
(if ps
(if (not (null? ps))
(begin
(if (not (eq? (print-check-format:format format-info) 'custom))
(begin