--- ray/src/gen/replmarks.c 2014/03/06 00:47:37 2.16 +++ ray/src/gen/replmarks.c 2025/06/07 05:09:45 2.23 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: replmarks.c,v 2.16 2014/03/06 00:47:37 greg Exp $"; +static const char RCSid[] = "$Id: replmarks.c,v 2.23 2025/06/07 05:09:45 greg Exp $"; #endif /* * Replace markers in Radiance scene description with objects or instances. @@ -14,7 +14,6 @@ static const char RCSid[] = "$Id: replmarks.c,v 2.16 2 #include "platform.h" #include "rtio.h" -#include "rtprocess.h" #include "fvect.h" #ifdef M_PI @@ -23,8 +22,6 @@ static const char RCSid[] = "$Id: replmarks.c,v 2.16 2 #define PI 3.14159265358979323846 #endif -#define FEQ(a,b) ((a)-(b) <= 1e-7 && (b)-(a) <= 1e-7) - #define MAXVERT 6 /* maximum number of vertices for markers */ #define MAXMARK 128 /* maximum number of markers */ @@ -48,8 +45,6 @@ int nmarkers = 0; /* number of markers */ int expand; /* expand commands? */ -char *progname; - static void convert(char *name, FILE *fin); static void cvcomm(char *fname, FILE *fin); static void cvobject(char *fname, FILE *fin); @@ -68,7 +63,7 @@ main( FILE *fp; int i, j; - progname = argv[0]; + fixargv0(argv[0]); /* sets global progname */ i = 1; while (i < argc && argv[i][0] == '-') { do { @@ -141,10 +136,10 @@ userr: void convert( /* replace marks in a stream */ char *name, - register FILE *fin + FILE *fin ) { - register int c; + int c; while ((c = getc(fin)) != EOF) { if (isspace(c)) /* blank */ @@ -174,7 +169,7 @@ cvcomm( /* convert a command */ ) { FILE *pin; - char buf[512], *fgetline(); + char buf[512]; fgetline(buf, sizeof(buf), fin); if (expand) { @@ -185,7 +180,10 @@ cvcomm( /* convert a command */ exit(1); } convert(buf, pin); - pclose(pin); + if (pclose(pin) != 0) + fprintf(stderr, + "%s: (%s): warning - bad status from \"%s\"\n", + progname, fname, buf); } else printf("\n%s\n", buf); } @@ -197,10 +195,9 @@ cvobject( /* convert an object */ FILE *fin ) { - extern char *fgetword(); char buf[128], typ[16], nam[128]; int i, n; - register int j; + int j; if (fgetword(buf, sizeof(buf), fin) == NULL || fgetword(typ, sizeof(typ), fin) == NULL || @@ -245,7 +242,7 @@ readerr: void replace( /* replace marker */ char *fname, - register struct mrkr *m, + struct mrkr *m, char *mark, FILE *fin ) @@ -299,7 +296,7 @@ edgecmp( /* compare two edges, descending order */ int buildxf( /* build transform for marker */ - register char *xf, + char *xf, double markscale, FILE *fin ) @@ -309,7 +306,7 @@ buildxf( /* build transform for marker */ FVECT xvec, yvec, zvec; double xlen; int n; - register int i; + int i; /* * Read and sort vectors: longest is hypotenuse, * second longest is x' axis, @@ -382,7 +379,7 @@ buildxf( /* build transform for marker */ int addrot( /* compute rotation (x,y,z) => (xp,yp,zp) */ - register char *xf, + char *xf, FVECT xp, FVECT yp, FVECT zp @@ -401,19 +398,19 @@ addrot( /* compute rotation (x,y,z) => (xp,yp,zp) */ } n = 0; theta = atan2(yp[2], zp[2]); - if (!FEQ(theta,0.0)) { + if (!FABSEQ(theta,0.0)) { sprintf(xf, " -rx %f", theta*(180./PI)); while (*xf) ++xf; n += 2; } theta = Asin(-xp[2]); - if (!FEQ(theta,0.0)) { + if (!FABSEQ(theta,0.0)) { sprintf(xf, " -ry %f", theta*(180./PI)); while (*xf) ++xf; n += 2; } theta = atan2(xp[1], xp[0]); - if (!FEQ(theta,0.0)) { + if (!FABSEQ(theta,0.0)) { sprintf(xf, " -rz %f", theta*(180./PI)); /* while (*xf) ++xf; */ n += 2;