[gnumeric] Criteria: "=" and "<>" are special.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Criteria: "=" and "<>" are special.
- Date: Tue, 16 Apr 2013 18:59:28 +0000 (UTC)
commit c350537706f6784ce9d00767c91a4a2366ea6f81
Author: Morten Welinder <terra gnome org>
Date: Tue Apr 16 14:58:40 2013 -0400
Criteria: "=" and "<>" are special.
These test for emptiness. Another great XL design!
ChangeLog | 3 +++
NEWS | 1 +
src/value.c | 18 ++++++++++++++++--
3 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index dfc3186..cada49b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,9 @@
* src/value.c (parse_criteria): Anchor only at start. Fixes
#661800.
+ (parse_criteria): Handle criteria "=" and "<>" (with no value
+ after the operator) special. These test for empty and non-empty
+ values. Fixes #686156.
* src/gutils.c (gnm_regcomp_XL): Split argument "full" into
"anchor_start" and "anchor_end". All callers changed.
diff --git a/NEWS b/NEWS
index c53dd15..f68e454 100644
--- a/NEWS
+++ b/NEWS
@@ -46,6 +46,7 @@ Morten:
* Fix XL import of names with array constants. [#654211]
* Fix XL import of booleans/error/empties in array constants.
* Fix database criteria anchoring. [#661800]
+ * Fix database criterias "=" and "<>" for emptiness test. [#686156]
--------------------------------------------------------------------------
Gnumeric 1.12.1
diff --git a/src/value.c b/src/value.c
index cc9d697..517cd04 100644
--- a/src/value.c
+++ b/src/value.c
@@ -1573,6 +1573,18 @@ criteria_test_match (GnmValue const *x, GnmCriteria *crit)
GO_REG_OK;
}
+static gboolean
+criteria_test_empty (GnmValue const *x, GnmCriteria *crit)
+{
+ return VALUE_IS_EMPTY (x);
+}
+
+static gboolean
+criteria_test_nonempty (GnmValue const *x, GnmCriteria *crit)
+{
+ return !VALUE_IS_EMPTY (x);
+}
+
/*
* Finds a column index of a field.
*/
@@ -1718,13 +1730,15 @@ parse_criteria (GnmValue const *crit_val, GODateConventions const *date_conv)
res->fun = criteria_test_greater_or_equal;
len = 2;
} else if (strncmp (criteria, "<>", 2) == 0) {
- res->fun = criteria_test_unequal;
+ /* "<>" by itself is special: */
+ res->fun = (criteria[2] == 0) ? criteria_test_nonempty : criteria_test_unequal;
len = 2;
} else if (*criteria == '<') {
res->fun = criteria_test_less;
len = 1;
} else if (*criteria == '=') {
- res->fun = criteria_test_equal;
+ /* "=" by itself is special: */
+ res->fun = (criteria[1] == 0) ? criteria_test_empty : criteria_test_equal;
len = 1;
} else if (*criteria == '>') {
res->fun = criteria_test_greater;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]