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

Comparing ray/src/util/rcrop.c (file contents):
Revision 1.10 by greg, Wed Mar 16 15:50:24 2022 UTC vs.
Revision 1.13 by greg, Thu Apr 7 16:58:30 2022 UTC

# Line 12 | Line 12 | static const char RCSid[] = "$Id$";
12   #include "fvect.h"
13   #include "view.h"
14  
15 #define MAXWORD         64      /* maximum word (number) length */
16
15   char    *progname;              /* global argv[0] */
16  
17   VIEW    vw = STDVIEW;
# Line 100 | Line 98 | binary_copyf(FILE *fp, int asize)
98                                          /* check if fseek() useful */
99          if (skip_len > skip_thresh &&
100                          fseek(fp, (rmin*width + cmin)*elsiz, SEEK_CUR) == 0) {
101 +                off_t   curpos;
102                  buf = (char *)malloc(ncols*elsiz);
103                  if (!buf)
104                          goto memerr;
105 + #ifdef NON_POSIX
106                  for (y = nrows; y-- > 0; ) {
107                          if (getbinary(buf, elsiz, ncols, fp) != ncols)
108                                  goto readerr;
# Line 114 | Line 114 | binary_copyf(FILE *fp, int asize)
114                                  return(0);
115                          }
116                  }
117 <                free(buf);              /* success! */
118 <                return(1);
117 > #else
118 >                curpos = ftello(fp);
119 >                for (y = nrows; y-- > 0; curpos += width*elsiz) {
120 >                        if (pread(fileno(fp), buf, ncols*elsiz,
121 >                                                curpos) != ncols*elsiz)
122 >                                goto readerr;
123 >                        if (putbinary(buf, elsiz, ncols, stdout) != ncols)
124 >                                goto writerr;
125 >                }
126 > #endif
127 >                free(buf);
128 >                if (fflush(stdout) == EOF)
129 >                        goto writerr;
130 >                return(1);              /* success! */
131          }                               /* else need to read it all... */
132          buf = (char *)malloc(width*elsiz);
133          if (!buf)
# Line 226 | Line 238 | adjust_view(void)
238                  p1[1] = 1. - p1[1];
239          }
240          err = cropview(&vw, p0[0], p0[1], p1[0], p1[1]);
241 <        if (err) {
242 <                fputs(progname, stderr);
243 <                fputs(": view error - ", stderr);
244 <                fputs(err, stderr);
245 <                fputc('\n', stderr);
246 <                return(0);
247 <        }
248 <        return(1);
241 >
242 >        if (!err)
243 >                return(1);      /* success! */
244 >
245 >        fputs(progname, stderr);
246 >        fputs(": view error - ", stderr);
247 >        fputs(err, stderr);
248 >        fputc('\n', stderr);
249 >        return(0);              /* something went wrong */
250   }
251  
252  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines