ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/readoct.c
(Generate patch)

Comparing ray/src/common/readoct.c (file contents):
Revision 1.2 by greg, Tue Feb 21 14:59:06 1989 UTC vs.
Revision 1.7 by greg, Mon Mar 12 10:39:17 1990 UTC

# Line 18 | Line 18 | static char SCCSid[] = "$SunId$ LBL";
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 */
# Line 59 | Line 59 | char  *ofn[];
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++)
# Line 133 | Line 133 | getfullnode()                  /* get a set, return fullnode */
133  
134  
135   static long
136 < getint(siz)                     /* get a siz-byte positive integer */
136 > getint(siz)                     /* get a siz-byte integer */
137   register int  siz;
138   {
139          register int  c;
140 <        register long  r = 0L;
140 >        register long  r;
141  
142 <        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  
# Line 155 | Line 160 | getflt()                       /* get a floating point number */
160          extern double  ldexp();
161          double  d;
162  
163 <        d = (double)getint(sizeof(long))/0x7fffffff;
164 <        return(ldexp(d, (char)getint(1)));      /* sign extend */
163 >        d = (double)getint(4)/0x7fffffff;
164 >        return(ldexp(d, getint(1)));
165   }
166          
167  
# Line 194 | Line 199 | getobj()                               /* get next object */
199          register OBJREC  *objp;
200  
201          i = getint(1);
202 <        if (i & 0x80)
202 >        if (i == -1)
203                  return(OVOID);          /* terminator */
204          if ((obj = newobject()) == OVOID)
205                  error(SYSTEM, "out of object space");
# Line 220 | Line 225 | getobj()                               /* get next object */
225                  if (objp->oargs.iarg == NULL)
226                          goto memerr;
227                  for (i = 0; i < objp->oargs.niargs; i++)
228 <                        objp->oargs.iarg[i] = getint(sizeof(long));
228 >                        objp->oargs.iarg[i] = getint(4);
229          } else
230                  objp->oargs.iarg = NULL;
231   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines