Commit 79c92bf5 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Fix error handling, I hope.

2002-04-15  Morten Welinder  <terra@diku.dk>

	* fn-math.c (gnumeric_subtotal): Fix error handling, I hope.

2002-04-15  Morten Welinder  <terra@diku.dk>

	* *.c: Include <gnumeric-config.h> as needed.

2002-04-15  Morten Welinder  <terra@diku.dk>

	* *.c: Include <gnumeric-config.h> as needed.
parent a9880973
...@@ -2818,28 +2818,22 @@ static const char *help_subtotal = { ...@@ -2818,28 +2818,22 @@ static const char *help_subtotal = {
static Value * static Value *
gnumeric_subtotal (FunctionEvalInfo *ei, GnmExprList *expr_node_list) gnumeric_subtotal (FunctionEvalInfo *ei, GnmExprList *expr_node_list)
{ {
GnmExpr *tree; const GnmExpr *tree;
Value *val; Value *val;
int fun_nbr; int fun_nbr;
if (expr_node_list == NULL) if (expr_node_list == NULL)
return value_new_error (ei->pos, gnumeric_err_NUM); return value_new_error (ei->pos, gnumeric_err_NUM);
tree = (GnmExpr *) expr_node_list->data; tree = expr_node_list->data;
if (tree == NULL) if (tree == NULL)
return value_new_error (ei->pos, gnumeric_err_NUM); return value_new_error (ei->pos, gnumeric_err_NUM);
val = gnm_expr_eval (tree, ei->pos, GNM_EXPR_EVAL_STRICT); val = gnm_expr_eval (tree, ei->pos, GNM_EXPR_EVAL_STRICT);
if (!val) return NULL; if (val->type == VALUE_ERROR)
if (!VALUE_IS_NUMBER (val)) { return val;
value_release (val);
return value_new_error (ei->pos, gnumeric_err_VALUE);
}
fun_nbr = value_get_as_int (val); fun_nbr = value_get_as_int (val);
value_release (val); value_release (val);
if (fun_nbr < 1 || fun_nbr > 11)
return value_new_error (ei->pos, gnumeric_err_NUM);
/* Skip the first node */ /* Skip the first node */
expr_node_list = expr_node_list->next; expr_node_list = expr_node_list->next;
...@@ -2856,9 +2850,8 @@ gnumeric_subtotal (FunctionEvalInfo *ei, GnmExprList *expr_node_list) ...@@ -2856,9 +2850,8 @@ gnumeric_subtotal (FunctionEvalInfo *ei, GnmExprList *expr_node_list)
case 9: return gnumeric_sum (ei, expr_node_list); case 9: return gnumeric_sum (ei, expr_node_list);
case 10: return gnumeric_var (ei, expr_node_list); case 10: return gnumeric_var (ei, expr_node_list);
case 11: return gnumeric_varp (ei, expr_node_list); case 11: return gnumeric_varp (ei, expr_node_list);
default: return value_new_error (ei->pos, gnumeric_err_NUM);
} }
return NULL;
} }
/***************************************************************************/ /***************************************************************************/
......
2002-04-15 Morten Welinder <terra@diku.dk>
* fn-math.c (gnumeric_subtotal): Fix error handling, I hope.
2002-04-04 Jody Goldberg <jody@gnome.org> 2002-04-04 Jody Goldberg <jody@gnome.org>
* fn-date.c (gnumeric_date2unix) : unix serials are integers. * fn-date.c (gnumeric_date2unix) : unix serials are integers.
......
...@@ -2818,28 +2818,22 @@ static const char *help_subtotal = { ...@@ -2818,28 +2818,22 @@ static const char *help_subtotal = {
static Value * static Value *
gnumeric_subtotal (FunctionEvalInfo *ei, GnmExprList *expr_node_list) gnumeric_subtotal (FunctionEvalInfo *ei, GnmExprList *expr_node_list)
{ {
GnmExpr *tree; const GnmExpr *tree;
Value *val; Value *val;
int fun_nbr; int fun_nbr;
if (expr_node_list == NULL) if (expr_node_list == NULL)
return value_new_error (ei->pos, gnumeric_err_NUM); return value_new_error (ei->pos, gnumeric_err_NUM);
tree = (GnmExpr *) expr_node_list->data; tree = expr_node_list->data;
if (tree == NULL) if (tree == NULL)
return value_new_error (ei->pos, gnumeric_err_NUM); return value_new_error (ei->pos, gnumeric_err_NUM);
val = gnm_expr_eval (tree, ei->pos, GNM_EXPR_EVAL_STRICT); val = gnm_expr_eval (tree, ei->pos, GNM_EXPR_EVAL_STRICT);
if (!val) return NULL; if (val->type == VALUE_ERROR)
if (!VALUE_IS_NUMBER (val)) { return val;
value_release (val);
return value_new_error (ei->pos, gnumeric_err_VALUE);
}
fun_nbr = value_get_as_int (val); fun_nbr = value_get_as_int (val);
value_release (val); value_release (val);
if (fun_nbr < 1 || fun_nbr > 11)
return value_new_error (ei->pos, gnumeric_err_NUM);
/* Skip the first node */ /* Skip the first node */
expr_node_list = expr_node_list->next; expr_node_list = expr_node_list->next;
...@@ -2856,9 +2850,8 @@ gnumeric_subtotal (FunctionEvalInfo *ei, GnmExprList *expr_node_list) ...@@ -2856,9 +2850,8 @@ gnumeric_subtotal (FunctionEvalInfo *ei, GnmExprList *expr_node_list)
case 9: return gnumeric_sum (ei, expr_node_list); case 9: return gnumeric_sum (ei, expr_node_list);
case 10: return gnumeric_var (ei, expr_node_list); case 10: return gnumeric_var (ei, expr_node_list);
case 11: return gnumeric_varp (ei, expr_node_list); case 11: return gnumeric_varp (ei, expr_node_list);
default: return value_new_error (ei->pos, gnumeric_err_NUM);
} }
return NULL;
} }
/***************************************************************************/ /***************************************************************************/
......
2002-04-15 Morten Welinder <terra@diku.dk>
* *.c: Include <gnumeric-config.h> as needed.
2002-03-29 Jukka-Pekka Iivonen <jiivonen@hutcs.cs.hut.fi> 2002-03-29 Jukka-Pekka Iivonen <jiivonen@hutcs.cs.hut.fi>
* lpkit.h: Added #ifndef. * lpkit.h: Added #ifndef.
......
#include <gnumeric-config.h>
#include "lpkit.h" #include "lpkit.h"
#include "lpglob.h" #include "lpglob.h"
#include <stdarg.h> #include <stdarg.h>
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
* 02111-1307, USA. * 02111-1307, USA.
*/ */
#include <gnumeric-config.h>
#include <glib.h> #include <glib.h>
#include "lpkit.h" #include "lpkit.h"
#include "lpglob.h" #include "lpglob.h"
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
* 02111-1307, USA. * 02111-1307, USA.
*/ */
#include <gnumeric-config.h>
#include <glib.h> #include <glib.h>
#include <string.h> #include <string.h>
#include "lpkit.h" #include "lpkit.h"
......
2002-04-15 Morten Welinder <terra@diku.dk>
* *.c: Include <gnumeric-config.h> as needed.
2002-04-12 Morten Welinder <terra@diku.dk> 2002-04-12 Morten Welinder <terra@diku.dk>
* gnumeric-cell-renderer-text.c * gnumeric-cell-renderer-text.c
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <gnumeric-config.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gdk/gdkx.h> #include <gdk/gdkx.h>
#include "gnumeric-cell-renderer-expr-entry.h" #include "gnumeric-cell-renderer-expr-entry.h"
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <gnumeric-config.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gdk/gdkx.h> #include <gdk/gdkx.h>
#include "gnumeric-cell-renderer-text.h" #include "gnumeric-cell-renderer-text.h"
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <gnumeric-config.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gdk/gdkx.h> #include <gdk/gdkx.h>
#include "gnumeric-cell-renderer-toggle.h" #include "gnumeric-cell-renderer-toggle.h"
......
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