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.15 by greg, Tue Jul 8 16:39:41 2014 UTC vs.
Revision 2.19 by greg, Thu Sep 18 00:12:42 2014 UTC

# Line 274 | Line 274 | int            ni_columns = 0;                 /* number of input columns */
274   int             ni_rows = 0;                    /* number of input rows */
275   int             no_columns = 0;                 /* number of output columns */
276   int             no_rows = 0;                    /* number of output rows */
277 + int             transpose = 0;                  /* transpose rows & cols? */
278 + int             i_header = 1;                   /* input header? */
279 + int             o_header = 1;                   /* output header? */
280  
281   /* check settings and assign defaults */
282   static int
# Line 293 | Line 296 | check_sizes()
296                          return(0);
297                  }
298          }
299 +        if (transpose && (no_rows <= 0) & (no_columns <= 0)) {
300 +                if (ni_rows > 0) no_columns = ni_rows;
301 +                if (ni_columns > 0) no_rows = ni_columns;
302 +        } else if ((no_rows <= 0) & (no_columns > 0) &&
303 +                        !((ni_rows*ni_columns) % no_columns))
304 +                no_rows = ni_rows*ni_columns/no_columns;
305          if (n_comp <= 0)
306                  n_comp = 3;
307          return(1);
# Line 372 | Line 381 | do_resize(FILE *fp)
381          int     columns2go = no_columns;
382          char    word[256];
383                                                  /* sanity checks */
384 <        if (comp_size)
385 <                return(output_stream(fp));      /* binary data -- just copy */
384 >        if (comp_size || (no_columns == ni_columns) & (no_rows == ni_rows))
385 >                return(output_stream(fp));      /* no-op -- just copy */
386          if (no_columns <= 0) {
387                  fprintf(stderr, "Missing -oc specification\n");
388                  return(0);
# Line 466 | Line 475 | headline(char *s, void *p)
475                  n_comp = n;
476                  return(0);
477          }
478 <        fputs(s, stdout);                       /* copy header info. */
478 >        if (o_header)
479 >                fputs(s, stdout);               /* copy header info. */
480          return(0);
481   }
482  
# Line 474 | Line 484 | headline(char *s, void *p)
484   int
485   main(int argc, char *argv[])
486   {
477        int     i_header = 1;                   /* input header? */
478        int     o_header = 1;                   /* output header? */
479        int     transpose = 0;                  /* transpose rows & cols? */
487          int     a;
488  
489          for (a = 1; a < argc && argv[a][0] == '-'; a++)
# Line 565 | Line 572 | main(int argc, char *argv[])
572                  SET_FILE_BINARY(stdout);
573          }
574                                                  /* check for no-op */
575 <        if (!transpose & (i_header == o_header) && (comp_size ||
576 <                        (no_columns == ni_columns) & (no_rows == ni_rows))) {
575 >        if (!transpose & (i_header == o_header) &&
576 >                        (no_columns == ni_columns) & (no_rows == ni_rows)) {
577                  if (warnings)
578                          fprintf(stderr, "%s: no-op -- copying input verbatim\n",
579                                  argv[0]);
# Line 587 | Line 594 | main(int argc, char *argv[])
594                  return(1);
595          if (o_header) {                         /* write header */
596                  printargs(a, argv, stdout);
590                if (transpose && (no_rows <= 0) & (no_columns <= 0)) {
591                        if (ni_rows > 0) no_columns = ni_rows;
592                        if (ni_columns > 0) no_rows = ni_columns;
593                }
597                  if (no_rows > 0)
598                          printf("NROWS=%d\n", no_rows);
599                  if (no_columns > 0)
# Line 600 | Line 603 | main(int argc, char *argv[])
603                  fputc('\n', stdout);            /* finish new header */
604          }
605          if (transpose) {                        /* transposing rows & columns? */
606 <                MEMLOAD myMem;                  /* need to load into memory */
606 >                MEMLOAD myMem;                  /* need to map into memory */
607                  if (a == argc-1) {
608                          if (load_file(&myMem, stdin) <= 0) {
609                                  fprintf(stderr, "%s: error loading file into memory\n",
# Line 614 | Line 617 | main(int argc, char *argv[])
617                  }
618                  if (!do_transpose(&myMem))
619                          return(1);
620 <                /* free_load(&myMem); */
621 <        } else if (!do_resize(stdin))           /* just reshaping input */
620 >                /* free_load(&myMem);   about to exit, so don't bother */
621 >        } else if (!do_resize(stdin))           /* reshaping input */
622                  return(1);
623          return(0);
624   userr:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines