ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/readobj.c
(Generate patch)

Comparing ray/src/common/readobj.c (file contents):
Revision 1.2 by greg, Wed Oct 4 16:32:04 1989 UTC vs.
Revision 1.6 by greg, Fri Jul 19 09:25:43 1991 UTC

# Line 19 | Line 19 | static char SCCSid[] = "$SunId$ LBL";
19   #include  <ctype.h>
20  
21   OBJREC  *objblock[MAXOBJBLK];           /* our objects */
22 < int  nobjects = 0;                      /* # of objects */
22 > OBJECT  nobjects = 0;                   /* # of objects */
23  
24  
25   readobj(input)                  /* read in an object file or stream */
# Line 70 | Line 70 | FILE  *fp;
70   {
71          OBJECT  obj;
72          char  sbuf[MAXSTR];
73 +        int  rval;
74          register OBJREC  *objp;
75  
76          if ((obj = newobject()) == OVOID)
# Line 105 | Line 106 | FILE  *fp;
106                          error(USER, errmsg);
107                  }
108                  objp->otype = objptr(alias)->otype;
109 <                bcopy(&objptr(alias)->oargs, &objp->oargs, sizeof(FUNARGS));
110 <        } else if (readfargs(&objp->oargs, fp) < 0) {
109 >                copystruct(&objp->oargs, &objptr(alias)->oargs);
110 >        } else if ((rval = readfargs(&objp->oargs, fp)) == 0) {
111                  sprintf(errmsg, "(%s): bad arguments", name);
112                  objerror(objp, USER, errmsg);
113 +        } else if (rval < 0) {
114 +                sprintf(errmsg, "(%s): error reading scene", name);
115 +                error(SYSTEM, errmsg);
116          }
117                                          /* initialize */
118          objp->os = NULL;
# Line 118 | Line 122 | FILE  *fp;
122   }
123  
124  
121 readfargs(fa, fp)               /* read function arguments from stream */
122 register FUNARGS  *fa;
123 FILE  *fp;
124 {
125        char  sbuf[MAXSTR];
126        int  n;
127        register int  i;
128
129        if (fscanf(fp, "%d", &n) != 1 || n < 0)
130                return(-1);
131        if (fa->nsargs = n) {
132                fa->sarg = (char **)bmalloc(n*sizeof(char *));
133                if (fa->sarg == NULL)
134                        goto memerr;
135                for (i = 0; i < fa->nsargs; i++) {
136                        if (fscanf(fp, "%s", sbuf) != 1)
137                                return(-1);
138                        fa->sarg[i] = savestr(sbuf);
139                }
140        } else
141                fa->sarg = NULL;
142        if (fscanf(fp, "%d", &n) != 1 || n < 0)
143                return(-1);
144 #ifdef  IARGS
145        if (fa->niargs = n) {
146                fa->iarg = (long *)bmalloc(n*sizeof(int));
147                if (fa->iarg == NULL)
148                        goto memerr;
149                for (i = 0; i < n; i++)
150                        if (fscanf(fp, "%ld", &fa->iarg[i]) != 1)
151                                return(-1);
152        } else
153                fa->iarg = NULL;
154 #else
155        if (n != 0)
156                return(-1);
157 #endif
158        if (fscanf(fp, "%d", &n) != 1 || n < 0)
159                return(-1);
160        if (fa->nfargs = n) {
161                fa->farg = (double *)bmalloc(n*sizeof(double));
162                if (fa->farg == NULL)
163                        goto memerr;
164                for (i = 0; i < n; i++)
165                        if (fscanf(fp, "%lf", &fa->farg[i]) != 1)
166                                return(-1);
167        } else
168                fa->farg = NULL;
169        return(0);
170 memerr:
171        error(SYSTEM, "out of memory in readfargs");
172 }
173
174
125   int
126   newobject()                             /* get a new object */
127   {
# Line 182 | Line 132 | newobject()                            /* get a new object */
132                  i = nobjects >> 6;
133                  if (i >= MAXOBJBLK)
134                          return(OVOID);
135 <                objblock[i] = (OBJREC *)malloc(0100*sizeof(OBJREC));
135 >                objblock[i] = (OBJREC *)bmalloc(0100*sizeof(OBJREC));
136                  if (objblock[i] == NULL)
137                          return(OVOID);
138          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines