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

Comparing ray/src/util/cmatrix.c (file contents):
Revision 2.26 by greg, Thu Mar 26 02:48:31 2020 UTC vs.
Revision 2.27 by greg, Thu Mar 26 16:56:10 2020 UTC

# Line 259 | Line 259 | cm_load(const char *inspec, int nrows, int ncols, int
259          }
260          if (nrows <= 0) {                       /* don't know length? */
261                  int     guessrows = 147;        /* usually big enough */
262 <                if ((dtype != DTascii) & (fp != stdin) & (inspec[0] != '!')) {
262 >                if (cm_elem_size[dtype] && (fp != stdin) & (inspec[0] != '!')) {
263                          long    startpos = ftell(fp);
264                          if (fseek(fp, 0L, SEEK_END) == 0) {
265 +                                long    rowsiz = (long)ncols*cm_elem_size[dtype];
266                                  long    endpos = ftell(fp);
266                                long    elemsiz = 3*(dtype==DTfloat ?
267                                            sizeof(float) : sizeof(double));
267  
268 <                                if ((endpos - startpos) % (ncols*elemsiz)) {
268 >                                if ((endpos - startpos) % rowsiz) {
269                                          sprintf(errmsg,
270                                          "improper length for binary file '%s'",
271                                                          inspec);
272                                          error(USER, errmsg);
273                                  }
274 <                                guessrows = (endpos - startpos)/(ncols*elemsiz);
274 >                                guessrows = (endpos - startpos)/rowsiz;
275                                  if (fseek(fp, startpos, SEEK_SET) < 0) {
276                                          sprintf(errmsg,
277                                                  "fseek() error on file '%s'",

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines