Commit 87c80759 authored by Jody Goldberg's avatar Jody Goldberg

Gnumeric 1.1.15


Gnumeric 1.1.15

Jody:
	* Remove unnecessary new/free of dates.
parent d6b2d022
......@@ -7,8 +7,6 @@ release, and longer term bugs.
Release Critical
----------------
- format-template.c, line 1221: FALSE used where pointer expected.
Pending Patches
---------------
- ?? more work on D&D based sheet reorg ?
......@@ -130,11 +128,8 @@ Functions
ODDFPRICE (test fails)
ODDFYEILD (unimplementeD)
YIELDDISC (test fails by alot)
openoffice/scaddins/source/analysis/analysishelper.cxx
has copies of these. Although the code looks simplistic
Need to read the docs
ODDLPRICE (test fails, so does OO)
ODDLYEILD (test fails, so does OO)
Convert the code from sc to use our more accurate date routines
WORKDAY Add holiday support
UTF-8:
- Window titles.
......
2002-12-31 Jody Goldberg <jody@gnome.org>
* src/commands.c (cmd_area_set_text_redo) : fix. It is an error to
pass NULL as the parse text.
2002-12-30 Morten Welinder <terra@diku.dk>
* src/format-template.c: Import CC2XML and CXML2C macros from
......
......@@ -9,6 +9,7 @@ Jody:
* Ins/Del Col/Row now handles frozen panes.
* Lower right of merge extends sheet bounds.
* Fix parser's handling of unknown function.
* Remove unnecessary new/free of dates.
Jon Kåre:
* Open DB connections read only.
......
2002-12-31 Jody Goldberg <jody@gnome.org>
* src/commands.c (cmd_area_set_text_redo) : fix. It is an error to
pass NULL as the parse text.
2002-12-30 Morten Welinder <terra@diku.dk>
* src/format-template.c: Import CC2XML and CXML2C macros from
......
2002-12-31 Jody Goldberg <jody@gnome.org>
* src/commands.c (cmd_area_set_text_redo) : fix. It is an error to
pass NULL as the parse text.
2002-12-30 Morten Welinder <terra@diku.dk>
* src/format-template.c: Import CC2XML and CXML2C macros from
......
......@@ -144,7 +144,7 @@ cum_biv_norm_dist(FunctionEvalInfo *ei, Value *argv[])
return value_new_float (result);
}
static const char *help_cum_biv_norm_dist = {
static char const *help_cum_biv_norm_dist = {
/* xgettext:no-c-format */
N_("@FUNCTION=CUM_BIV_NORM_DIST\n"
......@@ -198,7 +198,7 @@ opt_bs (FunctionEvalInfo *ei, Value *argv[])
return value_new_float (gfresult);
}
static const char *help_opt_bs = {
static char const *help_opt_bs = {
N_("@FUNCTION=OPT_BS\n"
"@SYNTAX=OPT_BS(call_put_flag,spot,strike,time,rate,volatility,"
"cost_of_carry)\n"
......@@ -809,7 +809,7 @@ opt_jump_diff(FunctionEvalInfo *ei, Value *argv[])
return value_new_float (gfresult);
}
static const char *help_opt_jump_diff = {
static char const *help_opt_jump_diff = {
/* xgettext:no-c-format */
N_("@FUNCTION=OPT_JUMP_DIFF\n"
......
......@@ -76,7 +76,7 @@ value_new_complex (const complex_t *c, char imunit)
/***************************************************************************/
static const char *help_complex = {
static char const *help_complex = {
N_("@FUNCTION=COMPLEX\n"
"@SYNTAX=COMPLEX(real,im[,suffix])\n"
......@@ -100,7 +100,7 @@ static Value *
gnumeric_complex (FunctionEvalInfo *ei, Value **argv)
{
complex_t c;
const char *suffix;
char const *suffix;
complex_init (&c,
value_get_as_float (argv[0]),
......@@ -115,7 +115,7 @@ gnumeric_complex (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imaginary = {
static char const *help_imaginary = {
N_("@FUNCTION=IMAGINARY\n"
"@SYNTAX=IMAGINARY(inumber)\n"
"@DESCRIPTION="
......@@ -148,7 +148,7 @@ gnumeric_imaginary (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imabs = {
static char const *help_imabs = {
N_("@FUNCTION=IMABS\n"
"@SYNTAX=IMABS(inumber)\n"
"@DESCRIPTION="
......@@ -181,7 +181,7 @@ gnumeric_imabs (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imreal = {
static char const *help_imreal = {
N_("@FUNCTION=IMREAL\n"
"@SYNTAX=IMREAL(inumber)\n"
"@DESCRIPTION="
......@@ -214,7 +214,7 @@ gnumeric_imreal (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imconjugate = {
static char const *help_imconjugate = {
N_("@FUNCTION=IMCONJUGATE\n"
"@SYNTAX=IMCONJUGATE(inumber)\n"
"@DESCRIPTION="
......@@ -248,7 +248,7 @@ gnumeric_imconjugate (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_iminv = {
static char const *help_iminv = {
N_("@FUNCTION=IMINV\n"
"@SYNTAX=IMINV(inumber)\n"
"@DESCRIPTION="
......@@ -279,7 +279,7 @@ gnumeric_iminv (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imneg = {
static char const *help_imneg = {
N_("@FUNCTION=IMNEG\n"
"@SYNTAX=IMNEG(inumber)\n"
"@DESCRIPTION="
......@@ -310,7 +310,7 @@ gnumeric_imneg (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imcos = {
static char const *help_imcos = {
N_("@FUNCTION=IMCOS\n"
"@SYNTAX=IMCOS(inumber)\n"
"@DESCRIPTION="
......@@ -341,7 +341,7 @@ gnumeric_imcos (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imtan = {
static char const *help_imtan = {
N_("@FUNCTION=IMTAN\n"
"@SYNTAX=IMTAN(inumber)\n"
"@DESCRIPTION="
......@@ -372,7 +372,7 @@ gnumeric_imtan (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imsec = {
static char const *help_imsec = {
N_("@FUNCTION=IMSEC\n"
"@SYNTAX=IMSEC(inumber)\n"
"@DESCRIPTION="
......@@ -405,7 +405,7 @@ gnumeric_imsec (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imcsc = {
static char const *help_imcsc = {
N_("@FUNCTION=IMCSC\n"
"@SYNTAX=IMCSC(inumber)\n"
"@DESCRIPTION="
......@@ -438,7 +438,7 @@ gnumeric_imcsc (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imcot = {
static char const *help_imcot = {
N_("@FUNCTION=IMCOT\n"
"@SYNTAX=IMCOT(inumber)\n"
"@DESCRIPTION="
......@@ -471,7 +471,7 @@ gnumeric_imcot (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imexp = {
static char const *help_imexp = {
N_("@FUNCTION=IMEXP\n"
"@SYNTAX=IMEXP(inumber)\n"
"@DESCRIPTION="
......@@ -502,7 +502,7 @@ gnumeric_imexp (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imargument = {
static char const *help_imargument = {
N_("@FUNCTION=IMARGUMENT\n"
"@SYNTAX=IMARGUMENT(inumber)\n"
"@DESCRIPTION="
......@@ -534,7 +534,7 @@ gnumeric_imargument (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imln = {
static char const *help_imln = {
N_("@FUNCTION=IMLN\n"
"@SYNTAX=IMLN(inumber)\n"
"@DESCRIPTION="
......@@ -570,7 +570,7 @@ gnumeric_imln (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imlog2 = {
static char const *help_imlog2 = {
N_("@FUNCTION=IMLOG2\n"
"@SYNTAX=IMLOG2(inumber)\n"
"@DESCRIPTION="
......@@ -602,7 +602,7 @@ gnumeric_imlog2 (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imlog10 = {
static char const *help_imlog10 = {
N_("@FUNCTION=IMLOG10\n"
"@SYNTAX=IMLOG10(inumber)\n"
"@DESCRIPTION="
......@@ -634,7 +634,7 @@ gnumeric_imlog10 (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_impower = {
static char const *help_impower = {
N_("@FUNCTION=IMPOWER\n"
"@SYNTAX=IMPOWER(inumber1,inumber2)\n"
"@DESCRIPTION="
......@@ -673,7 +673,7 @@ gnumeric_impower (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imdiv = {
static char const *help_imdiv = {
N_("@FUNCTION=IMDIV\n"
"@SYNTAX=IMDIV(inumber1,inumber2)\n"
"@DESCRIPTION="
......@@ -710,7 +710,7 @@ gnumeric_imdiv (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imsin = {
static char const *help_imsin = {
N_("@FUNCTION=IMSIN\n"
"@SYNTAX=IMSIN(inumber)\n"
"@DESCRIPTION="
......@@ -740,7 +740,7 @@ gnumeric_imsin (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imsinh = {
static char const *help_imsinh = {
N_("@FUNCTION=IMSINH\n"
"@SYNTAX=IMSINH(inumber)\n"
"@DESCRIPTION="
......@@ -772,7 +772,7 @@ gnumeric_imsinh (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imcosh = {
static char const *help_imcosh = {
N_("@FUNCTION=IMCOSH\n"
"@SYNTAX=IMCOSH(inumber)\n"
"@DESCRIPTION="
......@@ -803,7 +803,7 @@ gnumeric_imcosh (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imtanh = {
static char const *help_imtanh = {
N_("@FUNCTION=IMTANH\n"
"@SYNTAX=IMTANH(inumber)\n"
"@DESCRIPTION="
......@@ -834,7 +834,7 @@ gnumeric_imtanh (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imsech = {
static char const *help_imsech = {
N_("@FUNCTION=IMSECH\n"
"@SYNTAX=IMSECH(inumber)\n"
"@DESCRIPTION="
......@@ -865,7 +865,7 @@ gnumeric_imsech (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imcsch = {
static char const *help_imcsch = {
N_("@FUNCTION=IMCSCH\n"
"@SYNTAX=IMCSCH(inumber)\n"
"@DESCRIPTION="
......@@ -896,7 +896,7 @@ gnumeric_imcsch (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imcoth = {
static char const *help_imcoth = {
N_("@FUNCTION=IMCOTH\n"
"@SYNTAX=IMCOTH(inumber)\n"
"@DESCRIPTION="
......@@ -927,7 +927,7 @@ gnumeric_imcoth (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imarcsin = {
static char const *help_imarcsin = {
N_("@FUNCTION=IMARCSIN\n"
"@SYNTAX=IMARCSIN(inumber)\n"
"@DESCRIPTION="
......@@ -959,7 +959,7 @@ gnumeric_imarcsin (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imarccos = {
static char const *help_imarccos = {
N_("@FUNCTION=IMARCCOS\n"
"@SYNTAX=IMARCCOS(inumber)\n"
"@DESCRIPTION="
......@@ -991,7 +991,7 @@ gnumeric_imarccos (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imarctan = {
static char const *help_imarctan = {
N_("@FUNCTION=IMARCTAN\n"
"@SYNTAX=IMARCTAN(inumber)\n"
"@DESCRIPTION="
......@@ -1023,7 +1023,7 @@ gnumeric_imarctan (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imarcsec = {
static char const *help_imarcsec = {
N_("@FUNCTION=IMARCSEC\n"
"@SYNTAX=IMARCSEC(inumber)\n"
"@DESCRIPTION="
......@@ -1054,7 +1054,7 @@ gnumeric_imarcsec (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imarccsc = {
static char const *help_imarccsc = {
N_("@FUNCTION=IMARCCSC\n"
"@SYNTAX=IMARCCSC(inumber)\n"
"@DESCRIPTION="
......@@ -1085,7 +1085,7 @@ gnumeric_imarccsc (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imarccot = {
static char const *help_imarccot = {
N_("@FUNCTION=IMARCCOT\n"
"@SYNTAX=IMARCCOT(inumber)\n"
"@DESCRIPTION="
......@@ -1116,7 +1116,7 @@ gnumeric_imarccot (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imarcsinh = {
static char const *help_imarcsinh = {
N_("@FUNCTION=IMARCSINH\n"
"@SYNTAX=IMARCSINH(inumber)\n"
"@DESCRIPTION="
......@@ -1148,7 +1148,7 @@ gnumeric_imarcsinh (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imarccosh = {
static char const *help_imarccosh = {
N_("@FUNCTION=IMARCCOSH\n"
"@SYNTAX=IMARCCOSH(inumber)\n"
"@DESCRIPTION="
......@@ -1180,7 +1180,7 @@ gnumeric_imarccosh (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imarctanh = {
static char const *help_imarctanh = {
N_("@FUNCTION=IMARCTANH\n"
"@SYNTAX=IMARCTANH(inumber)\n"
"@DESCRIPTION="
......@@ -1212,7 +1212,7 @@ gnumeric_imarctanh (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imarcsech = {
static char const *help_imarcsech = {
N_("@FUNCTION=IMARCSECH\n"
"@SYNTAX=IMARCSECH(inumber)\n"
"@DESCRIPTION="
......@@ -1244,7 +1244,7 @@ gnumeric_imarcsech (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imarccsch = {
static char const *help_imarccsch = {
N_("@FUNCTION=IMARCCSCH\n"
"@SYNTAX=IMARCCSCH(inumber)\n"
"@DESCRIPTION="
......@@ -1275,7 +1275,7 @@ gnumeric_imarccsch (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imarccoth = {
static char const *help_imarccoth = {
N_("@FUNCTION=IMARCCOTH\n"
"@SYNTAX=IMARCCOTH(inumber)\n"
"@DESCRIPTION="
......@@ -1307,7 +1307,7 @@ gnumeric_imarccoth (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imsqrt = {
static char const *help_imsqrt = {
N_("@FUNCTION=IMSQRT\n"
"@SYNTAX=IMSQRT(inumber)\n"
"@DESCRIPTION="
......@@ -1338,7 +1338,7 @@ gnumeric_imsqrt (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_imsub = {
static char const *help_imsub = {
N_("@FUNCTION=IMSUB\n"
"@SYNTAX=IMSUB(inumber1,inumber2)\n"
"@DESCRIPTION="
......@@ -1372,7 +1372,7 @@ gnumeric_imsub (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_improduct = {
static char const *help_improduct = {
N_("@FUNCTION=IMPRODUCT\n"
"@SYNTAX=IMPRODUCT(inumber1[,inumber2,...])\n"
"@DESCRIPTION="
......@@ -1444,7 +1444,7 @@ gnumeric_improduct (FunctionEvalInfo *ei, GnmExprList *expr_node_list)
/***************************************************************************/
static const char *help_imsum = {
static char const *help_imsum = {
N_("@FUNCTION=IMSUM\n"
"@SYNTAX=IMSUM(inumber1,inumber2)\n"
"@DESCRIPTION="
......
......@@ -260,7 +260,7 @@ database_value_range_function (FunctionEvalInfo *ei,
/***************************************************************************/
static const char *help_daverage = {
static char const *help_daverage = {
N_("@FUNCTION=DAVERAGE\n"
"@SYNTAX=DAVERAGE(database,field,criteria)\n"
......@@ -333,7 +333,7 @@ gnumeric_daverage (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_dcount = {
static char const *help_dcount = {
N_("@FUNCTION=DCOUNT\n"
"@SYNTAX=DCOUNT(database,field,criteria)\n"
......@@ -405,7 +405,7 @@ gnumeric_dcount (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_dcounta = {
static char const *help_dcounta = {
N_("@FUNCTION=DCOUNTA\n"
"@SYNTAX=DCOUNTA(database,field,criteria)\n"
......@@ -475,7 +475,7 @@ gnumeric_dcounta (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_dget = {
static char const *help_dget = {
N_("@FUNCTION=DGET\n"
"@SYNTAX=DGET(database,field,criteria)\n"
......@@ -557,7 +557,7 @@ gnumeric_dget (FunctionEvalInfo *ei, Value **argv)
GNM_ERROR_NUM);
}
static const char *help_dmax = {
static char const *help_dmax = {
N_("@FUNCTION=DMAX\n"
"@SYNTAX=DMAX(database,field,criteria)\n"
......@@ -631,7 +631,7 @@ gnumeric_dmax (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_dmin = {
static char const *help_dmin = {
N_("@FUNCTION=DMIN\n"
"@SYNTAX=DMIN(database,field,criteria)\n"
......@@ -702,7 +702,7 @@ gnumeric_dmin (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_dproduct = {
static char const *help_dproduct = {
N_("@FUNCTION=DPRODUCT\n"
"@SYNTAX=DPRODUCT(database,field,criteria)\n"
......@@ -773,7 +773,7 @@ gnumeric_dproduct (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_dstdev = {
static char const *help_dstdev = {
N_("@FUNCTION=DSTDEV\n"
"@SYNTAX=DSTDEV(database,field,criteria)\n"
......@@ -845,7 +845,7 @@ gnumeric_dstdev (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_dstdevp = {
static char const *help_dstdevp = {
N_("@FUNCTION=DSTDEVP\n"
"@SYNTAX=DSTDEVP(database,field,criteria)\n"
......@@ -917,7 +917,7 @@ gnumeric_dstdevp (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_dsum = {
static char const *help_dsum = {
N_("@FUNCTION=DSUM\n"
"@SYNTAX=DSUM(database,field,criteria)\n"
......@@ -989,7 +989,7 @@ gnumeric_dsum (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_dvar = {
static char const *help_dvar = {
N_("@FUNCTION=DVAR\n"
"@SYNTAX=DVAR(database,field,criteria)\n"
......@@ -1061,7 +1061,7 @@ gnumeric_dvar (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_dvarp = {
static char const *help_dvarp = {
N_("@FUNCTION=DVARP\n"
"@SYNTAX=DVARP(database,field,criteria)\n"
......@@ -1133,7 +1133,7 @@ gnumeric_dvarp (FunctionEvalInfo *ei, Value **argv)
/***************************************************************************/
static const char *help_getpivotdata = {
static char const *help_getpivotdata = {
N_("@FUNCTION=GETPIVOTDATA\n"
"@SYNTAX=GETPIVOTDATA(pivot_table,field_name)\n"
......
......@@ -285,7 +285,7 @@ datedif_opt_yd (GDate *gdate1, GDate *gdate2, int excel_compat)
}
static int
datedif_opt_md (GDate *gdate1, GDate *gdate2, int excel_compat)
datedif_opt_md (GDate *gdate1, GDate *gdate2, gboolean excel_compat)
{
int day;
......@@ -326,52 +326,34 @@ gnumeric_datedif (FunctionEvalInfo *ei, Value **argv)
{
int date1, date2;
char const *opt;
GDate *gdate1, *gdate2;
Value *result;
GDate d1, d2;
date1 = floorgnum (value_get_as_float (argv [0]));
date2 = floorgnum (value_get_as_float (argv [1]));
opt = value_peek_string (argv[2]);
if (date1 > date2) {
if (date1 > date2)
return value_new_error_NUM (ei->pos);
}
if (!strcmp (opt, "d")) {
if (!strcmp (opt, "d"))
return value_new_int (date2 - date1);
}
gdate1 = datetime_serial_to_g (date1);
gdate2 = datetime_serial_to_g (date2);
if (!g_date_valid (gdate1) || !g_date_valid (gdate2)) {
result = value_new_error_VALUE (ei->pos);
} else {
if (!strcmp (opt, "m")) {
result = value_new_int (
datetime_g_months_between (gdate1, gdate2));
} else if (!strcmp (opt, "y")) {
result = value_new_int (
datetime_g_years_between (gdate1, gdate2));
} else if (!strcmp (opt, "ym")) {
result = value_new_int (
datedif_opt_ym (gdate1, gdate2));
} else if (!strcmp (opt, "yd")) {
result = value_new_int (
datedif_opt_yd (gdate1, gdate2, 1));
} else if (!strcmp (opt, "md")) {
result = value_new_int (
datedif_opt_md (gdate1, gdate2, 1));
} else {
result = value_new_error_VALUE (ei->pos);
}
}
datetime_g_free (gdate1);
datetime_g_free (gdate2);
datetime_serial_to_g (&d1, date1);
datetime_serial_to_g (&d2, date2);
if (!g_date_valid (&d1) || !g_date_valid (&d2))
return value_new_error_VALUE (ei->pos);
return result;
if (!strcmp (opt, "m"))
return value_new_int (datetime_g_months_between (&d1, &d2));
else if (!strcmp (opt, "y"))
return value_new_int (datetime_g_years_between (&d1, &d2));
else if (!strcmp (opt, "ym"))
return value_new_int (datedif_opt_ym (&d1, &d2));
else if (!strcmp (opt, "yd"))
return value_new_int (datedif_opt_yd (&d1, &d2, TRUE));
else if (!strcmp (opt, "md"))
return value_new_int (datedif_opt_md (&d1, &d2, TRUE));
else
return value_new_error_VALUE (ei->pos);
}
/***************************************************************************/
......@@ -400,32 +382,26 @@ static Value *
gnumeric_edate (FunctionEvalInfo *ei, Value **argv)
{
int serial, months;
GDate* date;
GDate date;
Value *res;
serial = value_get_as_int(argv[0]);
months = value_get_as_int(argv[1]);
date = datetime_serial_to_g (serial);
if (!g_date_valid (date)) {
datetime_g_free (date);
datetime_serial_to_g (&date, serial);
if (!g_date_valid (&date))
return value_new_error_VALUE (ei->pos);
}
if (months > 0)
g_date_add_months (date, months);
g_date_add_months (&date, months);
else
g_date_subtract_months (date, -months);
g_date_subtract_months (&date, -months);
if (!g_date_valid (date)) {
datetime_g_free (date);
if (!g_date_valid (&date))
return value_new_error_NUM (ei->pos);
}
res = value_new_int (datetime_g_to_serial (date));
res = value_new_int (datetime_g_to_serial (&date));
value_set_fmt (res, style_format_default_date ());
datetime_g_free (date);
return res;
}
......@@ -650,13 +626,10 @@ static Value *
gnumeric_year (FunctionEvalInfo *ei, Value **argv)
{
int res = 1900;
GDate *date;
GDate date;
date = datetime_value_to_g (argv[0]);
if (date != NULL) {
res = g_date_get_year (date);
g_date_free (date);
}
if (datetime_value_to_g (&date, argv[0]))
res = g_date_get_year (&date);
return value_new_int (res);
}
......@@ -684,13 +657,10 @@ static Value *
gnumeric_month (FunctionEvalInfo *ei, Value **argv)
{
int res = 1;
GDate *date;
GDate date;
date = datetime_value_to_g (argv[0]);
if (date != NULL) {
res = g_date_get_month (date);
g_date_free (date);
}
if (datetime_value_to_g (&date, argv[0]))
res = g_date_get_month (&date);
return value_new_int (res);
}
......@@ -718,13 +688,10 @@ static Value *
gnumeric_day (FunctionEvalInfo *ei, Value **argv)
{
int res = 1;
GDate *date;
GDate date;
date = datetime_value_to_g (argv[0]);
if (date != NULL) {
res = g_date_get_day (date);
g_date_free (date);
}
if (datetime_value_to_g (&date, argv[0]))
res = g_date_get_day (&date);
return value_new_int (res);
}
......@@ -758,26 +725,24 @@ static char const *help_weekday = {
static Value *
gnumeric_weekday (FunctionEvalInfo *ei, Value **argv)
{
int res;
GDate *date;
int method = argv[1] ? value_get_as_int (argv[1]) : 1;
GDate date;
int res;
int method = argv[1] ? value_get_as_int (argv[1]) : 1;