[gnumeric] D-funcs: various fixes.



commit cbca44549f07e8463bdf1a903d4e913ceac9e026
Author: Morten Welinder <terra gnome org>
Date:   Sat Jun 11 12:56:36 2016 -0400

    D-funcs: various fixes.
    
    Clearly a test suite was overdue for these functions.

 ChangeLog                     |    5 +++++
 NEWS                          |    3 ++-
 samples/excel12/database.xlsx |  Bin 9985 -> 9983 bytes
 src/value.c                   |    8 ++++++--
 4 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d3a0cd7..ad1f341 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
 2016-06-11  Morten Welinder  <terra gnome org>
 
        * src/value.c (find_rows_that_match): Fix blank handling.
+       (criteria_test_unequal): Wrong type means unequal.
+       (criteria_test_match): Only match strings.
+       (parse_criteria): Don't anchor matches.  This is the right thing
+       to do for DSUM and friends.  Hopefully this doesn't break anything
+       else.
 
 2016-05-19  Morten Welinder  <terra gnome org>
 
diff --git a/NEWS b/NEWS
index 7633477..409e63b 100644
--- a/NEWS
+++ b/NEWS
@@ -4,7 +4,8 @@ Morten:
        * Improve format guessing for csv and txt files.
        * Fix DCOUNT and DCOUNTA with missing field.  [#767290]
        * Fix strictness in database functions.
-       * Improve test suite.
+       * Fix a bunch of corner cases for database functions.
+       * Add tests for database functions.
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.29
diff --git a/samples/excel12/database.xlsx b/samples/excel12/database.xlsx
index 7314eff..778e452 100644
Binary files a/samples/excel12/database.xlsx and b/samples/excel12/database.xlsx differ
diff --git a/src/value.c b/src/value.c
index 0f9efc5..16712aa 100644
--- a/src/value.c
+++ b/src/value.c
@@ -1563,7 +1563,7 @@ criteria_test_unequal (GnmValue const *x, GnmCriteria *crit)
                g_assert_not_reached ();
        case CRIT_NULL:
        case CRIT_WRONGTYPE:
-               return FALSE;
+               return TRUE;
        case CRIT_FLOAT:
                return xf != yf;
        case CRIT_STRING:
@@ -1647,6 +1647,10 @@ criteria_test_match (GnmValue const *x, GnmCriteria *crit)
        if (!crit->has_rx)
                return FALSE;
 
+       // Only strings are matched
+       if (!VALUE_IS_STRING (x))
+               return FALSE;
+
        return go_regexec (&crit->rx, value_peek_string (x), 0, NULL, 0) ==
                GO_REG_OK;
 }
@@ -1828,7 +1832,7 @@ parse_criteria (GnmValue const *crit_val, GODateConventions const *date_conv)
                len = 1;
        } else {
                res->fun = criteria_test_match;
-               res->has_rx = (gnm_regcomp_XL (&res->rx, criteria, GO_REG_ICASE, TRUE, TRUE) == GO_REG_OK);
+               res->has_rx = (gnm_regcomp_XL (&res->rx, criteria, GO_REG_ICASE, FALSE, FALSE) == GO_REG_OK);
                len = 0;
        }
 


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