--- ray/src/common/readoct.c 1989/04/23 19:38:51 1.5 +++ ray/src/common/readoct.c 1990/03/12 10:39:17 1.7 @@ -18,11 +18,11 @@ static char SCCSid[] = "$SunId$ LBL"; #include "otypes.h" -double atof(); -double getflt(); -long getint(); -char *getstr(); -OCTREE getfullnode(), gettree(); +extern double atof(); +static double getflt(); +static long getint(); +static char *getstr(); +static OCTREE getfullnode(), gettree(); static char *infn; /* input file name */ static FILE *infp; /* input file stream */ @@ -139,16 +139,18 @@ register int siz; register int c; register long r; - c = getc(infp); - r = c&0x80 ? -1L : 0L; /* sign extend */ - ungetc(c, infp); - while (siz--) { + if ((c = getc(infp)) == EOF) + goto end_file; + r = 0x80&c ? -1<<8|c : c; /* sign extend */ + while (--siz > 0) { if ((c = getc(infp)) == EOF) - octerror(USER, "truncated octree"); + goto end_file; r <<= 8; r |= c; } return(r); +end_file: + octerror(USER, "truncated octree"); }