From 3d67fcd62f9a4fcd15fd82a1f95ce7ad65ee24cc Mon Sep 17 00:00:00 2001 From: Charles Day Date: Thu, 18 Sep 2008 20:49:01 +0000 Subject: [PATCH] Fix printing of fractions when parentheses are shown for negative values. BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@17555 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/app-utils/gnc-ui-util.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/app-utils/gnc-ui-util.c b/src/app-utils/gnc-ui-util.c index 5d888c0223..df4ba21e03 100644 --- a/src/app-utils/gnc-ui-util.c +++ b/src/app-utils/gnc-ui-util.c @@ -1253,7 +1253,9 @@ gnc_integral_print_info (void) /* Utility function for printing non-negative amounts */ static int -PrintAmountInternal(char *buf, gnc_numeric val, const GNCPrintAmountInfo *info) +PrintAmountInternal(char *buf, gnc_numeric val, + const GNCPrintAmountInfo *info, + gboolean print_absolute) { struct lconv *lc = gnc_localeconv(); int num_whole_digits; @@ -1401,7 +1403,7 @@ PrintAmountInternal(char *buf, gnc_numeric val, const GNCPrintAmountInfo *info) if (whole.num == 0) *buf = '\0'; - else if (value_is_negative) + else if (value_is_negative && !print_absolute) strcat(buf, " - "); else strcat(buf, " + "); @@ -1483,6 +1485,7 @@ xaccSPrintAmount (char * bufp, gnc_numeric val, GNCPrintAmountInfo info) gboolean print_sign = TRUE; gboolean is_shares = FALSE; + gboolean print_absolute = FALSE; if (!bufp) return 0; @@ -1570,10 +1573,13 @@ xaccSPrintAmount (char * bufp, gnc_numeric val, GNCPrintAmountInfo info) /* Now see if we print parentheses */ if (print_sign && (sign_posn == 0)) + { bufp = g_stpcpy(bufp, "("); + print_absolute = TRUE; + } /* Now print the value */ - bufp += PrintAmountInternal(bufp, val, &info); + bufp += PrintAmountInternal(bufp, val, &info, print_absolute); /* Now see if we print parentheses */ if (print_sign && (sign_posn == 0))