--- ray/src/common/sceneio.c 2003/06/07 12:50:20 2.2 +++ ray/src/common/sceneio.c 2021/02/19 16:51:10 2.6 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: sceneio.c,v 2.2 2003/06/07 12:50:20 schorsch Exp $"; +static const char RCSid[] = "$Id: sceneio.c,v 2.6 2021/02/19 16:51:10 greg Exp $"; #endif /* * Portable, binary Radiance i/o routines. @@ -18,15 +18,16 @@ static short otypmap[NUMOTYPE+32]; /* object type map static int -getobj(fp, objsiz) /* get next object */ -FILE *fp; -int objsiz; +getobj( /* get next object */ + FILE *fp, + int objsiz +) { char sbuf[MAXSTR]; int obj; - register int i; - register long m; - register OBJREC *objp; + int i; + long m; + OBJREC *objp; i = getint(1, fp); if (i == -1) @@ -64,8 +65,8 @@ int objsiz; objp->oargs.iarg = NULL; #endif if ((objp->oargs.nfargs = getint(2, fp)) > 0) { - objp->oargs.farg = (FLOAT *)malloc - (objp->oargs.nfargs*sizeof(FLOAT)); + objp->oargs.farg = (RREAL *)malloc + (objp->oargs.nfargs*sizeof(RREAL)); if (objp->oargs.farg == NULL) goto memerr; for (i = 0; i < objp->oargs.nfargs; i++) @@ -86,9 +87,10 @@ memerr: void -readscene(fp, objsiz) /* read binary scene description */ -FILE *fp; -int objsiz; +readscene( /* read binary scene description */ + FILE *fp, + int objsiz +) { char sbuf[32]; int i; @@ -108,11 +110,12 @@ int objsiz; static void -putobj(o, fp) /* write out object */ -FILE *fp; -register OBJREC *o; +putobj( /* write out object */ + OBJREC *o, + FILE *fp +) { - register int i; + int i; if (o == NULL) { /* terminator */ putint(-1L, 1, fp); @@ -136,9 +139,11 @@ register OBJREC *o; void -writescene(firstobj, nobjs, fp) /* write binary scene description */ -OBJECT firstobj, nobjs; -FILE *fp; +writescene( /* write binary scene description */ + int firstobj, + int nobjs, + FILE *fp +) { int i; /* write out type list */ @@ -149,6 +154,6 @@ FILE *fp; for (i = firstobj; i < firstobj+nobjs; i++) putobj(objptr(i), fp); putobj(NULL, fp); /* terminator */ - if (ferror(fp)) - error(SYSTEM, "write error in writescene"); + if (fflush(fp) == EOF) + error(SYSTEM, "output error in writescene"); }