gnucash master: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Sat Feb 4 23:12:09 EST 2023


Updated	 via  https://github.com/Gnucash/gnucash/commit/85c24916 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/928f4f62 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/1c09adec (commit)
	 via  https://github.com/Gnucash/gnucash/commit/ce3447e6 (commit)
	from  https://github.com/Gnucash/gnucash/commit/60209a76 (commit)



commit 85c2491664f07b27d2a122c91fee9ade099cc5d6
Merge: 60209a766 928f4f623
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Feb 5 12:09:38 2023 +0800

    Merge branch 'maint'


commit 928f4f62322856f864b7616c7e66b045c8aca0bd
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Feb 4 14:12:35 2023 -0800

    Fix test error from replacing guile * form.

diff --git a/gnucash/report/commodity-utilities.scm b/gnucash/report/commodity-utilities.scm
index 9eb6f6028..8e30d2fbe 100644
--- a/gnucash/report/commodity-utilities.scm
+++ b/gnucash/report/commodity-utilities.scm
@@ -781,9 +781,9 @@
                   (plist (assoc-ref pricealist foreign-comm))
                   (price (and plist
                               (gnc:pricelist-price-find-nearest plist date))))
-             (gnc-numeric_mul (gnc:make-gnc-monetary domestic)
-                              (gnc:make-gnc-monetary foreign-amt (or price 0))
-                              GNC-DENOM-AUTO GNC-RND-ROUND)))))
+             (gnc:make-gnc-monetary domestic
+                              (gnc-numeric-mul foreign-amt (or price 0)
+                              GNC-DENOM-AUTO GNC-RND-ROUND))))))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

commit 1c09adec87314f643ad7c3f7fc92a694a028ab7e
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Feb 4 09:36:46 2023 -0800

    Use gnc_numeric_multiply instead of Guile's * form for computing prices.
    
    Partly fixes bug 798550 (https://bugs.gnucash.org/show_bug.cgi?id=798550)
    
    Guile's * form when applied to rationals doesn't reduce and since
    guile uses gmp for unlimited precision arithmetic produces numbers
    that can't be passed back to C functions because they're too big for
    any normal C integer types.

diff --git a/gnucash/report/commodity-utilities.scm b/gnucash/report/commodity-utilities.scm
index 2ca72f09c..9eb6f6028 100644
--- a/gnucash/report/commodity-utilities.scm
+++ b/gnucash/report/commodity-utilities.scm
@@ -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
@@ -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-numeric_mul (gnc:make-gnc-monetary domestic)
+                              (gnc:make-gnc-monetary foreign-amt (or price 0))
+                              GNC-DENOM-AUTO GNC-RND-ROUND)))))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

commit ce3447e6ea8b2f734b24a2502e865ebbbc21aaaa
Author: John Ralls <jralls at ceridwen.us>
Date:   Mon Jan 30 10:23:05 2023 -0800

    Bug 798740 - Build fails with gcc 13
    
    Protect against passing an lseek failure rv to read().

diff --git a/libgnucash/app-utils/file-utils.c b/libgnucash/app-utils/file-utils.c
index b8d464cfd..f61e21f5b 100644
--- a/libgnucash/app-utils/file-utils.c
+++ b/libgnucash/app-utils/file-utils.c
@@ -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;
@@ -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);



Summary of changes:
 gnucash/report/commodity-utilities.scm |  7 +++++--
 libgnucash/app-utils/file-utils.c      | 15 +++++++++++----
 2 files changed, 16 insertions(+), 6 deletions(-)



More information about the gnucash-changes mailing list