[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

gnucash: [PATCH] Fixed the "missing cents" bug



Greetings,

First, the 1.4.5 gnucash upload did not fix bug 69866, involving all
currencies rounding to the nearest integer on PPC (and I believe ARM).

The problem is in src/engine/util.c line 401, where gnucash expects
localeconv() to set the char fields of the lconv structure to CHAR_MAX.
Of course, it does this, but that part of libc was built without
-fsigned_char, so the fields are set to unsigned CHAR_MAX, which is 255
(see /usr/include/limits.h).

Then gnucash is built using -fsigned_char for the whole package, so in
line 401, the 255 set by localeconv() becomes -1, which is compared to
signed CHAR_MAX which is 127, the comparison fails, and gnucash assumes
that the value has been set by libc.  Which of course it hasn't.  When
-1 is passed as precision to util_fptostr and PrintAmt and friends, it
is truncated to 0, so zero decimal places of precision are used, and no
cents (or other currency fractions) are printed.

The attached patch is a sort of kludge that makes it work.  I suppose
the long-term fix is to get rid of the CFLAGS=-fsigned_char
("sledgehammer" approach) in debian/rules, and actually find the parts
which need signed char and edit declarations (the "pen-knife" approach)
as appropriate.  I'll try building and testing without that CFLAGS
value, and see what breaks, when I get some more time. :-)

Zeen,

-Adam P.

          Welcome to the best software in the world today cafe!
--- gnucash-1.4.5/src/engine/util.c.bak	Sun Sep 10 18:02:09 2000
+++ gnucash-1.4.5/src/engine/util.c	Sun Sep 10 18:10:10 2000
@@ -398,7 +398,7 @@
 static void
 gnc_lconv_set_char(char *p_value, char default_value)
 {
-  if ((p_value != NULL) && (*p_value == CHAR_MAX))
+  if ((p_value != NULL) && ((*p_value == CHAR_MAX) || (*p_value == -1)))
     *p_value = default_value;
 }
 

Reply to: