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.5 by greg, Sun Apr 23 19:38:51 1989 UTC vs.
Revision 1.6 by greg, Tue Sep 19 13:40:48 1989 UTC

# Line 139 | Line 139 | register int  siz;
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  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines