Skip to content

Commit

Permalink
Merge branch 'maint'
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherlam committed Feb 5, 2023
2 parents 60209a7 + 928f4f6 commit 85c2491
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
7 changes: 5 additions & 2 deletions gnucash/report/commodity-utilities.scm
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,8 @@
(gnc:make-gnc-monetary
domestic
(if pair
(* (gnc:gnc-monetary-amount foreign) (cadr pair))
(gnc-numeric-mul (gnc:gnc-monetary-amount foreign) (cadr pair)
GNC-DENOM-AUTO GNC-RND-ROUND)
0)))))))

;; This is another ready-to-use function for calculation of exchange
Expand Down Expand Up @@ -780,7 +781,9 @@
(plist (assoc-ref pricealist foreign-comm))
(price (and plist
(gnc:pricelist-price-find-nearest plist date))))
(gnc:make-gnc-monetary domestic (* foreign-amt (or price 0)))))))
(gnc:make-gnc-monetary domestic
(gnc-numeric-mul foreign-amt (or price 0)
GNC-DENOM-AUTO GNC-RND-ROUND))))))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down
15 changes: 11 additions & 4 deletions libgnucash/app-utils/file-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ gncReadFile (const char * filename, char ** data)
{
char *buf = NULL;
char *fullname;
int size = 0;
off_t size = 0;
int fd;

if (!filename || filename[0] == '\0') return 0;
Expand All @@ -89,18 +89,25 @@ gncReadFile (const char * filename, char ** data)
size = lseek( fd, 0, SEEK_END );
lseek( fd, 0, SEEK_SET );

if (size < 0)
{
int norr = errno;
PERR ("file seek-to-end %s: (%d) %s\n", filename, norr, strerror(norr));
return 0;
}

/* Allocate memory */
buf = g_new(char, size + 1);
buf = g_new(char, (size_t)size + 1);

/* read in file */
if ( read(fd, buf, size) == -1 )
if ( read(fd, buf, (size_t)size) == -1 )
{
g_free(buf);
buf = NULL;
}
else
{
buf[size] = '\0';
buf[(size_t)size] = '\0';
}

close(fd);
Expand Down

0 comments on commit 85c2491

Please sign in to comment.