ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/gen/xform.c
(Generate patch)

Comparing ray/src/gen/xform.c (file contents):
Revision 2.12 by greg, Wed Jun 12 11:55:27 1996 UTC vs.
Revision 2.15 by gregl, Fri May 30 18:24:32 1997 UTC

# Line 31 | Line 31 | int  reverse;                          /* boolean true if scene mirrored */
31  
32   int  invert = 0;                        /* boolean true to invert surfaces */
33  
34 < int  expand = 0;                        /* boolean true to expand commands */
34 > int  expand = 1;                        /* boolean true to expand commands */
35  
36   char  *newmod = NULL;                   /* new modifier for surfaces */
37  
# Line 49 | Line 49 | int  nrept = 1;                                /* number of array repetitions */
49  
50   extern char  *malloc(), *fgetword();
51  
52 < char  *mainfn[MAXPATH];                 /* main file name */
52 > char  mainfn[MAXPATH];                  /* main file name */
53   FILE  *mainfp = NULL;                   /* main file pointer */
54  
55   #define  progname  (xav[0])
# Line 81 | Line 81 | char  *argv[];
81                                          break;
82                                  idprefix = argv[++a];
83                                  continue;
84 +                        case 'c':
85 +                                if (argv[a][2])
86 +                                        break;
87 +                                expand = 0;
88 +                                continue;
89                          case 'e':
90                                  if (argv[a][2])
91                                          break;
# Line 227 | Line 232 | FILE  *fin;
232          } else {
233                  printf("\n%s", buf);
234                  if (xac > 1) {
235 <                        printf(" | %s -e", xav[0]);
235 >                        printf(" | %s", xav[0]);
236                          for (i = 1; i < xac; i++)
237                                  printf(" %s", xav[i]);
238                  }
# Line 415 | Line 420 | FILE  *fin;
420  
421          if (readfargs(&fa, fin) != 1)
422                  return(-1);
423 <        if (fa.nfargs > 5)
423 >        if (fa.nfargs > 7)
424                  return(-1);
425          printf("%d", fa.nsargs);
426          if (idprefix == NULL)
# Line 441 | Line 446 | FILE  *fin;
446          if (fa.nfargs > 2)
447                  printf(" %12.6g %12.6g %12.6g", fa.farg[0]/tot.sca,
448                                  fa.farg[1]/tot.sca, fa.farg[2]/tot.sca);
449 <        if (fa.nfargs > 3)
450 <                printf(" %12.6g", fa.farg[3]);
446 <        if (fa.nfargs > 4)
447 <                printf(" %12.6g", fa.farg[4]);
449 >        for (i = 3; i < fa.nfargs; i++)
450 >                printf(" %12.6g", fa.farg[i]);
451          printf("\n");
452          freefargs(&fa);
453          return(0);
# Line 764 | Line 767 | char  *fname;
767          extern FILE  *tmpfile();
768          extern char  *getlibpath(), *getpath();
769          static char  origdir[MAXPATH];
770 <        static char  curdir[MAXPATH];
771 <        char  newdir[MAXPATH], *cp;
770 >        static char  curfn[MAXPATH];
771 >        static int  diffdir;
772 >        register char  *fpath;
773  
774          if (fname == NULL) {                    /* standard input */
775                  if (mainfp == NULL) {
# Line 789 | Line 793 | char  *fname;
793                  rewind(mainfp);                 /* rewind copy */
794                  return;
795          }
792                                                /* get full path */
793        if ((cp = getpath(fname, getlibpath(), R_OK)) == NULL) {
794                fprintf(stderr, "%s: cannot find file \"%s\"\n",
795                                progname, fname);
796                exit(1);
797        }
798        if (cp[0] == '.' && ISDIRSEP(cp[1]))    /* remove leading ./ */
799                cp += 2;
796          if (mainfp == NULL) {                   /* first call, initialize */
797                  getwd(origdir);
798 <                strcpy(curdir, origdir);
803 <        } else if (!strcmp(cp, mainfn)) {       /* just need to rewind? */
798 >        } else if (!strcmp(fname, curfn)) {     /* just need to rewind? */
799                  rewind(mainfp);
800                  return;
801 <        } else                                  /* else close old stream */
801 >        } else {                                /* else close old stream */
802                  fclose(mainfp);
803 +                if (diffdir) {
804 +                        chdir(origdir);
805 +                        diffdir = 0;
806 +                }
807 +        }
808 +        strcpy(curfn, fname);                   /* remember file name */
809 +                                                /* get full path */
810 +        if ((fpath = getpath(fname, getlibpath(), R_OK)) == NULL) {
811 +                fprintf(stderr, "%s: cannot find file \"%s\"\n",
812 +                                progname, fname);
813 +                exit(1);
814 +        }
815 +        if (fpath[0] == '.' && ISDIRSEP(fpath[1]))      /* remove leading ./ */
816 +                fpath += 2;
817                                                  /* record path name */
818 <        strcpy(mainfn, cp);
819 <        if (expand) {                           /* get directory component */
820 <                if (ISDIRSEP(cp[0]))
821 <                        strcpy(newdir, cp);
822 <                else
823 <                        sprintf(newdir, "%s%c%s", origdir, DIRSEP, cp);
824 <                for (cp = newdir+strlen(newdir); !ISDIRSEP(cp[-1]); cp--)
825 <                        ;
818 >        strcpy(mainfn, fpath);
819 >        if (expand) {                           /* change to local directory */
820 >                register char  *cp = fpath + strlen(fpath);     /* get dir. */
821 >                while (cp > fpath) {
822 >                        cp--;
823 >                        if (ISDIRSEP(*cp)) {
824 >                                if (cp == fpath)
825 >                                        cp++;   /* root special case */
826 >                                break;
827 >                        }
828 >                }
829                  *cp = '\0';
830 <                if (strcmp(newdir, curdir)) {   /* change to new directory? */
831 <                        if (chdir(newdir) < 0) {
830 >                if (fpath[0]) {                 /* change to new directory? */
831 >                        if (chdir(fpath) < 0) {
832                                  fprintf(stderr,
833                                  "%s: cannot change directory to \"%s\"\n",
834 <                                                progname, newdir);
834 >                                                progname, fpath);
835                                  exit(1);
836                          }
837 <                        strcpy(curdir, newdir);
837 >                        diffdir++;
838                  }
839                                                  /* get final path component */
840 <                for (cp = fname+strlen(fname);
841 <                                cp > fname && !ISDIRSEP(cp[-1]); cp--)
840 >                for (fpath = fname+strlen(fname);
841 >                                fpath > fname && !ISDIRSEP(fpath[-1]); fpath--)
842                          ;
843          }
844                                                  /* open the file */
845 <        if ((mainfp = fopen(cp, "r")) == NULL) {
845 >        if ((mainfp = fopen(fpath, "r")) == NULL) {
846                  fprintf(stderr, "%s: cannot open file \"%s\"\n",
847                                  progname, mainfn);
848                  exit(1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines