--- ray/src/util/dctimestep.c 2009/06/21 21:49:13 2.8 +++ ray/src/util/dctimestep.c 2009/12/09 20:33:48 2.11 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: dctimestep.c,v 2.8 2009/06/21 21:49:13 greg Exp $"; +static const char RCSid[] = "$Id: dctimestep.c,v 2.11 2009/12/09 20:33:48 greg Exp $"; #endif /* * Compute time-step result using Daylight Coefficient method. @@ -38,7 +38,7 @@ cm_alloc(int nrows, int ncols) CMATRIX *cm; if ((nrows <= 0) | (ncols <= 0)) - return(NULL); + error(USER, "attempt to create empty matrix"); cm = (CMATRIX *)malloc(sizeof(CMATRIX) + 3*sizeof(COLORV)*(nrows*ncols - 1)); if (cm == NULL) @@ -294,7 +294,6 @@ static CMATRIX * cm_bsdf(const struct BSDF_data *bsdf) { CMATRIX *cm = cm_alloc(bsdf->nout, bsdf->ninc); - COLORV *mp = cm->cmem; int nbadohm = 0; int nneg = 0; int r, c; @@ -313,12 +312,12 @@ cm_bsdf(const struct BSDF_data *bsdf) for (r = 0; r < cm->nrows; r++) { float f = BSDF_value(bsdf,c,r); + COLORV *mp = cm_lval(cm,r,c); if (f <= .0) { nneg += (f < -FTINY); f = .0f; } - mp = cm_lval(cm,r,c); mp[0] = mp[1] = mp[2] = f * dom; } } @@ -405,9 +404,9 @@ sum_images(const char *fspec, const CMATRIX *cv) return(fflush(stdout) == 0); } -/* check to see if a string contains a %d specification */ -int -hasDecimalSpec(const char *s) +/* check to see if a string contains a %d or %o specification */ +static int +hasNumberFormat(const char *s) { while (*s && *s != '%') s++; @@ -417,7 +416,7 @@ hasDecimalSpec(const char *s) ++s; while (isdigit(*s)); - return(*s == 'd'); + return(*s == 'd' | *s == 'i' | *s == 'o' | *s == 'x' | *s == 'X'); } int @@ -448,7 +447,7 @@ main(int argc, char *argv[]) free_BSDF(btdf); cvec = cm_multiply(Tmat, ivec); /* cvec = component vector */ cm_free(Tmat); cm_free(ivec); - if (hasDecimalSpec(argv[1])) { /* generating image */ + if (hasNumberFormat(argv[1])) { /* generating image */ SET_FILE_BINARY(stdout); newheader("RADIANCE", stdout); printargs(argc, argv, stdout);