[gnumeric] D-funcs: make strict, except DCOUNT and DCOUNTA.



commit c273c69ee63c0e30e13917c811eba8ddc3d09d30
Author: Morten Welinder <terra gnome org>
Date:   Fri Jun 10 15:08:53 2016 -0400

    D-funcs: make strict, except DCOUNT and DCOUNTA.

 plugins/fn-database/ChangeLog   |    4 ++++
 plugins/fn-database/functions.c |   15 ++++++++++++---
 samples/excel12/database.xlsx   |  Bin 5884 -> 6501 bytes
 3 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/plugins/fn-database/ChangeLog b/plugins/fn-database/ChangeLog
index ce22faa..cce9662 100644
--- a/plugins/fn-database/ChangeLog
+++ b/plugins/fn-database/ChangeLog
@@ -1,3 +1,7 @@
+2016-06-10  Morten Welinder  <terra gnome org>
+
+       * functions.c (database_find_values): Make the float case strict.
+
 2016-06-09  Morten Welinder  <terra gnome org>
 
        * functions.c (database_find_values): Accept also
diff --git a/plugins/fn-database/functions.c b/plugins/fn-database/functions.c
index f14bb5b..e5c34e8 100644
--- a/plugins/fn-database/functions.c
+++ b/plugins/fn-database/functions.c
@@ -172,6 +172,8 @@ database_find_values (Sheet *sheet, GnmValue const *database,
                g_warning ("unsupported flags in database_find_values %x", flags);
        }
 
+       *error = NULL;
+
        /* FIXME: expand and sanitise this call later.  */
        cells = find_cells_that_match (sheet, database, col, criterias);
        cellcount = g_slist_length (cells);
@@ -193,15 +195,22 @@ database_find_values (Sheet *sheet, GnmValue const *database,
                        continue;
                if ((flags & COLLECT_IGNORE_ERRORS) && VALUE_IS_ERROR (value))
                        continue;
-               if (floats)
+               if (floats) {
+                       if (VALUE_IS_ERROR (value)) {
+                               // We're strict.
+                               *error = value_dup (value);
+                               g_free (res);
+                               res = NULL;
+                               break;
+                       }
                        res1[count++] = value_get_as_float (value);
-               else
+               } else {
                        res2[count++] = value;
+               }
        }
 
        *pcount = count;
        g_slist_free (cells);
-       *error = NULL;
        return res;
 }
 
diff --git a/samples/excel12/database.xlsx b/samples/excel12/database.xlsx
index b11b05f..6038cd3 100644
Binary files a/samples/excel12/database.xlsx and b/samples/excel12/database.xlsx differ


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