--- ray/src/common/calfunc.c 1992/05/21 10:29:32 2.4 +++ ray/src/common/calfunc.c 1992/11/22 17:29:46 2.7 @@ -1,4 +1,4 @@ -/* Copyright (c) 1991 Regents of the University of California */ +/* Copyright (c) 1992 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -20,6 +20,8 @@ static char SCCSid[] = "$SunId$ LBL"; #include +#include + #include "calcomp.h" /* bits in argument flag (better be right!) */ @@ -102,17 +104,16 @@ int fundefined(fname) /* return # of arguments for function */ char *fname; { - LIBR *lp; + register LIBR *lp; register VARDEF *vp; - if ((vp = varlookup(fname)) == NULL || vp->def == NULL - || vp->def->v.kid->type != FUNC) - if ((lp = liblookup(fname)) == NULL) - return(0); - else - return(lp->nargs); - else + if ((vp = varlookup(fname)) != NULL && vp->def != NULL + && vp->def->v.kid->type == FUNC) return(nekids(vp->def->v.kid) - 1); + lp = vp != NULL ? vp->lib : liblookup(fname); + if (lp == NULL) + return(0); + return(lp->nargs); } @@ -153,6 +154,7 @@ int nargs; int assign; double (*fptr)(); { + int oldlibsize = libsize; register LIBR *lp; if ((lp = liblookup(fname)) == NULL) { /* insert */ @@ -185,7 +187,8 @@ double (*fptr)(); lp[0].atyp = assign; lp[0].f = fptr; } - libupdate(fname); /* relink library */ + if (libsize != oldlibsize) + libupdate(fname); /* relink library */ } @@ -469,7 +472,6 @@ l_select() /* return argument #(A1+1) */ static double l_rand() /* random function between 0 and 1 */ { - extern double floor(); double x; x = argument(1); @@ -483,8 +485,6 @@ l_rand() /* random function between 0 and 1 */ static double l_floor() /* return largest integer not greater than arg1 */ { - extern double floor(); - return(floor(argument(1))); } @@ -492,8 +492,6 @@ l_floor() /* return largest integer not greater than static double l_ceil() /* return smallest integer not less than arg1 */ { - extern double ceil(); - return(ceil(argument(1))); } @@ -502,8 +500,6 @@ l_ceil() /* return smallest integer not less than arg static double l_sqrt() { - extern double sqrt(); - return(sqrt(argument(1))); } @@ -511,8 +507,6 @@ l_sqrt() static double l_sin() { - extern double sin(); - return(sin(argument(1))); } @@ -520,8 +514,6 @@ l_sin() static double l_cos() { - extern double cos(); - return(cos(argument(1))); } @@ -529,8 +521,6 @@ l_cos() static double l_tan() { - extern double tan(); - return(tan(argument(1))); } @@ -538,8 +528,6 @@ l_tan() static double l_asin() { - extern double asin(); - return(asin(argument(1))); } @@ -547,8 +535,6 @@ l_asin() static double l_acos() { - extern double acos(); - return(acos(argument(1))); } @@ -556,8 +542,6 @@ l_acos() static double l_atan() { - extern double atan(); - return(atan(argument(1))); } @@ -565,8 +549,6 @@ l_atan() static double l_atan2() { - extern double atan2(); - return(atan2(argument(1), argument(2))); } @@ -574,8 +556,6 @@ l_atan2() static double l_exp() { - extern double exp(); - return(exp(argument(1))); } @@ -583,8 +563,6 @@ l_exp() static double l_log() { - extern double log(); - return(log(argument(1))); } @@ -592,8 +570,6 @@ l_log() static double l_log10() { - extern double log10(); - return(log10(argument(1))); } #endif