--- ray/src/common/calfunc.c 2003/03/05 16:16:52 2.10 +++ ray/src/common/calfunc.c 2003/11/14 17:22:06 2.14 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: calfunc.c,v 2.10 2003/03/05 16:16:52 greg Exp $"; +static const char RCSid[] = "$Id: calfunc.c,v 2.14 2003/11/14 17:22:06 schorsch Exp $"; #endif /* * calfunc.c - routines for calcomp using functions. @@ -13,11 +13,11 @@ static const char RCSid[] = "$Id: calfunc.c,v 2.10 200 #include "copyright.h" #include - +#include #include - #include +#include "rterror.h" #include "calcomp.h" /* bits in argument flag (better be right!) */ @@ -34,18 +34,18 @@ typedef struct activation { static ACTIVATION *curact = NULL; -static double libfunc(); +static double libfunc(char *fname, VARDEF *vp); #ifndef MAXLIB #define MAXLIB 64 /* maximum number of library functions */ #endif -static double l_if(), l_select(), l_rand(); -static double l_floor(), l_ceil(); -static double l_sqrt(); -static double l_sin(), l_cos(), l_tan(); -static double l_asin(), l_acos(), l_atan(), l_atan2(); -static double l_exp(), l_log(), l_log10(); +static double l_if(char *), l_select(char *), l_rand(char *); +static double l_floor(char *), l_ceil(char *); +static double l_sqrt(char *); +static double l_sin(char *), l_cos(char *), l_tan(char *); +static double l_asin(char *), l_acos(char *), l_atan(char *), l_atan2(char *); +static double l_exp(char *), l_log(char *), l_log10(char *); /* functions must be listed alphabetically */ static LIBR library[MAXLIB] = { @@ -125,7 +125,7 @@ funset(fname, nargs, assign, fptr) /* set a library fu char *fname; int nargs; int assign; -double (*fptr)(); +double (*fptr)(char *); { int oldlibsize = libsize; char *cp; @@ -193,7 +193,7 @@ argument(n) /* return nth argument for active functi register int n; { register ACTIVATION *actp = curact; - register EPNODE *ep; + register EPNODE *ep = NULL; double aval; if (actp == NULL || --n < 0) { @@ -255,6 +255,7 @@ badarg: eputs(actp->name); eputs(": argument not a function\n"); quit(1); + return NULL; /* pro forma return */ } @@ -371,7 +372,7 @@ VARDEF *vp; static double -l_if() /* if(cond, then, else) conditional expression */ +l_if(char *nm) /* if(cond, then, else) conditional expression */ /* cond evaluates true if greater than zero */ { if (argument(1) > 0.0) @@ -382,11 +383,11 @@ l_if() /* if(cond, then, else) conditional expressio static double -l_select() /* return argument #(A1+1) */ +l_select(char *nm) /* return argument #(A1+1) */ { register int n; - n = argument(1) + .5; + n = (int)(argument(1) + .5); if (n == 0) return(nargum()-1); if (n < 1 || n > nargum()-1) { @@ -398,7 +399,7 @@ l_select() /* return argument #(A1+1) */ static double -l_rand() /* random function between 0 and 1 */ +l_rand(char *nm) /* random function between 0 and 1 */ { double x; @@ -411,91 +412,91 @@ l_rand() /* random function between 0 and 1 */ static double -l_floor() /* return largest integer not greater than arg1 */ +l_floor(char *nm) /* return largest integer not greater than arg1 */ { return(floor(argument(1))); } static double -l_ceil() /* return smallest integer not less than arg1 */ +l_ceil(char *nm) /* return smallest integer not less than arg1 */ { return(ceil(argument(1))); } static double -l_sqrt() +l_sqrt(char *nm) { return(sqrt(argument(1))); } static double -l_sin() +l_sin(char *nm) { return(sin(argument(1))); } static double -l_cos() +l_cos(char *nm) { return(cos(argument(1))); } static double -l_tan() +l_tan(char *nm) { return(tan(argument(1))); } static double -l_asin() +l_asin(char *nm) { return(asin(argument(1))); } static double -l_acos() +l_acos(char *nm) { return(acos(argument(1))); } static double -l_atan() +l_atan(char *nm) { return(atan(argument(1))); } static double -l_atan2() +l_atan2(char *nm) { return(atan2(argument(1), argument(2))); } static double -l_exp() +l_exp(char *nm) { return(exp(argument(1))); } static double -l_log() +l_log(char *nm) { return(log(argument(1))); } static double -l_log10() +l_log10(char *nm) { return(log10(argument(1))); }