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

Comparing ray/src/util/rcollate.c (file contents):
Revision 2.2 by greg, Thu Sep 5 18:30:58 2013 UTC vs.
Revision 2.4 by greg, Fri Sep 6 21:34:39 2013 UTC

# Line 35 | Line 35 | typedef struct {
35          char    *rec[1];        /* record array (extends struct) */
36   } RECINDEX;
37  
38 + int             warnings = 1;   /* report warnings? */
39 +
40   /* free loaded file */
41   static void
42   free_load(MEMLOAD *mp)
# Line 279 | Line 281 | do_transpose(const MEMLOAD *mp)
281                  if (ni_columns <= 0)
282                          ni_columns = count_columns(rp);
283                  nrecords = rp->nrecs;
284 <        } else if ((ni_rows > 0) & (ni_columns > 0))
284 >        } else if ((ni_rows > 0) & (ni_columns > 0)) {
285                  nrecords = ni_rows*ni_columns;
286 <        else
286 >                if (nrecords > mp->len / -record_width) {
287 >                        fprintf(stderr,
288 >                            "Input too small for specified size and type\n");
289 >                        return(0);
290 >                }
291 >        } else
292                  nrecords = mp->len / -record_width;
293                                                  /* check sizes */
294          if (ni_rows <= 0)
# Line 378 | Line 385 | do_resize(FILE *fp)
385                          putc('\t', stdout);
386          } while (--records2go);                 /* expected EOD? */
387   done:
388 <        if (columns2go != no_columns)
388 >        if (warnings && columns2go != no_columns)
389                  fprintf(stderr, "Warning -- incomplete final row\n");
390 <        if (fget_word(word, fp) != NULL)
391 <                fprintf(stderr, "Warning -- data beyond expected EOF\n");
390 >        if (warnings && fget_word(word, fp) != NULL)
391 >                fprintf(stderr, "Warning -- characters beyond expected EOD\n");
392          return(1);
393   }
394  
# Line 464 | Line 471 | main(int argc, char *argv[])
471                                  record_width *= atoi(argv[i]+3);
472                          }
473                          break;
474 +                case 'w':                       /* warnings on/off */
475 +                        warnings = !warnings;
476 +                        break;
477                  default:
478                          goto userr;
479                  }
# Line 483 | Line 493 | main(int argc, char *argv[])
493                                                  /* check for no-op */
494          if (!transpose && (record_width < 0 ||
495                          (no_columns == ni_columns) & (no_rows == ni_rows))) {
496 <                fprintf(stderr, "%s: no-op -- copying input verbatim\n",
496 >                if (warnings)
497 >                        fprintf(stderr, "%s: no-op -- copying input verbatim\n",
498                                  argv[0]);
499                  if (!output_stream(stdin))
500                          return(1);
# Line 517 | Line 528 | main(int argc, char *argv[])
528          return(0);
529   userr:
530          fprintf(stderr,
531 < "Usage: %s [-h][-f[afdb][N]][-t][-ic in_col][-ir in_row][-oc out_col][-or out_row] [input.dat]\n",
531 > "Usage: %s [-h][-w][-f[afdb][N]][-t][-ic in_col][-ir in_row][-oc out_col][-or out_row] [input.dat]\n",
532                          argv[0]);
533          return(1);
534   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines