Commit 20b08bfe authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

number_match can match non-numbers too. ditto.

2001-10-18  Jody Goldberg <jgoldberg@home.com>

	* fn-string.c (gnumeric_value) : number_match can match non-numbers too.
	* fn-information.c (gnumeric_n) : ditto.

2001-10-18  Jody Goldberg <jgoldberg@home.com>

	* src/xml-io.c (xml_node_get_int) : use strtol
	(xml_node_get_double) : strtod.

	* src/number-match.c (format_match_number) : new.

	* src/expr.c (eval_expr_real) : format_match can match non-numbers now.

2001-10-17  Jody Goldberg <jgoldberg@home.com>

	* src/item-bar.c (ib_draw_cell) : add some protection in case of bad
	  fonts.
parent 05aad978
2001-10-18 Jody Goldberg <jgoldberg@home.com>
* src/xml-io.c (xml_node_get_int) : use strtol
(xml_node_get_double) : strtod.
* src/number-match.c (format_match_number) : new.
* src/expr.c (eval_expr_real) : format_match can match non-numbers now.
2001-10-18 Morten Welinder <terra@diku.dk>
* src/pixmaps/16_search.xpm: new file (derived from from Evolution).
......
......@@ -26,6 +26,9 @@ Jody:
* Fix graph leaks.
* Allow xls exporter to (poorly) handle large format regions.
* Fix changing data for graphs
* Format match can match strings, don't assume only numbers.
* Improve XL chart import.
* Plug memory leaks.
John Gotts:
* Make bonobo optional in the sample rpm specfile.
......@@ -35,6 +38,7 @@ Jukka:
Morten:
* New Search Control Center.
* Find memory leaks.
--------------------------------------------------------------------------
Gnumeric 0.71
......
2001-10-18 Jody Goldberg <jgoldberg@home.com>
* src/xml-io.c (xml_node_get_int) : use strtol
(xml_node_get_double) : strtod.
* src/number-match.c (format_match_number) : new.
* src/expr.c (eval_expr_real) : format_match can match non-numbers now.
2001-10-18 Morten Welinder <terra@diku.dk>
* src/pixmaps/16_search.xpm: new file (derived from from Evolution).
......
2001-10-18 Jody Goldberg <jgoldberg@home.com>
* src/xml-io.c (xml_node_get_int) : use strtol
(xml_node_get_double) : strtod.
* src/number-match.c (format_match_number) : new.
* src/expr.c (eval_expr_real) : format_match can match non-numbers now.
2001-10-18 Morten Welinder <terra@diku.dk>
* src/pixmaps/16_search.xpm: new file (derived from from Evolution).
......
2001-10-18 Jody Goldberg <jgoldberg@home.com>
* src/xml-io.c (xml_node_get_int) : use strtol
(xml_node_get_double) : strtod.
* src/number-match.c (format_match_number) : new.
* src/expr.c (eval_expr_real) : format_match can match non-numbers now.
2001-10-18 Morten Welinder <terra@diku.dk>
* src/pixmaps/16_search.xpm: new file (derived from from Evolution).
......
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* fn-information.c: Information built-in functions
*
......@@ -888,7 +889,8 @@ gnumeric_n (FunctionEvalInfo *ei, Value **argv)
return value_new_error (ei->pos, gnumeric_err_NUM);
str = value_peek_string (argv[0]);
if (NULL != (v = format_match (str, NULL, NULL)))
v = format_match_number (str, NULL, NULL);
if (v != NULL)
return v;
return value_new_float (0);
}
......
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* fn-string.c: Built in string functions.
*
......@@ -799,10 +800,10 @@ gnumeric_value (FunctionEvalInfo *ei, Value **argv)
for (p = arg ; *p && isspace (*p) ; ++p)
;
v = format_match (p, NULL, NULL);
v = format_match_number (p, NULL, NULL);
g_free (arg);
if (v)
if (v != NULL)
return v;
return value_new_error (ei->pos, gnumeric_err_VALUE);
}
......
......@@ -532,11 +532,11 @@ rows_height_update (Sheet *sheet, Range const * range, gboolean shrink)
/*****************************************************************************/
struct colrow_visiblity
typedef struct
{
gboolean is_cols, visible;
ColRowVisList *elements;
};
} colrow_visiblity;
static gint
colrow_index_cmp (ColRowIndex const *a, ColRowIndex const *b)
......@@ -546,7 +546,7 @@ colrow_index_cmp (ColRowIndex const *a, ColRowIndex const *b)
}
static void
colrow_visibility (Sheet const *sheet, struct colrow_visiblity * const dat,
colrow_visibility (Sheet const *sheet, colrow_visiblity * const dat,
int first, int last, gboolean honour_collapse)
{
int i;
......@@ -599,7 +599,7 @@ ColRowVisList *
colrow_get_outline_toggle (Sheet const *sheet, gboolean is_cols, gboolean visible,
int first, int last)
{
struct colrow_visiblity closure;
colrow_visiblity closure;
closure.is_cols = is_cols;
closure.visible = visible;
closure.elements = NULL;
......@@ -609,10 +609,9 @@ colrow_get_outline_toggle (Sheet const *sheet, gboolean is_cols, gboolean visibl
}
static void
cb_colrow_visibility (Sheet *sheet, Range const *r,
void *closure)
cb_colrow_visibility (Sheet *sheet, Range const *r, void *closure)
{
struct colrow_visiblity * const dat = (struct colrow_visiblity *)closure;
colrow_visiblity * const dat = (colrow_visiblity *)closure;
int first, last;
if (dat->is_cols) {
......@@ -624,7 +623,8 @@ cb_colrow_visibility (Sheet *sheet, Range const *r,
}
colrow_visibility (sheet, dat, first, last, FALSE);
}
/*
/**
* colrow_get_visiblity_toggle :
* @sheet : The sheet whose selection we are interested in.
* @is_cols: A flag indicating whether this it is a column or a row.
......@@ -640,7 +640,7 @@ ColRowVisList *
colrow_get_visiblity_toggle (Sheet *sheet, gboolean is_cols,
gboolean visible)
{
struct colrow_visiblity closure;
colrow_visiblity closure;
closure.is_cols = is_cols;
closure.visible = visible;
closure.elements = NULL;
......
......@@ -81,7 +81,7 @@ struct _FormulaGuruState
gboolean var_args;
ArgumentState *cur_arg;
int max_arg; /* max arg # with a value */
WorkbookControlGUI *wbcg;
WorkbookControlGUI *wbcg;
FunctionDefinition *fd;
TokenizedHelp *help_tokens;
GPtrArray *args;
......
......@@ -377,7 +377,7 @@ cb_dialog_apply_clicked(GtkWidget *button, GoalSeekState *state)
text = gtk_entry_get_text (GTK_ENTRY (state->to_value_entry));
format = mstyle_get_format (cell_get_mstyle (state->set_cell));
value = format_match (text, format, &target_value_format);
value = format_match_number (text, format, &target_value_format);
if (format != NULL)
target_value_format = format;
state->target_value = value_get_as_float(value);
......@@ -390,7 +390,7 @@ cb_dialog_apply_clicked(GtkWidget *button, GoalSeekState *state)
text = g_strdup(gtk_entry_get_text (GTK_ENTRY (state->at_least_entry)));
g_strstrip(text);
if (strlen(text) > 0) {
value = format_match (text, format, &min_value_format);
value = format_match_number (text, format, &min_value_format);
g_free(text);
if (format != NULL)
min_value_format = format;
......@@ -408,7 +408,7 @@ cb_dialog_apply_clicked(GtkWidget *button, GoalSeekState *state)
text = g_strdup(gtk_entry_get_text (GTK_ENTRY (state->at_most_entry)));
g_strstrip(text);
if (strlen(text) > 0) {
value = format_match (text, format, &max_value_format);
value = format_match_number (text, format, &max_value_format);
g_free(text);
if (format != NULL)
max_value_format = format;
......
......@@ -611,7 +611,7 @@ eval_expr_real (EvalPos const *pos, ExprTree const *expr,
/* 2) #!VALUE error if A is not a number */
if (a->type == VALUE_STRING) {
Value *tmp = format_match (a->v_str.val->str, NULL, NULL);
Value *tmp = format_match_number (a->v_str.val->str, NULL, NULL);
value_release (a);
if (tmp == NULL)
......@@ -645,7 +645,7 @@ eval_expr_real (EvalPos const *pos, ExprTree const *expr,
/* 4) #!VALUE error if B is not a number */
if (b->type == VALUE_STRING) {
Value *tmp = format_match (b->v_str.val->str, NULL, NULL);
Value *tmp = format_match_number (b->v_str.val->str, NULL, NULL);
value_release (b);
if (tmp == NULL) {
......
2001-10-18 Jody Goldberg <jgoldberg@home.com>
* fn-string.c (gnumeric_value) : number_match can match non-numbers too.
* fn-information.c (gnumeric_n) : ditto.
2001-10-17 Andreas J. Guelzow <aguelzow@taliesin.ca>
* fn-database.c (find_cells_that_match) : Undefined cells should not satisfy
......
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* fn-information.c: Information built-in functions
*
......@@ -888,7 +889,8 @@ gnumeric_n (FunctionEvalInfo *ei, Value **argv)
return value_new_error (ei->pos, gnumeric_err_NUM);
str = value_peek_string (argv[0]);
if (NULL != (v = format_match (str, NULL, NULL)))
v = format_match_number (str, NULL, NULL);
if (v != NULL)
return v;
return value_new_float (0);
}
......
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* fn-string.c: Built in string functions.
*
......@@ -799,10 +800,10 @@ gnumeric_value (FunctionEvalInfo *ei, Value **argv)
for (p = arg ; *p && isspace (*p) ; ++p)
;
v = format_match (p, NULL, NULL);
v = format_match_number (p, NULL, NULL);
g_free (arg);
if (v)
if (v != NULL)
return v;
return value_new_error (ei->pos, gnumeric_err_VALUE);
}
......
......@@ -1046,7 +1046,6 @@ format_match_simple (char const *text)
* @format : An optional place to store the target format
*
* Attempts to parse the supplied string to see if it matches a known value format.
* Will eventually use the current cell format in preference to canned formats.
* If @format is supplied it will get a copy of the matching format with no
* additional references. The caller is responsible for releasing the
* resulting value.
......@@ -1145,3 +1144,30 @@ format_match (char const *text, StyleFormat *cur_fmt,
return NULL;
}
/**
* format_match_number :
*
* @text : The text to parse
* @cur_fmt : The current format for the value (potentially NULL)
* @format : An optional place to store the target format
*
* Attempts to parse the supplied string to see if it matches a known value format.
* Will eventually use the current cell format in preference to canned formats.
* If @format is supplied it will get a copy of the matching format with no
* additional references. The caller is responsible for releasing the
* resulting value. Will ONLY return numbers.
*/
Value *
format_match_number (char const *s, StyleFormat *current_format,
StyleFormat **format)
{
Value *res = format_match (s, current_format, format);
if (res != NULL) {
if (VALUE_IS_NUMBER (res))
return res;
value_release (res);
}
return NULL;
}
......@@ -9,6 +9,8 @@ void format_match_release (StyleFormat *fmt);
Value *format_match_simple (char const *s);
Value *format_match (char const *s, StyleFormat *current_format,
StyleFormat **format);
Value *format_match_number (char const *s, StyleFormat *current_format,
StyleFormat **format);
void format_match_init (void);
void format_match_finish (void);
......
......@@ -226,16 +226,19 @@ gboolean
xml_node_get_int (xmlNodePtr node, char const *name, int *val)
{
xmlChar *buf;
int res;
char *end;
buf = xml_node_get_cstr (node, name);
if (buf == NULL)
return FALSE;
res = sscanf (buf, "%d", val);
errno = 0; /* strto(ld) sets errno, but does not clear it. */
*val = strtol (buf, &end, 10);
xmlFree (buf);
return (res == 1);
return ((char *)buf != end) && (errno != ERANGE);
}
void
xml_node_set_int (xmlNodePtr node, char const *name, int val)
{
......@@ -247,17 +250,20 @@ xml_node_set_int (xmlNodePtr node, char const *name, int val)
gboolean
xml_node_get_double (xmlNodePtr node, char const *name, double *val)
{
int res;
xmlChar *buf;
char *end;
buf = xml_node_get_cstr (node, name);
if (buf == NULL)
return FALSE;
res = sscanf (buf, "%lf", val);
errno = 0; /* strto(ld) sets errno, but does not clear it. */
*val = strtod (buf, &end);
xmlFree (buf);
return (res == 1);
return ((char *)buf != end) && (errno != ERANGE);
}
void
xml_node_set_double (xmlNodePtr node, char const *name, double val,
int precision)
......
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