Skip to content

Commit

Permalink
Bug 797233 - Balance Sheet, Chart of Accounts, and other reports...
Browse files Browse the repository at this point in the history
crash when involving foreign currency stocks.

Scheme's inexact->exact function just converts the floating-point
representation of a number into an exact rational (documented in the
API Reference, Simple Generic Data Types, Numerical data types, Exact
and Inexact Numbers), which isn't what we want.

We want the number converted to exact directly from the string and to do
that we have gnc-fq-helper preface it with #e.
  • Loading branch information
jralls committed May 14, 2019
1 parent 217418b commit fc56720
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
2 changes: 1 addition & 1 deletion libgnucash/quotes/gnc-fq-helper.in
Expand Up @@ -186,7 +186,7 @@ sub schemify_num {
if(!$numstr) { return "failed-conversion"; }

if($numstr =~ /^\s*(\d+(\.\d+)?([eE][+-]?\d+)?)$/o) {
return $1;
return "#e" . $1;
} else {
return "failed-conversion";
}
Expand Down
8 changes: 1 addition & 7 deletions libgnucash/scm/price-quotes.scm
Expand Up @@ -404,13 +404,7 @@
(else #f)))

(if price
;; The second argument to inexact->exact is chosen to give reasonable values
;; for prices between .12345e-9 and 12345678.87654

;; inexact->exact is probably not necessary but it can't hurt and is cheap.
(set! price
(gnc-scm-to-numeric
(rationalize (inexact->exact price) 1/1000000000000000))))
(set! price (gnc-scm-to-numeric price)))
(if gnc-time
(set! gnc-time (timestr->time64 gnc-time time-zone))
(set! gnc-time (gnc:get-today)))
Expand Down

0 comments on commit fc56720

Please sign in to comment.