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

Comparing ray/src/common/fltdepth.c (file contents):
Revision 3.2 by greg, Thu Nov 7 23:33:45 2019 UTC vs.
Revision 3.3 by greg, Fri Nov 8 17:08:21 2019 UTC

# Line 61 | Line 61 | open_float_depth(const char *fname, long expected_leng
61          if (expected_length <= 0) {     /* need to sniff file? */
62                  extern const char       HDRSTR[];
63                  const int               len = strlen(HDRSTR);
64 <                n = read(fd, buf, len+1);
65 <                if (n < len+1)
64 >                if (read(fd, buf, len+1) < len+1)
65                          goto gotEOF;
66                  if (lseek(fd, 0, SEEK_SET) != 0)
67                          goto seek_error;
68                  for (n = 0; n < len; n++)
69                          if (buf[n] != HDRSTR[n])
70                                  break;
71 <                if (n < len || !isprint(buf[len]))      
71 >                if ((n < len) | !isprint(buf[len]))    
72                          return(fd);     /* unknown length raw float... */
73          } else {
74                  off_t   flen = lseek(fd, 0, SEEK_END);
# Line 92 | Line 91 | open_float_depth(const char *fname, long expected_leng
91                  fclose(dc.finp);        /* already reported error */
92                  return(-1);
93          }
94 <        if (expected_length > 0 && (long)dc.res.xr*dc.res.yr != expected_length) {
94 >        if ((expected_length > 0) &
95 >                        ((long)dc.res.xr*dc.res.yr != expected_length)) {
96                  fprintf(stderr, "%s: expected length is %ld, actual length is %ld\n",
97 <                                fname, (long)expected_length, (long)dc.res.xr*dc.res.yr);
97 >                                fname, expected_length, (long)dc.res.xr*dc.res.yr);
98                  fclose(dc.finp);
99                  return(-1);
100          }
101          strcpy(buf, TEMPLATE);          /* create temporary file to hold raw */
102          fd = mkstemp(buf);
103          if (fd < 0) {
104 <                fputs(buf, stderr);
105 <                fputs(": cannot create temporary file\n", stderr);
104 >                perror(buf);
105                  fclose(dc.finp);
106                  return(-1);
107          }
108 <        unlink(buf);                    /* unlink it now (Windows forbids) */
108 >        unlink(buf);                    /* preemptive remove (Windows forbids) */
109          for (nleft = (ssize_t)dc.res.xr*dc.res.yr; nleft > 0; nleft -= FBUFLEN) {
110                  for (n = 0; n < FBUFLEN; n++) {
111                          double  d = decode_depth_next(&dc);
# Line 115 | Line 114 | open_float_depth(const char *fname, long expected_leng
114                                          goto gotEOF;
115                                  break;
116                          }
117 <                        ((float *)buf)[n] = (float)d;
117 >                        ((float *)buf)[n] = d;
118                  }
119                  n *= sizeof(float);
120                  if (write(fd, buf, n) != n) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines