Commit de2dbf79 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

Some simple auditing of the functions.

They were not handling error arguments nicely.
This sort of things should really be handled in a more centralized manner.

2000-08-09  Jody Goldberg <jgoldberg@home.com>

	* src/functions/fn-date.c (gnumeric_datevalue) : Handle error values.
	(gnumeric_timevalue) : Ditto.
	(gnumeric_year) : Ditto.
	(gnumeric_month) : Ditto.
	(gnumeric_day) : Ditto.
	(gnumeric_weekday) : Ditto.
	(gnumeric_days360) : Ditto.
	(gnumeric_eomonth) : Ditto.
	(gnumeric_workday) : Ditto.
	(networkdays_holiday_callback) : Ditto.
	(gnumeric_networkdays) : Ditto.

	* src/functions/fn-financial.c (gnumeric_coupdaybs) : Ditto.
	(gnumeric_coupdays) : Ditto.
	(gnumeric_coupncd) : Ditto.
	(gnumeric_coupnum) : Ditto.
parent ea00c98c
2000-08-09 Jody Goldberg <jgoldberg@home.com>
* src/functions/fn-date.c (gnumeric_datevalue) : Handle error values.
(gnumeric_timevalue) : Ditto.
(gnumeric_year) : Ditto.
(gnumeric_month) : Ditto.
(gnumeric_day) : Ditto.
(gnumeric_weekday) : Ditto.
(gnumeric_days360) : Ditto.
(gnumeric_eomonth) : Ditto.
(gnumeric_workday) : Ditto.
(networkdays_holiday_callback) : Ditto.
(gnumeric_networkdays) : Ditto.
* src/functions/fn-financial.c (gnumeric_coupdaybs) : Ditto.
(gnumeric_coupdays) : Ditto.
(gnumeric_coupncd) : Ditto.
(gnumeric_coupnum) : Ditto.
2000-08-07 Arturo Tena <arturo@directmail.org>
* configure.in : Fix libole2 test.
2000-08-07 Jody Goldberg <jgoldberg@home.com>
* src/workbook.c (workbook_menu_insert_special) : No need to specify
......
2000-08-09 Jody Goldberg <jgoldberg@home.com>
* src/functions/fn-date.c (gnumeric_datevalue) : Handle error values.
(gnumeric_timevalue) : Ditto.
(gnumeric_year) : Ditto.
(gnumeric_month) : Ditto.
(gnumeric_day) : Ditto.
(gnumeric_weekday) : Ditto.
(gnumeric_days360) : Ditto.
(gnumeric_eomonth) : Ditto.
(gnumeric_workday) : Ditto.
(networkdays_holiday_callback) : Ditto.
(gnumeric_networkdays) : Ditto.
* src/functions/fn-financial.c (gnumeric_coupdaybs) : Ditto.
(gnumeric_coupdays) : Ditto.
(gnumeric_coupncd) : Ditto.
(gnumeric_coupnum) : Ditto.
2000-08-07 Arturo Tena <arturo@directmail.org>
* configure.in : Fix libole2 test.
2000-08-07 Jody Goldberg <jgoldberg@home.com>
* src/workbook.c (workbook_menu_insert_special) : No need to specify
......
2000-08-09 Jody Goldberg <jgoldberg@home.com>
* src/functions/fn-date.c (gnumeric_datevalue) : Handle error values.
(gnumeric_timevalue) : Ditto.
(gnumeric_year) : Ditto.
(gnumeric_month) : Ditto.
(gnumeric_day) : Ditto.
(gnumeric_weekday) : Ditto.
(gnumeric_days360) : Ditto.
(gnumeric_eomonth) : Ditto.
(gnumeric_workday) : Ditto.
(networkdays_holiday_callback) : Ditto.
(gnumeric_networkdays) : Ditto.
* src/functions/fn-financial.c (gnumeric_coupdaybs) : Ditto.
(gnumeric_coupdays) : Ditto.
(gnumeric_coupncd) : Ditto.
(gnumeric_coupnum) : Ditto.
2000-08-07 Arturo Tena <arturo@directmail.org>
* configure.in : Fix libole2 test.
2000-08-07 Jody Goldberg <jgoldberg@home.com>
* src/workbook.c (workbook_menu_insert_special) : No need to specify
......
2000-08-09 Jody Goldberg <jgoldberg@home.com>
* src/functions/fn-date.c (gnumeric_datevalue) : Handle error values.
(gnumeric_timevalue) : Ditto.
(gnumeric_year) : Ditto.
(gnumeric_month) : Ditto.
(gnumeric_day) : Ditto.
(gnumeric_weekday) : Ditto.
(gnumeric_days360) : Ditto.
(gnumeric_eomonth) : Ditto.
(gnumeric_workday) : Ditto.
(networkdays_holiday_callback) : Ditto.
(gnumeric_networkdays) : Ditto.
* src/functions/fn-financial.c (gnumeric_coupdaybs) : Ditto.
(gnumeric_coupdays) : Ditto.
(gnumeric_coupncd) : Ditto.
(gnumeric_coupnum) : Ditto.
2000-08-07 Arturo Tena <arturo@directmail.org>
* configure.in : Fix libole2 test.
2000-08-07 Jody Goldberg <jgoldberg@home.com>
* src/workbook.c (workbook_menu_insert_special) : No need to specify
......
2000-08-09 Jody Goldberg <jgoldberg@home.com>
* src/functions/fn-date.c (gnumeric_datevalue) : Handle error values.
(gnumeric_timevalue) : Ditto.
(gnumeric_year) : Ditto.
(gnumeric_month) : Ditto.
(gnumeric_day) : Ditto.
(gnumeric_weekday) : Ditto.
(gnumeric_days360) : Ditto.
(gnumeric_eomonth) : Ditto.
(gnumeric_workday) : Ditto.
(networkdays_holiday_callback) : Ditto.
(gnumeric_networkdays) : Ditto.
* src/functions/fn-financial.c (gnumeric_coupdaybs) : Ditto.
(gnumeric_coupdays) : Ditto.
(gnumeric_coupncd) : Ditto.
(gnumeric_coupnum) : Ditto.
2000-08-07 Arturo Tena <arturo@directmail.org>
* configure.in : Fix libole2 test.
2000-08-07 Jody Goldberg <jgoldberg@home.com>
* src/workbook.c (workbook_menu_insert_special) : No need to specify
......
2000-08-09 Jody Goldberg <jgoldberg@home.com>
* src/functions/fn-date.c (gnumeric_datevalue) : Handle error values.
(gnumeric_timevalue) : Ditto.
(gnumeric_year) : Ditto.
(gnumeric_month) : Ditto.
(gnumeric_day) : Ditto.
(gnumeric_weekday) : Ditto.
(gnumeric_days360) : Ditto.
(gnumeric_eomonth) : Ditto.
(gnumeric_workday) : Ditto.
(networkdays_holiday_callback) : Ditto.
(gnumeric_networkdays) : Ditto.
* src/functions/fn-financial.c (gnumeric_coupdaybs) : Ditto.
(gnumeric_coupdays) : Ditto.
(gnumeric_coupncd) : Ditto.
(gnumeric_coupnum) : Ditto.
2000-08-07 Arturo Tena <arturo@directmail.org>
* configure.in : Fix libole2 test.
2000-08-07 Jody Goldberg <jgoldberg@home.com>
* src/workbook.c (workbook_menu_insert_special) : No need to specify
......
2000-08-09 Jody Goldberg <jgoldberg@home.com>
* src/functions/fn-date.c (gnumeric_datevalue) : Handle error values.
(gnumeric_timevalue) : Ditto.
(gnumeric_year) : Ditto.
(gnumeric_month) : Ditto.
(gnumeric_day) : Ditto.
(gnumeric_weekday) : Ditto.
(gnumeric_days360) : Ditto.
(gnumeric_eomonth) : Ditto.
(gnumeric_workday) : Ditto.
(networkdays_holiday_callback) : Ditto.
(gnumeric_networkdays) : Ditto.
* src/functions/fn-financial.c (gnumeric_coupdaybs) : Ditto.
(gnumeric_coupdays) : Ditto.
(gnumeric_coupncd) : Ditto.
(gnumeric_coupnum) : Ditto.
2000-08-07 Arturo Tena <arturo@directmail.org>
* configure.in : Fix libole2 test.
2000-08-07 Jody Goldberg <jgoldberg@home.com>
* src/workbook.c (workbook_menu_insert_special) : No need to specify
......
......@@ -90,6 +90,8 @@ static char *help_datevalue = {
static Value *
gnumeric_datevalue (FunctionEvalInfo *ei, Value **argv)
{
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
return value_new_int (datetime_value_to_serial (argv[0]));
}
......@@ -237,6 +239,9 @@ static Value *
gnumeric_timevalue (FunctionEvalInfo *ei, Value **argv)
{
float_t raw;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
raw = datetime_value_to_serial_raw (argv[0]);
return value_new_float (raw - (int)raw);
}
......@@ -346,7 +351,12 @@ static Value *
gnumeric_year (FunctionEvalInfo *ei, Value **argv)
{
int res = 1900;
GDate *date = datetime_value_to_g (argv[0]);
GDate *date;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
date = datetime_value_to_g (argv[0]);
if (date != NULL) {
res = g_date_year (date);
g_date_free (date);
......@@ -376,7 +386,12 @@ static Value *
gnumeric_month (FunctionEvalInfo *ei, Value **argv)
{
int res = 1;
GDate *date = datetime_value_to_g (argv[0]);
GDate *date;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
date = datetime_value_to_g (argv[0]);
if (date != NULL) {
res = g_date_month (date);
g_date_free (date);
......@@ -406,7 +421,12 @@ static Value *
gnumeric_day (FunctionEvalInfo *ei, Value **argv)
{
int res = 1;
GDate *date = datetime_value_to_g (argv[0]);
GDate *date;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
date = datetime_value_to_g (argv[0]);
if (date != NULL) {
res = g_date_day (date);
g_date_free (date);
......@@ -436,7 +456,12 @@ static Value *
gnumeric_weekday (FunctionEvalInfo *ei, Value **argv)
{
int res = 1;
GDate *date = datetime_value_to_g (argv[0]);
GDate *date;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
date = datetime_value_to_g (argv[0]);
if (date != NULL) {
res = (g_date_weekday (date) + 1) % 7;
g_date_free (date);
......@@ -487,6 +512,10 @@ gnumeric_days360 (FunctionEvalInfo *ei, Value **argv)
} else
method = METHOD_US;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
if (argv[1]->type == VALUE_ERROR)
return value_duplicate (argv[1]);
serial1 = datetime_value_to_serial (argv[0]);
serial2 = datetime_value_to_serial (argv[1]);
if ((flipped = (serial1 > serial2))) {
......@@ -563,8 +592,12 @@ gnumeric_eomonth (FunctionEvalInfo *ei, Value **argv)
{
Value *res;
int months = 0;
GDate *date = datetime_value_to_g (argv[0]);
GDate *date;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
date = datetime_value_to_g (argv[0]);
if (date == NULL || !g_date_valid (date))
return value_new_error (ei->pos, gnumeric_err_VALUE);
......@@ -608,8 +641,12 @@ gnumeric_workday (FunctionEvalInfo *ei, Value **argv)
Value *res;
int days;
GDateWeekday weekday;
GDate *date = datetime_value_to_g (argv[0]);
GDate *date;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
date = datetime_value_to_g (argv[0]);
if (date == NULL || !g_date_valid (date))
return value_new_error (ei->pos, gnumeric_err_VALUE);
weekday = g_date_weekday (date);
......@@ -702,9 +739,12 @@ networkdays_holiday_callback(EvalPos const *ep,
Value *res = NULL;
networkdays_holiday_closure * close =
(networkdays_holiday_closure *)user_data;
int const serial = datetime_value_to_serial (v);
int serial;
GDate * date;
if (v->type == VALUE_ERROR)
return value_duplicate (v);
serial = datetime_value_to_serial (v);
if (serial <= 0)
return value_new_error (ep, gnumeric_err_NUM);
......@@ -730,6 +770,14 @@ gnumeric_networkdays (FunctionEvalInfo *ei, Value **argv)
int start_offset, end_offset, res;
networkdays_holiday_closure close;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
if (argv[1]->type == VALUE_ERROR)
return value_duplicate (argv[1]);
start_serial = datetime_value_to_serial (argv[0]);
end_serial = datetime_value_to_serial (argv[1]);
/* Swap if necessary */
if (start_serial > end_serial) {
int tmp = start_serial;
......
......@@ -2576,6 +2576,11 @@ gnumeric_coupdaybs (FunctionEvalInfo *ei, Value **argv)
int freq, basis;
int days;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
if (argv[1]->type == VALUE_ERROR)
return value_duplicate (argv[1]);
settlement = datetime_value_to_g(argv[0]);
maturity = datetime_value_to_g(argv[1]);
freq = value_get_as_int (argv[2]);
......@@ -2621,6 +2626,11 @@ gnumeric_coupdays (FunctionEvalInfo *ei, Value **argv)
int freq, basis;
float_t days;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
if (argv[1]->type == VALUE_ERROR)
return value_duplicate (argv[1]);
settlement = datetime_value_to_g(argv[0]);
maturity = datetime_value_to_g(argv[1]);
freq = value_get_as_int (argv[2]);
......@@ -2686,6 +2696,11 @@ gnumeric_coupncd (FunctionEvalInfo *ei, Value **argv)
int freq, basis;
Value *v;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
if (argv[1]->type == VALUE_ERROR)
return value_duplicate (argv[1]);
settlement = datetime_value_to_g(argv[0]);
maturity = datetime_value_to_g(argv[1]);
freq = value_get_as_int (argv[2]);
......@@ -2748,6 +2763,11 @@ gnumeric_coupnum (FunctionEvalInfo *ei, Value **argv)
int freq, basis;
float_t n;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
if (argv[1]->type == VALUE_ERROR)
return value_duplicate (argv[1]);
settlement = datetime_value_to_g(argv[0]);
maturity = datetime_value_to_g(argv[1]);
freq = value_get_as_int (argv[2]);
......
......@@ -90,6 +90,8 @@ static char *help_datevalue = {
static Value *
gnumeric_datevalue (FunctionEvalInfo *ei, Value **argv)
{
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
return value_new_int (datetime_value_to_serial (argv[0]));
}
......@@ -237,6 +239,9 @@ static Value *
gnumeric_timevalue (FunctionEvalInfo *ei, Value **argv)
{
float_t raw;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
raw = datetime_value_to_serial_raw (argv[0]);
return value_new_float (raw - (int)raw);
}
......@@ -346,7 +351,12 @@ static Value *
gnumeric_year (FunctionEvalInfo *ei, Value **argv)
{
int res = 1900;
GDate *date = datetime_value_to_g (argv[0]);
GDate *date;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
date = datetime_value_to_g (argv[0]);
if (date != NULL) {
res = g_date_year (date);
g_date_free (date);
......@@ -376,7 +386,12 @@ static Value *
gnumeric_month (FunctionEvalInfo *ei, Value **argv)
{
int res = 1;
GDate *date = datetime_value_to_g (argv[0]);
GDate *date;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
date = datetime_value_to_g (argv[0]);
if (date != NULL) {
res = g_date_month (date);
g_date_free (date);
......@@ -406,7 +421,12 @@ static Value *
gnumeric_day (FunctionEvalInfo *ei, Value **argv)
{
int res = 1;
GDate *date = datetime_value_to_g (argv[0]);
GDate *date;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
date = datetime_value_to_g (argv[0]);
if (date != NULL) {
res = g_date_day (date);
g_date_free (date);
......@@ -436,7 +456,12 @@ static Value *
gnumeric_weekday (FunctionEvalInfo *ei, Value **argv)
{
int res = 1;
GDate *date = datetime_value_to_g (argv[0]);
GDate *date;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
date = datetime_value_to_g (argv[0]);
if (date != NULL) {
res = (g_date_weekday (date) + 1) % 7;
g_date_free (date);
......@@ -487,6 +512,10 @@ gnumeric_days360 (FunctionEvalInfo *ei, Value **argv)
} else
method = METHOD_US;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
if (argv[1]->type == VALUE_ERROR)
return value_duplicate (argv[1]);
serial1 = datetime_value_to_serial (argv[0]);
serial2 = datetime_value_to_serial (argv[1]);
if ((flipped = (serial1 > serial2))) {
......@@ -563,8 +592,12 @@ gnumeric_eomonth (FunctionEvalInfo *ei, Value **argv)
{
Value *res;
int months = 0;
GDate *date = datetime_value_to_g (argv[0]);
GDate *date;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
date = datetime_value_to_g (argv[0]);
if (date == NULL || !g_date_valid (date))
return value_new_error (ei->pos, gnumeric_err_VALUE);
......@@ -608,8 +641,12 @@ gnumeric_workday (FunctionEvalInfo *ei, Value **argv)
Value *res;
int days;
GDateWeekday weekday;
GDate *date = datetime_value_to_g (argv[0]);
GDate *date;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
date = datetime_value_to_g (argv[0]);
if (date == NULL || !g_date_valid (date))
return value_new_error (ei->pos, gnumeric_err_VALUE);
weekday = g_date_weekday (date);
......@@ -702,9 +739,12 @@ networkdays_holiday_callback(EvalPos const *ep,
Value *res = NULL;
networkdays_holiday_closure * close =
(networkdays_holiday_closure *)user_data;
int const serial = datetime_value_to_serial (v);
int serial;
GDate * date;
if (v->type == VALUE_ERROR)
return value_duplicate (v);
serial = datetime_value_to_serial (v);
if (serial <= 0)
return value_new_error (ep, gnumeric_err_NUM);
......@@ -730,6 +770,14 @@ gnumeric_networkdays (FunctionEvalInfo *ei, Value **argv)
int start_offset, end_offset, res;
networkdays_holiday_closure close;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
if (argv[1]->type == VALUE_ERROR)
return value_duplicate (argv[1]);
start_serial = datetime_value_to_serial (argv[0]);
end_serial = datetime_value_to_serial (argv[1]);
/* Swap if necessary */
if (start_serial > end_serial) {
int tmp = start_serial;
......
......@@ -2576,6 +2576,11 @@ gnumeric_coupdaybs (FunctionEvalInfo *ei, Value **argv)
int freq, basis;
int days;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
if (argv[1]->type == VALUE_ERROR)
return value_duplicate (argv[1]);
settlement = datetime_value_to_g(argv[0]);
maturity = datetime_value_to_g(argv[1]);
freq = value_get_as_int (argv[2]);
......@@ -2621,6 +2626,11 @@ gnumeric_coupdays (FunctionEvalInfo *ei, Value **argv)
int freq, basis;
float_t days;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
if (argv[1]->type == VALUE_ERROR)
return value_duplicate (argv[1]);
settlement = datetime_value_to_g(argv[0]);
maturity = datetime_value_to_g(argv[1]);
freq = value_get_as_int (argv[2]);
......@@ -2686,6 +2696,11 @@ gnumeric_coupncd (FunctionEvalInfo *ei, Value **argv)
int freq, basis;
Value *v;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
if (argv[1]->type == VALUE_ERROR)
return value_duplicate (argv[1]);
settlement = datetime_value_to_g(argv[0]);
maturity = datetime_value_to_g(argv[1]);
freq = value_get_as_int (argv[2]);
......@@ -2748,6 +2763,11 @@ gnumeric_coupnum (FunctionEvalInfo *ei, Value **argv)
int freq, basis;
float_t n;
if (argv[0]->type == VALUE_ERROR)
return value_duplicate (argv[0]);
if (argv[1]->type == VALUE_ERROR)
return value_duplicate (argv[1]);
settlement = datetime_value_to_g(argv[0]);
maturity = datetime_value_to_g(argv[1]);
freq = value_get_as_int (argv[2]);
......
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