--- ray/src/px/pcond.c 2004/11/14 22:19:50 3.23 +++ ray/src/px/pcond.c 2021/04/07 21:13:52 3.31 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: pcond.c,v 3.23 2004/11/14 22:19:50 greg Exp $"; +static const char RCSid[] = "$Id: pcond.c,v 3.31 2021/04/07 21:13:52 greg Exp $"; #endif /* * Condition Radiance picture for display/output @@ -8,12 +8,12 @@ static const char RCSid[] = "$Id: pcond.c,v 3.23 2004/ #include "platform.h" #include "paths.h" -#include "rtprocess.h" +#include "paths.h" #include "pcond.h" #define LDMAX 100 /* default max. display luminance */ -#define LDDYN 32 /* default dynamic range */ +#define LDDYN 100 /* default dynamic range */ int what2do = 0; /* desired adjustments */ @@ -60,7 +60,7 @@ main( { static RGBPRIMS outprimS; int i; -#define bool(flg) switch (argv[i][2]) { \ +#define check_bool(flg) switch (argv[i][2]) { \ case '\0': what2do ^= flg; break; \ case 'y': case 'Y': case 't': case 'T': \ case '+': case '1': what2do |= flg; break; \ @@ -73,22 +73,22 @@ main( for (i = 1; i < argc && argv[i][0] == '-'; i++) switch (argv[i][1]) { case 'h': - bool(DO_HUMAN); + check_bool(DO_HUMAN); break; case 'a': - bool(DO_ACUITY); + check_bool(DO_ACUITY); break; case 'v': - bool(DO_VEIL); + check_bool(DO_VEIL); break; case 's': - bool(DO_HSENS); + check_bool(DO_HSENS); break; case 'c': - bool(DO_COLOR); + check_bool(DO_COLOR); break; case 'w': - bool(DO_CWEIGHT); + check_bool(DO_CWEIGHT); break; case 'i': if (i+1 >= argc) goto userr; @@ -97,10 +97,10 @@ main( else what2do &= ~DO_FIXHIST; break; case 'I': - bool(DO_PREHIST); + check_bool(DO_PREHIST); break; case 'l': - bool(DO_LINEAR); + check_bool(DO_LINEAR); break; case 'p': if (i+8 >= argc) goto userr; @@ -195,11 +195,11 @@ userr: progname); exit(1); return 1; /* pro forma return */ -#undef bool +#undef check_bool } -extern void +void syserror( /* report system error and exit */ char *s ) @@ -217,7 +217,7 @@ headline( /* process header line */ ) { static RGBPRIMS inprimS; - char fmt[32]; + char fmt[MAXFMTLEN]; if (formatval(fmt, s)) { /* check if format string */ if (!strcmp(fmt,COLRFMT)) lumf = rgblum; @@ -225,9 +225,9 @@ headline( /* process header line */ else lumf = NULL; return(0); /* don't echo */ } - if (isprims(s)) { /* get input primaries */ - primsval(inprimS, s); - inprims= inprimS; + /* get input primaries */ + if (isprims(s) && primsval(inprimS, s)) { + inprims = inprimS; return(0); /* don't echo */ } if (isexpos(s)) { /* picture exposure */ @@ -261,7 +261,7 @@ getahead(void) /* load picture header */ exit(1); } if (!gotview || ourview.type == VT_PAR || - ourview.horiz <= 5. | ourview.vert <= 5.) { + (ourview.horiz <= 5.) | (ourview.vert <= 5.)) { ourview = stdview; ourview.type = VT_PER; if (pixaspect*inpres.yr < inpres.xr) { @@ -344,6 +344,7 @@ getfovimg(void) /* load foveal sampled image */ sprintf(combuf, "pfilt -1 -b -pa 0 -x %d -y %d \"%s\"", fvxr, fvyr, infn); if ((fp = popen(combuf, "r")) == NULL) syserror("popen"); + SET_FILE_BINARY(fp); getheader(fp, NULL, NULL); /* skip header */ if (fgetresolu(&x, &y, fp) < 0 || (x != fvxr) | (y != fvyr)) goto readerr; @@ -364,7 +365,7 @@ check2do(void) /* check histogram to see what isn't w { double sum; double b, l; - register int i; + int i; /* check for within display range */ if (bwmax - bwmin <= Bldmax - Bldmin)