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.42 by greg, Sun Jul 26 18:36:17 2009 UTC vs.
Revision 2.51 by greg, Sun Dec 2 16:30:30 2018 UTC

# Line 13 | Line 13 | static const char RCSid[] = "$Id$";
13  
14   #include  "platform.h"
15   #include  "paths.h"
16 #include  "rtprocess.h" /* win_popen() */
16   #include  "rtio.h"
17   #include  "rtmath.h"
18   #include  "object.h"
# Line 98 | Line 97 | main(          /* get transform options and transform file */
97                                  if (idprefix == NULL)
98                                          idprefix = argv[a];
99                                  else {
100 <                                        register char   *newp;
100 >                                        char    *newp;
101                                          newp = (char *)malloc(strlen(idprefix)+
102                                                          strlen(argv[a])+2);
103                                          if (newp == NULL)
# Line 106 | Line 105 | main(          /* get transform options and transform file */
105                                          sprintf(newp, "%s.%s",
106                                                          idprefix, argv[a]);
107                                          if (mal_prefix++)
108 <                                                free((void *)idprefix);
108 >                                                free(idprefix);
109                                          idprefix = newp;
110                                  }
111                                  continue;
# Line 134 | Line 133 | main(          /* get transform options and transform file */
133  
134          a += xf(&tot, argc-a, argv+a);
135  
136 <        if ( (reverse = tot.sca < 0.0) )
136 >        if ( (reverse = (tot.sca < 0.0)) )
137                  tot.sca = -tot.sca;
138          if (invert)
139                  reverse = !reverse;
# Line 167 | Line 166 | main(          /* get transform options and transform file */
166                  }
167  
168          if (mal_prefix)
169 <                free((void *)idprefix);
169 >                free(idprefix);
170          return(0);
171   }
172  
# Line 184 | Line 183 | doargf(                        /* take argument list from file */
183          char  argbuf[2048];
184          char  *newid, newidbuf[128];
185          char  *oldid;
186 <        register char   *cp;
186 >        char    *cp;
187          FILE    *argfp;
188          int  n, i, k, newac, err;
189          
# Line 210 | Line 209 | doargf(                        /* take argument list from file */
209                  }
210                  n = 0;                  /* count number of lines in file */
211                  while (fgetline(argbuf,sizeof(argbuf),argfp) != NULL)
212 <                        n += argbuf[0] && argbuf[0] != '#';
212 >                        n += (argbuf[0] != '\0') & (argbuf[0] != '#');
213                  if (!n) {
214                          fprintf(stderr, "%s: empty argument file \"%s\"\n",
215                                          av[0], av[fi+1]);
216                          exit(1);
217                  }
219                nrept *= n;
218                  rewind(argfp);
219          }
220 +        nrept *= n;
221          err = 0; k = 0;                 /* read each arg list and call main */
222          while (fgetline(argbuf,sizeof(argbuf),argfp) != NULL) {
223 <                if (!argbuf[0] || argbuf[0] == '#')
223 >                if (!argbuf[0] | (argbuf[0] == '#')) {
224 >                        printf("%s\n", argbuf);
225                          continue;
226 +                }
227                  avp = newav+2;
228                  avp[0] = av[0];
229                  for (i = 1; i < fi; i++)
# Line 284 | Line 285 | doargf(                        /* take argument list from file */
285                          sprintf(newid, "%s.%d", oldid, k);
286                  err |= main(newac, avp);
287                  if (newid != newidbuf)
288 <                        free((void *)newid);
288 >                        free(newid);
289                  k++;
290          }
291          fclose(argfp);
# Line 343 | Line 344 | doarray(                       /* make array */
344   void
345   xform(                  /* transform stream by tot.xfm */
346          char  *name,
347 <        register FILE  *fin
347 >        FILE  *fin
348   )
349   {
350          int  nobjs = 0;
351 <        register int  c;
351 >        int  c;
352  
353          while ((c = getc(fin)) != EOF) {
354                  if (isspace(c))                         /* blank */
# Line 456 | Line 457 | o_default(                     /* pass on arguments unchanged */
457          FILE  *fin
458   )
459   {
460 <        register int  i;
460 >        int  i;
461          FUNARGS  fa;
462  
463          if (readfargs(&fa, fin) != 1)
# Line 492 | Line 493 | addxform(                      /* add xf arguments to strings */
493          FILE  *fin
494   )
495   {
496 <        register int  i;
496 >        int  i;
497          int  resetarr = 0;
498          FUNARGS  fa;
499  
# Line 553 | Line 554 | m_glow(                        /* transform arguments for proximity light *
554  
555          if (readfargs(&fa, fin) != 1)
556                  return(-1);
557 <        if (fa.nsargs != 0  || fa.nfargs != 4)
557 >        if ((fa.nsargs != 0) | (fa.nfargs != 4))
558                  return(-1);
559          printf("0\n0\n4");
560          printf(" %18.12g %18.12g %18.12g",
# Line 574 | Line 575 | m_spot(                        /* transform arguments for spotlight */
575  
576          if (readfargs(&fa, fin) != 1)
577                  return(-1);
578 <        if (fa.nsargs != 0  || fa.nfargs != 7)
578 >        if ((fa.nsargs != 0) | ( fa.nfargs != 7))
579                  return(-1);
580          printf("0\n0\n7");
581          printf(" %18.12g %18.12g %18.12g %18.12g\n",
# Line 605 | Line 606 | m_mist(                /* transform arguments for mist */
606          else
607                  for (i = 0; i < fa.nsargs; i++) {
608                          char    sname[256], *sp;
609 <                        register char   *cp1, *cp2 = sname;
609 >                        char    *cp1, *cp2 = sname;
610                                                          /* add idprefix */
611                          for (sp = fa.sarg[i]; *sp; sp = cp1) {
612                                  for (cp1 = idprefix; *cp1; )
# Line 775 | Line 776 | o_face(                        /* transform face arguments */
776   )
777   {
778          FVECT  p;
779 <        register int  i;
779 >        int  i;
780          FUNARGS  fa;
781  
782          if (readfargs(&fa, fin) != 1)
# Line 889 | Line 890 | o_ring(                        /* transform ring arguments */
890   void
891   initotypes(void)                        /* initialize ofun[] array */
892   {
893 <        register int  i;
893 >        int  i;
894  
895          if (ofun[OBJ_SOURCE].funp == o_source)
896                  return;                 /* done already */
# Line 929 | Line 930 | initotypes(void)                       /* initialize ofun[] array */
930          tinvers[OBJ_CYLINDER] = OBJ_TUBE;
931          tinvers[OBJ_TUBE] = OBJ_CYLINDER;
932          tinvers[OBJ_INSTANCE] = OBJ_INSTANCE;   /* oh, well */
933 +        tinvers[OBJ_MESH] = OBJ_MESH;           /* ditto */
934   }
935  
936  
# Line 966 | Line 968 | openmain(              /* open input, changing directory for file
968          static char  origdir[PATH_MAX];
969          static char  curfn[PATH_MAX];
970          static int  diffdir;
971 <        register char  *fpath;
971 >        char  *fpath;
972  
973          if (iname == NULL) {                    /* standard input */
974                  if (mainfp == NULL) {
975 <                        register int  c;
975 >                        int  c;
976                          strcpy(mainfn, "standard input");
977                          if (nrept <= 1) {
978                                  mainfp = stdin;
# Line 1014 | Line 1016 | openmain(              /* open input, changing directory for file
1016                                                  /* record path name */
1017          strcpy(mainfn, fpath);
1018          if (expand) {                           /* change to local directory */
1019 <                register char  *cp = fpath + strlen(fpath);     /* get dir. */
1019 >                char  *cp = fpath + strlen(fpath);      /* get dir. */
1020                  while (cp > fpath) {
1021                          cp--;
1022                          if (ISDIRSEP(*cp)) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines