[gnumeric] IF: Fix problem with empty and array results.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnumeric] IF: Fix problem with empty and array results.
- Date: Thu, 18 Jun 2009 16:51:52 -0400 (EDT)
commit 8da662850e797b1c24bfb54f0625492def9e595c
Author: Morten Welinder <terra gnome org>
Date: Thu Jun 18 16:51:27 2009 -0400
IF: Fix problem with empty and array results.
ChangeLog | 5 +++++
NEWS | 1 +
src/func-builtin.c | 17 ++++++++++++-----
3 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 85e53b0..f0bdb33 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-06-18 Morten Welinder <terra gnome org>
+
+ * src/func-builtin.c (gnumeric_if2): Allow empty and array results
+ results.
+
2009-06-18 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/expr.h (gnm_func_lookup_or_add_placeholder): new
diff --git a/NEWS b/NEWS
index d3b375b..a55dedf 100644
--- a/NEWS
+++ b/NEWS
@@ -49,6 +49,7 @@ Morten:
* Start introducing external references for function docs.
* Implement new functions COTH and ACOTH. [#586170]
* Fix tsa crash. [#586191]
+ * Fix IF problem with empties and arrays. [#586218]
--------------------------------------------------------------------------
Gnumeric 1.9.8
diff --git a/src/func-builtin.c b/src/func-builtin.c
index 7438bd7..e03caf5 100644
--- a/src/func-builtin.c
+++ b/src/func-builtin.c
@@ -331,11 +331,18 @@ gnumeric_if2 (GnmFuncEvalInfo *ei, int argc, GnmExprConstPtr const *argv)
branch = value_get_as_bool (args[0], &err) ? 1 : 2;
for (i = 1; i <= 2; i++) {
- args[i] = argc > i
- ? (branch == i ?
- gnm_expr_eval (argv[branch], ei->pos, 0)
- : value_new_empty ())
- : NULL;
+ GnmExprEvalFlags flags =
+ GNM_EXPR_EVAL_PERMIT_NON_SCALAR |
+ GNM_EXPR_EVAL_PERMIT_EMPTY;
+
+ if (i >= argc)
+ args[i] = NULL;
+ else if (branch == i) {
+ args[i] = gnm_expr_eval (argv[branch], ei->pos, flags);
+ if (!args[i])
+ args[i] = value_new_empty ();
+ } else
+ args[i] = value_new_empty ();
}
res = gnumeric_if (ei, (GnmValue const * const *)args);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]