--- ray/src/px/ra_ps.c 2018/08/02 18:33:47 2.30 +++ ray/src/px/ra_ps.c 2024/10/04 01:53:45 2.33 @@ -1,16 +1,15 @@ #ifndef lint -static const char RCSid[] = "$Id: ra_ps.c,v 2.30 2018/08/02 18:33:47 greg Exp $"; +static const char RCSid[] = "$Id: ra_ps.c,v 2.33 2024/10/04 01:53:45 greg Exp $"; #endif /* * Radiance picture to PostScript file translator -- one way! */ -#include -#include #include #include #include "platform.h" +#include "paths.h" #include "rtio.h" #include "color.h" #include "resolu.h" @@ -60,7 +59,7 @@ typedef void putprimf_t(COLR *scn, int pri); static gethfunc headline; static putprimf_t Aputprim, Bputprim, Cputprim; -static double unit2inch(register char *s); +static double unit2inch(char *s); static int matchid(char *name, char *id); static void parsepaper(char *ps); static void quiterr(char *err); @@ -82,11 +81,14 @@ headline( /* check header line */ { char fmt[MAXFMTLEN]; - if (isformat(s)) { - formatval(fmt, s); - wrongformat = strcmp(fmt, COLRFMT); - } else if (isaspect(s)) + if (formatval(fmt, s)) + wrongformat = strcmp(fmt, COLRFMT) && strcmp(fmt, SPECFMT); + else if (isaspect(s)) pixaspect *= aspectval(s); + else if (isncomp(s)) + NCSAMP = ncompval(s); + else if (iswlsplit(s)) + wlsplitval(WLPART, s); return(0); } @@ -198,7 +200,7 @@ userr: static double unit2inch( /* determine unit */ - register char *s + char *s ) { static struct unit {char n; float f;} u[] = { @@ -206,7 +208,7 @@ unit2inch( /* determine unit */ {'m', 1./25.4}, {'c', 1./2.54}, {'\0',0} }; - register struct unit *up; + struct unit *up; while (*s && !isalpha(*s)) s++; @@ -220,10 +222,10 @@ unit2inch( /* determine unit */ static int matchid( /* see if name matches id (case insensitive) */ char *name, - register char *id + char *id ) { - register char *s = name; + char *s = name; while (*s) { if (isalpha(*s)) { @@ -263,8 +265,8 @@ parsepaper( /* determine paper size from name */ {"DL", 4.33, 8.66}, {"hagaki", 3.94, 5.83}, {"",0.0,0.0} }; - register struct psize *pp; - register char *s = ps; + struct psize *pp; + char *s = ps; double d; if (isdigit(*s)) { /* check for WWxHH specification */ @@ -427,7 +429,7 @@ PSprocdef( /* define PS procedure to read image */ ) { short itab[128]; - register int i; + int i; /* assign code values */ for (i = 0; i < 128; i++) /* clear */ itab[i] = -1; @@ -466,7 +468,7 @@ PSprocdef( /* define PS procedure to read image */ static void ra2ps(void) /* convert Radiance scanlines to 6-bit */ { - register COLR *scanin; + COLR *scanin; int y; /* allocate scanline */ scanin = (COLR *)malloc(xmax*sizeof(COLR)); @@ -474,9 +476,9 @@ ra2ps(void) /* convert Radiance scanlines to 6-bit quiterr("out of memory in ra2ps"); /* convert image */ for (y = ymax-1; y >= 0; y--) { - if (freadcolrs(scanin, xmax, stdin) < 0) + if (fread2colrs(scanin, xmax, stdin, NCSAMP, WLPART) < 0) quiterr("error reading Radiance picture"); - if (putprim == Cputprim || devgam != 1.) { + if ((putprim == Cputprim) | (devgam != 1.)) { if (bradj) /* adjust exposure */ shiftcolrs(scanin, xmax, bradj); colrs_gambs(scanin, xmax); /* gamma compression */ @@ -505,7 +507,7 @@ Aputprim( /* put out hex ASCII primary from scanline { static char hexdigit[] = "0123456789ABCDEF"; static int col = 0; - register int x, c; + int x, c; for (x = 0; x < xmax; x++) { if (pri == GRY) @@ -529,7 +531,7 @@ Bputprim( /* put out binary primary from scanline */ int pri ) { - register int x, c; + int x, c; for (x = 0; x < xmax; x++) { if (pri == GRY) @@ -548,8 +550,8 @@ Cputprim( /* put out compressed primary from scanline int pri ) { - register int c; - register int x; + int c; + int x; int lastc, cnt; lastc = -1; cnt = 0; @@ -574,8 +576,8 @@ Cputprim( /* put out compressed primary from scanline static void putrle( /* put out cnt of cod */ - register int cnt, - register int cod + int cnt, + int cod ) { static int col = 0;