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.22 by greg, Sat Apr 8 03:56:44 2017 UTC vs.
Revision 2.26 by greg, Sat Dec 7 02:05:30 2024 UTC

# Line 47 | Line 47 | readobj(                               /* read in an object file or stream */
47                  sprintf(errmsg, "cannot open scene file \"%s\"", inpspec);
48                  error(SYSTEM, errmsg);
49          }
50 + #ifdef getc_unlocked                    /* avoid stupid semaphores */
51 +        flockfile(infp);
52 + #endif
53          while ((c = getc(infp)) != EOF) {
54                  if (isspace(c))
55                          continue;
# Line 63 | Line 66 | readobj(                               /* read in an object file or stream */
66          }
67          if (inpspec[0] == '!')
68                  pclose(infp);
69 <        else
69 >        else if (infp != stdin)
70                  fclose(infp);
71 + #ifdef getc_unlocked
72 +        else
73 +                funlockfile(infp);
74 + #endif
75          if (nobjects == lastobj) {
76                  sprintf(errmsg, "(%s): empty file", inpspec);
77                  error(WARNING, errmsg);
# Line 121 | Line 128 | getobject(                             /* read the next object */
128          objp->oname = savqstr(sbuf);
129                                          /* get arguments */
130          if (objp->otype == MOD_ALIAS) {
131 <                OBJECT  alias;
131 >                OBJECT  ref;
132 >                OBJREC  *rfp;
133                  strcpy(sbuf, "EOF");
134                  fgetword(sbuf, MAXSTR, fp);
135 <                if ((alias = modifier(sbuf)) == OVOID) {
135 >                if ((ref = modifier(sbuf)) == OVOID) {
136                          sprintf(errmsg, "(%s): bad reference \"%s\"",
137                                          name, sbuf);
138                          objerror(objp, USER, errmsg);
139 <                }
140 <                if (objp->omod == OALIAS ||
141 <                                objp->omod == objptr(alias)->omod) {
142 <                        objp->omod = alias;
139 >                }                       /* skip pass-thru aliases */
140 >                while ((rfp=objptr(ref))->otype == MOD_ALIAS &&
141 >                                !rfp->oargs.nsargs & (rfp->omod != OVOID))
142 >                        ref = rfp->omod;
143 >
144 >                if ((objp->omod == OALIAS) | (objp->omod == rfp->omod)) {
145 >                        objp->omod = ref;
146                  } else {
147                          objp->oargs.sarg = (char **)malloc(sizeof(char *));
148                          if (objp->oargs.sarg == NULL)
# Line 198 | Line 209 | freeobjects(                           /* free a range of objects */
209                  freefargs(&o->oargs);
210                  memset((void *)o, '\0', sizeof(OBJREC));
211          }
201        clearobjndx();
212                                          /* free objects off end */
213          for (obj = nobjects; obj-- > 0; )
214                  if (objptr(obj)->oname != NULL)
215                          break;
216 <        ++obj;
216 >        if (++obj >= nobjects)
217 >                return;
218          while (nobjects > obj)          /* free empty end blocks */
219                  if ((--nobjects & (OBJBLKSIZ-1)) == 0) {
220                          int     i = nobjects >> OBJBLKSHFT;
221                          free((void *)objblock[i]);
222                          objblock[i] = NULL;
223                  }
224 +        truncobjndx();                  /* truncate modifier look-up */
225   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines