--- ray/src/util/rmtxop.c 2014/05/31 19:21:21 2.2 +++ ray/src/util/rmtxop.c 2016/08/18 17:57:57 2.10 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rmtxop.c,v 2.2 2014/05/31 19:21:21 greg Exp $"; +static const char RCSid[] = "$Id: rmtxop.c,v 2.10 2016/08/18 17:57:57 greg Exp $"; #endif /* * General component matrix operations. @@ -10,6 +10,7 @@ static const char RCSid[] = "$Id: rmtxop.c,v 2.2 2014/ #include "rtio.h" #include "resolu.h" #include "rmatrix.h" +#include "platform.h" #define MAXCOMP 50 /* #components we support */ @@ -22,7 +23,6 @@ typedef struct { int op; /* '*' or '+' */ } ROPERAT; /* matrix operation */ -int outfmt = DTascii; /* output format */ int verbose = 0; /* verbose reporting? */ static void @@ -165,9 +165,9 @@ get_factors(double da[], int n, char *av[]) int main(int argc, char *argv[]) { + int outfmt = DTfromHeader; RMATRIX *mres = NULL; ROPERAT op; - long nbw; int i; /* initialize */ op_default(&op); @@ -232,16 +232,17 @@ main(int argc, char *argv[]) if (mres == NULL) /* check that we got something */ goto userr; /* write result to stdout */ + if (outfmt == DTfromHeader) + outfmt = mres->dtype; + if (outfmt != DTascii) + SET_FILE_BINARY(stdout); newheader("RADIANCE", stdout); printargs(argc, argv, stdout); - nbw = rmx_write(mres, outfmt, stdout); - /* rmx_free(mres); mres = NULL; */ - if (nbw <= 0) { + if (!rmx_write(mres, outfmt, stdout)) { fprintf(stderr, "%s: error writing result matrix\n", argv[0]); return(1); } - if (verbose) - fprintf(stderr, "%s: %ld bytes written\n", argv[0], nbw); + /* rmx_free(mres); mres = NULL; */ return(0); userr: fprintf(stderr,