--- ray/src/gen/replmarks.c 1992/03/03 21:30:03 2.2 +++ ray/src/gen/replmarks.c 2003/03/10 17:26:26 2.6 @@ -1,9 +1,6 @@ -/* 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. * @@ -11,13 +8,14 @@ static char SCCSid[] = "$SunId$ LBL"; */ #include +#include #include #include #include "fvect.h" #ifdef M_PI -#define PI M_PI +#define PI ((double)M_PI) #else #define PI 3.14159265358979323846 #endif @@ -170,6 +168,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; @@ -194,11 +193,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'); } @@ -218,6 +218,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) @@ -258,7 +259,7 @@ EDGE *e1, *e2; int buildxf(xf, markscale, fin) /* build transform for marker */ -char *xf; +register char *xf; double markscale; FILE *fin; { @@ -325,11 +326,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], @@ -339,7 +340,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; @@ -349,19 +350,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);