gnucash maint: Multiple changes pushed

Mike Evans mikee at code.gnucash.org
Sun Jan 25 05:44:37 EST 2015


Updated	 via  https://github.com/Gnucash/gnucash/commit/5e60a234 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/564b9874 (commit)
	from  https://github.com/Gnucash/gnucash/commit/2494bfc6 (commit)



commit 5e60a234006ef68a517af0204d92f96ebe2f5de6
Author: Mike Evans <mikee at saxicola.co.uk>
Date:   Sun Jan 25 11:14:53 2015 +0000

    Bug 721196 - Use a regex for checking for a valid numeric value.
    
    Just testing for an empty field will miss the cases where there are
    spaces or decimal separators present.

diff --git a/src/import-export/csv-imp/gnc-csv-model.c b/src/import-export/csv-imp/gnc-csv-model.c
index b892b55..877529a 100644
--- a/src/import-export/csv-imp/gnc-csv-model.c
+++ b/src/import-export/csv-imp/gnc-csv-model.c
@@ -647,6 +647,8 @@ static gboolean trans_property_set (TransProperty* prop, char* str)
 {
     char *endptr, *possible_currency_symbol, *str_dupe;
     gnc_numeric val;
+    int reti;
+    regex_t regex;
     switch (prop->type)
     {
     case GNC_CSV_DATE:
@@ -664,9 +666,11 @@ static gboolean trans_property_set (TransProperty* prop, char* str)
     case GNC_CSV_DEPOSIT:
     case GNC_CSV_WITHDRAWAL:
         str_dupe = g_strdup (str); /* First, we make a copy so we can't mess up real data. */
-        /* If a cell is empty make its value = "0" */
-        if (strcmp (str_dupe, "") == 0)
-        { 
+        /* If a cell is empty or just spaces make its value = "0" */
+        reti = regcomp(&regex, "[0-9]", 0);
+        reti = regexec(&regex, str_dupe, 0, NULL, 0);
+        if (reti == REG_NOMATCH)
+        {
             g_free (str_dupe);
             str_dupe = g_strdup ("0");
         }

commit 564b9874575bb689974caca91a6737c8b12ef9cb
Author: Mike Evans <mikee at saxicola.co.uk>
Date:   Sun Jan 25 11:08:05 2015 +0000

    Numeric values with more than commodity smallest fraction get silently dropped.
    
    If there are more DPs than the commodity smallest fraction they get
    lost when calling gnc_numeric_convert().  Removed the call.

diff --git a/src/plugins/bi_import/dialog-bi-import.c b/src/plugins/bi_import/dialog-bi-import.c
index 05ef930..3c2a8b0 100644
--- a/src/plugins/bi_import/dialog-bi-import.c
+++ b/src/plugins/bi_import/dialog-bi-import.c
@@ -719,7 +719,6 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
         {
             gncEntrySetBillAccount (entry, acc);
             gnc_exp_parser_parse (price, &value, NULL);
-            value = gnc_numeric_convert (value, denom, GNC_HOW_RND_NEVER);
             gncEntrySetBillPrice (entry, value);
             gncEntrySetBillTaxable (entry, text2bool (taxable));
             gncEntrySetBillTaxIncluded (entry, text2bool (taxincluded));
@@ -732,13 +731,11 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
             gncEntrySetNotes (entry, notes);
             gncEntrySetInvAccount (entry, acc);
             gnc_exp_parser_parse (price, &value, NULL);
-            value = gnc_numeric_convert (value, denom, GNC_HOW_RND_NEVER);
             gncEntrySetInvPrice (entry, value);
             gncEntrySetInvTaxable (entry, text2bool (taxable));
             gncEntrySetInvTaxIncluded (entry, text2bool (taxincluded));
             gncEntrySetInvTaxTable (entry, gncTaxTableLookupByName (book, tax_table));
             gnc_exp_parser_parse (discount, &value, NULL);
-            value = gnc_numeric_convert (value, denom, GNC_HOW_RND_NEVER);
             gncEntrySetInvDiscount (entry, value);
             gncEntrySetInvDiscountType (entry, text2disc_type (disc_type));
             gncEntrySetInvDiscountHow (entry, text2disc_how (disc_how));



Summary of changes:
 src/import-export/csv-imp/gnc-csv-model.c | 10 +++++++---
 src/plugins/bi_import/dialog-bi-import.c  |  3 ---
 2 files changed, 7 insertions(+), 6 deletions(-)



More information about the gnucash-changes mailing list