--- ray/src/gen/replmarks.c 1993/08/02 14:29:31 2.3 +++ ray/src/gen/replmarks.c 2003/10/27 10:27:25 2.8 @@ -1,23 +1,23 @@ -/* Copyright (c) 1992 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id"; #endif - /* * Replace markers in Radiance scene description with objects or instances. * * Created: 17 Feb 1991 Greg Ward */ -#include +#include #include #include +#include +#include "platform.h" +#include "rtprocess.h" #include "fvect.h" #ifdef M_PI -#define PI M_PI +#define PI ((double)M_PI) #else #define PI 3.14159265358979323846 #endif @@ -27,10 +27,6 @@ static char SCCSid[] = "$SunId$ LBL"; #define MAXVERT 6 /* maximum number of vertices for markers */ #define MAXMARK 32 /* maximum number of markers */ -#ifdef DCL_ATOF -extern double atof(); -#endif - typedef struct { short beg, end; /* beginning and ending vertex */ float len2; /* length squared */ @@ -152,7 +148,7 @@ cvcomm(fname, fin) /* convert a command */ char *fname; FILE *fin; { - FILE *pin, *popen(); + FILE *pin; char buf[512], *fgetline(); fgetline(buf, sizeof(buf), fin); @@ -174,6 +170,7 @@ cvobject(fname, fin) /* convert an object */ char *fname; FILE *fin; { + extern char *fgetword(); char buf[128], typ[16], nam[128]; int i, n; register int j; @@ -198,11 +195,12 @@ FILE *fin; goto readerr; printf("%d", n); for (j = 0; j < n; j++) { - if (fscanf(fin, "%s", buf) != 1) + if (fgetword(buf, sizeof(buf), fin) == NULL) goto readerr; if (j%3 == 0) putchar('\n'); - printf("\t%s", buf); + putchar('\t'); + fputword(buf, stdout); } putchar('\n'); } @@ -222,6 +220,7 @@ FILE *fin; int n; char buf[256]; + buf[0] = '\0'; /* bug fix thanks to schorsch */ if (m->doxform) { sprintf(buf, "xform -e -n %s", mark); if (m->modout != NULL) @@ -262,7 +261,7 @@ EDGE *e1, *e2; int buildxf(xf, markscale, fin) /* build transform for marker */ -char *xf; +register char *xf; double markscale; FILE *fin; { @@ -329,11 +328,11 @@ FILE *fin; if (markscale > 0.0) { /* add scale factor */ sprintf(xf, " -s %f", xlen*markscale); n += 2; - xf += strlen(xf); + while (*xf) ++xf; } /* add rotation */ n += addrot(xf, xvec, yvec, zvec); - xf += strlen(xf); + while (*xf) ++xf; /* add translation */ n += 4; sprintf(xf, " -t %f %f %f", vlist[elist[1].beg][0], @@ -343,7 +342,7 @@ FILE *fin; addrot(xf, xp, yp, zp) /* compute rotation (x,y,z) => (xp,yp,zp) */ -char *xf; +register char *xf; FVECT xp, yp, zp; { int n; @@ -353,19 +352,19 @@ FVECT xp, yp, zp; theta = atan2(yp[2], zp[2]); if (!FEQ(theta,0.0)) { sprintf(xf, " -rx %f", theta*(180./PI)); - xf += strlen(xf); + while (*xf) ++xf; n += 2; } theta = asin(-xp[2]); if (!FEQ(theta,0.0)) { sprintf(xf, " -ry %f", theta*(180./PI)); - xf += strlen(xf); + while (*xf) ++xf; n += 2; } theta = atan2(xp[1], xp[0]); if (!FEQ(theta,0.0)) { sprintf(xf, " -rz %f", theta*(180./PI)); - /* xf += strlen(xf); */ + /* while (*xf) ++xf; */ n += 2; } return(n);