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.3 by greg, Thu Sep 5 18:47:12 2013 UTC vs.
Revision 2.7 by greg, Mon Nov 18 22:02:12 2013 UTC

# Line 6 | Line 6 | static const char RCSid[] = "$Id$";
6   */
7  
8   #include <stdlib.h>
9 #include <unistd.h>
9   #include <string.h>
10   #include <ctype.h>
11   #include "platform.h"
12   #include "rtio.h"
13   #include "resolu.h"
14 < #ifndef _WIN32
14 > #ifdef _WIN32
15 > #undef ftello
16 > #define ftello  ftell
17 > #undef ssize_t
18 > #define ssize_t size_t
19 > #else
20   #include <sys/mman.h>
21   #endif
22  
# Line 35 | Line 39 | typedef struct {
39          char    *rec[1];        /* record array (extends struct) */
40   } RECINDEX;
41  
42 + int             warnings = 1;   /* report warnings? */
43 +
44   /* free loaded file */
45   static void
46   free_load(MEMLOAD *mp)
# Line 272 | Line 278 | do_transpose(const MEMLOAD *mp)
278          RECINDEX                *rp = NULL;
279          long                    nrecords;
280          int                     i, j;
281 +                                                /* propogate sizes */
282 +        if (ni_rows <= 0)
283 +                ni_rows = no_columns;
284 +        if (ni_columns <= 0)
285 +                ni_columns = no_rows;
286                                                  /* get # records (& index) */
287          if (record_width > 0) {
288                  if ((rp = index_records(mp, record_width)) == NULL)
# Line 289 | Line 300 | do_transpose(const MEMLOAD *mp)
300          } else
301                  nrecords = mp->len / -record_width;
302                                                  /* check sizes */
292        if (ni_rows <= 0)
293                ni_rows = no_columns;
294        if (ni_columns <= 0)
295                ni_columns = no_rows;
303          if ((ni_rows <= 0) & (ni_columns > 0))
304                  ni_rows = nrecords/ni_columns;
305          if ((ni_columns <= 0) & (ni_rows > 0))
# Line 383 | Line 390 | do_resize(FILE *fp)
390                          putc('\t', stdout);
391          } while (--records2go);                 /* expected EOD? */
392   done:
393 <        if (columns2go != no_columns)
393 >        if (warnings && columns2go != no_columns)
394                  fprintf(stderr, "Warning -- incomplete final row\n");
395 <        if (fget_word(word, fp) != NULL)
396 <                fprintf(stderr, "Warning -- data beyond expected EOF\n");
395 >        if (warnings && fget_word(word, fp) != NULL)
396 >                fprintf(stderr, "Warning -- characters beyond expected EOD\n");
397          return(1);
398   }
399  
# Line 469 | Line 476 | main(int argc, char *argv[])
476                                  record_width *= atoi(argv[i]+3);
477                          }
478                          break;
479 +                case 'w':                       /* warnings on/off */
480 +                        warnings = !warnings;
481 +                        break;
482                  default:
483                          goto userr;
484                  }
# Line 488 | Line 498 | main(int argc, char *argv[])
498                                                  /* check for no-op */
499          if (!transpose && (record_width < 0 ||
500                          (no_columns == ni_columns) & (no_rows == ni_rows))) {
501 <                fprintf(stderr, "%s: no-op -- copying input verbatim\n",
501 >                if (warnings)
502 >                        fprintf(stderr, "%s: no-op -- copying input verbatim\n",
503                                  argv[0]);
504                  if (!output_stream(stdin))
505                          return(1);
# Line 522 | Line 533 | main(int argc, char *argv[])
533          return(0);
534   userr:
535          fprintf(stderr,
536 < "Usage: %s [-h][-f[afdb][N]][-t][-ic in_col][-ir in_row][-oc out_col][-or out_row] [input.dat]\n",
536 > "Usage: %s [-h][-w][-f[afdb][N]][-t][-ic in_col][-ir in_row][-oc out_col][-or out_row] [input.dat]\n",
537                          argv[0]);
538          return(1);
539   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines