r20478 - gnucash/trunk/src/import-export - Bug #645406: Make transaction matching on memo and description case-insensitive

Christian Stimming cstim at code.gnucash.org
Fri Mar 25 15:56:51 EDT 2011


Author: cstim
Date: 2011-03-25 15:56:51 -0400 (Fri, 25 Mar 2011)
New Revision: 20478
Trac: http://svn.gnucash.org/trac/changeset/20478

Modified:
   gnucash/trunk/src/import-export/import-backend.c
Log:
Bug #645406: Make transaction matching on memo and description case-insensitive

Patch by gnemas:

The function split_find_match() in import-backend.c scores
transactions according to comparisons of amount, date, description,
etc.

I noticed that the comparison of the description and memo fields is
case-sensitive.

This means that my supermarket entries that have descriptions "Giant
Food" do not match the downloaded descriptions "GIANT FOOD".

This applies to both the exact and the 50% match cases, and for both
the memo and the description fields.

The attached patch should fix this.

Modified: gnucash/trunk/src/import-export/import-backend.c
===================================================================
--- gnucash/trunk/src/import-export/import-backend.c	2011-03-25 07:57:15 UTC (rev 20477)
+++ gnucash/trunk/src/import-export/import-backend.c	2011-03-25 19:56:51 UTC (rev 20478)
@@ -721,13 +721,13 @@
             const char *memo = xaccSplitGetMemo(new_trans_fsplit);
             if (memo && strlen(memo) != 0)
             {
-                if (safe_strcmp(memo, xaccSplitGetMemo(split)) == 0)
+                if (safe_strcasecmp(memo, xaccSplitGetMemo(split)) == 0)
                 {
                     /* An exact match of memo gives a +2 */
                     prob = prob + 2;
                     /* DEBUG("heuristics:  probability + 2 (memo)"); */
                 }
-                else if ((strncmp(memo, xaccSplitGetMemo(split),
+                else if ((strncasecmp(memo, xaccSplitGetMemo(split),
                                   strlen(xaccSplitGetMemo(split)) / 2)
                           == 0))
                 {
@@ -746,7 +746,7 @@
             const char *descr = xaccTransGetDescription(new_trans);
             if (descr && strlen(descr) != 0)
             {
-                if (safe_strcmp(descr,
+                if (safe_strcasecmp(descr,
                                 xaccTransGetDescription(xaccSplitGetParent(split)))
                         == 0)
                 {
@@ -754,7 +754,7 @@
                     prob = prob + 2;
                     /*DEBUG("heuristics:  probability + 2 (description)");*/
                 }
-                else if ((strncmp(descr,
+                else if ((strncasecmp(descr,
                                   xaccTransGetDescription (xaccSplitGetParent(split)),
                                   strlen(xaccTransGetDescription (new_trans)) / 2)
                           == 0))



More information about the gnucash-changes mailing list