Commit 1bf8eac5 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Replace expression list by argc/argv members. All users fixed.

2006-02-19  Morten Welinder  <terra@gnome.org>

	* src/expr-impl.h (GnmExprFunction, GnmExprSet): Replace
	expression list by argc/argv members.  All users fixed.

	* src/func.c (function_call_with_exprs): Renamed from
	function_call_with_list and changed to argc/argv input.  All
	callers changed.

	* src/auto-format.c (do_af_suggest_list): Changed to argc/argv
	input.  All callers changed.

	* src/expr.c (gnm_expr_list_equal, gnm_expr_list_eq): Remove.

	* src/mstyle.c (gnm_style_dump): Dump non-localized format.
parent 33487eff
2006-02-19 Morten Welinder <terra@gnome.org>
* src/expr-impl.h (GnmExprFunction, GnmExprSet): Replace
expression list by argc/argv members. All users fixed.
* src/func.c (function_call_with_exprs): Renamed from
function_call_with_list and changed to argc/argv input. All
callers changed.
* src/auto-format.c (do_af_suggest_list): Changed to argc/argv
input. All callers changed.
* src/expr.c (gnm_expr_list_equal, gnm_expr_list_eq): Remove.
* src/mstyle.c (gnm_style_dump): Dump non-localized format.
2006-02-18 Morten Welinder <terra@gnome.org>
* src/wbc-gtk.c (toolbar_context_menu): Add an entry to hide the
......
......@@ -80,6 +80,7 @@ Morten:
* Fix bogus duplicate-accelerator warnings. [#324692]
* Fix criticals relating to toolbar combos for very narrow windows.
* Allow vertical toolbars.
* Save a bit of memory for function calls.
Jon Kåre:
* Hand clipboard off to clipboard manager when exiting.
......
2006-02-19 Morten Welinder <terra@gnome.org>
* src/expr-impl.h (GnmExprFunction, GnmExprSet): Replace
expression list by argc/argv members. All users fixed.
* src/func.c (function_call_with_exprs): Renamed from
function_call_with_list and changed to argc/argv input. All
callers changed.
* src/auto-format.c (do_af_suggest_list): Changed to argc/argv
input. All callers changed.
* src/expr.c (gnm_expr_list_equal, gnm_expr_list_eq): Remove.
* src/mstyle.c (gnm_style_dump): Dump non-localized format.
2006-02-18 Morten Welinder <terra@gnome.org>
* src/wbc-gtk.c (toolbar_context_menu): Add an entry to hide the
......
......@@ -984,14 +984,20 @@ excel_parse_formula (MSContainer const *container,
/* not exactly legal, but should be reasonable
* XL has union operator we have sets.
*/
*/
if (GNM_EXPR_GET_OPER (l) != GNM_EXPR_OP_SET) {
GnmExprList *args = gnm_expr_list_prepend (NULL, r);
args = gnm_expr_list_prepend (args, l);
parse_list_push (&stack, gnm_expr_new_set (args));
} else {
gnm_expr_list_append (l->set.set, r);
parse_list_push (&stack, l);
/* Barf! -- MW. */
GnmExpr *ll = (GnmExpr *)l;
GnmExpr *rr = (GnmExpr *)r;
ll->set.argc++;
ll->set.argv = g_renew (GnmExpr *,
ll->set.argv,
ll->set.argc);
ll->set.argv[ll->set.argc - 1] = rr;
}
break;
}
......
......@@ -99,12 +99,11 @@ excel_write_prep_expr (ExcelWriteState *ewb, GnmExpr const *expr)
case GNM_EXPR_OP_FUNCALL: {
GnmFunc *func = expr->func.func;
GnmExprList *l;
ExcelFunc *ef = g_hash_table_lookup (ewb->function_map, func);
int i;
for (l = expr->func.arg_list; l; l = l->next)
excel_write_prep_expr (ewb, l->data);
for (i = 0; i < expr->func.argc; i++)
excel_write_prep_expr (ewb, expr->func.argv[i]);
if (ef != NULL)
return;
......@@ -142,10 +141,10 @@ excel_write_prep_expr (ExcelWriteState *ewb, GnmExpr const *expr)
break;
case GNM_EXPR_OP_SET: {
GnmExprList *l;
int i;
for (l = expr->set.set; l; l = l->next)
excel_write_prep_expr (ewb, l->data);
for (i = 0; i < expr->set.argc; i++)
excel_write_prep_expr (ewb, expr->set.argv[i]);
break;
}
......@@ -488,11 +487,10 @@ write_funcall (PolishData *pd, GnmExpr const *expr,
{
static guint8 const zeros [12];
int num_args = 0;
int arg;
gboolean prompt = FALSE;
gboolean cmdequiv = FALSE;
char const *arg_types = NULL;
GnmExprList *ptr;
GnmFunc *func = expr->func.func;
ExcelFunc *ef = g_hash_table_lookup (pd->ewb->function_map, func);
XLOpType arg_type = XL_VAL; /* default */
......@@ -525,11 +523,11 @@ write_funcall (PolishData *pd, GnmExpr const *expr,
} else
arg_types = ef->efunc->known_args;
for (ptr = expr->func.arg_list ; ptr != NULL; ptr = ptr->next, num_args++)
if (ef->efunc != NULL && num_args >= ef->efunc->max_args) {
for (arg = 0; arg < expr->func.argc; arg++)
if (ef->efunc != NULL && arg >= ef->efunc->max_args) {
gnm_io_warning (pd->ewb->io_context,
_("Too many arguments for function '%s', MS Excel can only handle %d not %d"),
ef->efunc->name, ef->efunc->max_args, num_args);
ef->efunc->name, ef->efunc->max_args, arg);
break;
} else { /* convert the args */
if (arg_types != NULL && *arg_types) {
......@@ -537,7 +535,7 @@ write_funcall (PolishData *pd, GnmExpr const *expr,
if (arg_types[1])
arg_types++;
}
write_node (pd, ptr->data, 0, arg_type);
write_node (pd, expr->func.argv[arg], 0, arg_type);
}
if (ef->efunc != NULL) {
......@@ -551,12 +549,12 @@ write_funcall (PolishData *pd, GnmExpr const *expr,
/* If XL requires more arguments than we do
* pad the remainder with missing args */
for ( ; num_args < ef->efunc->min_args ; num_args++)
for ( ; arg < ef->efunc->min_args ; arg++)
push_guint8 (pd, FORMULA_PTG_MISSARG);
if (ef->efunc->min_args != ef->efunc->max_args) {
push_guint8 (pd, FORMULA_PTG_FUNC_VAR + op_class);
push_guint8 (pd, num_args | (prompt ? 0x80 : 0));
push_guint8 (pd, arg | (prompt ? 0x80 : 0));
push_guint16 (pd, ef->idx | (cmdequiv ? 0x8000 : 0));
} else {
push_guint8 (pd, FORMULA_PTG_FUNC + op_class);
......@@ -565,7 +563,7 @@ write_funcall (PolishData *pd, GnmExpr const *expr,
} else { /* Undocumented, assume result is XL_VAL */
push_guint8 (pd, FORMULA_PTG_FUNC_VAR +
xl_get_op_class (pd, XL_VAL, target_type));
push_guint8 (pd, (num_args+1) | (prompt ? 0x80 : 0));
push_guint8 (pd, (arg + 1) | (prompt ? 0x80 : 0));
push_guint16 (pd, 0xff | (cmdequiv ? 0x8000 : 0));
}
}
......
......@@ -488,7 +488,7 @@ gnumeric_areas (FunctionEvalInfo *ei, GnmExprList const *l)
break;
case GNM_EXPR_OP_SET:
res = gnm_expr_list_length (expr->set.set);
res = expr->set.argc;
break;
default:
......@@ -900,8 +900,10 @@ gnumeric_index (FunctionEvalInfo *ei, GnmExprList const *l)
}
if (GNM_EXPR_GET_OPER (source) == GNM_EXPR_OP_SET) {
source = gnm_expr_list_nth (source->set.set, elem[2]);
if (elem[2] < 0 || source == NULL)
source = (elem[2] >= 0 && elem[2] < source->set.argc)
? source->set.argv[elem[2]]
: NULL;
if (source == NULL)
return value_new_error_REF (ei->pos);
} else if (elem[2] != 0)
return value_new_error_REF (ei->pos);
......
......@@ -48,7 +48,7 @@ typedef struct {
typedef GObjectClass GnmPerlPluginLoaderClass;
static GnmValue*
call_perl_function_args (FunctionEvalInfo *ei, GnmValue **args)
call_perl_function_args (FunctionEvalInfo *ei, GnmValue const * const *args)
{
GnmFunc const *fndef;
gint min_n_args, max_n_args, n_args;
......
......@@ -58,7 +58,8 @@
#define AF_EXPLICIT ((GnmFuncFlags)(GNM_FUNC_AUTO_MASK + 1))
static GnmFuncFlags do_af_suggest_list (GnmExprList *list,
static GnmFuncFlags do_af_suggest_list (int argc,
GnmExpr **argv,
GnmEvalPos const *epos,
GOFormat **explicit);
......@@ -152,15 +153,14 @@ do_af_suggest (GnmExpr const *expr, const GnmEvalPos *epos, GOFormat **explicit)
switch (typ) {
case GNM_FUNC_AUTO_FIRST:
return do_af_suggest_list (expr->func.arg_list,
return do_af_suggest_list (expr->func.argc,
expr->func.argv,
epos, explicit);
case GNM_FUNC_AUTO_SECOND: {
GnmExprList *l;
l = expr->func.arg_list;
if (l) l = l->next;
return do_af_suggest_list (l, epos, explicit);
}
case GNM_FUNC_AUTO_SECOND:
return do_af_suggest_list (expr->func.argc - 1,
expr->func.argv + 1,
epos, explicit);
default:
return typ;
......@@ -236,14 +236,19 @@ do_af_suggest (GnmExpr const *expr, const GnmEvalPos *epos, GOFormat **explicit)
}
static GnmFuncFlags
do_af_suggest_list (GnmExprList *list, const GnmEvalPos *epos, GOFormat **explicit)
do_af_suggest_list (int argc, GnmExpr **argv,
const GnmEvalPos *epos, GOFormat **explicit)
{
GnmFuncFlags typ = GNM_FUNC_AUTO_UNKNOWN;
while (list && (typ == GNM_FUNC_AUTO_UNKNOWN || typ == GNM_FUNC_AUTO_UNITLESS)) {
typ = do_af_suggest (list->data, epos, explicit);
list = list->next;
int i;
for (i = 0; i < argc; i++) {
GnmFuncFlags typ = do_af_suggest (argv[i], epos, explicit);
if (typ != GNM_FUNC_AUTO_UNKNOWN &&
typ != GNM_FUNC_AUTO_UNITLESS)
return typ;
}
return typ;
return GNM_FUNC_AUTO_UNKNOWN;
}
/* ------------------------------------------------------------------------- */
......
......@@ -737,7 +737,7 @@ link_expr_dep (GnmEvalPos *ep, GnmExpr const *tree)
/* TODO : Can we use argument types to be smarter here ? */
case GNM_EXPR_OP_FUNCALL: {
GnmExprList *l;
int i;
DependentFlags flag = DEPENDENT_NO_FLAG;
if (tree->func.func->fn_type == GNM_FUNC_TYPE_STUB)
gnm_func_load_stub (tree->func.func);
......@@ -748,8 +748,8 @@ link_expr_dep (GnmEvalPos *ep, GnmExpr const *tree)
flag = tree->func.func->linker (&fei);
}
if (!(flag & DEPENDENT_IGNORE_ARGS))
for (l = tree->func.arg_list; l; l = l->next)
flag |= link_expr_dep (ep, l->data);
for (i = 0; i < tree->func.argc; i++)
flag |= link_expr_dep (ep, tree->func.argv[i]);
return flag;
}
......@@ -785,11 +785,11 @@ link_expr_dep (GnmEvalPos *ep, GnmExpr const *tree)
}
case GNM_EXPR_OP_SET: {
GnmExprList *l;
int i;
DependentFlags res = DEPENDENT_NO_FLAG;
for (l = tree->set.set; l; l = l->next)
res |= link_expr_dep (ep, l->data);
for (i = 0; i < tree->set.argc; i++)
res |= link_expr_dep (ep, tree->set.argv[i]);
return res;
}
case GNM_EXPR_OP_RANGE_CTOR:
......@@ -832,7 +832,7 @@ unlink_expr_dep (GnmDependent *dep, GnmExpr const *tree)
* more cunning handling of argument type matching.
*/
case GNM_EXPR_OP_FUNCALL: {
GnmExprList *l;
int i;
if (tree->func.func->unlinker) {
GnmEvalPos ep;
FunctionEvalInfo fei;
......@@ -840,8 +840,8 @@ unlink_expr_dep (GnmDependent *dep, GnmExpr const *tree)
fei.func_call = &tree->func;
tree->func.func->unlinker (&fei);
}
for (l = tree->func.arg_list; l; l = l->next)
unlink_expr_dep (dep, l->data);
for (i = 0; i < tree->func.argc; i++)
unlink_expr_dep (dep, tree->func.argv[i]);
return;
}
......@@ -873,10 +873,10 @@ unlink_expr_dep (GnmDependent *dep, GnmExpr const *tree)
return;
case GNM_EXPR_OP_SET: {
GnmExprList *l;
int i;
for (l = tree->set.set; l; l = l->next)
unlink_expr_dep (dep, l->data);
for (i = 0; i < tree->set.argc; i++)
unlink_expr_dep (dep, tree->set.argv[i]);
return;
}
......
......@@ -445,10 +445,6 @@ dialog_formula_guru_load_expr (GtkTreePath const *parent_path, gint child_num,
GnmExpr const *expr, FormulaGuruState *state)
{
GtkTreePath *path;
char *text;
GSList *args;
GtkTreeIter iter;
int i;
if (parent_path == NULL)
path = gtk_tree_path_new_first ();
......@@ -459,26 +455,32 @@ dialog_formula_guru_load_expr (GtkTreePath const *parent_path, gint child_num,
}
switch (GNM_EXPR_GET_OPER (expr)) {
case GNM_EXPR_OP_FUNCALL:
case GNM_EXPR_OP_FUNCALL: {
int i;
GtkTreeIter iter;
dialog_formula_guru_load_fd (path, expr->func.func, state);
for (args = expr->func.arg_list, i = 0; args; args = args->next, i++)
for (i = 0; i < expr->func.argc; i++)
dialog_formula_guru_load_expr (path, i,
(GnmExpr const *) args->data,
expr->func.argv[i],
state);
gtk_tree_path_append_index (path, i - 1);
gtk_tree_path_append_index (path, MAX (0, i - 1));
if (gtk_tree_model_get_iter (GTK_TREE_MODEL (state->model),
&iter, path))
dialog_formula_guru_adjust_varargs (&iter, state);
break;
}
case GNM_EXPR_OP_ANY_BINARY:
case GNM_EXPR_OP_UNARY_NEG:
default:
text = gnm_expr_as_string (expr, state->pos,
default: {
char *text = gnm_expr_as_string (expr, state->pos,
gnm_expr_conventions_default);
dialog_formula_guru_load_string (path, text, state);
g_free (text);
break;
}
}
gtk_tree_path_free (path);
......
......@@ -14,8 +14,9 @@ struct _GnmExprConstant {
struct _GnmExprFunction {
guint32 oper_and_refcount;
int argc;
GnmFunc *func;
GnmExprList *arg_list;
GnmExpr **argv;
};
struct _GnmExprUnary {
......@@ -55,7 +56,8 @@ struct _GnmExprArrayElem {
struct _GnmExprSet {
guint32 oper_and_refcount;
GnmExprList *set;
int argc;
GnmExpr **argv;
};
union _GnmExpr {
......
......@@ -358,9 +358,9 @@ expr_name_check_for_loop (char const *name, GnmExpr const *expr)
return FALSE;
}
case GNM_EXPR_OP_FUNCALL: {
GnmExprList *l = expr->func.arg_list;
for (; l ; l = l->next)
if (expr_name_check_for_loop (name, l->data))
int i;
for (i = 0; i < expr->func.argc; i++)
if (expr_name_check_for_loop (name, expr->func.argv[i]))
return TRUE;
break;
}
......@@ -370,9 +370,9 @@ expr_name_check_for_loop (char const *name, GnmExpr const *expr)
case GNM_EXPR_OP_ARRAY_ELEM:
break;
case GNM_EXPR_OP_SET: {
GnmExprList *l = expr->set.set;
for (; l ; l = l->next)
if (expr_name_check_for_loop (name, l->data))
int i;
for (i = 0; i < expr->set.argc; i++)
if (expr_name_check_for_loop (name, expr->set.argv[i]))
return TRUE;
break;
}
......
......@@ -129,7 +129,15 @@ gnm_expr_new_funcall (GnmFunc *func, GnmExprList *arg_list)
GNM_EXPR_SET_OPER_REF1 (ans, GNM_EXPR_OP_FUNCALL);
gnm_func_ref (func);
ans->func = func;
ans->arg_list = arg_list;
ans->argc = gnm_expr_list_length (arg_list);
if (arg_list) {
int i;
ans->argv = g_new (GnmExpr *, ans->argc);
for (i = 0; arg_list; i++, arg_list = arg_list->next)
ans->argv[i] = arg_list->data;
gnm_expr_list_free (arg_list);
} else
ans->argv = NULL;
return (GnmExpr *)ans;
}
......@@ -322,7 +330,15 @@ gnm_expr_new_set (GnmExprList *set)
return NULL;
GNM_EXPR_SET_OPER_REF1 (ans, GNM_EXPR_OP_SET);
ans->set = set;
ans->argc = gnm_expr_list_length (set);
if (set) {
int i;
ans->argv = g_new (GnmExpr *, ans->argc);
for (i = 0; set; i++, set = set->next)
ans->argv[i] = set->data;
gnm_expr_list_unref (set);
} else
ans->argv = NULL;
return (GnmExpr *)ans;
}
......@@ -361,11 +377,15 @@ do_gnm_expr_unref (GnmExpr const *expr)
CHUNK_FREE (expression_pool_small, (gpointer)expr);
break;
case GNM_EXPR_OP_FUNCALL:
gnm_expr_list_unref (expr->func.arg_list);
case GNM_EXPR_OP_FUNCALL: {
int i;
for (i = 0; i < expr->func.argc; i++)
do_gnm_expr_unref (expr->func.argv[i]);
gnm_func_unref (expr->func.func);
CHUNK_FREE (expression_pool_small, (gpointer)expr);
break;
}
case GNM_EXPR_OP_NAME:
expr_name_unref (expr->name.name);
......@@ -397,10 +417,14 @@ do_gnm_expr_unref (GnmExpr const *expr)
CHUNK_FREE (expression_pool_small, (gpointer)expr);
break;
case GNM_EXPR_OP_SET:
gnm_expr_list_unref (expr->set.set);
case GNM_EXPR_OP_SET: {
int i;
for (i = 0; i < expr->set.argc; i++)
do_gnm_expr_unref (expr->set.argv[i]);
CHUNK_FREE (expression_pool_small, (gpointer)expr);
break;
}
#ifndef DEBUG_SWITCH_ENUM
default:
......@@ -468,9 +492,18 @@ gnm_expr_equal (GnmExpr const *a, GnmExpr const *b)
case GNM_EXPR_OP_ANY_UNARY:
return gnm_expr_equal (a->unary.value, b->unary.value);
case GNM_EXPR_OP_FUNCALL:
return (a->func.func == b->func.func) &&
gnm_expr_list_equal (a->func.arg_list, b->func.arg_list);
case GNM_EXPR_OP_FUNCALL: {
int i;
if (a->func.func != b->func.func ||
a->func.argc != b->func.argc)
return FALSE;
for (i = 0; i < a->func.argc; i++)
if (!gnm_expr_equal (a->func.argv[i], b->func.argv[i]))
return FALSE;
return TRUE;
}
case GNM_EXPR_OP_NAME:
return a->name.name == b->name.name &&
......@@ -497,8 +530,17 @@ gnm_expr_equal (GnmExpr const *a, GnmExpr const *b)
return aa->x == ab->x && aa->y == ab->y;
}
case GNM_EXPR_OP_SET:
return gnm_expr_list_equal (a->set.set, b->set.set);
case GNM_EXPR_OP_SET: {
int i;
if (a->set.argc != b->set.argc)
return FALSE;
for (i = 0; i < a->set.argc; i++)
if (!gnm_expr_equal (a->set.argv[i], b->set.argv[i]))
return FALSE;
return TRUE;
}
}
return FALSE;
......@@ -530,9 +572,12 @@ gnm_expr_extract_ref (GnmRangeRef *res, GnmExpr const *expr,
GnmValue *v;
FunctionEvalInfo ei;
ei.pos = pos;
ei.func_call = (GnmExprFunction const *)expr;
ei.func_call = &expr->func;
v = function_call_with_list (&ei, expr->func.arg_list, flags);
v = function_call_with_exprs (&ei,
expr->func.argc,
expr->func.argv,
flags);
if (v != NULL) {
if (v->type == VALUE_CELLRANGE) {
*res = v->v_range.cell;
......@@ -1272,8 +1317,11 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
case GNM_EXPR_OP_FUNCALL: {
FunctionEvalInfo ei;
ei.pos = pos;
ei.func_call = (GnmExprFunction const *)expr;
res = function_call_with_list (&ei, expr->func.arg_list, flags);
ei.func_call = &expr->func;
res = function_call_with_exprs (&ei,
expr->func.argc,
expr->func.argv,
flags);
if (res == NULL)
return (flags & GNM_EXPR_EVAL_PERMIT_EMPTY)
? NULL : value_new_int (0);
......@@ -1400,7 +1448,8 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
static void
gnm_expr_list_as_string (GString *target,
GnmExprList const *list, GnmParsePos const *pp,
int argc, GnmExpr **argv,
GnmParsePos const *pp,
GnmExprConventions const *fmt);
......@@ -1501,12 +1550,13 @@ do_expr_as_string (GString *target, GnmExpr const *expr, GnmParsePos const *pp,
}
case GNM_EXPR_OP_FUNCALL: {
GnmExprList const * const arg_list = expr->func.arg_list;
char const *name = gnm_func_get_name (expr->func.func);
const GnmExprFunction *func = &expr->func;
char const *name = gnm_func_get_name (func->func);
g_string_append (target, name);
/* FIXME: possibly a space here. */
gnm_expr_list_as_string (target, arg_list, pp, conv);
gnm_expr_list_as_string (target, func->argc, func->argv,
pp, conv);
return;
}
......@@ -1566,7 +1616,10 @@ do_expr_as_string (GString *target, GnmExpr const *expr, GnmParsePos const *pp,
}
case GNM_EXPR_OP_SET:
gnm_expr_list_as_string (target, expr->set.set, pp, conv);
gnm_expr_list_as_string (target,
expr->set.argc,
expr->set.argv,
pp, conv);
return;
}
......@@ -1866,22 +1919,23 @@ gnm_expr_rewrite (GnmExpr const *expr, GnmExprRewriteInfo const *rwinfo)
case GNM_EXPR_OP_FUNCALL: {
gboolean rewrite = FALSE;
GnmExprList *new_args = NULL;
GnmExprList *l;
int i;
for (l = expr->func.arg_list; l; l = l->next) {
GnmExpr const *arg = gnm_expr_rewrite (l->data, rwinfo);
/* FIXME: Quite inefficient! */
for (i = 0; i < expr->func.argc; i++) {
GnmExpr const *arg =
gnm_expr_rewrite (expr->func.argv[i], rwinfo);
new_args = gnm_expr_list_append (new_args, arg);
if (arg != NULL)
rewrite = TRUE;
}
if (rewrite) {
GnmExprList *m;
GnmExprList *m = new_args;
for (l = expr->func.arg_list, m = new_args; l; l = l->next, m = m->next) {
for (i = 0; i < expr->func.argc; i++, m = m->next)
if (m->data == NULL)
gnm_expr_ref ((m->data = l->data));
}
gnm_expr_ref ((m->data = expr->func.argv[i]));
return gnm_expr_new_funcall (expr->func.func, new_args);
}
......@@ -1891,21 +1945,22 @@ gnm_expr_rewrite (GnmExpr const *expr, GnmExprRewriteInfo const *rwinfo)
case GNM_EXPR_OP_SET: {
gboolean rewrite = FALSE;
GnmExprList *new_set = NULL;
GnmExprList *l;
int i;
for (l = expr->set.set; l; l = l->next) {
GnmExpr const *arg = gnm_expr_rewrite (l->data, rwinfo);
for (i = 0; i < expr->set.argc; i++) {
GnmExpr const *arg =
gnm_expr_rewrite (expr->set.argv[i], rwinfo);
new_set = gnm_expr_list_append (new_set, arg);
if (arg != NULL)
rewrite = TRUE;
}
if (rewrite) {
GnmExprList *m;
GnmExprList *m = new_set;
for (l = expr->set.set, m = new_set; l; l = l->next, m = m->next) {
for (i = 0; i < expr->set.argc; i++, m = m->next) {
if (m->data == NULL)
gnm_expr_ref ((m->data = l->data));
gnm_expr_ref ((m->data = expr->set.argv[i]));
}
return gnm_expr_new_set (new_set);
......@@ -2072,7 +2127,7 @@ gnm_expr_get_func_argcount (GnmExpr const *expr)
g_return_val_if_fail (expr != NULL, 0);
g_return_val_if_fail (GNM_EXPR_GET_OPER (expr) == GNM_EXPR_OP_FUNCALL, 0);
return g_slist_length (expr->func.arg_list);
return expr->func.argc;
}
......@@ -2170,15 +2225,17 @@ do_referenced_sheets (GnmExpr const *expr, GSList *sheets)
return do_referenced_sheets (expr->unary.value, sheets);
case GNM_EXPR_OP_FUNCALL: {
GnmExprList *l;
for (l = expr->func.arg_list; l; l = l->next)
sheets = do_referenced_sheets (l->data, sheets);
int i;
for (i = 0; i < expr->func.argc; i++)
sheets = do_referenced_sheets (expr->func.argv[i],