--- ray/src/util/rtcontrib.c 2005/06/17 16:07:18 1.24 +++ ray/src/util/rtcontrib.c 2005/09/21 17:17:24 1.28 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rtcontrib.c,v 1.24 2005/06/17 16:07:18 greg Exp $"; +static const char RCSid[] = "$Id: rtcontrib.c,v 1.28 2005/09/21 17:17:24 greg Exp $"; #endif /* * Gather rtrace output to compute contributions from particular sources @@ -173,6 +173,13 @@ main(int argc, char *argv[]) char *binval = NULL; char fmt[8]; int i, j; + /* need at least one argument */ + if (argc < 2) { + fprintf(stderr, +"Usage: %s [-n nprocs][-r][-e expr][-f source][-o ospec][-b binv] {-m mod | -M file} [rtrace options] octree\n", + argv[0]); + exit(1); + } /* global program name */ gargv = argv; /* initialize calcomp routines */ @@ -323,12 +330,15 @@ main(int argc, char *argv[]) quit(0); } +#ifndef SIGALRM +#define SIGALRM SIGTERM +#endif /* kill persistent rtrace process */ static void killpersist(void) { FILE *fp = fopen(persistfn, "r"); - int pid; + RT_PID pid; if (fp == NULL) return; @@ -706,7 +716,7 @@ add_contrib(const char *modn) bn = (int)(evalue(mp->binv) + .5); if (bn <= 0) bn = 0; - else if (bn > mp->nbins) { /* new bin */ + else if (bn >= mp->nbins) { /* new bin */ mp = (MODCONT *)realloc(mp, sizeof(MODCONT) + bn*sizeof(DCOLOR)); if (mp == NULL) @@ -905,7 +915,7 @@ wait_rproc(void) if (rt->bsiz + BUFSIZ <= treebufsiz) rt->bsiz = treebufsiz; else - rt->bsiz = treebufsiz += BUFSIZ; + treebufsiz = rt->bsiz += BUFSIZ; rt->buf = (char *)realloc(rt->buf, rt->bsiz); } if (rt->buf == NULL) @@ -1099,7 +1109,7 @@ recover_output(FILE *fin) /* seek on all files */ nvals = lastout * outvsiz; lu_doall(&ofiletab, myseeko, &nvals); - /* discard input */ + /* skip repeated input */ for (nvals = 0; nvals < lastout; nvals++) if (getinp(oname, fin) <= 0) error(USER, "unexpected EOF on input");