gnucash maint: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Thu Aug 25 14:02:10 EDT 2016
Updated via https://github.com/Gnucash/gnucash/commit/ea386249 (commit)
via https://github.com/Gnucash/gnucash/commit/9069f262 (commit)
from https://github.com/Gnucash/gnucash/commit/a4f96d04 (commit)
commit ea3862499b992efed5f24d0ff1be9881a81aa00d
Author: Geoff Lee <geoff.lee99 at gmail.com>
Date: Thu Aug 25 10:50:09 2016 -0700
Bug 770303 - Incorrect commodity match during import OFX and possible solution.
Comparing only on the strlen of the imported commodity produces false
matches when the account commodity string begins with the same
characters but is longer. E.g. if the imported commodity is F (Ford
Motor) and Facebook (FB) is encountered first in the account list then
the matcher will select Facebook, but that will fail when the commodity
GUIDs are compared.
diff --git a/src/import-export/import-commodity-matcher.c b/src/import-export/import-commodity-matcher.c
index 98eb21d..a2c6170 100644
--- a/src/import-export/import-commodity-matcher.c
+++ b/src/import-export/import-commodity-matcher.c
@@ -83,14 +83,18 @@ gnc_commodity * gnc_import_select_commodity(const char * cusip,
commodity_list = g_list_first(commodity_list);
while ( commodity_list != NULL && retval == NULL)
{
+ const char* tmp_cusip = NULL;
tmp_commodity = commodity_list->data;
- if (gnc_commodity_get_cusip(tmp_commodity) != NULL &&
- cusip != NULL &&
- strncmp(gnc_commodity_get_cusip(tmp_commodity), cusip, strlen(cusip)) == 0)
DEBUG("Looking at commodity %s",
gnc_commodity_get_fullname(tmp_commodity));
+ tmp_cusip = gnc_commodity_get_cusip(tmp_commodity);
+ if (tmp_cusip != NULL && cusip != NULL)
{
- retval = tmp_commodity;
+ int len = strlen(cusip) > strlen(tmp_cusip) ? strlen(cusip) :
+ strlen(tmp_cusip);
+ if (strncmp(tmp_cusip, cusip, len) == 0)
+ {
+ retval = tmp_commodity;
DEBUG("Commodity %s%s",
gnc_commodity_get_fullname(retval), " matches.");
}
commit 9069f2626a252305d4d4e0ac1b32834e24a16ee8
Author: John Ralls <jralls at ceridwen.us>
Date: Thu Aug 25 10:48:55 2016 -0700
Whitespace cleanup in gnc_import_select_commodity.
diff --git a/src/import-export/import-commodity-matcher.c b/src/import-export/import-commodity-matcher.c
index 1122bbf..98eb21d 100644
--- a/src/import-export/import-commodity-matcher.c
+++ b/src/import-export/import-commodity-matcher.c
@@ -78,34 +78,28 @@ gnc_commodity * gnc_import_select_commodity(const char * cusip,
{
tmp_namespace = namespace_list->data;
DEBUG("Looking at namespace %s", tmp_namespace);
-
-
- /*Nested loop*/
commodity_list = gnc_commodity_table_get_commodities(commodity_table,
- tmp_namespace);
+ tmp_namespace);
commodity_list = g_list_first(commodity_list);
while ( commodity_list != NULL && retval == NULL)
{
tmp_commodity = commodity_list->data;
- DEBUG("Looking at commodity %s", gnc_commodity_get_fullname(tmp_commodity));
-
if (gnc_commodity_get_cusip(tmp_commodity) != NULL &&
cusip != NULL &&
strncmp(gnc_commodity_get_cusip(tmp_commodity), cusip, strlen(cusip)) == 0)
+ DEBUG("Looking at commodity %s",
+ gnc_commodity_get_fullname(tmp_commodity));
{
retval = tmp_commodity;
- DEBUG("Commodity %s%s", gnc_commodity_get_fullname(retval), " matches.");
+ DEBUG("Commodity %s%s",
+ gnc_commodity_get_fullname(retval), " matches.");
+ }
}
commodity_list = g_list_next(commodity_list);
}
- /*End nested loop*/
-
namespace_list = g_list_next(namespace_list);
}
-
-
-
g_list_free(commodity_list);
g_list_free(namespace_list);
Summary of changes:
src/import-export/import-commodity-matcher.c | 30 +++++++++++++---------------
1 file changed, 14 insertions(+), 16 deletions(-)
More information about the gnucash-changes
mailing list