[gnumeric] Calc: fix array intersection problem with IF.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Calc: fix array intersection problem with IF.
- Date: Wed, 8 Dec 2010 18:17:52 +0000 (UTC)
commit e5b9e4ecfea55ba4cacb2c29ba44e56788dc9c2b
Author: Morten Welinder <terra gnome org>
Date: Wed Dec 8 13:11:22 2010 -0500
Calc: fix array intersection problem with IF.
ChangeLog | 6 ++++++
NEWS | 3 +++
src/func-builtin.c | 9 +++------
src/func-builtin.h | 2 +-
src/func.c | 2 +-
5 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 4445cb0..8c7a2d2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-12-08 Morten Welinder <terra gnome org>
+
+ * src/func-builtin.c (gnumeric_if2): Take flags argument and use
+ it for "then" and "else" branches. Caller changed. Fixes
+ #636433.
+
2010-12-01 Morten Welinder <terra gnome org>
* src/test-pango.c: Kill warnings.
diff --git a/NEWS b/NEWS
index a895ce2..f86d2a8 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,9 @@ Andreas:
Jean:
* Only disable the formula bar when a chart sheet is selected. [#636031]
+Morten:
+ * Fix array intersection problem with IF. [#633433]
+
--------------------------------------------------------------------------
Gnumeric 1.10.12
diff --git a/src/func-builtin.c b/src/func-builtin.c
index 5d15941..3b6e2fa 100644
--- a/src/func-builtin.c
+++ b/src/func-builtin.c
@@ -299,7 +299,8 @@ gnumeric_if (GnmFuncEvalInfo *ei, GnmValue const * const *args)
GnmValue *
-gnumeric_if2 (GnmFuncEvalInfo *ei, int argc, GnmExprConstPtr const *argv)
+gnumeric_if2 (GnmFuncEvalInfo *ei, int argc, GnmExprConstPtr const *argv,
+ GnmExprEvalFlags flags)
{
gboolean err;
int i, branch;
@@ -311,7 +312,7 @@ gnumeric_if2 (GnmFuncEvalInfo *ei, int argc, GnmExprConstPtr const *argv)
/*
* In this version of IF, we evaluate the arguments ourselves,
- * the call the regular IF. However, arguments we do not need
+ * then call the regular IF. However, arguments we do not need
* we do not evaluate.
*
* IF is sometimes used to avoid expensive calculations. Always
@@ -326,10 +327,6 @@ 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++) {
- GnmExprEvalFlags flags =
- GNM_EXPR_EVAL_PERMIT_NON_SCALAR |
- GNM_EXPR_EVAL_PERMIT_EMPTY;
-
args[i] = NULL;
if (i < argc && i == branch && !gnm_expr_is_empty (argv[i])) {
args[i] = gnm_expr_eval (argv[i], ei->pos, flags);
diff --git a/src/func-builtin.h b/src/func-builtin.h
index 6adca26..30253e6 100644
--- a/src/func-builtin.h
+++ b/src/func-builtin.h
@@ -9,7 +9,7 @@ G_BEGIN_DECLS
GnmValue *gnumeric_sum (GnmFuncEvalInfo *ei, int argc, GnmExprConstPtr const *argv);
GnmValue *gnumeric_product (GnmFuncEvalInfo *ei, int argc, GnmExprConstPtr const *argv);
GnmValue *gnumeric_if (GnmFuncEvalInfo *ei, GnmValue const * const *args);
-GnmValue *gnumeric_if2 (GnmFuncEvalInfo *ei, int argc, GnmExprConstPtr const *argv);
+GnmValue *gnumeric_if2 (GnmFuncEvalInfo *ei, int argc, GnmExprConstPtr const *argv, GnmExprEvalFlags flags);
void func_builtin_init (void);
void func_builtin_shutdown (void);
diff --git a/src/func.c b/src/func.c
index 87da2e2..2928036 100644
--- a/src/func.c
+++ b/src/func.c
@@ -1479,7 +1479,7 @@ function_call_with_exprs (GnmFuncEvalInfo *ei, GnmExprEvalFlags flags)
/* Optimization for IF when implicit iteration is not used. */
if (ei->func_call->func->fn.args.func == gnumeric_if &&
iter_count == -1)
- return gnumeric_if2 (ei, argc, argv);
+ return gnumeric_if2 (ei, argc, argv, flags);
for (i = 0; i < argc; i++) {
char arg_type = fn_def->fn.args.arg_types[i];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]