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
This commit is contained in:
Charles Day 2008-09-18 20:49:01 +00:00
parent ad6df218a0
commit 3d67fcd62f

View File

@ -1253,7 +1253,9 @@ gnc_integral_print_info (void)
/* Utility function for printing non-negative amounts */ /* Utility function for printing non-negative amounts */
static int 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(); struct lconv *lc = gnc_localeconv();
int num_whole_digits; int num_whole_digits;
@ -1401,7 +1403,7 @@ PrintAmountInternal(char *buf, gnc_numeric val, const GNCPrintAmountInfo *info)
if (whole.num == 0) if (whole.num == 0)
*buf = '\0'; *buf = '\0';
else if (value_is_negative) else if (value_is_negative && !print_absolute)
strcat(buf, " - "); strcat(buf, " - ");
else else
strcat(buf, " + "); strcat(buf, " + ");
@ -1483,6 +1485,7 @@ xaccSPrintAmount (char * bufp, gnc_numeric val, GNCPrintAmountInfo info)
gboolean print_sign = TRUE; gboolean print_sign = TRUE;
gboolean is_shares = FALSE; gboolean is_shares = FALSE;
gboolean print_absolute = FALSE;
if (!bufp) if (!bufp)
return 0; return 0;
@ -1570,10 +1573,13 @@ xaccSPrintAmount (char * bufp, gnc_numeric val, GNCPrintAmountInfo info)
/* Now see if we print parentheses */ /* Now see if we print parentheses */
if (print_sign && (sign_posn == 0)) if (print_sign && (sign_posn == 0))
{
bufp = g_stpcpy(bufp, "("); bufp = g_stpcpy(bufp, "(");
print_absolute = TRUE;
}
/* Now print the value */ /* Now print the value */
bufp += PrintAmountInternal(bufp, val, &info); bufp += PrintAmountInternal(bufp, val, &info, print_absolute);
/* Now see if we print parentheses */ /* Now see if we print parentheses */
if (print_sign && (sign_posn == 0)) if (print_sign && (sign_posn == 0))