| 18 |
|
|
| 19 |
|
#include "otypes.h" |
| 20 |
|
|
| 21 |
< |
double atof(); |
| 22 |
< |
double getflt(); |
| 23 |
< |
long getint(); |
| 24 |
< |
char *getstr(); |
| 25 |
< |
OCTREE getfullnode(), gettree(); |
| 21 |
> |
extern double atof(); |
| 22 |
> |
static double getflt(); |
| 23 |
> |
static long getint(); |
| 24 |
> |
static char *getstr(); |
| 25 |
> |
static OCTREE getfullnode(), gettree(); |
| 26 |
|
|
| 27 |
|
static char *infn; /* input file name */ |
| 28 |
|
static FILE *infp; /* input file stream */ |
| 59 |
|
getheader(infp, NULL); |
| 60 |
|
/* check format */ |
| 61 |
|
if (getint(2) != OCTMAGIC) |
| 62 |
< |
octerror(USER, "bad octree"); |
| 62 |
> |
octerror(USER, "invalid octree format"); |
| 63 |
|
/* get boundaries */ |
| 64 |
|
if (load & IO_BOUNDS) { |
| 65 |
|
for (i = 0; i < 3; i++) |
| 139 |
|
register int c; |
| 140 |
|
register long r; |
| 141 |
|
|
| 142 |
< |
c = getc(infp); |
| 143 |
< |
r = c&0x80 ? -1L : 0L; /* sign extend */ |
| 144 |
< |
ungetc(c, infp); |
| 145 |
< |
while (siz--) { |
| 142 |
> |
if ((c = getc(infp)) == EOF) |
| 143 |
> |
goto end_file; |
| 144 |
> |
r = 0x80&c ? -1<<8|c : c; /* sign extend */ |
| 145 |
> |
while (--siz > 0) { |
| 146 |
|
if ((c = getc(infp)) == EOF) |
| 147 |
< |
octerror(USER, "truncated octree"); |
| 147 |
> |
goto end_file; |
| 148 |
|
r <<= 8; |
| 149 |
|
r |= c; |
| 150 |
|
} |
| 151 |
|
return(r); |
| 152 |
+ |
end_file: |
| 153 |
+ |
octerror(USER, "truncated octree"); |
| 154 |
|
} |
| 155 |
|
|
| 156 |
|
|