Commit 54534f74 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Use gnm_expr_new_range_ctor, not build_binop.

2009-01-31  Morten Welinder  <terra@gnome.org>

	* src/parser.y (build_range_ctor): Use gnm_expr_new_range_ctor,
	not build_binop.

	* src/expr.c (gnm_expr_new_range_ctor): New function.


svn path=/trunk/; revision=17120
parent 3a632184
2009-01-31 Morten Welinder <terra@gnome.org>
* src/parser.y (build_range_ctor): Use gnm_expr_new_range_ctor,
not build_binop.
* src/expr.c (gnm_expr_new_range_ctor): New function.
2009-01-30 J.H.M. Dassen (Ray) <jdassen@debian.org>
* configure.in: Change the help strings not to have curly braces in
......
......@@ -93,6 +93,7 @@ Morten:
too. Fix issues with bools versus floats.
* Fix parsing problem for constructed ranges. [#569730]
* Fix plugin menu merging. [#569724]
* Improve handling of 3D ranges. [#569372]
--------------------------------------------------------------------------
Gnumeric 1.9.3
......
2009-01-31 Morten Welinder <terra@gnome.org>
* ms-formula-read.c (excel_parse_formula1): Use
gnm_expr_new_range_ctor, not build_binop.
2009-01-23 Morten Welinder <terra@gnome.org>
* ms-excel-write.c (excel_sheet_write_block): Handle the case of a
......
......@@ -1012,8 +1012,7 @@ excel_parse_formula1 (MSContainer const *container,
case FORMULA_PTG_EQUAL :
case FORMULA_PTG_GTE : case FORMULA_PTG_GT :
case FORMULA_PTG_NOT_EQUAL :
case FORMULA_PTG_INTERSECT :
case FORMULA_PTG_RANGE : {
case FORMULA_PTG_INTERSECT : {
GnmExpr const *r = parse_list_pop (&stack);
GnmExpr const *l = parse_list_pop (&stack);
parse_list_push (&stack, gnm_expr_new_binary (
......@@ -1023,6 +1022,14 @@ excel_parse_formula1 (MSContainer const *container,
break;
}
case FORMULA_PTG_RANGE : {
GnmExpr const *r = parse_list_pop (&stack);
GnmExpr const *l = parse_list_pop (&stack);
parse_list_push (&stack,
gnm_expr_new_range_ctor (l, r));
break;
}
case FORMULA_PTG_UNION : {
GnmExpr const *r = parse_list_pop (&stack);
GnmExpr const *l = parse_list_pop (&stack);
......
......@@ -317,6 +317,40 @@ gnm_expr_new_set (GnmExprList *set)
/***************************************************************************/
/**
* gnm_expr_new_range_ctor:
* @l: start range
* @r: end range
*
* This function builds a range constructor or something simpler,
* but equivalent, if the arguments allow it.
*
* Note: this takes ownership of @l and @r and may delete them.
**/
GnmExpr const *
gnm_expr_new_range_ctor (GnmExpr const *l, GnmExpr const *r)
{
GnmValue *v;
g_return_val_if_fail (l != NULL, NULL);
g_return_val_if_fail (r != NULL, NULL);
if (GNM_EXPR_GET_OPER (l) != GNM_EXPR_OP_CELLREF)
goto fallback;
if (GNM_EXPR_GET_OPER (r) != GNM_EXPR_OP_CELLREF)
goto fallback;
v = value_new_cellrange_unsafe (&l->cellref.ref, &r->cellref.ref);
gnm_expr_free (l);
gnm_expr_free (r);
return gnm_expr_new_constant (v);
fallback:
return gnm_expr_new_binary (l, GNM_EXPR_OP_RANGE_CTOR, r);
}
/***************************************************************************/
GnmExpr const *
gnm_expr_copy (GnmExpr const *expr)
{
......
......@@ -72,6 +72,7 @@ GnmExpr const *gnm_expr_new_name (GnmNamedExpr *name,
Sheet *sheet_scope, Workbook *wb_scope);
GnmExpr const *gnm_expr_new_cellref (GnmCellRef const *cr);
GnmExpr const *gnm_expr_new_set (GnmExprList *args);
GnmExpr const *gnm_expr_new_range_ctor (GnmExpr const *l, GnmExpr const *r);
GnmValue *gnm_expr_get_range (GnmExpr const *expr);
GnmFunc *gnm_expr_get_func_def (GnmExpr const *expr);
......
......@@ -388,6 +388,8 @@ build_array (GSList *cols)
static GnmExpr *
build_range_ctor (GnmExpr *l, GnmExpr *r, GnmExpr *validate)
{
if (!l || !r) return NULL;
if (validate != NULL) {
if (GNM_EXPR_GET_OPER (validate) != GNM_EXPR_OP_CELLREF ||
validate->cellref.ref.sheet != NULL) {
......@@ -397,7 +399,10 @@ build_range_ctor (GnmExpr *l, GnmExpr *r, GnmExpr *validate)
return NULL;
}
}
return build_binop (l, GNM_EXPR_OP_RANGE_CTOR, r);
unregister_allocation (r);
unregister_allocation (l);
return register_expr_allocation (gnm_expr_new_range_ctor (l, r));
}
/*
......@@ -788,7 +793,8 @@ cellref: RANGEREF { $$ = $1; }
if ($$ == NULL) { YYERROR; }
}
| RANGEREF RANGE_SEP RANGEREF {
$$ = build_binop ($1, GNM_EXPR_OP_RANGE_CTOR, $3);
$$ = build_range_ctor ($1, $3, NULL);
if ($$ == NULL) { YYERROR; }
}
;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment