Commit 30d3f971 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Rename COLLECT_DATES flags to COLLECT_COERCE_STRINGS and make it make all

2006-03-06  Morten Welinder  <terra@gnome.org>

	* src/collect.c (callback_function_collect): Rename COLLECT_DATES
	flags to COLLECT_COERCE_STRINGS and make it make all kinds of
	strings.  All callers changed.

2006-03-06  Morten Welinder  <terra@gnome.org>

	* functions.c (gnumeric_xnpv): Fix handling of bools and strings.
	(gnumeric_xirr): Fix handling of strings.  [#333620]
	(gnumeric_xirr): Handle failing Newton search.  [#333631]
parent 5bf49c61
2006-03-06 Morten Welinder <terra@gnome.org>
* src/collect.c (callback_function_collect): Rename COLLECT_DATES
flags to COLLECT_COERCE_STRINGS and make it make all kinds of
strings. All callers changed.
2006-03-01 Morten Welinder <terra@gnome.org>
* src/print-cell.c (print_cell): Fix zoom issue #332932.
......
......@@ -4,6 +4,7 @@ Morten:
* Fix printing issue when sheet is zoomed. [#332932]
* Fix dbf import issue. [#332878]
* Fix stf text import speed regression. [#333407]
* Fix XIRR issues. [#333620] [#333631]
--------------------------------------------------------------------------
Gnumeric 1.6.2
......
2006-03-06 Morten Welinder <terra@gnome.org>
* src/collect.c (callback_function_collect): Rename COLLECT_DATES
flags to COLLECT_COERCE_STRINGS and make it make all kinds of
strings. All callers changed.
2006-03-01 Morten Welinder <terra@gnome.org>
* src/print-cell.c (print_cell): Fix zoom issue #332932.
......
2006-03-06 Morten Welinder <terra@gnome.org>
* functions.c (gnumeric_xnpv): Fix handling of bools and strings.
(gnumeric_xirr): Fix handling of strings. [#333620]
(gnumeric_xirr): Handle failing Newton search. [#333631]
2006-01-30 Jody Goldberg <jody@gnome.org>
* Release 1.6.2
......
......@@ -1837,14 +1837,13 @@ gnumeric_xnpv (FunctionEvalInfo *ei, GnmValue const * const *argv)
sum = 0;
payments = collect_floats_value (argv[1], ei->pos,
COLLECT_IGNORE_STRINGS |
COLLECT_IGNORE_BOOLS,
COLLECT_COERCE_STRINGS,
&p_n, &result);
if (result)
goto out;
dates = collect_floats_value (argv[2], ei->pos,
COLLECT_DATES,
COLLECT_COERCE_STRINGS,
&d_n, &result);
if (result)
goto out;
......@@ -1948,7 +1947,7 @@ gnumeric_xirr (FunctionEvalInfo *ei, GnmValue const * const *argv)
rate0 = argv[2] ? value_get_as_float (argv[2]) : 0.1;
p.values = collect_floats_value (argv[0], ei->pos,
COLLECT_IGNORE_STRINGS,
COLLECT_COERCE_STRINGS,
&n, &result);
p.dates = NULL;
......@@ -1956,13 +1955,23 @@ gnumeric_xirr (FunctionEvalInfo *ei, GnmValue const * const *argv)
goto out;
p.dates = collect_floats_value (argv[1], ei->pos,
COLLECT_DATES,
COLLECT_COERCE_STRINGS,
&d_n, &result);
if (result != NULL)
goto out;
p.n = n;
status = goal_seek_newton (&xirr_npv, NULL, &data, &p, rate0);
if (status != GOAL_SEEK_OK) {
int i;
for (i = 1; i <= 1024; i += i) {
(void)goal_seek_point (&xirr_npv, &data, &p, -1 + 10.0 / (i + 9));
(void)goal_seek_point (&xirr_npv, &data, &p, i);
status = goal_seek_bisection (&xirr_npv, &data, &p);
if (status == GOAL_SEEK_OK)
break;
}
}
if (status == GOAL_SEEK_OK)
result = value_new_float (data.root);
......
......@@ -75,10 +75,18 @@ callback_function_collect (GnmEvalPos const *ep, GnmValue const *value,
break;
case VALUE_STRING:
if (cl->flags & COLLECT_DATES) {
x = datetime_value_to_serial (value, cl->date_conv);
if (x == 0)
return value_new_error_VALUE (ep);
if (cl->flags & COLLECT_COERCE_STRINGS) {
GnmValue *vc = format_match_number (value_peek_string (value),
NULL,
cl->date_conv);
gboolean bad = !vc || VALUE_TYPE(vc) == VALUE_BOOLEAN;
if (vc) {
x = value_get_as_float (vc);
value_release (vc);
}
if (bad)
return value_new_error_VALUE (ep);
} else if (cl->flags & COLLECT_IGNORE_STRINGS)
goto callback_function_collect_store_info;
else if (cl->flags & COLLECT_ZERO_STRINGS)
......@@ -122,9 +130,9 @@ callback_function_collect (GnmEvalPos const *ep, GnmValue const *value,
* exprlist: List of expressions to evaluate.
* cr: Current location (for resolving relative cells).
* flags: COLLECT_IGNORE_STRINGS: silently ignore strings.
* COLLECT_COERCE_STRINGS: coerce string into numbers
* COLLECT_ZERO_STRINGS: count strings as 0.
* (Alternative: return #VALUE!.)
* COLLECT_DATES: count strings as dates.
* COLLECT_IGNORE_BOOLS: silently ignore bools.
* COLLECT_ZEROONE_BOOLS: count FALSE as 0, TRUE as 1.
* (Alternative: return #VALUE!.)
......
......@@ -7,6 +7,7 @@
typedef enum {
COLLECT_IGNORE_STRINGS = 0x01,
COLLECT_ZERO_STRINGS = 0x02,
COLLECT_COERCE_STRINGS = 0x04,
COLLECT_IGNORE_BOOLS = 0x10,
COLLECT_ZEROONE_BOOLS = 0x20,
......@@ -16,7 +17,6 @@ typedef enum {
COLLECT_IGNORE_BLANKS = 0x1000,
COLLECT_IGNORE_SUBTOTAL = 0x2000,
COLLECT_DATES = 0x4000,
COLLECT_INFO = 0x8000,
COLLECT_NO_INFO_MASK = 0x7777
......
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