--- ray/src/gen/xform.c 2003/02/22 02:07:24 2.23 +++ ray/src/gen/xform.c 2003/10/22 02:06:34 2.33 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: xform.c,v 2.23 2003/02/22 02:07:24 greg Exp $"; +static const char RCSid[] = "$Id: xform.c,v 2.33 2003/10/22 02:06:34 greg Exp $"; #endif /* * xform.c - program to transform object files. @@ -9,14 +9,12 @@ static const char RCSid[] = "$Id: xform.c,v 2.23 2003/ * 11/6/86 Finally added error checking! */ -#include "standard.h" - -#include "paths.h" - #include +#include "platform.h" +#include "standard.h" +#include "paths.h" #include "object.h" - #include "otypes.h" int xac; /* global xform argument count */ @@ -34,19 +32,15 @@ char *newmod; /* new modifier for surfaces */ char *idprefix; /* prefix for object identifiers */ -#define ALIAS NUMOTYPE /* put alias at end of array */ +FUN ofun[NUMOTYPE] = INIT_OTYPE; /* default types and actions */ -#define NUMTYPES (NUMOTYPE+1) /* total number of object types */ - -FUN ofun[NUMTYPES] = INIT_OTYPE; /* default types and actions */ - short tinvers[NUMOTYPE]; /* inverse types for surfaces */ int nrept = 1; /* number of array repetitions */ int stdinused = 0; /* stdin has been used by -f option? */ -char mainfn[MAXPATH]; /* main file name */ +char mainfn[PATH_MAX]; /* main file name */ FILE *mainfp = NULL; /* main file pointer */ #define progname (xav[0]) @@ -78,14 +72,14 @@ char *argv[]; if (argv[a][0] == '-') switch (argv[a][1]) { case 'm': - if (argv[a][2] | a+1 >= argc) + if (argv[a][2] | (a+1 >= argc)) break; a++; if (newmod == NULL) newmod = argv[a]; continue; case 'n': - if (argv[a][2] | a+1 >= argc) + if (argv[a][2] | (a+1 >= argc)) break; a++; if (idprefix == NULL) @@ -127,7 +121,7 @@ char *argv[]; a += xf(&tot, argc-a, argv+a); - if (reverse = tot.sca < 0.0) + if ( (reverse = tot.sca < 0.0) ) tot.sca = -tot.sca; if (invert) reverse = !reverse; @@ -226,7 +220,7 @@ int ac, fi; skipspaces: while (isspace(*cp)) /* nullify spaces */ *cp++ = '\0'; - if ((*cp == '"' | *cp == '\'')) + if ((*cp == '"') | (*cp == '\'')) inquote = *cp++; if (!*cp) /* all done? */ break; @@ -492,20 +486,6 @@ FILE *fin; } -int -otype(ofname) /* get object function number from its name */ -register char *ofname; -{ - register int i; - - for (i = 0; i < NUMTYPES; i++) - if (!strcmp(ofun[i].funame, ofname)) - return(i); - - return(-1); /* not found */ -} - - alias(fin) /* transfer alias */ FILE *fin; { @@ -842,11 +822,8 @@ initotypes() /* initialize ofun[] array */ if (ofun[OBJ_SOURCE].funp == o_source) return; /* done already */ - /* alias is additional */ - ofun[ALIAS].funame = ALIASID; - ofun[ALIAS].flags = 0; /* functions get new transform */ - for (i = 0; i < NUMTYPES; i++) + for (i = 0; i < NUMOTYPE; i++) if (hasfunc(i)) ofun[i].funp = addxform; /* special cases */ @@ -859,7 +836,8 @@ initotypes() /* initialize ofun[] array */ ofun[OBJ_CYLINDER].funp = ofun[OBJ_TUBE].funp = o_cylinder; ofun[OBJ_RING].funp = o_ring; - ofun[OBJ_INSTANCE].funp = addxform; + ofun[OBJ_INSTANCE].funp = + ofun[OBJ_MESH].funp = addxform; ofun[MAT_GLOW].funp = m_glow; ofun[MAT_SPOT].funp = m_spot; ofun[MAT_DIELECTRIC].funp = m_dielectric; @@ -868,7 +846,7 @@ initotypes() /* initialize ofun[] array */ ofun[PAT_CTEXT].funp = ofun[PAT_BTEXT].funp = ofun[MIX_TEXT].funp = text; - ofun[ALIAS].funp = alias; + ofun[MOD_ALIAS].funp = alias; /* surface inverses */ tinvers[OBJ_FACE] = OBJ_FACE; tinvers[OBJ_SOURCE] = OBJ_SOURCE; @@ -910,8 +888,8 @@ char *fname; openmain(iname) /* open input, changing directory for file */ char *iname; { - static char origdir[MAXPATH]; - static char curfn[MAXPATH]; + static char origdir[PATH_MAX]; + static char curfn[PATH_MAX]; static int diffdir; register char *fpath; @@ -937,7 +915,7 @@ char *iname; return; } if (mainfp == NULL) { /* first call, initialize */ - getwd(origdir); + getcwd(origdir, sizeof(origdir)); } else if (!strcmp(iname, curfn)) { /* just need to rewind? */ rewind(mainfp); return; @@ -951,7 +929,7 @@ char *iname; } strcpy(curfn, iname); /* remember input name */ /* get full path for file */ - if ((fpath = getpath(iname, getlibpath(), R_OK)) == NULL) { + if ((fpath = getpath(iname, getrlibpath(), R_OK)) == NULL) { fprintf(stderr, "%s: cannot find file \"%s\"\n", progname, iname); exit(1);