--- ray/src/common/calexpr.c 2003/07/27 22:12:01 2.26 +++ ray/src/common/calexpr.c 2004/03/28 20:33:12 2.29 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: calexpr.c,v 2.26 2003/07/27 22:12:01 schorsch Exp $"; +static const char RCSid[] = "$Id: calexpr.c,v 2.29 2004/03/28 20:33:12 schorsch Exp $"; #endif /* * Compute data values using expression parser @@ -26,6 +26,8 @@ static const char RCSid[] = "$Id: calexpr.c,v 2.26 200 #include #include +#include "rtmisc.h" +#include "rtio.h" #include "rterror.h" #include "calcomp.h" @@ -47,7 +49,7 @@ unsigned int esupport = /* what to support */ int nextc; /* lookahead character */ -double (*eoper[])() = { /* expression operations */ +double (*eoper[])(EPNODE *) = { /* expression operations */ ebotch, evariable, enumber, @@ -82,8 +84,9 @@ static int linepos; /* position in buffer */ EPNODE * -eparse(expr) /* parse an expression string */ -char *expr; +eparse( /* parse an expression string */ + char *expr +) { EPNODE *ep; @@ -97,8 +100,9 @@ char *expr; double -eval(expr) /* evaluate an expression string */ -char *expr; +eval( /* evaluate an expression string */ + char *expr +) { register EPNODE *ep; double rval; @@ -111,8 +115,10 @@ char *expr; int -epcmp(ep1, ep2) /* compare two expressions for equivalence */ -register EPNODE *ep1, *ep2; +epcmp( /* compare two expressions for equivalence */ + register EPNODE *ep1, + register EPNODE *ep2 +) { double d; @@ -159,8 +165,9 @@ register EPNODE *ep1, *ep2; void -epfree(epar) /* free a parse tree */ -register EPNODE *epar; +epfree( /* free a parse tree */ + register EPNODE *epar +) { register EPNODE *ep; @@ -194,22 +201,25 @@ register EPNODE *epar; /* the following used to be a switch */ static double -eargument(ep) -EPNODE *ep; +eargument( + EPNODE *ep +) { return(argument(ep->v.chan)); } static double -enumber(ep) -EPNODE *ep; +enumber( + EPNODE *ep +) { return(ep->v.num); } static double -euminus(ep) -EPNODE *ep; +euminus( + EPNODE *ep +) { register EPNODE *ep1 = ep->v.kid; @@ -217,15 +227,17 @@ EPNODE *ep; } static double -echannel(ep) -EPNODE *ep; +echannel( + EPNODE *ep +) { return(chanvalue(ep->v.chan)); } static double -eadd(ep) -EPNODE *ep; +eadd( + EPNODE *ep +) { register EPNODE *ep1 = ep->v.kid; @@ -233,8 +245,9 @@ EPNODE *ep; } static double -esubtr(ep) -EPNODE *ep; +esubtr( + EPNODE *ep +) { register EPNODE *ep1 = ep->v.kid; @@ -242,8 +255,9 @@ EPNODE *ep; } static double -emult(ep) -EPNODE *ep; +emult( + EPNODE *ep +) { register EPNODE *ep1 = ep->v.kid; @@ -251,8 +265,9 @@ EPNODE *ep; } static double -edivi(ep) -EPNODE *ep; +edivi( + EPNODE *ep +) { register EPNODE *ep1 = ep->v.kid; double d; @@ -267,8 +282,9 @@ EPNODE *ep; } static double -epow(ep) -EPNODE *ep; +epow( + EPNODE *ep +) { register EPNODE *ep1 = ep->v.kid; double d; @@ -290,8 +306,9 @@ EPNODE *ep; } static double -ebotch(ep) -EPNODE *ep; +ebotch( + EPNODE *ep +) { eputs("Bad expression!\n"); quit(1); @@ -300,9 +317,10 @@ EPNODE *ep; EPNODE * -ekid(ep, n) /* return pointer to a node's nth kid */ -register EPNODE *ep; -register int n; +ekid( /* return pointer to a node's nth kid */ + register EPNODE *ep, + register int n +) { for (ep = ep->v.kid; ep != NULL; ep = ep->sibling) @@ -314,8 +332,9 @@ register int n; int -nekids(ep) /* return # of kids for node ep */ -register EPNODE *ep; +nekids( /* return # of kids for node ep */ + register EPNODE *ep +) { register int n = 0; @@ -327,10 +346,11 @@ register EPNODE *ep; void -initfile(fp, fn, ln) /* prepare input file */ -FILE *fp; -char *fn; -int ln; +initfile( /* prepare input file */ + FILE *fp, + char *fn, + int ln +) { static char inpbuf[MAXLINE]; @@ -345,10 +365,11 @@ int ln; void -initstr(s, fn, ln) /* prepare input string */ -char *s; -char *fn; -int ln; +initstr( /* prepare input string */ + char *s, + char *fn, + int ln +) { infp = NULL; infile = fn; @@ -360,11 +381,12 @@ int ln; void -getscanpos(fnp, lnp, spp, fpp) /* return current scan position */ -char **fnp; -int *lnp; -char **spp; -FILE **fpp; +getscanpos( /* return current scan position */ + char **fnp, + int *lnp, + char **spp, + FILE **fpp +) { if (fnp != NULL) *fnp = infile; if (lnp != NULL) *lnp = lineno; @@ -374,7 +396,7 @@ FILE **fpp; int -scan() /* scan next character, return literal next */ +scan(void) /* scan next character, return literal next */ { register int lnext = 0; @@ -406,8 +428,9 @@ scan() /* scan next character, return literal next char * -long2ascii(l) /* convert long to ascii */ -long l; +long2ascii( /* convert long to ascii */ + long l +) { static char buf[16]; register char *cp; @@ -432,8 +455,9 @@ long l; void -syntax(err) /* report syntax error and quit */ -char *err; +syntax( /* report syntax error and quit */ + char *err +) { register int i; @@ -458,9 +482,10 @@ char *err; void -addekid(ep, ekid) /* add a child to ep */ -register EPNODE *ep; -EPNODE *ekid; +addekid( /* add a child to ep */ + register EPNODE *ep, + EPNODE *ekid +) { if (ep->v.kid == NULL) ep->v.kid = ekid; @@ -474,7 +499,7 @@ EPNODE *ekid; char * -getname() /* scan an identifier */ +getname(void) /* scan an identifier */ { static char str[RMAXWORD+1]; register int i, lnext; @@ -491,7 +516,7 @@ getname() /* scan an identifier */ int -getinum() /* scan a positive integer */ +getinum(void) /* scan a positive integer */ { register int n, lnext; @@ -506,7 +531,7 @@ getinum() /* scan a positive integer */ double -getnum() /* scan a positive float */ +getnum(void) /* scan a positive float */ { register int i, lnext; char str[RMAXWORD+1]; @@ -548,7 +573,7 @@ getnum() /* scan a positive float */ EPNODE * -getE1() /* E1 -> E1 ADDOP E2 */ +getE1(void) /* E1 -> E1 ADDOP E2 */ /* E2 */ { register EPNODE *ep1, *ep2; @@ -570,7 +595,7 @@ getE1() /* E1 -> E1 ADDOP E2 */ EPNODE * -getE2() /* E2 -> E2 MULOP E3 */ +getE2(void) /* E2 -> E2 MULOP E3 */ /* E3 */ { register EPNODE *ep1, *ep2; @@ -592,7 +617,7 @@ getE2() /* E2 -> E2 MULOP E3 */ EPNODE * -getE3() /* E3 -> E4 ^ E3 */ +getE3(void) /* E3 -> E4 ^ E3 */ /* E4 */ { register EPNODE *ep1, *ep2; @@ -614,7 +639,7 @@ getE3() /* E3 -> E4 ^ E3 */ EPNODE * -getE4() /* E4 -> ADDOP E5 */ +getE4(void) /* E4 -> ADDOP E5 */ /* E5 */ { register EPNODE *ep1, *ep2; @@ -642,7 +667,7 @@ getE4() /* E4 -> ADDOP E5 */ EPNODE * -getE5() /* E5 -> (E1) */ +getE5(void) /* E5 -> (E1) */ /* VAR */ /* NUM */ /* $N */ @@ -720,8 +745,9 @@ getE5() /* E5 -> (E1) */ EPNODE * -rconst(epar) /* reduce a constant expression */ -register EPNODE *epar; +rconst( /* reduce a constant expression */ + register EPNODE *epar +) { register EPNODE *ep; @@ -738,8 +764,9 @@ register EPNODE *epar; int -isconstvar(ep) /* is ep linked to a constant expression? */ -register EPNODE *ep; +isconstvar( /* is ep linked to a constant expression? */ + register EPNODE *ep +) { register EPNODE *ep1; @@ -763,8 +790,9 @@ register EPNODE *ep; int -isconstfun(ep) /* is ep linked to a constant function? */ -register EPNODE *ep; +isconstfun( /* is ep linked to a constant function? */ + register EPNODE *ep +) { register EPNODE *dp; register LIBR *lp;