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 2.10 by greg, Mon Mar 10 17:13:29 2003 UTC vs.
Revision 2.18 by schorsch, Mon Oct 27 10:19:31 2003 UTC

# Line 9 | Line 9 | static const char RCSid[] = "$Id$";
9  
10   #include "copyright.h"
11  
12 < #include  "standard.h"
12 > #include  <ctype.h>
13 > #include  <string.h>
14 > #include  <stdio.h>
15  
16 + #include  "platform.h"
17 + #include  "rtprocess.h"
18 + #include  "standard.h"
19   #include  "object.h"
15
20   #include  "otypes.h"
21  
18 #include  <ctype.h>
22  
23   OBJREC  *objblock[MAXOBJBLK];           /* our objects */
24   OBJECT  nobjects = 0;                   /* # of objects */
# Line 73 | Line 76 | getobject(name, fp)                    /* read the next object */
76   char  *name;
77   FILE  *fp;
78   {
79 + #define OALIAS  -2
80          OBJECT  obj;
81          char  sbuf[MAXSTR];
82          int  rval;
# Line 86 | Line 90 | FILE  *fp;
90          fgetword(sbuf, MAXSTR, fp);
91          if (!strcmp(sbuf, VOIDID))
92                  objp->omod = OVOID;
93 +        else if (!strcmp(sbuf, ALIASMOD))
94 +                objp->omod = OALIAS;
95          else if ((objp->omod = modifier(sbuf)) == OVOID) {
96                  sprintf(errmsg, "(%s): undefined modifier \"%s\"", name, sbuf);
97                  error(USER, errmsg);
# Line 93 | Line 99 | FILE  *fp;
99                                          /* get type */
100          strcpy(sbuf, "EOF");
101          fgetword(sbuf, MAXSTR, fp);
102 <        if (!strcmp(sbuf, ALIASID))
97 <                objp->otype = -1;
98 <        else if ((objp->otype = otype(sbuf)) < 0) {
102 >        if ((objp->otype = otype(sbuf)) < 0) {
103                  sprintf(errmsg, "(%s): unknown type \"%s\"", name, sbuf);
104                  error(USER, errmsg);
105          }
# Line 104 | Line 108 | FILE  *fp;
108          fgetword(sbuf, MAXSTR, fp);
109          objp->oname = savqstr(sbuf);
110                                          /* get arguments */
111 <        if (objp->otype == -1) {
111 >        if (objp->otype == MOD_ALIAS) {
112                  register OBJECT  alias;
113                  strcpy(sbuf, "EOF");
114                  fgetword(sbuf, MAXSTR, fp);
115                  if ((alias = modifier(sbuf)) == OVOID) {
116 <                        sprintf(errmsg,
117 <                        "(%s): bad reference \"%s\" for %s \"%s\"",
118 <                                        name, sbuf, ALIASID, objp->oname);
115 <                        error(USER, errmsg);
116 >                        sprintf(errmsg, "(%s): bad reference \"%s\"",
117 >                                        name, sbuf);
118 >                        objerror(objp, USER, errmsg);
119                  }
120 <                objp->otype = objptr(alias)->otype;
121 <                copystruct(&objp->oargs, &objptr(alias)->oargs);
120 >                if (objp->omod == OALIAS ||
121 >                                objp->omod == objptr(alias)->omod) {
122 >                        objp->omod = alias;
123 >                } else {
124 >                        objp->oargs.sarg = (char **)malloc(sizeof(char *));
125 >                        if (objp->oargs.sarg == NULL)
126 >                                error(SYSTEM, "out of memory in getobject");
127 >                        objp->oargs.nsargs = 1;
128 >                        objp->oargs.sarg[0] = savestr(sbuf);
129 >                }
130          } else if ((rval = readfargs(&objp->oargs, fp)) == 0) {
131                  sprintf(errmsg, "(%s): bad arguments", name);
132                  objerror(objp, USER, errmsg);
# Line 123 | Line 134 | FILE  *fp;
134                  sprintf(errmsg, "(%s): error reading scene", name);
135                  error(SYSTEM, errmsg);
136          }
137 +        if (objp->omod == OALIAS) {
138 +                sprintf(errmsg, "(%s): inappropriate use of '%s' modifier",
139 +                                name, ALIASMOD);
140 +                objerror(objp, USER, errmsg);
141 +        }
142                                          /* initialize */
143          objp->os = NULL;
144  
145          insertobject(obj);              /* add to global structure */
146 + #undef OALIAS
147   }
148  
149  
# Line 149 | Line 166 | newobject()                            /* get a new object */
166  
167   void
168   freeobjects(firstobj, nobjs)            /* free a range of objects */
169 < OBJECT  firstobj, nobjs;
169 > int  firstobj, nobjs;
170   {
171          register int  obj;
172                                          /* check bounds */
# Line 165 | Line 182 | OBJECT  firstobj, nobjs;
182                  free_os(o);             /* free client memory */
183                  freeqstr(o->oname);
184                  freefargs(&o->oargs);
185 <                bzero(o, sizeof(OBJREC));
185 >                memset((void *)o, '\0', sizeof(OBJREC));
186          }
187          clearobjndx();
188                                          /* free objects off end */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines