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; |
64 |
|
getobject(inpspec, infp); |
65 |
|
} |
66 |
|
} |
67 |
< |
if (inpspec[0] == '!') |
68 |
< |
pclose(infp); |
69 |
< |
else |
67 |
> |
if (inpspec[0] == '!') { |
68 |
> |
if (pclose(infp) != 0) { |
69 |
> |
sprintf(errmsg, "bad status from \"%s\"", inpspec); |
70 |
> |
error(USER, errmsg); |
71 |
> |
} |
72 |
> |
} else if (infp != stdin) |
73 |
|
fclose(infp); |
74 |
+ |
#ifdef getc_unlocked |
75 |
+ |
else |
76 |
+ |
funlockfile(infp); |
77 |
+ |
#endif |
78 |
|
if (nobjects == lastobj) { |
79 |
|
sprintf(errmsg, "(%s): empty file", inpspec); |
80 |
|
error(WARNING, errmsg); |
131 |
|
objp->oname = savqstr(sbuf); |
132 |
|
/* get arguments */ |
133 |
|
if (objp->otype == MOD_ALIAS) { |
134 |
< |
OBJECT alias; |
134 |
> |
OBJECT ref; |
135 |
> |
OBJREC *rfp; |
136 |
|
strcpy(sbuf, "EOF"); |
137 |
|
fgetword(sbuf, MAXSTR, fp); |
138 |
< |
if ((alias = modifier(sbuf)) == OVOID) { |
138 |
> |
if ((ref = modifier(sbuf)) == OVOID) { |
139 |
|
sprintf(errmsg, "(%s): bad reference \"%s\"", |
140 |
|
name, sbuf); |
141 |
|
objerror(objp, USER, errmsg); |
142 |
< |
} |
143 |
< |
if (objp->omod == OALIAS || |
144 |
< |
objp->omod == objptr(alias)->omod) { |
145 |
< |
objp->omod = alias; |
142 |
> |
} /* skip pass-thru aliases */ |
143 |
> |
while ((rfp=objptr(ref))->otype == MOD_ALIAS && |
144 |
> |
!rfp->oargs.nsargs & (rfp->omod != OVOID)) |
145 |
> |
ref = rfp->omod; |
146 |
> |
|
147 |
> |
if ((objp->omod == OALIAS) | (objp->omod == rfp->omod)) { |
148 |
> |
objp->omod = ref; |
149 |
|
} else { |
150 |
|
objp->oargs.sarg = (char **)malloc(sizeof(char *)); |
151 |
|
if (objp->oargs.sarg == NULL) |
212 |
|
freefargs(&o->oargs); |
213 |
|
memset((void *)o, '\0', sizeof(OBJREC)); |
214 |
|
} |
201 |
– |
clearobjndx(); |
215 |
|
/* free objects off end */ |
216 |
|
for (obj = nobjects; obj-- > 0; ) |
217 |
|
if (objptr(obj)->oname != NULL) |
218 |
|
break; |
219 |
< |
++obj; |
219 |
> |
if (++obj >= nobjects) |
220 |
> |
return; |
221 |
|
while (nobjects > obj) /* free empty end blocks */ |
222 |
|
if ((--nobjects & (OBJBLKSIZ-1)) == 0) { |
223 |
|
int i = nobjects >> OBJBLKSHFT; |
224 |
|
free((void *)objblock[i]); |
225 |
|
objblock[i] = NULL; |
226 |
|
} |
227 |
+ |
truncobjndx(); /* truncate modifier look-up */ |
228 |
|
} |