gnucash maint: Resolve ubuntu 14.04 naming conflict.

John Ralls jralls at code.gnucash.org
Sun Jul 15 19:56:08 EDT 2018


Updated	 via  https://github.com/Gnucash/gnucash/commit/ff91056a (commit)
	from  https://github.com/Gnucash/gnucash/commit/a51be515 (commit)



commit ff91056ab1227004953ad867413f0707cd839e69
Author: John Ralls <jralls at ceridwen.us>
Date:   Sun Jul 15 16:55:55 2018 -0700

    Resolve ubuntu 14.04 naming conflict.

diff --git a/libgnucash/app-utils/gnc-ui-util.c b/libgnucash/app-utils/gnc-ui-util.c
index 7aeeda8..7b9b8cb 100644
--- a/libgnucash/app-utils/gnc-ui-util.c
+++ b/libgnucash/app-utils/gnc-ui-util.c
@@ -82,7 +82,7 @@ static gboolean reverse_type[NUM_ACCOUNT_TYPES];
 static gchar *user_default_currency = NULL;
 static gchar *user_report_currency = NULL;
 const static int maximum_decimals = 15;
-static const gint64 pow10[] = {1, 10, 100, 1000, 10000, 100000, 1000000,
+static const gint64 pow_10[] = {1, 10, 100, 1000, 10000, 100000, 1000000,
                                10000000, 100000000, 1000000000, 10000000000,
                                100000000000, 1000000000000, 10000000000000,
                                100000000000000, 1000000000000000};
@@ -1398,17 +1398,16 @@ PrintAmountInternal(char *buf, gnc_numeric val, const GNCPrintAmountInfo *info)
     value_is_decimal = gnc_numeric_to_decimal(&val, NULL);
     if (!value_is_decimal && info->force_fit && info->round)
     {
-        gint64 denom = pow10[maximum_decimals];
         /* if there's a commodity use 100x the commodity's fraction. N.B. This
          * assumes that commodity fractions are multiples of 10, a reasonable
          * assumption in 2018. Otherwise, if there's a reasonable
          * max_decimal_places, use that.
          */
-        if (info->commodity)
-            denom = gnc_commodity_get_fraction(info->commodity) * 100;
-        else if (info->max_decimal_places &&
-                 info->max_decimal_places <= maximum_decimals)
-            denom = pow10[info->max_decimal_places];
+        const gint64 denom = info->commodity ?
+             gnc_commodity_get_fraction(info->commodity) * 100 :
+             (info->max_decimal_places &&
+               info->max_decimal_places <= maximum_decimals) ?
+             pow_10[info->max_decimal_places] : pow_10[maximum_decimals];
         val = gnc_numeric_convert(val, denom, GNC_HOW_RND_ROUND_HALF_UP);
         value_is_decimal = gnc_numeric_to_decimal(&val, NULL);
     }



Summary of changes:
 libgnucash/app-utils/gnc-ui-util.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)



More information about the gnucash-changes mailing list