Commit de741043 authored by Morten Welinder's avatar Morten Welinder

Cleanup and severe eval queue fix.

parent 940ac911
1999-05-04 Morten Welinder <terra@diku.dk>
* src/eval.c (dependency_remove_cell): Remove unused assignment.
(cell_queue_recalc_list): Mark queued cells as being so.
* src/fn-math.c (gnumeric_combin): Clean up.
(combin): Handle large numbers carefully.
* src/utils.c (january_1900): Fix argument list.
* src/fn-stat.c (gnumeric_var): Remove unused variable.
(gnumeric_varp): Ditto.
1999-05-04 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/fn-math: Added ROUND().
......
1999-05-04 Morten Welinder <terra@diku.dk>
* src/eval.c (dependency_remove_cell): Remove unused assignment.
(cell_queue_recalc_list): Mark queued cells as being so.
* src/fn-math.c (gnumeric_combin): Clean up.
(combin): Handle large numbers carefully.
* src/utils.c (january_1900): Fix argument list.
* src/fn-stat.c (gnumeric_var): Remove unused variable.
(gnumeric_varp): Ditto.
1999-05-04 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/fn-math: Added ROUND().
......
1999-05-04 Morten Welinder <terra@diku.dk>
* src/eval.c (dependency_remove_cell): Remove unused assignment.
(cell_queue_recalc_list): Mark queued cells as being so.
* src/fn-math.c (gnumeric_combin): Clean up.
(combin): Handle large numbers carefully.
* src/utils.c (january_1900): Fix argument list.
* src/fn-stat.c (gnumeric_var): Remove unused variable.
(gnumeric_varp): Ditto.
1999-05-04 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/fn-math: Added ROUND().
......
1999-05-04 Morten Welinder <terra@diku.dk>
* src/eval.c (dependency_remove_cell): Remove unused assignment.
(cell_queue_recalc_list): Mark queued cells as being so.
* src/fn-math.c (gnumeric_combin): Clean up.
(combin): Handle large numbers carefully.
* src/utils.c (january_1900): Fix argument list.
* src/fn-stat.c (gnumeric_var): Remove unused variable.
(gnumeric_varp): Ditto.
1999-05-04 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/fn-math: Added ROUND().
......
1999-05-04 Morten Welinder <terra@diku.dk>
* ms-excel.c (ms_excel_workbook_new): Fix argument list.
1999-05-02 Michael Meeks <michael@imaginator.com>
* ms-excel.c (biff_get_externsheet_name): Converted to return
......
......@@ -1297,7 +1297,7 @@ ms_excel_sheet_destroy (MS_EXCEL_SHEET * sheet)
}
static MS_EXCEL_WORKBOOK *
ms_excel_workbook_new ()
ms_excel_workbook_new (void)
{
MS_EXCEL_WORKBOOK *ans = (MS_EXCEL_WORKBOOK *) g_malloc (sizeof (MS_EXCEL_WORKBOOK));
......
......@@ -1297,7 +1297,7 @@ ms_excel_sheet_destroy (MS_EXCEL_SHEET * sheet)
}
static MS_EXCEL_WORKBOOK *
ms_excel_workbook_new ()
ms_excel_workbook_new (void)
{
MS_EXCEL_WORKBOOK *ans = (MS_EXCEL_WORKBOOK *) g_malloc (sizeof (MS_EXCEL_WORKBOOK));
......
......@@ -482,30 +482,33 @@ static char *help_combin = {
float_t
combin (int n, int k)
{
return fact(n) / (fact(k) * fact(n-k));
if (n >= 15) {
float_t res;
res = exp (lgamma (n + 1) - lgamma (k + 1) - lgamma (n - k + 1));
return floor (res + 0.5); /* Round, just in case. */
} else {
float_t res;
res = fact (n) / fact (k) / fact (n - k);
return res;
}
}
static Value *
gnumeric_combin (struct FunctionDefinition *id,
Value *argv [], char **error_string)
{
Value *res;
float_t n, k;
int n ,k;
if (argv [0]->type == VALUE_INTEGER &&
argv [1]->type == VALUE_INTEGER &&
argv[0]->v.v_int >= argv[1]->v.v_int){
n = argv [0]->v.v_int;
k = argv [1]->v.v_int;
} else {
*error_string = _("#NUM!");
return NULL;
}
res = g_new (Value, 1);
res->type = VALUE_INTEGER;
res->v.v_int = combin ((int)n, (int)k);
return res;
n = value_get_as_int (argv[0]);
k = value_get_as_int (argv[1]);
if (k >= 0 && n >= k)
return value_float (combin (n ,k));
*error_string = _("#NUM!");
return NULL;
}
static char *help_floor = {
......@@ -671,7 +674,7 @@ gnumeric_mod (struct FunctionDefinition *i,
Value *argv [], char **error_string)
{
int a,b;
a = value_get_as_int (argv[0]) ;
b = value_get_as_int (argv[1]) ;
/* Obscure handling of C's mod function */
......
......@@ -650,7 +650,6 @@ gnumeric_varp (Sheet *sheet, GList *expr_node_list, int eval_col,
int eval_row, char **error_string)
{
stat_closure_t cl;
float_t ans, num;
setup_stat_closure (&cl);
......@@ -688,7 +687,6 @@ gnumeric_var (Sheet *sheet, GList *expr_node_list, int eval_col,
int eval_row, char **error_string)
{
stat_closure_t cl;
float_t ans, num;
setup_stat_closure (&cl);
......
......@@ -239,7 +239,7 @@ static void
dependency_remove_cell (gpointer key, gpointer value, gpointer the_cell)
{
DependencyRange *range = value;
GList *list = range->cell_list;
GList *list;
list = g_list_find (range->cell_list, the_cell);
if (!list)
......@@ -413,6 +413,12 @@ cell_queue_recalc_list (GList *list)
wb = ((Sheet *)(first_cell->sheet))->workbook;
wb->eval_queue = g_list_concat (wb->eval_queue, list);
while (list) {
Cell *cell = list->data;
cell->flags |= CELL_QUEUED_FOR_RECALC;
list = list->next;
}
}
static Cell *
......
......@@ -239,7 +239,7 @@ static void
dependency_remove_cell (gpointer key, gpointer value, gpointer the_cell)
{
DependencyRange *range = value;
GList *list = range->cell_list;
GList *list;
list = g_list_find (range->cell_list, the_cell);
if (!list)
......@@ -413,6 +413,12 @@ cell_queue_recalc_list (GList *list)
wb = ((Sheet *)(first_cell->sheet))->workbook;
wb->eval_queue = g_list_concat (wb->eval_queue, list);
while (list) {
Cell *cell = list->data;
cell->flags |= CELL_QUEUED_FOR_RECALC;
list = list->next;
}
}
static Cell *
......
......@@ -482,30 +482,33 @@ static char *help_combin = {
float_t
combin (int n, int k)
{
return fact(n) / (fact(k) * fact(n-k));
if (n >= 15) {
float_t res;
res = exp (lgamma (n + 1) - lgamma (k + 1) - lgamma (n - k + 1));
return floor (res + 0.5); /* Round, just in case. */
} else {
float_t res;
res = fact (n) / fact (k) / fact (n - k);
return res;
}
}
static Value *
gnumeric_combin (struct FunctionDefinition *id,
Value *argv [], char **error_string)
{
Value *res;
float_t n, k;
int n ,k;
if (argv [0]->type == VALUE_INTEGER &&
argv [1]->type == VALUE_INTEGER &&
argv[0]->v.v_int >= argv[1]->v.v_int){
n = argv [0]->v.v_int;
k = argv [1]->v.v_int;
} else {
*error_string = _("#NUM!");
return NULL;
}
res = g_new (Value, 1);
res->type = VALUE_INTEGER;
res->v.v_int = combin ((int)n, (int)k);
return res;
n = value_get_as_int (argv[0]);
k = value_get_as_int (argv[1]);
if (k >= 0 && n >= k)
return value_float (combin (n ,k));
*error_string = _("#NUM!");
return NULL;
}
static char *help_floor = {
......@@ -671,7 +674,7 @@ gnumeric_mod (struct FunctionDefinition *i,
Value *argv [], char **error_string)
{
int a,b;
a = value_get_as_int (argv[0]) ;
b = value_get_as_int (argv[1]) ;
/* Obscure handling of C's mod function */
......
......@@ -650,7 +650,6 @@ gnumeric_varp (Sheet *sheet, GList *expr_node_list, int eval_col,
int eval_row, char **error_string)
{
stat_closure_t cl;
float_t ans, num;
setup_stat_closure (&cl);
......@@ -688,7 +687,6 @@ gnumeric_var (Sheet *sheet, GList *expr_node_list, int eval_col,
int eval_row, char **error_string)
{
stat_closure_t cl;
float_t ans, num;
setup_stat_closure (&cl);
......
......@@ -482,30 +482,33 @@ static char *help_combin = {
float_t
combin (int n, int k)
{
return fact(n) / (fact(k) * fact(n-k));
if (n >= 15) {
float_t res;
res = exp (lgamma (n + 1) - lgamma (k + 1) - lgamma (n - k + 1));
return floor (res + 0.5); /* Round, just in case. */
} else {
float_t res;
res = fact (n) / fact (k) / fact (n - k);
return res;
}
}
static Value *
gnumeric_combin (struct FunctionDefinition *id,
Value *argv [], char **error_string)
{
Value *res;
float_t n, k;
int n ,k;
if (argv [0]->type == VALUE_INTEGER &&
argv [1]->type == VALUE_INTEGER &&
argv[0]->v.v_int >= argv[1]->v.v_int){
n = argv [0]->v.v_int;
k = argv [1]->v.v_int;
} else {
*error_string = _("#NUM!");
return NULL;
}
res = g_new (Value, 1);
res->type = VALUE_INTEGER;
res->v.v_int = combin ((int)n, (int)k);
return res;
n = value_get_as_int (argv[0]);
k = value_get_as_int (argv[1]);
if (k >= 0 && n >= k)
return value_float (combin (n ,k));
*error_string = _("#NUM!");
return NULL;
}
static char *help_floor = {
......@@ -671,7 +674,7 @@ gnumeric_mod (struct FunctionDefinition *i,
Value *argv [], char **error_string)
{
int a,b;
a = value_get_as_int (argv[0]) ;
b = value_get_as_int (argv[1]) ;
/* Obscure handling of C's mod function */
......
......@@ -650,7 +650,6 @@ gnumeric_varp (Sheet *sheet, GList *expr_node_list, int eval_col,
int eval_row, char **error_string)
{
stat_closure_t cl;
float_t ans, num;
setup_stat_closure (&cl);
......@@ -688,7 +687,6 @@ gnumeric_var (Sheet *sheet, GList *expr_node_list, int eval_col,
int eval_row, char **error_string)
{
stat_closure_t cl;
float_t ans, num;
setup_stat_closure (&cl);
......
......@@ -197,7 +197,7 @@ gnumeric_strcase_hash (gconstpointer v)
}
static guint32
january_1900()
january_1900 (void)
{
static guint32 julian = 0;
......
......@@ -197,7 +197,7 @@ gnumeric_strcase_hash (gconstpointer v)
}
static guint32
january_1900()
january_1900 (void)
{
static guint32 julian = 0;
......
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