1 |
< |
/* Copyright (c) 1986 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1994 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
24 |
|
OBJECT nobjects = 0; /* # of objects */ |
25 |
|
|
26 |
|
|
27 |
< |
readobj(input) /* read in an object file or stream */ |
28 |
< |
char *input; |
27 |
> |
readobj(inpspec) /* read in an object file or stream */ |
28 |
> |
char *inpspec; |
29 |
|
{ |
30 |
|
FILE *popen(); |
31 |
|
char *fgetline(); |
32 |
+ |
OBJECT lastobj; |
33 |
|
FILE *infp; |
34 |
< |
char buf[512]; |
34 |
> |
char buf[1024]; |
35 |
|
register int c; |
36 |
|
|
37 |
< |
if (input == NULL) { |
37 |
> |
lastobj = nobjects; |
38 |
> |
if (inpspec == NULL) { |
39 |
|
infp = stdin; |
40 |
< |
input = "standard input"; |
41 |
< |
} else if (input[0] == '!') { |
42 |
< |
if ((infp = popen(input+1, "r")) == NULL) { |
43 |
< |
sprintf(errmsg, "cannot execute \"%s\"", input); |
40 |
> |
inpspec = "standard input"; |
41 |
> |
} else if (inpspec[0] == '!') { |
42 |
> |
if ((infp = popen(inpspec+1, "r")) == NULL) { |
43 |
> |
sprintf(errmsg, "cannot execute \"%s\"", inpspec); |
44 |
|
error(SYSTEM, errmsg); |
45 |
|
} |
46 |
< |
} else if ((infp = fopen(input, "r")) == NULL) { |
47 |
< |
sprintf(errmsg, "cannot open scene file \"%s\"", input); |
46 |
> |
} else if ((infp = fopen(inpspec, "r")) == NULL) { |
47 |
> |
sprintf(errmsg, "cannot open scene file \"%s\"", inpspec); |
48 |
|
error(SYSTEM, errmsg); |
49 |
|
} |
50 |
|
while ((c = getc(infp)) != EOF) { |
58 |
|
readobj(buf); |
59 |
|
} else { /* object */ |
60 |
|
ungetc(c, infp); |
61 |
< |
getobject(input, infp); |
61 |
> |
getobject(inpspec, infp); |
62 |
|
} |
63 |
|
} |
64 |
< |
if (input[0] == '!') |
64 |
> |
if (inpspec[0] == '!') |
65 |
|
pclose(infp); |
66 |
|
else |
67 |
|
fclose(infp); |
68 |
+ |
if (nobjects == lastobj) { |
69 |
+ |
sprintf(errmsg, "(%s): empty file", inpspec); |
70 |
+ |
error(WARNING, errmsg); |
71 |
+ |
} |
72 |
|
} |
73 |
|
|
74 |
|
|
138 |
|
{ |
139 |
|
register int i; |
140 |
|
|
141 |
< |
if ((nobjects & 077) == 0) { /* new block */ |
141 |
> |
if ((nobjects & (OBJBLKSIZ-1)) == 0) { /* new block */ |
142 |
|
errno = 0; |
143 |
< |
i = nobjects >> 6; |
143 |
> |
i = nobjects >> OBJBLKSHFT; |
144 |
|
if (i >= MAXOBJBLK) |
145 |
|
return(OVOID); |
146 |
< |
objblock[i] = (OBJREC *)bmalloc(0100*sizeof(OBJREC)); |
146 |
> |
objblock[i] = (OBJREC *)bmalloc(OBJBLKSIZ*sizeof(OBJREC)); |
147 |
|
if (objblock[i] == NULL) |
148 |
|
return(OVOID); |
149 |
|
} |