Commit 6645844a authored by Morten Welinder's avatar Morten Welinder

Excel error-constant fixes.

ERROR.TYPE excel read fix.
A constify that caught an error.
parent fbd3597b
Mon Jun 21 20:50:13 1999 Morten Welinder <welinder@rentec.com>
* src/dialog-function-wizard.c (arg_data_list_new): Fix case of
missing SYNTAX section.
(create_description): Handle constness of tokenized_help_find.
Delete weird #define.
* src/func.c (tokenized_help_find): Constify.
* src/expr.c (expr_tree_new_error): Smarten.
* src/fn-misc.c (gnumeric_error_type): Fix case of incorrect
number of arguments.
* src/fn-information.c (get_value_class): Fix leak.
1999-06-21 Miguel de Icaza <miguel@gnu.org>
* src/func.c: Do not pre-initialize them. If they need to be
......
Mon Jun 21 20:50:13 1999 Morten Welinder <welinder@rentec.com>
* src/dialog-function-wizard.c (arg_data_list_new): Fix case of
missing SYNTAX section.
(create_description): Handle constness of tokenized_help_find.
Delete weird #define.
* src/func.c (tokenized_help_find): Constify.
* src/expr.c (expr_tree_new_error): Smarten.
* src/fn-misc.c (gnumeric_error_type): Fix case of incorrect
number of arguments.
* src/fn-information.c (get_value_class): Fix leak.
1999-06-21 Miguel de Icaza <miguel@gnu.org>
* src/func.c: Do not pre-initialize them. If they need to be
......
Mon Jun 21 20:50:13 1999 Morten Welinder <welinder@rentec.com>
* src/dialog-function-wizard.c (arg_data_list_new): Fix case of
missing SYNTAX section.
(create_description): Handle constness of tokenized_help_find.
Delete weird #define.
* src/func.c (tokenized_help_find): Constify.
* src/expr.c (expr_tree_new_error): Smarten.
* src/fn-misc.c (gnumeric_error_type): Fix case of incorrect
number of arguments.
* src/fn-information.c (get_value_class): Fix leak.
1999-06-21 Miguel de Icaza <miguel@gnu.org>
* src/func.c: Do not pre-initialize them. If they need to be
......
Mon Jun 21 20:50:13 1999 Morten Welinder <welinder@rentec.com>
* src/dialog-function-wizard.c (arg_data_list_new): Fix case of
missing SYNTAX section.
(create_description): Handle constness of tokenized_help_find.
Delete weird #define.
* src/func.c (tokenized_help_find): Constify.
* src/expr.c (expr_tree_new_error): Smarten.
* src/fn-misc.c (gnumeric_error_type): Fix case of incorrect
number of arguments.
* src/fn-information.c (get_value_class): Fix leak.
1999-06-21 Miguel de Icaza <miguel@gnu.org>
* src/func.c: Do not pre-initialize them. If they need to be
......
1999-06-21 Morten Welinder <terra@diku.dk>
* ms-excel-read.c (ms_excel_read_cell): Handle errors and boolean
constants without going through text. (In particular, this gets
errors right and prepares for a proper bool type.)
* ms-formula-read.c (ms_excel_parse_formula): Fix error constants.
1999-06-21 Michael Meeks <michael@edenproject.org>
* ms-excel-read.c (ms_excel_read_cell): Remove Jody's
......
......@@ -2062,17 +2062,14 @@ ms_excel_read_cell (BIFF_QUERY * q, MS_EXCEL_SHEET * sheet)
}
case BIFF_BOOLERR: /* S59D5F.HTM */
{
ExprTree *e;
if (BIFF_GETBYTE(q->data + 7)) /* Error */
ms_excel_sheet_insert (sheet, EX_GETXF (q), EX_GETCOL (q),
EX_GETROW (q),
biff_get_error_text (BIFF_GETBYTE(q->data + 6))) ;
e = expr_tree_new_error (biff_get_error_text (BIFF_GETBYTE(q->data + 6)));
else /* Boolean */
{
char *bl = "0" ; /* FALSE */
if (BIFF_GETBYTE(q->data + 6))
bl = "1" ; /* TRUE */
ms_excel_sheet_insert (sheet, EX_GETXF (q), EX_GETCOL (q), EX_GETROW (q), bl) ;
}
e = expr_tree_new_constant (value_new_bool (BIFF_GETBYTE(q->data + 6)));
ms_excel_sheet_insert_form (sheet, EX_GETXF (q), EX_GETCOL (q),
EX_GETROW (q), e);
expr_tree_unref (e);
break;
}
default:
......
......@@ -335,7 +335,7 @@ FORMULA_FUNC_DATA formula_func_data[] =
/* 258 */ { "GETTOOLBAR", -2 },
/* 259 */ { "GETTOOL", -2 },
/* 260 */ { "SPELLINGCHECK", -2 },
/* 261 */ { "ERRORTYPE", 1 },
/* 261 */ { "ERROR.TYPE", 1 },
/* 262 */ { "APPTITLE", -2 },
/* 263 */ { "WINDOWTITLE", -2 },
/* 264 */ { "SAVETOOLBAR", -2 },
......@@ -672,9 +672,9 @@ make_function (PARSE_LIST **stack, int fn_idx, int numargs)
numargs = fd->num_args ;
else if (fd->num_args == -2)
g_warning("This sheet uses an Excel function "
"('%s') for which we do not have "
"adequate documentation.\n"
"Please forward a copy (if possible) to "
"('%s') for which we do \n"
"not have adequate documentation. "
"Please forward a copy (if possible) to\n"
"gnumeric-list@gnome.org. Thanks\n",
fd->prefix);
......@@ -1067,8 +1067,10 @@ ms_excel_parse_formula (MS_EXCEL_SHEET *sheet, guint8 *mem,
}
case FORMULA_PTG_ERR:
{
parse_list_push_raw (&stack,
value_new_string (biff_get_error_text(BIFF_GETBYTE(cur))));
const char *errtxt = biff_get_error_text (BIFF_GETBYTE(cur));
/* FIXME: we do not have errors as first-class values, so we
must build an expression that generates the error. */
parse_list_push (&stack, expr_tree_new_error (errtxt));
ptg_length = 1 ;
break ;
}
......
......@@ -49,6 +49,7 @@ get_value_class (ExprTree *expr, Sheet *sheet, int col, int row)
res = VALUE_CLASS_BOGUS;
break;
}
value_release (value);
} else
res = VALUE_CLASS_ERROR;
......
......@@ -232,7 +232,7 @@ gnumeric_var (Sheet *sheet, GList *expr_node_list, int eval_col,
return NULL;
if (cl.N <= 1) {
*error_string = gnumeric_err_NUM;
*error_string = gnumeric_err_VALUE;
return NULL;
}
......
......@@ -31,7 +31,6 @@ create_description (FunctionDefinition *fd)
{
GtkBox *vbox;
TokenizedHelp *tok;
#define TEXT_WIDTH 80
tok = tokenized_help_new (fd);
......@@ -45,7 +44,7 @@ create_description (FunctionDefinition *fd)
{ /* Description */
GtkText *text;
char *txt = tokenized_help_find (tok, "DESCRIPTION");
const char *txt = tokenized_help_find (tok, "DESCRIPTION");
text = GTK_TEXT (gtk_text_new (NULL, NULL));
gtk_text_set_editable (text, FALSE);
gtk_text_insert (text, NULL, NULL, NULL,
......@@ -74,6 +73,7 @@ static void
arg_data_list_new (State *state)
{
gchar *copy_args;
const gchar *syntax;
gchar *ptr, *start = NULL;
gchar *type;
int optional = 0;
......@@ -102,14 +102,14 @@ arg_data_list_new (State *state)
return;
}
copy_args = tokenized_help_find (state->tok, "SYNTAX");
if (!copy_args){
syntax = tokenized_help_find (state->tok, "SYNTAX");
if (!syntax){
g_ptr_array_free (state->args, FALSE);
state->args = NULL;
return;
}
copy_args = g_strdup (copy_args);
ptr = copy_args = g_strdup (syntax);
ptr = copy_args;
while (*ptr){
if (*ptr == '(' && !start)
start = ptr+1;
......
......@@ -31,7 +31,6 @@ create_description (FunctionDefinition *fd)
{
GtkBox *vbox;
TokenizedHelp *tok;
#define TEXT_WIDTH 80
tok = tokenized_help_new (fd);
......@@ -45,7 +44,7 @@ create_description (FunctionDefinition *fd)
{ /* Description */
GtkText *text;
char *txt = tokenized_help_find (tok, "DESCRIPTION");
const char *txt = tokenized_help_find (tok, "DESCRIPTION");
text = GTK_TEXT (gtk_text_new (NULL, NULL));
gtk_text_set_editable (text, FALSE);
gtk_text_insert (text, NULL, NULL, NULL,
......@@ -74,6 +73,7 @@ static void
arg_data_list_new (State *state)
{
gchar *copy_args;
const gchar *syntax;
gchar *ptr, *start = NULL;
gchar *type;
int optional = 0;
......@@ -102,14 +102,14 @@ arg_data_list_new (State *state)
return;
}
copy_args = tokenized_help_find (state->tok, "SYNTAX");
if (!copy_args){
syntax = tokenized_help_find (state->tok, "SYNTAX");
if (!syntax){
g_ptr_array_free (state->args, FALSE);
state->args = NULL;
return;
}
copy_args = g_strdup (copy_args);
ptr = copy_args = g_strdup (syntax);
ptr = copy_args;
while (*ptr){
if (*ptr == '(' && !start)
start = ptr+1;
......
......@@ -31,7 +31,6 @@ create_description (FunctionDefinition *fd)
{
GtkBox *vbox;
TokenizedHelp *tok;
#define TEXT_WIDTH 80
tok = tokenized_help_new (fd);
......@@ -45,7 +44,7 @@ create_description (FunctionDefinition *fd)
{ /* Description */
GtkText *text;
char *txt = tokenized_help_find (tok, "DESCRIPTION");
const char *txt = tokenized_help_find (tok, "DESCRIPTION");
text = GTK_TEXT (gtk_text_new (NULL, NULL));
gtk_text_set_editable (text, FALSE);
gtk_text_insert (text, NULL, NULL, NULL,
......@@ -74,6 +73,7 @@ static void
arg_data_list_new (State *state)
{
gchar *copy_args;
const gchar *syntax;
gchar *ptr, *start = NULL;
gchar *type;
int optional = 0;
......@@ -102,14 +102,14 @@ arg_data_list_new (State *state)
return;
}
copy_args = tokenized_help_find (state->tok, "SYNTAX");
if (!copy_args){
syntax = tokenized_help_find (state->tok, "SYNTAX");
if (!syntax){
g_ptr_array_free (state->args, FALSE);
state->args = NULL;
return;
}
copy_args = g_strdup (copy_args);
ptr = copy_args = g_strdup (syntax);
ptr = copy_args;
while (*ptr){
if (*ptr == '(' && !start)
start = ptr+1;
......
......@@ -123,13 +123,19 @@ expr_tree_new_var (const CellRef *cr)
ExprTree *
expr_tree_new_error (const char *txt)
{
ExprTree *val, *call;
Symbol *func;
GList *args = NULL;
if (strcmp (txt, gnumeric_err_NA) == 0) {
func = symbol_lookup (global_symbol_table, "NA");
} else {
func = symbol_lookup (global_symbol_table, "ERROR");
args = g_list_prepend (NULL,
expr_tree_new_constant (value_new_string (txt)));
}
val = expr_tree_new_constant (value_new_string (txt));
func = symbol_lookup (global_symbol_table, "ERROR");
symbol_ref (func);
return expr_tree_new_funcall (func, g_list_prepend (NULL, val));
return expr_tree_new_funcall (func, args);
}
......
......@@ -49,6 +49,7 @@ get_value_class (ExprTree *expr, Sheet *sheet, int col, int row)
res = VALUE_CLASS_BOGUS;
break;
}
value_release (value);
} else
res = VALUE_CLASS_ERROR;
......
......@@ -137,10 +137,14 @@ static Value *
gnumeric_error_type (Sheet *sheet, GList *expr_node_list,
int eval_col, int eval_row, char **error_string)
{
int res, retval = 0;
if (gnumeric_check_for_err (sheet, expr_node_list,
eval_col, eval_row, error_string))
{
int res, retval;
res = gnumeric_check_for_err (sheet, expr_node_list,
eval_col, eval_row, error_string);
if (res == -1)
return NULL;
else if (res == 0)
retval = 0;
else {
if (!strcmp (gnumeric_err_NULL, *error_string))
retval = 1;
else if (!strcmp (gnumeric_err_DIV0, *error_string))
......
......@@ -232,7 +232,7 @@ gnumeric_var (Sheet *sheet, GList *expr_node_list, int eval_col,
return NULL;
if (cl.N <= 1) {
*error_string = gnumeric_err_NUM;
*error_string = gnumeric_err_VALUE;
return NULL;
}
......
......@@ -226,8 +226,8 @@ tokenized_help_new (FunctionDefinition *fd)
/**
* Use to find a token eg. "FUNCTION"'s value.
**/
char *
tokenized_help_find (TokenizedHelp *tok, char *token)
const char *
tokenized_help_find (TokenizedHelp *tok, const char *token)
{
int lp;
......@@ -235,13 +235,13 @@ tokenized_help_find (TokenizedHelp *tok, char *token)
return "Incorrect Function Description.";
for (lp = 0; lp < tok->sections->len-1; lp++){
char *cmp = g_ptr_array_index (tok->sections, lp);
const char *cmp = g_ptr_array_index (tok->sections, lp);
if (strcasecmp (cmp, token) == 0){
return g_ptr_array_index (tok->sections, lp+1);
}
}
return "Can not find token";
return "Cannot find token";
}
void
......
......@@ -108,7 +108,7 @@ typedef struct {
} stat_closure_t;
TokenizedHelp *tokenized_help_new (FunctionDefinition *fd) ;
char *tokenized_help_find (TokenizedHelp *tok, char *token) ;
const char *tokenized_help_find (TokenizedHelp *tok, const char *token) ;
void tokenized_help_destroy (TokenizedHelp *tok) ;
float_t combin (int n, int k);
......
......@@ -49,6 +49,7 @@ get_value_class (ExprTree *expr, Sheet *sheet, int col, int row)
res = VALUE_CLASS_BOGUS;
break;
}
value_release (value);
} else
res = VALUE_CLASS_ERROR;
......
......@@ -137,10 +137,14 @@ static Value *
gnumeric_error_type (Sheet *sheet, GList *expr_node_list,
int eval_col, int eval_row, char **error_string)
{
int res, retval = 0;
if (gnumeric_check_for_err (sheet, expr_node_list,
eval_col, eval_row, error_string))
{
int res, retval;
res = gnumeric_check_for_err (sheet, expr_node_list,
eval_col, eval_row, error_string);
if (res == -1)
return NULL;
else if (res == 0)
retval = 0;
else {
if (!strcmp (gnumeric_err_NULL, *error_string))
retval = 1;
else if (!strcmp (gnumeric_err_DIV0, *error_string))
......
......@@ -232,7 +232,7 @@ gnumeric_var (Sheet *sheet, GList *expr_node_list, int eval_col,
return NULL;
if (cl.N <= 1) {
*error_string = gnumeric_err_NUM;
*error_string = gnumeric_err_VALUE;
return NULL;
}
......
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