--- ray/src/ot/readobj2.c 1991/07/19 09:29:24 1.4 +++ ray/src/ot/readobj2.c 2003/02/22 02:07:26 2.4 @@ -1,9 +1,6 @@ -/* Copyright (c) 1991 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: readobj2.c,v 2.4 2003/02/22 02:07:26 greg Exp $"; #endif - /* * readobj2.c - routines for reading in object descriptions. */ @@ -16,17 +13,14 @@ static char SCCSid[] = "$SunId$ LBL"; #include -OBJREC *objblock[MAXOBJBLK]; /* our objects */ -OBJECT nobjects = 0; /* # of objects */ -int newobject() {return(0);} +extern char *fgetword(); - -readobj(input, callback) /* read in an object file or stream */ +readobj2(input, callback) /* read in an object file or stream */ char *input; int (*callback)(); { FILE *popen(); - char *fgets(), *fgetline(); + char *fgetline(); FILE *infp; char buf[512]; register int c; @@ -51,10 +45,10 @@ int (*callback)(); } else if (c == '!') { /* command */ ungetc(c, infp); fgetline(buf, sizeof(buf), infp); - readobj(buf, callback); + readobj2(buf, callback); } else { /* object */ ungetc(c, infp); - getobject(input, infp, callback); + getobject2(input, infp, callback); } } if (input[0] == '!') @@ -64,7 +58,7 @@ int (*callback)(); } -getobject(name, fp, f) /* read the next object */ +getobject2(name, fp, f) /* read the next object */ char *name; FILE *fp; int (*f)(); @@ -72,10 +66,10 @@ int (*f)(); char sbuf[MAXSTR]; OBJREC thisobj; /* get modifier */ - fscanf(fp, "%*s"); + fgetword(sbuf, MAXSTR, fp); thisobj.omod = OVOID; /* get type */ - fscanf(fp, "%s", sbuf); + fgetword(sbuf, MAXSTR, fp); if (!strcmp(sbuf, ALIASID)) thisobj.otype = -1; else if ((thisobj.otype = otype(sbuf)) < 0) { @@ -83,7 +77,7 @@ int (*f)(); error(USER, errmsg); } /* get identifier */ - fscanf(fp, "%s", sbuf); + fgetword(sbuf, MAXSTR, fp); thisobj.oname = sbuf; /* get arguments */ if (thisobj.otype == -1) { @@ -95,25 +89,9 @@ int (*f)(); objerror(&thisobj, USER, errmsg); } thisobj.os = NULL; - thisobj.lastrno = -1; /* call function */ (*f)(&thisobj); /* free memory */ - if (thisobj.os != NULL) - switch (thisobj.otype) { - case OBJ_CONE: - case OBJ_CUP: - case OBJ_CYLINDER: - case OBJ_TUBE: - case OBJ_RING: - freecone(&thisobj); - break; - case OBJ_FACE: - freeface(&thisobj); - break; - case OBJ_INSTANCE: - freeinstance(&thisobj); - break; - } freefargs(&thisobj.oargs); + free_os(&thisobj); }