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.3 by greg, Fri Nov 8 17:08:21 2019 UTC vs.
Revision 3.4 by greg, Mon Nov 11 16:45:30 2019 UTC

# Line 22 | Line 22 | open_float_depth(const char *fname, long expected_leng
22   {
23          int     fd = open(fname, O_RDONLY|O_BINARY);
24  
25 <        if (fd < 0)
25 >        if (fd < 0) {
26 >                fprintf(stderr, "%s: cannot open for reading\n", fname);
27                  return(-1);
28 +        }
29          if (expected_length > 0) {
30                  off_t   flen = lseek(fd, 0, SEEK_END);
31                  if (flen != expected_length*sizeof(float)) {
# Line 55 | Line 57 | open_float_depth(const char *fname, long expected_leng
57          ssize_t         n, nleft;
58          int             fd = open(fname, O_RDONLY);
59  
60 <        if (fd < 0)
60 >        if (fd < 0) {
61 >                perror(fname);
62                  return(-1);
63 +        }
64          dc.finp = NULL;
65          if (expected_length <= 0) {     /* need to sniff file? */
66                  extern const char       HDRSTR[];
67                  const int               len = strlen(HDRSTR);
68                  if (read(fd, buf, len+1) < len+1)
69 <                        goto gotEOF;
69 >                        goto badEOF;
70                  if (lseek(fd, 0, SEEK_SET) != 0)
71                          goto seek_error;
72                  for (n = 0; n < len; n++)
# Line 111 | Line 115 | open_float_depth(const char *fname, long expected_leng
115                          double  d = decode_depth_next(&dc);
116                          if (d < 0) {
117                                  if (n < nleft)
118 <                                        goto gotEOF;
118 >                                        goto badEOF;
119                                  break;
120                          }
121                          ((float *)buf)[n] = d;
# Line 128 | Line 132 | open_float_depth(const char *fname, long expected_leng
132          if (lseek(fd, 0, SEEK_SET) != 0)
133                  goto seek_error;
134          return(fd);
135 < gotEOF:
135 > badEOF:
136          fputs(fname, stderr);
137          fputs(": unexpected end-of-file\n", stderr);
138          if (dc.finp) fclose(dc.finp);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines