--- ray/src/px/pcomb.c 1991/11/11 14:01:24 1.23 +++ ray/src/px/pcomb.c 1992/08/28 21:41:49 2.5 @@ -124,10 +124,13 @@ char *argv[]; goto usage; } else { - input[nfiles].name = argv[a]; - input[nfiles].fp = argv[a][0]=='!' ? - popen(argv[a]+1, "r") : - fopen(argv[a], "r"); + if (argv[a][0] == '!') { + input[nfiles].name = ""; + input[nfiles].fp = popen(argv[a]+1, "r"); + } else { + input[nfiles].name = argv[a]; + input[nfiles].fp = fopen(argv[a], "r"); + } if (input[nfiles].fp == NULL) { perror(argv[a]); quit(1); @@ -331,6 +334,7 @@ combine() /* combine pictures */ advance() /* read in data for next scanline */ { + extern double fabs(); int ytarget; register COLOR *st; register int i, j; @@ -343,13 +347,16 @@ advance() /* read in data for next scanline */ input[i].scan[0] = st; if (yscan <= MIDSCN) /* hit bottom? */ continue; - if (freadscan(st, xmax, input[i].fp) < 0) { /* read */ + if (freadscan(st, xmax, input[i].fp) < 0) { /* read */ eputs(input[i].name); eputs(": read error\n"); quit(1); } - for (j = 0; j < xmax; j++) /* adjust color */ - multcolor(st[j], input[i].coef); + if (fabs(colval(input[i].coef,RED)-1.0) > 1e-3 || + fabs(colval(input[i].coef,GRN)-1.0) > 1e-3 || + fabs(colval(input[i].coef,BLU)-1.0) > 1e-3) + for (j = 0; j < xmax; j++) /* adjust color */ + multcolor(st[j], input[i].coef); } } @@ -446,8 +453,29 @@ char *msg; } +#ifdef NIX + quit(code) -int code; +int code; { exit(code); } + +#else + +quit(code) /* exit gracefully */ +int code; +{ + int status; + register int i; + /* close input files */ + for (i = 0; i < nfiles; i++) + fclose(input[i].fp); + /* reap children */ + while (wait(&status) != -1) + if (code == 0) + code = status>>8 & 0xff; + exit(code); +} + +#endif