Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
GNOME
gnumeric
Commits
ddece2e1
Commit
ddece2e1
authored
Mar 25, 1999
by
Michael Meeks
Browse files
Added optional token to function arguments.
parent
7a88fba5
Changes
9
Hide whitespace changes
Inline
Side-by-side
ChangeLog-1999-07-09
View file @
ddece2e1
1999-03-25 Michael Meeks <michael@imaginator.com>
* src/expr.c (eval_funcall): Updated to add new optional argument
token.
* src/expr.h: Comments to explain above.
* src/fn-eng.c (gnumeric_erf, gnumeric_delta): Drastic clean to use
new optional token.
1999-03-23 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/fn-math.c: ceiling added.
...
...
ChangeLog-2000-02-23
View file @
ddece2e1
1999-03-25 Michael Meeks <michael@imaginator.com>
* src/expr.c (eval_funcall): Updated to add new optional argument
token.
* src/expr.h: Comments to explain above.
* src/fn-eng.c (gnumeric_erf, gnumeric_delta): Drastic clean to use
new optional token.
1999-03-23 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/fn-math.c: ceiling added.
...
...
OChangeLog-1999-07-09
View file @
ddece2e1
1999-03-25 Michael Meeks <michael@imaginator.com>
* src/expr.c (eval_funcall): Updated to add new optional argument
token.
* src/expr.h: Comments to explain above.
* src/fn-eng.c (gnumeric_erf, gnumeric_delta): Drastic clean to use
new optional token.
1999-03-23 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/fn-math.c: ceiling added.
...
...
OChangeLog-2000-02-23
View file @
ddece2e1
1999-03-25 Michael Meeks <michael@imaginator.com>
* src/expr.c (eval_funcall): Updated to add new optional argument
token.
* src/expr.h: Comments to explain above.
* src/fn-eng.c (gnumeric_erf, gnumeric_delta): Drastic clean to use
new optional token.
1999-03-23 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/fn-math.c: ceiling added.
...
...
plugins/fn-eng/functions.c
View file @
ddece2e1
...
...
@@ -484,37 +484,13 @@ static char *help_erf = {
static
Value
*
gnumeric_erf
(
void
*
sheet
,
GList
*
l
,
int
eval_col
,
int
eval_row
,
char
**
error_string
)
gnumeric_erf
(
struct
FunctionDefinition
*
i
,
Value
*
argv
[]
,
char
**
error_string
)
{
float_t
ans
,
lower
,
upper
=
0
.
0
;
int
argc
=
g_list_length
(
l
)
;
Value
*
vlower
,
*
vupper
=
0
;
if
(
argc
<
1
||
argc
>
2
||
!
l
->
data
)
{
*
error_string
=
_
(
"Invalid number of arguments"
)
;
return
NULL
;
}
vlower
=
eval_expr
(
sheet
,
l
->
data
,
eval_col
,
eval_row
,
error_string
)
;
if
(
vlower
->
type
!=
VALUE_INTEGER
&&
vlower
->
type
!=
VALUE_FLOAT
)
{
*
error_string
=
_
(
"#VALUE!"
)
;
return
NULL
;
}
lower
=
value_get_as_double
(
vlower
)
;
value_release
(
vlower
)
;
l
=
g_list_next
(
l
)
;
if
(
l
&&
l
->
data
)
{
vupper
=
eval_expr
(
sheet
,
l
->
data
,
eval_col
,
eval_row
,
error_string
)
;
if
(
vupper
->
type
!=
VALUE_INTEGER
&&
vupper
->
type
!=
VALUE_FLOAT
)
{
*
error_string
=
_
(
"#VALUE!"
)
;
return
NULL
;
}
upper
=
value_get_as_double
(
vupper
)
;
value_release
(
vupper
)
;
}
lower
=
value_get_as_double
(
argv
[
0
])
;
if
(
argv
[
1
])
upper
=
value_get_as_double
(
argv
[
1
])
;
if
(
lower
<
0
.
0
||
upper
<
0
.
0
)
{
*
error_string
=
_
(
"#NUM!"
)
;
...
...
@@ -522,7 +498,7 @@ gnumeric_erf (void *sheet, GList *l, int eval_col, int eval_row, char **error_st
}
ans
=
erf
(
lower
)
;
if
(
vupper
)
if
(
argv
[
1
]
)
ans
=
erf
(
upper
)
-
ans
;
return
value_float
(
ans
)
;
...
...
@@ -569,35 +545,17 @@ static char *help_delta = {
static
Value
*
gnumeric_delta
(
void
*
sheet
,
GList
*
l
,
int
eval_col
,
int
eval_row
,
char
**
error_string
)
gnumeric_delta
(
struct
FunctionDefinition
*
i
,
Value
*
argv
[]
,
char
**
error_string
)
{
int
ans
=
0
;
int
argc
=
g_list_length
(
l
)
;
Value
*
vx
,
*
vy
;
if
(
argc
<
1
||
argc
>
2
||
!
l
->
data
)
{
*
error_string
=
_
(
"Invalid number of arguments"
)
;
return
NULL
;
}
vx
=
eval_expr
(
sheet
,
l
->
data
,
eval_col
,
eval_row
,
error_string
)
;
if
(
vx
->
type
!=
VALUE_INTEGER
&&
vx
->
type
!=
VALUE_FLOAT
)
{
*
error_string
=
_
(
"#VALUE!"
)
;
return
NULL
;
}
l
=
g_list_next
(
l
)
;
if
(
l
&&
l
->
data
)
{
vy
=
eval_expr
(
sheet
,
l
->
data
,
eval_col
,
eval_row
,
error_string
)
;
if
(
vy
->
type
!=
VALUE_INTEGER
&&
vy
->
type
!=
VALUE_FLOAT
)
{
*
error_string
=
_
(
"#VALUE!"
)
;
return
NULL
;
}
}
vx
=
argv
[
0
]
;
if
(
argv
[
1
])
vy
=
argv
[
1
]
;
else
vy
=
value_int
(
0
)
;
vy
=
value_int
(
0
)
;
switch
(
vx
->
type
)
{
case
VALUE_INTEGER
:
...
...
@@ -637,8 +595,6 @@ gnumeric_delta (void *sheet, GList *l, int eval_col, int eval_row, char **error_
return
NULL
;
}
value_release
(
vx
)
;
value_release
(
vy
)
;
return
value_int
(
ans
)
;
}
...
...
@@ -764,8 +720,8 @@ FunctionDefinition eng_functions [] = {
{
"dec2bin"
,
0
,
"xnum,ynum"
,
&
help_dec2bin
,
gnumeric_dec2bin
,
NULL
},
{
"dec2oct"
,
0
,
"xnum,ynum"
,
&
help_dec2oct
,
gnumeric_dec2oct
,
NULL
},
{
"dec2hex"
,
0
,
"xnum,ynum"
,
&
help_dec2hex
,
gnumeric_dec2hex
,
NULL
},
{
"delta"
,
0
,
"xnum,ynum"
,
&
help_delta
,
gnumeric_delta
,
NULL
},
{
"erf"
,
0
,
"lower,upper"
,
&
help_erf
,
gnumeric_erf
,
NULL
},
{
"delta"
,
"f|f"
,
"xnum,ynum"
,
&
help_delta
,
NULL
,
gnumeric_delta
},
{
"erf"
,
"f|f"
,
"lower,upper"
,
&
help_erf
,
NULL
,
gnumeric_erf
},
{
"erfc"
,
"f"
,
"number"
,
&
help_erfc
,
NULL
,
gnumeric_erfc
},
{
"gestep"
,
0
,
"xnum,ynum"
,
&
help_gestep
,
gnumeric_gestep
,
NULL
},
{
"hex2bin"
,
0
,
"xnum,ynum"
,
&
help_hex2bin
,
gnumeric_hex2bin
,
NULL
},
...
...
src/expr.c
View file @
ddece2e1
...
...
@@ -475,17 +475,28 @@ eval_funcall (Sheet *sheet, ExprTree *tree, int eval_col, int eval_row, char **e
{
/* Functions that take pre-computed Values */
Value
**
values
;
int
fn_argc
;
char
*
arg_type
=
fd
->
args
;
int
fn_argc_min
=
0
,
fn_argc_max
=
0
,
var_len
=
0
;
char
*
arg_type
=
fd
->
args
,
*
argptr
=
fd
->
args
;
/* Get variable limits */
while
(
*
argptr
)
{
if
(
*
argptr
++==
'|'
)
{
var_len
=
1
;
continue
;
}
if
(
!
var_len
)
fn_argc_min
++
;
fn_argc_max
++
;
}
fn_argc
=
strlen
(
fd
->
args
);
/*
fn_argc = strlen (fd->args);
*/
if
(
fn_argc
!=
argc
)
{
if
(
argc
>
fn_argc_max
||
argc
<
fn_argc_min
)
{
*
error_string
=
_
(
"Invalid number of arguments"
);
return
NULL
;
}
values
=
g_new
(
Value
*
,
argc
);
values
=
g_new
(
Value
*
,
fn_
argc
_max
);
for
(
arg
=
0
;
l
;
l
=
l
->
next
,
arg
++
,
arg_type
++
){
ExprTree
*
t
=
(
ExprTree
*
)
l
->
data
;
...
...
@@ -493,8 +504,8 @@ eval_funcall (Sheet *sheet, ExprTree *tree, int eval_col, int eval_row, char **e
v
=
eval_expr
(
sheet
,
t
,
eval_col
,
eval_row
,
error_string
);
if
(
v
==
NULL
)
goto
free_list
;
switch
(
*
arg_type
){
if
(
*
arg_type
==
'|'
)
arg_type
++
;
switch
(
*
arg_type
)
{
case
'f'
:
if
(
v
->
type
==
VALUE_INTEGER
||
v
->
type
==
VALUE_FLOAT
)
...
...
@@ -513,11 +524,15 @@ eval_funcall (Sheet *sheet, ExprTree *tree, int eval_col, int eval_row, char **e
values
[
arg
]
=
v
;
}
while
(
arg
<
fn_argc_max
)
values
[
arg
++
]
=
NULL
;
v
=
fd
->
fn
(
fd
,
values
,
error_string
);
free_list:
for
(
i
=
0
;
i
<
arg
;
i
++
)
value_release
(
values
[
i
]);
for
(
i
=
0
;
i
<
arg
;
i
++
)
{
if
(
values
[
i
]
!=
NULL
)
value_release
(
values
[
i
])
;
}
g_free
(
values
);
return
v
;
}
...
...
src/expr.h
View file @
ddece2e1
...
...
@@ -107,12 +107,15 @@ struct FunctionDefinition {
/* The function name */
char
*
name
;
/* The types accepted:
/**
* The types accepted:
* f for float
* s for string
* b for boolean
* ? for any kind
*/
* For optional arguments do:
* "ff|ss" where the strings are optional
**/
char
*
args
;
char
*
named_arguments
;
char
**
help
;
...
...
src/fn-eng.c
View file @
ddece2e1
...
...
@@ -484,37 +484,13 @@ static char *help_erf = {
static
Value
*
gnumeric_erf
(
void
*
sheet
,
GList
*
l
,
int
eval_col
,
int
eval_row
,
char
**
error_string
)
gnumeric_erf
(
struct
FunctionDefinition
*
i
,
Value
*
argv
[]
,
char
**
error_string
)
{
float_t
ans
,
lower
,
upper
=
0
.
0
;
int
argc
=
g_list_length
(
l
)
;
Value
*
vlower
,
*
vupper
=
0
;
if
(
argc
<
1
||
argc
>
2
||
!
l
->
data
)
{
*
error_string
=
_
(
"Invalid number of arguments"
)
;
return
NULL
;
}
vlower
=
eval_expr
(
sheet
,
l
->
data
,
eval_col
,
eval_row
,
error_string
)
;
if
(
vlower
->
type
!=
VALUE_INTEGER
&&
vlower
->
type
!=
VALUE_FLOAT
)
{
*
error_string
=
_
(
"#VALUE!"
)
;
return
NULL
;
}
lower
=
value_get_as_double
(
vlower
)
;
value_release
(
vlower
)
;
l
=
g_list_next
(
l
)
;
if
(
l
&&
l
->
data
)
{
vupper
=
eval_expr
(
sheet
,
l
->
data
,
eval_col
,
eval_row
,
error_string
)
;
if
(
vupper
->
type
!=
VALUE_INTEGER
&&
vupper
->
type
!=
VALUE_FLOAT
)
{
*
error_string
=
_
(
"#VALUE!"
)
;
return
NULL
;
}
upper
=
value_get_as_double
(
vupper
)
;
value_release
(
vupper
)
;
}
lower
=
value_get_as_double
(
argv
[
0
])
;
if
(
argv
[
1
])
upper
=
value_get_as_double
(
argv
[
1
])
;
if
(
lower
<
0
.
0
||
upper
<
0
.
0
)
{
*
error_string
=
_
(
"#NUM!"
)
;
...
...
@@ -522,7 +498,7 @@ gnumeric_erf (void *sheet, GList *l, int eval_col, int eval_row, char **error_st
}
ans
=
erf
(
lower
)
;
if
(
vupper
)
if
(
argv
[
1
]
)
ans
=
erf
(
upper
)
-
ans
;
return
value_float
(
ans
)
;
...
...
@@ -569,35 +545,17 @@ static char *help_delta = {
static
Value
*
gnumeric_delta
(
void
*
sheet
,
GList
*
l
,
int
eval_col
,
int
eval_row
,
char
**
error_string
)
gnumeric_delta
(
struct
FunctionDefinition
*
i
,
Value
*
argv
[]
,
char
**
error_string
)
{
int
ans
=
0
;
int
argc
=
g_list_length
(
l
)
;
Value
*
vx
,
*
vy
;
if
(
argc
<
1
||
argc
>
2
||
!
l
->
data
)
{
*
error_string
=
_
(
"Invalid number of arguments"
)
;
return
NULL
;
}
vx
=
eval_expr
(
sheet
,
l
->
data
,
eval_col
,
eval_row
,
error_string
)
;
if
(
vx
->
type
!=
VALUE_INTEGER
&&
vx
->
type
!=
VALUE_FLOAT
)
{
*
error_string
=
_
(
"#VALUE!"
)
;
return
NULL
;
}
l
=
g_list_next
(
l
)
;
if
(
l
&&
l
->
data
)
{
vy
=
eval_expr
(
sheet
,
l
->
data
,
eval_col
,
eval_row
,
error_string
)
;
if
(
vy
->
type
!=
VALUE_INTEGER
&&
vy
->
type
!=
VALUE_FLOAT
)
{
*
error_string
=
_
(
"#VALUE!"
)
;
return
NULL
;
}
}
vx
=
argv
[
0
]
;
if
(
argv
[
1
])
vy
=
argv
[
1
]
;
else
vy
=
value_int
(
0
)
;
vy
=
value_int
(
0
)
;
switch
(
vx
->
type
)
{
case
VALUE_INTEGER
:
...
...
@@ -637,8 +595,6 @@ gnumeric_delta (void *sheet, GList *l, int eval_col, int eval_row, char **error_
return
NULL
;
}
value_release
(
vx
)
;
value_release
(
vy
)
;
return
value_int
(
ans
)
;
}
...
...
@@ -764,8 +720,8 @@ FunctionDefinition eng_functions [] = {
{
"dec2bin"
,
0
,
"xnum,ynum"
,
&
help_dec2bin
,
gnumeric_dec2bin
,
NULL
},
{
"dec2oct"
,
0
,
"xnum,ynum"
,
&
help_dec2oct
,
gnumeric_dec2oct
,
NULL
},
{
"dec2hex"
,
0
,
"xnum,ynum"
,
&
help_dec2hex
,
gnumeric_dec2hex
,
NULL
},
{
"delta"
,
0
,
"xnum,ynum"
,
&
help_delta
,
gnumeric_delta
,
NULL
},
{
"erf"
,
0
,
"lower,upper"
,
&
help_erf
,
gnumeric_erf
,
NULL
},
{
"delta"
,
"f|f"
,
"xnum,ynum"
,
&
help_delta
,
NULL
,
gnumeric_delta
},
{
"erf"
,
"f|f"
,
"lower,upper"
,
&
help_erf
,
NULL
,
gnumeric_erf
},
{
"erfc"
,
"f"
,
"number"
,
&
help_erfc
,
NULL
,
gnumeric_erfc
},
{
"gestep"
,
0
,
"xnum,ynum"
,
&
help_gestep
,
gnumeric_gestep
,
NULL
},
{
"hex2bin"
,
0
,
"xnum,ynum"
,
&
help_hex2bin
,
gnumeric_hex2bin
,
NULL
},
...
...
src/functions/fn-eng.c
View file @
ddece2e1
...
...
@@ -484,37 +484,13 @@ static char *help_erf = {
static
Value
*
gnumeric_erf
(
void
*
sheet
,
GList
*
l
,
int
eval_col
,
int
eval_row
,
char
**
error_string
)
gnumeric_erf
(
struct
FunctionDefinition
*
i
,
Value
*
argv
[]
,
char
**
error_string
)
{
float_t
ans
,
lower
,
upper
=
0
.
0
;
int
argc
=
g_list_length
(
l
)
;
Value
*
vlower
,
*
vupper
=
0
;
if
(
argc
<
1
||
argc
>
2
||
!
l
->
data
)
{
*
error_string
=
_
(
"Invalid number of arguments"
)
;
return
NULL
;
}
vlower
=
eval_expr
(
sheet
,
l
->
data
,
eval_col
,
eval_row
,
error_string
)
;
if
(
vlower
->
type
!=
VALUE_INTEGER
&&
vlower
->
type
!=
VALUE_FLOAT
)
{
*
error_string
=
_
(
"#VALUE!"
)
;
return
NULL
;
}
lower
=
value_get_as_double
(
vlower
)
;
value_release
(
vlower
)
;
l
=
g_list_next
(
l
)
;
if
(
l
&&
l
->
data
)
{
vupper
=
eval_expr
(
sheet
,
l
->
data
,
eval_col
,
eval_row
,
error_string
)
;
if
(
vupper
->
type
!=
VALUE_INTEGER
&&
vupper
->
type
!=
VALUE_FLOAT
)
{
*
error_string
=
_
(
"#VALUE!"
)
;
return
NULL
;
}
upper
=
value_get_as_double
(
vupper
)
;
value_release
(
vupper
)
;
}
lower
=
value_get_as_double
(
argv
[
0
])
;
if
(
argv
[
1
])
upper
=
value_get_as_double
(
argv
[
1
])
;
if
(
lower
<
0
.
0
||
upper
<
0
.
0
)
{
*
error_string
=
_
(
"#NUM!"
)
;
...
...
@@ -522,7 +498,7 @@ gnumeric_erf (void *sheet, GList *l, int eval_col, int eval_row, char **error_st
}
ans
=
erf
(
lower
)
;
if
(
vupper
)
if
(
argv
[
1
]
)
ans
=
erf
(
upper
)
-
ans
;
return
value_float
(
ans
)
;
...
...
@@ -569,35 +545,17 @@ static char *help_delta = {
static
Value
*
gnumeric_delta
(
void
*
sheet
,
GList
*
l
,
int
eval_col
,
int
eval_row
,
char
**
error_string
)
gnumeric_delta
(
struct
FunctionDefinition
*
i
,
Value
*
argv
[]
,
char
**
error_string
)
{
int
ans
=
0
;
int
argc
=
g_list_length
(
l
)
;
Value
*
vx
,
*
vy
;
if
(
argc
<
1
||
argc
>
2
||
!
l
->
data
)
{
*
error_string
=
_
(
"Invalid number of arguments"
)
;
return
NULL
;
}
vx
=
eval_expr
(
sheet
,
l
->
data
,
eval_col
,
eval_row
,
error_string
)
;
if
(
vx
->
type
!=
VALUE_INTEGER
&&
vx
->
type
!=
VALUE_FLOAT
)
{
*
error_string
=
_
(
"#VALUE!"
)
;
return
NULL
;
}
l
=
g_list_next
(
l
)
;
if
(
l
&&
l
->
data
)
{
vy
=
eval_expr
(
sheet
,
l
->
data
,
eval_col
,
eval_row
,
error_string
)
;
if
(
vy
->
type
!=
VALUE_INTEGER
&&
vy
->
type
!=
VALUE_FLOAT
)
{
*
error_string
=
_
(
"#VALUE!"
)
;
return
NULL
;
}
}
vx
=
argv
[
0
]
;
if
(
argv
[
1
])
vy
=
argv
[
1
]
;
else
vy
=
value_int
(
0
)
;
vy
=
value_int
(
0
)
;
switch
(
vx
->
type
)
{
case
VALUE_INTEGER
:
...
...
@@ -637,8 +595,6 @@ gnumeric_delta (void *sheet, GList *l, int eval_col, int eval_row, char **error_
return
NULL
;
}
value_release
(
vx
)
;
value_release
(
vy
)
;
return
value_int
(
ans
)
;
}
...
...
@@ -764,8 +720,8 @@ FunctionDefinition eng_functions [] = {
{
"dec2bin"
,
0
,
"xnum,ynum"
,
&
help_dec2bin
,
gnumeric_dec2bin
,
NULL
},
{
"dec2oct"
,
0
,
"xnum,ynum"
,
&
help_dec2oct
,
gnumeric_dec2oct
,
NULL
},
{
"dec2hex"
,
0
,
"xnum,ynum"
,
&
help_dec2hex
,
gnumeric_dec2hex
,
NULL
},
{
"delta"
,
0
,
"xnum,ynum"
,
&
help_delta
,
gnumeric_delta
,
NULL
},
{
"erf"
,
0
,
"lower,upper"
,
&
help_erf
,
gnumeric_erf
,
NULL
},
{
"delta"
,
"f|f"
,
"xnum,ynum"
,
&
help_delta
,
NULL
,
gnumeric_delta
},
{
"erf"
,
"f|f"
,
"lower,upper"
,
&
help_erf
,
NULL
,
gnumeric_erf
},
{
"erfc"
,
"f"
,
"number"
,
&
help_erfc
,
NULL
,
gnumeric_erfc
},
{
"gestep"
,
0
,
"xnum,ynum"
,
&
help_gestep
,
gnumeric_gestep
,
NULL
},
{
"hex2bin"
,
0
,
"xnum,ynum"
,
&
help_hex2bin
,
gnumeric_hex2bin
,
NULL
},
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment