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.14 by greg, Tue Nov 21 02:06:14 2023 UTC vs.
Revision 1.16 by greg, Fri May 17 20:50:57 2024 UTC

# Line 97 | Line 97 | binary_copyf(FILE *fp, int asize)
97          int             y;
98                                          /* check if fseek() useful */
99          if (skip_len > skip_thresh &&
100 <                        fseek(fp, (rmin*width + cmin)*elsiz, SEEK_CUR) == 0) {
100 >                        fseek(fp, ((long)rmin*width + cmin)*elsiz, SEEK_CUR) == 0) {
101                  off_t   curpos;
102                  buf = (char *)malloc(ncols*elsiz);
103                  if (!buf)
# Line 134 | Line 134 | binary_copyf(FILE *fp, int asize)
134                  goto memerr;
135                                          /* skip rows as requested */
136          if (skip_len > skip_thresh ||
137 <                        (rmin && fseek(fp, rmin*width*elsiz, SEEK_CUR) < 0))
137 >                        (rmin && fseek(fp, (long)rmin*width*elsiz, SEEK_CUR) < 0))
138                  for (y = 0; y < rmin; y++)
139                          if (getbinary(buf, elsiz, width, fp) != width)
140                                  goto readerr;
# Line 163 | Line 163 | memerr:
163  
164   /* Read (and copy) specified number of white-space-separated words */
165   static int
166 < readwords(FILE *finp, int nwords, FILE *fout)
166 > readwords(FILE *finp, long nwords, FILE *fout)
167   {
168          while (nwords-- > 0) {
169                  int     c;
# Line 192 | Line 192 | ascii_copyf(FILE *fp)
192          SET_FILE_TEXT(fp);              /* started as binary */
193          SET_FILE_TEXT(stdout);
194                                          /* skip rows as requested */
195 <        if (readwords(fp, rmin*width*ncomp, NULL) < 0)
195 >        if (readwords(fp, (long)rmin*width*ncomp, NULL) < 0)
196                  goto io_err;
197          for (y = 0; y < nrows; y++) {   /* copy part */
198                  if (readwords(fp, cmin*ncomp, NULL) < 0)
# Line 269 | Line 269 | main(int argc, char *argv[])
269          cmin = atoi(argv[2]);
270          nrows = atoi(argv[3]);
271          ncols = atoi(argv[4]);
272 <        if ((rmin < 0) | (cmin < 0) | (nrows < 0) | (ncols < 0))
272 >        if ((rmin < 0) | (cmin < 0))
273                  goto usage;
274          if (argc <= 5)
275                  SET_FILE_BINARY(fp);
# Line 301 | Line 301 | main(int argc, char *argv[])
301                  fputs(": missing input dimensions\n", stderr);
302                  return(1);
303          }
304 <        if (!nrows)
305 <                nrows = numscans(&res) - rmin;
306 <        if (!ncols)
307 <                ncols = scanlen(&res) - cmin;
304 >        if (nrows <= 0 )
305 >                nrows += numscans(&res) - rmin;
306 >        if (ncols <= 0)
307 >                ncols += scanlen(&res) - cmin;
308          if ((nrows <= 0) | (ncols <= 0) |
309                          (rmin+nrows > numscans(&res)) |
310                          (cmin+ncols > scanlen(&res))) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines