~ubuntu-branches/ubuntu/feisty/gnumeric/feisty

« back to all changes in this revision

Viewing changes to src/func.c

  • Committer: Bazaar Package Importer
  • Author(s): Gauvain Pocentek
  • Date: 2006-11-14 14:02:03 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20061114140203-iv3j2aii3vch6isl
Tags: 1.7.2-1ubuntu1
* Merge with debian experimental:
  - debian/control, debian/*-gtk-*, debian/rules,
    debian/shlibs.local: Xubuntu changes for
    gtk/gnome multibuild.
  - run intltool-update in po*
  - Build Depend on intltool

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 *  Jody Goldberg   (jody@gnome.org)
11
11
 */
12
12
#include <gnumeric-config.h>
13
 
#include <glib/gi18n.h>
 
13
#include <glib/gi18n-lib.h>
14
14
#include <glib/gstdio.h>
15
15
#include "gnumeric.h"
16
16
#include "func.h"
1050
1050
                return value_new_error_NA (ei->pos);
1051
1051
 
1052
1052
        args = g_alloca (sizeof (GnmValue *) * fn_def->fn.args.max_args);
1053
 
        iter_count = (flags & GNM_EXPR_EVAL_PERMIT_NON_SCALAR) ? 0 : -1;
 
1053
        iter_count = (ei->pos->array != NULL &&
 
1054
                      (flags & GNM_EXPR_EVAL_PERMIT_NON_SCALAR))
 
1055
                ? 0 : -1;
1054
1056
 
1055
1057
        for (i = 0; i < argc; i++) {
1056
1058
                char arg_type = fn_def->fn.args.arg_types[i];
1063
1065
                                GnmCellRef r;
1064
1066
                                gnm_cellref_make_abs (&r, &expr->cellref.ref, ei->pos);
1065
1067
                                args[i] = value_new_cellrange_unsafe (&r, &r);
1066
 
                                /* TODO decide on the semantics of these argument types */
1067
 
#warning "Do we need to force an eval here?"
1068
1068
                        } else {
1069
1069
                                tmp = args[i] = gnm_expr_eval (expr, ei->pos,
1070
1070
                                        GNM_EXPR_EVAL_PERMIT_NON_SCALAR);
1223
1223
                                                } else if (VALUE_IS_ERROR (elem)) {
1224
1224
                                                        err = elem;
1225
1225
                                                        break;
1226
 
                                                } else if (!VALUE_IS_STRING (tmp))
 
1226
                                                } else if (!VALUE_IS_STRING (elem))
1227
1227
                                                        break;
1228
1228
                                        } else if (elem == NULL) {
1229
1229
                                                args [iter_item[i]] = iter_args [i] = value_new_empty ();
1318
1318
        gboolean           ignore_subtotal;
1319
1319
} IterateCallbackClosure;
1320
1320
 
1321
 
/*
 
1321
/**
1322
1322
 * cb_iterate_cellrange:
1323
1323
 *
1324
1324
 * Helper routine used by the function_iterate_do_value routine.
1325
1325
 * Invoked by the sheet cell range iterator.
1326
 
 */
 
1326
 **/
1327
1327
static GnmValue *
1328
 
cb_iterate_cellrange (Sheet *sheet, int col, int row,
1329
 
                      GnmCell *cell, gpointer user_data)
 
1328
cb_iterate_cellrange (GnmCellIter const *iter, gpointer user)
 
1329
                      
1330
1330
{
1331
 
        IterateCallbackClosure *data = user_data;
 
1331
        IterateCallbackClosure *data = user;
 
1332
        GnmCell  *cell;
1332
1333
        GnmValue *res;
1333
1334
        GnmEvalPos ep;
1334
1335
 
1335
 
        if (cell == NULL) {
1336
 
                ep.sheet = sheet;
 
1336
        if (NULL == (cell = iter->cell)) {
 
1337
                ep.sheet = iter->pp.sheet;
1337
1338
                ep.dep = NULL;
1338
 
                ep.eval.col = col;
1339
 
                ep.eval.row = row;
 
1339
                ep.eval.col = iter->pp.eval.col;
 
1340
                ep.eval.row = iter->pp.eval.row;
1340
1341
                return (*data->callback)(&ep, NULL, data->closure);
1341
1342
        }
1342
1343
 
1483
1484
 
1484
1485
                /* We need a cleaner model of what to do here.  For now it
1485
1486
                 * seems as if var-arg functions treat explict ranges as special cases
1486
 
                 *      SUM(Range)
 
1487
                 *      SUM(Range) or
 
1488
                 *      SUM(INDIRECT(foo))
1487
1489
                 * will pass the range not do implicit intersection in non-array mode
1488
1490
                 *      SUM(Range=3)
1489
1491
                 * will do implicit intersection in non-array mode */
1490
1492
                if (GNM_EXPR_GET_OPER (expr) == GNM_EXPR_OP_CONSTANT)
1491
1493
                        val = value_dup (expr->constant.value);
1492
 
                else if (ep->array != NULL)
 
1494
                else if (ep->array != NULL ||
 
1495
                         GNM_EXPR_GET_OPER (expr) == GNM_EXPR_OP_FUNCALL)
1493
1496
                        val = gnm_expr_eval (expr, ep,
1494
1497
                                GNM_EXPR_EVAL_PERMIT_EMPTY | GNM_EXPR_EVAL_PERMIT_NON_SCALAR);
1495
1498
                else
1501
1504
 
1502
1505
                if (strict && VALUE_IS_ERROR (val)) {
1503
1506
                        /* Be careful not to make VALUE_TERMINATE into a real value */
1504
 
                        /* FIXME : Make the new position of the error here */
1505
1507
                        return val;
1506
1508
                }
1507
1509