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.9 by greg, Tue Feb 25 02:47:21 2003 UTC vs.
Revision 2.14 by schorsch, Sun Jun 8 12:03:09 2003 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines