--- ray/src/common/readfargs.c 1991/07/22 11:23:00 1.2 +++ ray/src/common/readfargs.c 1998/08/25 10:20:30 2.6 @@ -8,47 +8,44 @@ static char SCCSid[] = "$SunId$ LBL"; * Allocate, read and free object arguments */ -#include +#include "standard.h" #include "object.h" -extern char *savestr(), *malloc(), *fgetword(); -extern double atof(); -extern int atoi(); -extern long atol(); - -#ifdef MEMHOG -extern char *bmalloc(); -#else +#ifndef MEMHOG #define bmalloc malloc #endif +extern char *fgetword(); +extern int atoi(); +extern long atol(); + readfargs(fa, fp) /* read function arguments from stream */ register FUNARGS *fa; FILE *fp; { -#define getstr() (fgetword(sbuf,MAXSTR,fp)!=NULL) -#define getint() (getstr() && isint(sbuf)) -#define getflt() (getstr() && isflt(sbuf)) +#define getstr(s) (fgetword(s,sizeof(s),fp)!=NULL) +#define getint(s) (getstr(s) && isint(s)) +#define getflt(s) (getstr(s) && isflt(s)) char sbuf[MAXSTR]; register int n, i; - if (!getint() || (n = atoi(sbuf)) < 0) + if (!getint(sbuf) || (n = atoi(sbuf)) < 0) return(0); if (fa->nsargs = n) { fa->sarg = (char **)bmalloc(n*sizeof(char *)); if (fa->sarg == NULL) return(-1); for (i = 0; i < fa->nsargs; i++) { - if (!getstr()) + if (!getstr(sbuf)) return(0); fa->sarg[i] = savestr(sbuf); } } else fa->sarg = NULL; - if (!getint() || (n = atoi(sbuf)) < 0) + if (!getint(sbuf) || (n = atoi(sbuf)) < 0) return(0); #ifdef IARGS if (fa->niargs = n) { @@ -56,7 +53,7 @@ FILE *fp; if (fa->iarg == NULL) return(-1); for (i = 0; i < n; i++) { - if (!getint()) + if (!getint(sbuf)) return(0); fa->iarg[i] = atol(sbuf); } @@ -66,14 +63,14 @@ FILE *fp; if (n != 0) return(0); #endif - if (!getint() || (n = atoi(sbuf)) < 0) + if (!getint(sbuf) || (n = atoi(sbuf)) < 0) return(0); if (fa->nfargs = n) { - fa->farg = (double *)bmalloc(n*sizeof(double)); + fa->farg = (FLOAT *)bmalloc(n*sizeof(FLOAT)); if (fa->farg == NULL) return(-1); for (i = 0; i < n; i++) { - if (!getflt()) + if (!getflt(sbuf)) return(0); fa->farg[i] = atof(sbuf); }